Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Help! My su is broken!
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Admiral LSD
Guru
Guru


Joined: 27 Jun 2003
Posts: 522
Location: Northam, W.A., Australia

PostPosted: Wed Jul 30, 2003 7:12 am    Post subject: Help! My su is broken! Reply with quote

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
View user's profile Send private message
BackSeat
Apprentice
Apprentice


Joined: 12 Apr 2002
Posts: 242
Location: Reading, UK

PostPosted: Wed Jul 30, 2003 7:32 am    Post subject: Reply with quote

What command are you using?
Code:
su
will give you root privileges whereas
Code:
su -
will strive to give you the full login environment of the root user.

BS
Back to top
View user's profile Send private message
chiatello
Guru
Guru


Joined: 21 Jul 2003
Posts: 321
Location: knoxvegas, tn, AMERIKA

PostPosted: Wed Jul 30, 2003 7:32 am    Post subject: Reply with quote

i think this might be related to the problem im having, yeah id like to know too
Back to top
View user's profile Send private message
jbc28
Apprentice
Apprentice


Joined: 07 Jan 2003
Posts: 205
Location: Edinburgh

PostPosted: Wed Jul 30, 2003 7:42 am    Post subject: Reply with quote

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
View user's profile Send private message
Admiral LSD
Guru
Guru


Joined: 27 Jun 2003
Posts: 522
Location: Northam, W.A., Australia

PostPosted: Wed Jul 30, 2003 9:11 am    Post subject: Reply with quote

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
View user's profile Send private message
bsolar
Bodhisattva
Bodhisattva


Joined: 12 Jan 2003
Posts: 2764

PostPosted: Wed Jul 30, 2003 9:28 am    Post subject: Reply with quote

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
View user's profile Send private message
Admiral LSD
Guru
Guru


Joined: 27 Jun 2003
Posts: 522
Location: Northam, W.A., Australia

PostPosted: Wed Jul 30, 2003 9:56 am    Post subject: Reply with quote

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
View user's profile Send private message
jbc28
Apprentice
Apprentice


Joined: 07 Jan 2003
Posts: 205
Location: Edinburgh

PostPosted: Wed Jul 30, 2003 9:57 am    Post subject: Reply with quote

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
View user's profile Send private message
bsolar
Bodhisattva
Bodhisattva


Joined: 12 Jan 2003
Posts: 2764

PostPosted: Wed Jul 30, 2003 9:58 am    Post subject: Reply with quote

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
View user's profile Send private message
jbc28
Apprentice
Apprentice


Joined: 07 Jan 2003
Posts: 205
Location: Edinburgh

PostPosted: Wed Jul 30, 2003 9:59 am    Post subject: Reply with quote

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 :P
Back to top
View user's profile Send private message
Admiral LSD
Guru
Guru


Joined: 27 Jun 2003
Posts: 522
Location: Northam, W.A., Australia

PostPosted: Wed Jul 30, 2003 10:09 am    Post subject: Reply with quote

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
View user's profile Send private message
jbc28
Apprentice
Apprentice


Joined: 07 Jan 2003
Posts: 205
Location: Edinburgh

PostPosted: Wed Jul 30, 2003 10:13 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum