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
bash2 fails to read any of the initialization files.
As a side note bash also has broken behavior when reading the startup
Try adding some echo statements to .bash_profile, .bashrc, and .profile
and watch what happens when using "su - <user>". It's fascinating.
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/"
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