[distribution-discuss] The userid in the prompt does not change after a su
Bernd Schemmer
Bernd.Schemmer at gmx.de
Tue Apr 29 14:17:13 PDT 2008
Hi,
in the current Milax Distribution the userid printed in the prompt does
not change after doing a su to become another user.
The reason for this misbehaviour is not working code in .bashrc (looks
like the .bashrc is copied from Linux):
The .bashrc uses "who am I" to get the current userid - that works in
Linux but not in Solaris, example:
bash-3.2# id
uid=0(root) gid=0(root)
bash-3.2# who am i
root pts/2 Apr 30 00:16 (t61p)
bash-3.2# su - nobody
$ id
uid=60001(nobody) gid=60001(nobody)
$ who am i
root pts/2 Apr 30 00:16 (t61p)
To get around this, change the line
u=`who am i | cut -f1 -d" "`
in the .bashrc to
__id=` id -u `
if [ $__id != 0 ] ; then
u=`who am i | cut -f1 -d" "`
else
u="root"
fi
And copy the .bashrc also into the home directory of root
regards
Bernd
--
Bernd Schemmer, Frankfurt am Main, Germany
http://home.arcor.de/bnsmb/index.html
M s temprano que tarde el mundo cambiar .
Fidel Castro
More information about the distribution-discuss
mailing list