Wind River Support Network


LIN6-9586 : Running su user -l -c 'echo Success' does not execute users login script

Created: Mar 16, 2015    Updated: Dec 3, 2018
Resolved Date: Mar 19, 2015
Found In Version:
Fix Version:
Severity: Standard
Applicable for: Wind River Linux 6
Component/s: Userspace


Running commands with "su -l" does not cause the shell to run the login scripts (.profile or .bash_profile).

Tested with both /bin/sh and /bin/bash as the user shell (in /etc/passwd).

Steps to Reproduce

$configure --enable-board=intel-x86-64 --enable-rootfs=glibc_std --enable-kernel=standard
$ make -C build bash.patch

Apply patch for LIN6-9533 to ensure bash runs login scripts.

$ make -C build bash
$ make fs
$ make start-target

Log in as root

# echo "echo profile" > .profile
# echo "echo bash_profile" > .bash_profile
# echo "echo bashrc" > .bashrc

Test normal login (log out first) and ".profile" is displayed when logging in as expected. Use "chsh" to change the user shell to "/bin/bash" and re-test logging in and you get ".bash_profile" displayed as expected. Run bash as non-login and "bashrc" is displayed as expected.

Now test su:

# su root -l bash -c "echo success"

Note that neither bash_profile nor profile is displayed as would be expected (depending on user's shell).

Running the test case for LIN6-9533 does work though:

# exec -l bash -c "echo success; sleep 100"

Other Downloads

Live chat