Bug 21804 - bash2 doesn't read .bash_profile and friends under certain conditions
bash2 doesn't read .bash_profile and friends under certain conditions
Status: CLOSED WORKSFORME
Product: Red Hat Linux
Classification: Retired
Component: bash (Show other bugs)
6.2
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bernhard Rosenkraenzer
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-12-06 10:46 EST by Need Real Name
Modified: 2008-05-01 11:37 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-12-15 17:17:29 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2000-12-06 10:46:59 EST
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 05:29:55 EDT
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

Note You need to log in before you can comment on or make changes to this bug.