Bug 21804

Summary: bash2 doesn't read .bash_profile and friends under certain conditions
Product: [Retired] Red Hat Linux Reporter: Need Real Name <kitchen>
Component: bashAssignee: Bernhard Rosenkraenzer <bero>
Status: CLOSED WORKSFORME QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2CC: dr
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-12-15 22:17:29 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Need Real Name 2000-12-06 15:46:59 UTC
bash2 doesn't  read .bash_profile and friends when invoking bash2 by a
command such as "su - postgres -c /home/postgres <some_command>.
It works properly if "su - postgres" is used but when the -c option is
added
bash2 fails to read any of the initialization files.

As a side note bash also has broken behavior when reading the startup
files.
Try adding some echo statements to .bash_profile, .bashrc, and .profile
and watch what happens when using "su - <user>".  It's fascinating.

Comment 1 Phil Knirsch 2002-07-23 09:29:55 UTC
Just tested it, on 7.3 at least it works as expected, that is, i added an   echo
"FOOBAR was here!" to a test accounts .bashrc and that was printed with a

[root@hamburg root]# su - test -c "/bin/ls /tmp/"
FOOBAR!!!
fonts.alias.kJoSlU  krb5cc_2903_kARIoT  mcop-root
kde-pknirsch        ksocket-pknirsch    plugtmp
kde-root            mcop-pknirsch       ssh-XXUBayLZ

Keep in mind though that if you use something like /sbin/nologin or /bin/false
as a loginshell the -c won't work as expected (as the actual command line being
executed will be:  /bin/false -c your_command_here which is very likely not
going to do what you'd expect ;-).

Read ya, Phil