su 5.2.1 does not invoke bash as a login shell when stdin is from a pipe - Questions

This is a discussion on su 5.2.1 does not invoke bash as a login shell when stdin is from a pipe - Questions ; Here's a scenario in which su from coreutils 5.2.1 does not invoke bash as a login shell: root>su --version su (coreutils) 5.2.1 [...] root>echo "echo \"This is .bash_profile.\"" >~usr1/.bash_profile root>cat ~usr1/.bash_profile echo "This is .bash_profile." root>echo 'echo $PATH' | su ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: su 5.2.1 does not invoke bash as a login shell when stdin is from a pipe

  1. su 5.2.1 does not invoke bash as a login shell when stdin is from a pipe

    Here's a scenario in which su from coreutils 5.2.1 does not
    invoke bash as a login shell:

    root>su --version
    su (coreutils) 5.2.1
    [...]
    root>echo "echo \"This is .bash_profile.\"" >~usr1/.bash_profile
    root>cat ~usr1/.bash_profile
    echo "This is .bash_profile."
    root>echo 'echo $PATH' | su - usr1
    /usr/bin:/bin
    # NOTE: bash was not invoked as a login shell, which is
    unexpected
    root> su - usr1
    This is .bash_profile.
    usr1>
    # NOTE: as expected, bash was invoked as a login shell

    Is this a problem in su and if so, is there a patch for it?

  2. Re: su 5.2.1 does not invoke bash as a login shell when stdin is from a pipe

    Angel Tsankov wrote:
    > Here's a scenario in which su from coreutils 5.2.1 does not
    > invoke bash as a login shell:
    >
    > root>su --version
    > su (coreutils) 5.2.1
    > [...]
    > root>echo "echo \"This is .bash_profile.\"" >~usr1/.bash_profile
    > root>cat ~usr1/.bash_profile
    > echo "This is .bash_profile."
    > root>echo 'echo $PATH' | su - usr1
    > /usr/bin:/bin
    > # NOTE: bash was not invoked as a login shell, which is
    > unexpected
    > root> su - usr1
    > This is .bash_profile.
    > usr1>
    > # NOTE: as expected, bash was invoked as a login shell
    >
    > Is this a problem in su and if so, is there a patch for it?


    As a workaround, pass '-l' through to the shell:

    # echo 'echo $PATH' | su - -- USER -l

    Alternatively, install the shadow password suite:





    [Followup-To: set]

+ Reply to Thread