public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA 3/5 v4] Darwin: set startup-with-shell to off on Sierra and later.
@ 2018-09-09 13:46 Xavier Roirand
  2018-09-10 14:03 ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Xavier Roirand @ 2018-09-09 13:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: brobecker, simon.marchi, tom, Xavier Roirand

On Mac OS X Sierra and later, the shell is not allowed to be
debug so add a check and disable startup with shell in that
case. This disabling is done temporary before forking
inferior and restored after the fork.

gdb/ChangeLog:

        * darwin-nat.c (should_disable_startup_with_shell):
        New function.
        (darwin_nat_target::create_inferior): Add call.

Change-Id: Ie4d9090f65fdf2e83ecf7a0f9d0647fb1c27cdcc
---
 gdb/darwin-nat.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index be80163d22e..c83c5854da6 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1854,11 +1854,38 @@ darwin_execvp (const char *file, char * const argv[], char * const env[])
   posix_spawnp (NULL, argv[0], NULL, &attr, argv, env);
 }
 
+/* Read kernel version, and return TRUE on Sierra or later.  */
+
+static bool
+should_disable_startup_with_shell ()
+{
+  char str[16];
+  size_t sz = sizeof (str);
+  int ret;
+
+  ret = sysctlbyname ("kern.osrelease", str, &sz, NULL, 0);
+  if (ret == 0 && sz < sizeof (str))
+    {
+      unsigned long ver = strtoul (str, NULL, 10);
+      if (ver >= 16)
+        return true;
+    }
+  return false;
+}
+
 void
 darwin_nat_target::create_inferior (const char *exec_file,
 				    const std::string &allargs,
 				    char **env, int from_tty)
 {
+  gdb::optional<scoped_restore_tmpl<int>> restore_startup_with_shell;
+
+  if (startup_with_shell && should_disable_startup_with_shell ())
+    {
+      warning (_("startup-with-shell not supported on this macOS version, disabling it."));
+      restore_startup_with_shell.emplace (&startup_with_shell, 0);
+    }
+
   /* Do the hard work.  */
   fork_inferior (exec_file, allargs, env, darwin_ptrace_me,
 		 darwin_ptrace_him, darwin_pre_ptrace, NULL,
-- 
2.15.2 (Apple Git-101.1)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFA 3/5 v4] Darwin: set startup-with-shell to off on Sierra and later.
  2018-09-09 13:46 [RFA 3/5 v4] Darwin: set startup-with-shell to off on Sierra and later Xavier Roirand
@ 2018-09-10 14:03 ` Tom Tromey
  2018-09-11 10:25   ` Xavier Roirand
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2018-09-10 14:03 UTC (permalink / raw)
  To: Xavier Roirand; +Cc: gdb-patches, brobecker, simon.marchi, tom

>>>>> "Xavier" == Xavier Roirand <roirand@adacore.com> writes:

Xavier> On Mac OS X Sierra and later, the shell is not allowed to be
Xavier> debug so add a check and disable startup with shell in that
Xavier> case. This disabling is done temporary before forking
Xavier> inferior and restored after the fork.

I believe Simon approved this version, but in case you're unsure, it is
ok.

Thank you for this series.
Has everything been approved or are you waiting for more reviews?

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFA 3/5 v4] Darwin: set startup-with-shell to off on Sierra and later.
  2018-09-10 14:03 ` Tom Tromey
@ 2018-09-11 10:25   ` Xavier Roirand
  0 siblings, 0 replies; 7+ messages in thread
From: Xavier Roirand @ 2018-09-11 10:25 UTC (permalink / raw)
  To: gdb-patches

Hello,

Le 9/10/18 à 4:03 PM, Tom Tromey a écrit :
>>>>>> "Xavier" == Xavier Roirand <roirand@adacore.com> writes:
> 
> Xavier> On Mac OS X Sierra and later, the shell is not allowed to be
> Xavier> debug so add a check and disable startup with shell in that
> Xavier> case. This disabling is done temporary before forking
> Xavier> inferior and restored after the fork.
> 
> I believe Simon approved this version, but in case you're unsure, it is
> ok.
> 
> Thank you for this series.
> Has everything been approved or are you waiting for more reviews?

Most of  patches (2 on 3) have been approved, I only need to resubmit 
the "Handle unrelocated dyld" one for a minor change.

Xavier
> 
> Tom
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFA 3/5 v4] Darwin: set startup-with-shell to off on Sierra and later.
  2018-09-10 19:12 ` Simon Marchi
  2018-09-11 10:25   ` Xavier Roirand
@ 2018-09-11 13:44   ` Xavier Roirand
  1 sibling, 0 replies; 7+ messages in thread
From: Xavier Roirand @ 2018-09-11 13:44 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches; +Cc: brobecker, simon.marchi, tom

Thanks. Pushed to master.

https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d6be54ef73eacaaf5bf28bafc7dfebc80ebac832

Le 9/10/18 à 9:11 PM, Simon Marchi a écrit :
> On 2018-09-10 04:33 PM, Xavier Roirand wrote:
>> On Mac OS X Sierra and later, the shell is not allowed to be
>> debug so add a check and disable startup with shell in that
>> case. This disabling is done temporary before forking
>> inferior and restored after the fork.
>>
>> gdb/ChangeLog:
>>
>>          * darwin-nat.c (should_disable_startup_with_shell):
>>          New function.
>>          (darwin_nat_target::create_inferior): Add call.
>>
>> Change-Id: Ie4d9090f65fdf2e83ecf7a0f9d0647fb1c27cdcc
>> ---
>>   gdb/darwin-nat.c | 28 ++++++++++++++++++++++++++++
>>   1 file changed, 28 insertions(+)
>>
>> diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
>> index be80163d22e..eee9380d650 100644
>> --- a/gdb/darwin-nat.c
>> +++ b/gdb/darwin-nat.c
>> @@ -1854,11 +1854,39 @@ darwin_execvp (const char *file, char * const argv[], char * const env[])
>>     posix_spawnp (NULL, argv[0], NULL, &attr, argv, env);
>>   }
>>   
>> +/* Read kernel version, and return TRUE on Sierra or later.  */
>> +
>> +static bool
>> +should_disable_startup_with_shell ()
>> +{
>> +  char str[16];
>> +  size_t sz = sizeof (str);
>> +  int ret;
>> +
>> +  ret = sysctlbyname ("kern.osrelease", str, &sz, NULL, 0);
>> +  if (ret == 0 && sz < sizeof (str))
>> +    {
>> +      unsigned long ver = strtoul (str, NULL, 10);
>> +      if (ver >= 16)
>> +        return true;
>> +    }
>> +  return false;
>> +}
>> +
>>   void
>>   darwin_nat_target::create_inferior (const char *exec_file,
>>   				    const std::string &allargs,
>>   				    char **env, int from_tty)
>>   {
>> +  gdb::optional<scoped_restore_tmpl<int>> restore_startup_with_shell;
>> +
>> +  if (startup_with_shell && should_disable_startup_with_shell ())
>> +    {
>> +      warning (_("startup-with-shell not supported on this macOS version,"
>> +	         " disabling it."));
>> +      restore_startup_with_shell.emplace (&startup_with_shell, 0);
>> +    }
>> +
>>     /* Do the hard work.  */
>>     fork_inferior (exec_file, allargs, env, darwin_ptrace_me,
>>   		 darwin_ptrace_him, darwin_pre_ptrace, NULL,
>>
> 
> Just to avoid confusion, I think this should actually be v5.  The new change
> is the line wrapping.  Still LGTM, thanks.
> 
> Simon
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFA 3/5 v4] Darwin: set startup-with-shell to off on Sierra and later.
  2018-09-10 19:12 ` Simon Marchi
@ 2018-09-11 10:25   ` Xavier Roirand
  2018-09-11 13:44   ` Xavier Roirand
  1 sibling, 0 replies; 7+ messages in thread
From: Xavier Roirand @ 2018-09-11 10:25 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches; +Cc: brobecker, simon.marchi, tom

Hello,

Le 9/10/18 à 9:11 PM, Simon Marchi a écrit :
> On 2018-09-10 04:33 PM, Xavier Roirand wrote:
>> On Mac OS X Sierra and later, the shell is not allowed to be
>> debug so add a check and disable startup with shell in that
>> case. This disabling is done temporary before forking
>> inferior and restored after the fork.
>>
>> gdb/ChangeLog:
>>
>>          * darwin-nat.c (should_disable_startup_with_shell):
>>          New function.
>>          (darwin_nat_target::create_inferior): Add call.
>>
>> Change-Id: Ie4d9090f65fdf2e83ecf7a0f9d0647fb1c27cdcc
>> ---
>>   gdb/darwin-nat.c | 28 ++++++++++++++++++++++++++++
>>   1 file changed, 28 insertions(+)
>>
>> diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
>> index be80163d22e..eee9380d650 100644
>> --- a/gdb/darwin-nat.c
>> +++ b/gdb/darwin-nat.c
>> @@ -1854,11 +1854,39 @@ darwin_execvp (const char *file, char * const argv[], char * const env[])
>>     posix_spawnp (NULL, argv[0], NULL, &attr, argv, env);
>>   }
>>   
>> +/* Read kernel version, and return TRUE on Sierra or later.  */
>> +
>> +static bool
>> +should_disable_startup_with_shell ()
>> +{
>> +  char str[16];
>> +  size_t sz = sizeof (str);
>> +  int ret;
>> +
>> +  ret = sysctlbyname ("kern.osrelease", str, &sz, NULL, 0);
>> +  if (ret == 0 && sz < sizeof (str))
>> +    {
>> +      unsigned long ver = strtoul (str, NULL, 10);
>> +      if (ver >= 16)
>> +        return true;
>> +    }
>> +  return false;
>> +}
>> +
>>   void
>>   darwin_nat_target::create_inferior (const char *exec_file,
>>   				    const std::string &allargs,
>>   				    char **env, int from_tty)
>>   {
>> +  gdb::optional<scoped_restore_tmpl<int>> restore_startup_with_shell;
>> +
>> +  if (startup_with_shell && should_disable_startup_with_shell ())
>> +    {
>> +      warning (_("startup-with-shell not supported on this macOS version,"
>> +	         " disabling it."));
>> +      restore_startup_with_shell.emplace (&startup_with_shell, 0);
>> +    }
>> +
>>     /* Do the hard work.  */
>>     fork_inferior (exec_file, allargs, env, darwin_ptrace_me,
>>   		 darwin_ptrace_him, darwin_pre_ptrace, NULL,
>>
> 
> Just to avoid confusion, I think this should actually be v5.  The new change
> is the line wrapping.  Still LGTM, thanks.

Agree :)

Xavier
> 
> Simon
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFA 3/5 v4] Darwin: set startup-with-shell to off on Sierra and later.
  2018-09-10 15:33 Xavier Roirand
@ 2018-09-10 19:12 ` Simon Marchi
  2018-09-11 10:25   ` Xavier Roirand
  2018-09-11 13:44   ` Xavier Roirand
  0 siblings, 2 replies; 7+ messages in thread
From: Simon Marchi @ 2018-09-10 19:12 UTC (permalink / raw)
  To: Xavier Roirand, gdb-patches; +Cc: brobecker, simon.marchi, tom

On 2018-09-10 04:33 PM, Xavier Roirand wrote:
> On Mac OS X Sierra and later, the shell is not allowed to be
> debug so add a check and disable startup with shell in that
> case. This disabling is done temporary before forking
> inferior and restored after the fork.
> 
> gdb/ChangeLog:
> 
>         * darwin-nat.c (should_disable_startup_with_shell):
>         New function.
>         (darwin_nat_target::create_inferior): Add call.
> 
> Change-Id: Ie4d9090f65fdf2e83ecf7a0f9d0647fb1c27cdcc
> ---
>  gdb/darwin-nat.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
> index be80163d22e..eee9380d650 100644
> --- a/gdb/darwin-nat.c
> +++ b/gdb/darwin-nat.c
> @@ -1854,11 +1854,39 @@ darwin_execvp (const char *file, char * const argv[], char * const env[])
>    posix_spawnp (NULL, argv[0], NULL, &attr, argv, env);
>  }
>  
> +/* Read kernel version, and return TRUE on Sierra or later.  */
> +
> +static bool
> +should_disable_startup_with_shell ()
> +{
> +  char str[16];
> +  size_t sz = sizeof (str);
> +  int ret;
> +
> +  ret = sysctlbyname ("kern.osrelease", str, &sz, NULL, 0);
> +  if (ret == 0 && sz < sizeof (str))
> +    {
> +      unsigned long ver = strtoul (str, NULL, 10);
> +      if (ver >= 16)
> +        return true;
> +    }
> +  return false;
> +}
> +
>  void
>  darwin_nat_target::create_inferior (const char *exec_file,
>  				    const std::string &allargs,
>  				    char **env, int from_tty)
>  {
> +  gdb::optional<scoped_restore_tmpl<int>> restore_startup_with_shell;
> +
> +  if (startup_with_shell && should_disable_startup_with_shell ())
> +    {
> +      warning (_("startup-with-shell not supported on this macOS version,"
> +	         " disabling it."));
> +      restore_startup_with_shell.emplace (&startup_with_shell, 0);
> +    }
> +
>    /* Do the hard work.  */
>    fork_inferior (exec_file, allargs, env, darwin_ptrace_me,
>  		 darwin_ptrace_him, darwin_pre_ptrace, NULL,
> 

Just to avoid confusion, I think this should actually be v5.  The new change
is the line wrapping.  Still LGTM, thanks.

Simon

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RFA 3/5 v4] Darwin: set startup-with-shell to off on Sierra and later.
@ 2018-09-10 15:33 Xavier Roirand
  2018-09-10 19:12 ` Simon Marchi
  0 siblings, 1 reply; 7+ messages in thread
From: Xavier Roirand @ 2018-09-10 15:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: brobecker, simon.marchi, tom, Xavier Roirand

On Mac OS X Sierra and later, the shell is not allowed to be
debug so add a check and disable startup with shell in that
case. This disabling is done temporary before forking
inferior and restored after the fork.

gdb/ChangeLog:

        * darwin-nat.c (should_disable_startup_with_shell):
        New function.
        (darwin_nat_target::create_inferior): Add call.

Change-Id: Ie4d9090f65fdf2e83ecf7a0f9d0647fb1c27cdcc
---
 gdb/darwin-nat.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index be80163d22e..eee9380d650 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1854,11 +1854,39 @@ darwin_execvp (const char *file, char * const argv[], char * const env[])
   posix_spawnp (NULL, argv[0], NULL, &attr, argv, env);
 }
 
+/* Read kernel version, and return TRUE on Sierra or later.  */
+
+static bool
+should_disable_startup_with_shell ()
+{
+  char str[16];
+  size_t sz = sizeof (str);
+  int ret;
+
+  ret = sysctlbyname ("kern.osrelease", str, &sz, NULL, 0);
+  if (ret == 0 && sz < sizeof (str))
+    {
+      unsigned long ver = strtoul (str, NULL, 10);
+      if (ver >= 16)
+        return true;
+    }
+  return false;
+}
+
 void
 darwin_nat_target::create_inferior (const char *exec_file,
 				    const std::string &allargs,
 				    char **env, int from_tty)
 {
+  gdb::optional<scoped_restore_tmpl<int>> restore_startup_with_shell;
+
+  if (startup_with_shell && should_disable_startup_with_shell ())
+    {
+      warning (_("startup-with-shell not supported on this macOS version,"
+	         " disabling it."));
+      restore_startup_with_shell.emplace (&startup_with_shell, 0);
+    }
+
   /* Do the hard work.  */
   fork_inferior (exec_file, allargs, env, darwin_ptrace_me,
 		 darwin_ptrace_him, darwin_pre_ptrace, NULL,
-- 
2.15.2 (Apple Git-101.1)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-09-11 13:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-09 13:46 [RFA 3/5 v4] Darwin: set startup-with-shell to off on Sierra and later Xavier Roirand
2018-09-10 14:03 ` Tom Tromey
2018-09-11 10:25   ` Xavier Roirand
2018-09-10 15:33 Xavier Roirand
2018-09-10 19:12 ` Simon Marchi
2018-09-11 10:25   ` Xavier Roirand
2018-09-11 13:44   ` Xavier Roirand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).