View previous topic :: View next topic |
Author |
Message |
Admiral LSD Guru
Joined: 27 Jun 2003 Posts: 522 Location: Northam, W.A., Australia
|
Posted: Wed Jul 30, 2003 7:12 am Post subject: Help! My su is broken! |
|
|
I mentioned this in another thread but that seems to have gone unnoticed so I'm repeating it here as it seems the most appropriate forum. Note, this isn't another "why can't I su to root?" thread. Now, with that out of the way I can get on with my question:
After finally getting coreutils to upgrade the other day I've noticed that su doesn't automatically source the system profile the way it used to meaning I get a standard user prompt (root@hostname pwd in standard user green and blue) instead of the more usual red hostname and blue pwd but more importantly, none of my customised system-wide aliases such as mc-wrapper and custome ls options work right until I manually source /etc/profile. Does anyone know what causes this and how I can fix it? |
|
Back to top |
|
|
BackSeat Apprentice
Joined: 12 Apr 2002 Posts: 242 Location: Reading, UK
|
Posted: Wed Jul 30, 2003 7:32 am Post subject: |
|
|
What command are you using?will give you root privileges whereaswill strive to give you the full login environment of the root user.
BS |
|
Back to top |
|
|
chiatello Guru
Joined: 21 Jul 2003 Posts: 321 Location: knoxvegas, tn, AMERIKA
|
Posted: Wed Jul 30, 2003 7:32 am Post subject: |
|
|
i think this might be related to the problem im having, yeah id like to know too |
|
Back to top |
|
|
jbc28 Apprentice
Joined: 07 Jan 2003 Posts: 205 Location: Edinburgh
|
Posted: Wed Jul 30, 2003 7:42 am Post subject: |
|
|
Hi,
I have the same problem myself but never thought of it as a problem. Rather than type
source /etc/profile
you could add it to root's .bashrc and .bash_profile files:
echo source /etc/profile >> ~/.bashrc
echo source /etc/profile >> ~/.bash_profile
This seems to reproduce the behaviour you're wanting.
I hope this helps,
J |
|
Back to top |
|
|
Admiral LSD Guru
Joined: 27 Jun 2003 Posts: 522 Location: Northam, W.A., Australia
|
Posted: Wed Jul 30, 2003 9:11 am Post subject: |
|
|
But does that get executed for non-login shells though? That's the problem I'm having. It coorectly sources the profile when I log in as root just not when I su. |
|
Back to top |
|
|
bsolar Bodhisattva
Joined: 12 Jan 2003 Posts: 2764
|
Posted: Wed Jul 30, 2003 9:28 am Post subject: |
|
|
I remember of a similar problem. It was because in /etc/profile there was:
Code: | if [ "$LOGNAME" = 'root' ] |
instead of:
Code: | if [ `/usr/bin/whoami` = 'root' ] |
_________________ I may not agree with what you say, but I'll defend to the death your right to say it. |
|
Back to top |
|
|
Admiral LSD Guru
Joined: 27 Jun 2003 Posts: 522 Location: Northam, W.A., Australia
|
Posted: Wed Jul 30, 2003 9:56 am Post subject: |
|
|
I just had a look and I definitely have the "whoami" line in there, $LOGNAME doesn't appear anywhere in my /etc/profile. It's not that much of a problem, I only su to root to update my system anyway so I might wait another week or so until Gentoo 1.4 final is released and then see about reinstalling from scratch and seeing if that clears it up. Thanks for your help nonetheless. |
|
Back to top |
|
|
jbc28 Apprentice
Joined: 07 Jan 2003 Posts: 205 Location: Edinburgh
|
Posted: Wed Jul 30, 2003 9:57 am Post subject: |
|
|
hi,
when you log in it sources the profile. When you su it won't. Typing
su -
will source the profile. I guess the solution is either to use 'su -' or to source /etc/profile using .bashrc and .bash_login. As bsolar says, check that /etc/profile contains
if [ `/usr/bin/whoami` = 'root' ]
rather than
if [ "$LOGNAME" = 'root' ]
hope this helps,
J |
|
Back to top |
|
|
bsolar Bodhisattva
Joined: 12 Jan 2003 Posts: 2764
|
Posted: Wed Jul 30, 2003 9:58 am Post subject: |
|
|
Admiral LSD` wrote: | I just had a look and I definitely have the "whoami" line in there, $LOGNAME doesn't appear anywhere in my /etc/profile. |
Yeah it was an old problem.
BTW I have source /etc/profile in my .bashrd and it works (PATH set correctly ecc...). _________________ I may not agree with what you say, but I'll defend to the death your right to say it. |
|
Back to top |
|
|
jbc28 Apprentice
Joined: 07 Jan 2003 Posts: 205 Location: Edinburgh
|
Posted: Wed Jul 30, 2003 9:59 am Post subject: |
|
|
Please don't re-install from scratch!
My system never did this (red for root on su) until you metioned that yours once did.
My fix works for me |
|
Back to top |
|
|
Admiral LSD Guru
Joined: 27 Jun 2003 Posts: 522 Location: Northam, W.A., Australia
|
Posted: Wed Jul 30, 2003 10:09 am Post subject: |
|
|
I planned to reinstall from scratch when the final came out anyway, mainly to clean out all the old crap in my /usr/portage/distfiles directory but now it's to see if I can't get this working right again. I think it may have had something to do with the fact that, in trying to update coreutils, I unmerged them without realising that much of portage is dependent on programs contained in the coreutils package and to get portage running again I substituted binaries from my original stage 1 tarball. |
|
Back to top |
|
|
jbc28 Apprentice
Joined: 07 Jan 2003 Posts: 205 Location: Edinburgh
|
Posted: Wed Jul 30, 2003 10:13 am Post subject: |
|
|
Hi,
This sounds messy enough to warrant a reinstall.
I'm glad you raised the problem though, I'd never thought of it before. Now my gentoo's even nicer!
Good luck with the reinstall,
J |
|
Back to top |
|
|
|