[Bug cli/23364] New: macOS can't startup with shell

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug cli/23364] New: macOS can't startup with shell

agentzh at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23364

            Bug ID: 23364
           Summary: macOS can't startup with shell
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: cli
          Assignee: unassigned at sourceware dot org
          Reporter: tromey at sourceware dot org
  Target Milestone: ---

Recent versions of macOS support SIP ("system integrity protection")
which prevents gdb from attaching to certain executables -- one of
those being the shell.

So, currently macOS users have to "set startup-with-shell off".

It would be friendlier, though, for gdb to emulate the shell somehow,
so that globbing, substitutions, and redirections still work.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug cli/23364] macOS can't startup with shell

agentzh at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23364

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
It seems one possibility is to cp $SHELL /tmp and then use the copy.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug cli/23364] macOS can't startup with shell

agentzh at gmail dot com
In reply to this post by agentzh at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23364

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |*-*-darwin*

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug cli/23364] macOS can't startup with shell

agentzh at gmail dot com
In reply to this post by agentzh at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23364

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
From https://support.apple.com/en-us/HT204899, SIP covers:

/System
/usr
/bin
/sbin

So the idea would be to run "csrutil status" to see if SIP is enabled;
if so, check $SHELL against this list; and then make a copy of the
shell in /tmp and use that instead.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug cli/23364] macOS can't startup with shell

agentzh at gmail dot com
In reply to this post by agentzh at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23364

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at sourceware dot org   |tromey at sourceware dot org

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
A workaround went in that disables startup-on-shell temporarily.

I'm testing a patch that caches the shell.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug cli/23364] macOS can't startup with shell

agentzh at gmail dot com
In reply to this post by agentzh at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23364

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nikolaikrill at gmail dot com

--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
*** Bug 20266 has been marked as a duplicate of this bug. ***

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug cli/23364] macOS can't startup with shell

agentzh at gmail dot com
In reply to this post by agentzh at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23364

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |8.3

--- Comment #6 from Tom Tromey <tromey at sourceware dot org> ---
Fixed.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug cli/23364] macOS can't startup with shell

agentzh at gmail dot com
In reply to this post by agentzh at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23364

--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom Tromey <[hidden email]>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b50a8b9a916ea2fe1379bcd8f122feef8129a0e9

commit b50a8b9a916ea2fe1379bcd8f122feef8129a0e9
Author: Tom Tromey <[hidden email]>
Date:   Mon Sep 17 12:29:22 2018 -0600

    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  <[hidden email]>

        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.

--
You are receiving this mail because:
You are on the CC list for the bug.