Cache a copy of the user's shell on macOS
authorTom Tromey <tom@tromey.com>
Mon, 17 Sep 2018 18:29:22 +0000 (12:29 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 27 Oct 2018 17:58:41 +0000 (11:58 -0600)
commitb50a8b9a916ea2fe1379bcd8f122feef8129a0e9
tree407ac2d5de2885afc30a8b067926c959e7db1694
parent36033ef57cd048588f9a3d5523712147066421f2
Cache a copy of the user's shell on macOS

Recent versions of macOS have a feature called System Integrity
Protection.  Among other things, This feature prevents ptrace from
tracing certain programs --- for example, the programs in /bin, which
includes typical shells.

This means that startup-with-shell does not work properly.  This is PR
cli/23364.  Currently there is a workaround in gdb to disable
startup-with-shell when this feature might be in use.

This patch changes gdb to be a bit more precise about when
startup-with-shell will not work, by checking whether the shell
executable is restricted.

If the shell is restricted, then this patch will also cause gdb to
cache a copy of the shell in the gdb cache directory, and then reset
the SHELL environment variable to point to this copy.  This lets
startup-with-shell work again.

Tested on High Sierra by trying to start a program using redirection,
and by running startup-with-shell.exp.

gdb/ChangeLog
2018-10-27  Tom Tromey  <tom@tromey.com>

PR cli/23364:
* darwin-nat.c (copied_shell): New global.
(may_have_sip): Rename from should_disable_startup_with_shell.
(copy_shell_to_cache, maybe_cache_shell): New functions.
(darwin_nat_target::create_inferior): Update.  Use
copied_shell.
gdb/ChangeLog
gdb/darwin-nat.c
This page took 0.026387 seconds and 4 git commands to generate.