Which su?

Greg Schafer diy-linux-dev@diy-linux.org
Wed, 10 Aug 2005 11:54:02 +1000


Hi Guys

The Ref' Build currently chooses to use the `su' from Shadow. I'm proposing
a switch to the `su' from Coreutils. The reason is that the `su' from Shadow
contains some (IMHO) questionable behaviour that interacts rather badly with
the Pkg Mgmt goals of the Ref' Build.

Specifically, if you `su' from root to pkgmgr (without the hyphen in order
to retain the environment), you lose root's PATH and end up with a default
"user" PATH a) from /etc/login.defs or b) from info hardwired the `su'
binary itself. This problem doesn't really affect the Ref' Build per se, but
becomes apparent very quickly when building pkgs beyond the base.

Interactive shells can mask the problem by using Bash startup files (.bashrc
etc). But when Bash is invoked non-interactively to run a shell script, it
doesn't read the startup files unless you jump thru' some hoops (supply
--login or fiddle with BASH_ENV etc).

If someone can suggest a simple way to force the `su' from Shadow to do what
I want without resorting to editing /etc/login.defs then maybe I won't need
to switch.

FWIW, Red Hat/Fedora appear to use the `su' from Coreutils while Debian
appear to use the one from Shadow (albeit heavily modified).

It could be argued that because Shadow supports PAM out-of-the-box the `su'
from Shadow is preferable for users who want PAM. But it's worth noting that
some distros patch the `su' from Coreutils to support PAM.

Anyhoo, if anyone thinks this is a really bad idea, please speak up.

Regards
Greg