• Adriaan de Groot's avatar
    Allow sessions with /bin/sh · 5871a53c
    Adriaan de Groot authored
    The existing code scans through `programs` to find an acceptable
    shell to start; `_program` is the shell that is configured for
    the session (line 456). The first shell to be found from that
    list, is assigned to `exec` and we'll run that shell.
    
    If the shell found wasn't the one configured (e.g. one of the
    other ones from the list) then a warning is printed, but we carry on.
    **However**, if the shell found is the **last** one in the list
    (i.e. `/bin/sh`) then a warning is printed and the shell does
    not start.
    
    If the configured shell is `/bin/sh` this obviously breaks down:
    it is found (as the first one in the list!) but still equals the
    last one; the warning is printed and nothing runs.
    
    It is unclear **why** `/bin/sh` is not allowed as a shell:
    it exists, it's an executable, and it's an interactive shell.
    
    Curiously, configuring the shell as `sh` for the session runs
    `/bin/sh` in the end, but just tricks the logic here:
     - `checkProgram("sh")` returns `sh` as string,
     - so the comparison against `/bin/sh` fails,
     - and we can run `sh` .. which is `/bin/sh`.
    
    There's no good reason to forbid `/bin/sh`, so change the check to
    **only** fail if no shell was found at all (`exec` stayed empty)
    or if the found shell behaves weirdly (is not equal to itself).
    5871a53c
Session.cpp 51 KB