LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-05-2004, 08:02 PM   #1
adrianmariano
Member
 
Registered: Dec 2004
Distribution: Ubuntu Yakkety
Posts: 193

Rep: Reputation: 15
Programs use old home after "su"


I'm upgrading from an ancient SUSE installation where I found it useful to switch users with "su" and then run applications like mozilla, emacs, etc. Once I arranged the X authentication to allow this, it worked fine.

Now I have installed a debian derived distribution (Mepis 2004.04) with the 2.6.7 kernel and I find that after issuing an "su", firefox, mozilla, and emacs start up with the config info from the original user's home, not the configuration corresponding to the current uid.

The old "su" program was part of GNU sh-utils 2.0. The new "su" doesn't give a version number of any other identifying information other than its author, Julianne Frances Haugh. The new program also uses pam. It appears to be completely different than the old "su".

How do programs even know the home directory of the original user? Is there a way I can restore the old behavior I was accustomed to, perhaps by modifying the pam configuration fils?
 
Old 12-05-2004, 08:09 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Perhaps just a su - or even su - user1 will fix your problem. Majority of the time, when issuing a su, its still going to use the old users path. With the - or - [user], it uses the new users full path, etc.
 
Old 12-05-2004, 08:33 PM   #3
adrianmariano
Member
 
Registered: Dec 2004
Distribution: Ubuntu Yakkety
Posts: 193

Original Poster
Rep: Reputation: 15
Well, 'su -' resets the environment which means it clears things like DISPLAY and WINDOWID, which is troublesome. I might be able to kludge something in the .login files to make this work. But I wasn't using 'su -' before with the old su and it was working. I am also curious to understand the mechanism whereby applications start up with startup info that is not from the home directory corresponding to the current uid.
 
Old 12-05-2004, 08:39 PM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Maybe the only way around this would be for you to include the users actual home directory is updated. After su'ing, you can envoke something like:

export HOME=/home/newuser

Which should use the new users home directory, thus using their configs, etc.
 
Old 12-05-2004, 09:56 PM   #5
adrianmariano
Member
 
Registered: Dec 2004
Distribution: Ubuntu Yakkety
Posts: 193

Original Poster
Rep: Reputation: 15
After "su", the HOME variable is set to the home of the new uid. But applications still use the home of the OLD uid when they start up.

I hunted through the environment for traces of the old user and found something. There is a variable LOGNAME which has the name of the old user. So setting that to the new user gives the desired behavior. It would appear that doing the equivalent of
export LOGNAME=$USER
would do the trick. This is, however, still in the category of kludge in shell's init files. Is there some reason why the behavior of su has changed in this fashion? Is there a way to get su to reset LOGNAME?
 
Old 12-05-2004, 11:10 PM   #6
kevinalm
Member
 
Registered: Oct 2003
Location: Iowa
Distribution: LFS 5.0, building 6.3, win98se, multiboot
Posts: 288

Rep: Reputation: 30
You should be able to add

export LOGNAME=$USER

to either ~/.bash_profile or ~/.bashrc . That is what they are there for.
 
Old 12-06-2004, 07:31 AM   #7
adrianmariano
Member
 
Registered: Dec 2004
Distribution: Ubuntu Yakkety
Posts: 193

Original Poster
Rep: Reputation: 15
Of course. I was thinking I could add it to the system wide file in /etc. Bit will there be any strange side effects? Could it perhaps affect suid processes? Maybe it would make them unable to determine the calling user, for example? Would it be undesirable do have LOGNAME=root?
 
Old 12-06-2004, 04:59 PM   #8
kevinalm
Member
 
Registered: Oct 2003
Location: Iowa
Distribution: LFS 5.0, building 6.3, win98se, multiboot
Posts: 288

Rep: Reputation: 30
Well, myself I would just try it. My understanding is that su username only sources ~/.bash_profile and ~/.bashrc for the user, while su - username sources the files in /etc first, then the users files. You don't want to fully reload the environment, Just alter the su environment, so I'd try doctoring the ~/ bash files. Back them up first though.
 
Old 12-06-2004, 06:37 PM   #9
adrianmariano
Member
 
Registered: Dec 2004
Distribution: Ubuntu Yakkety
Posts: 193

Original Poster
Rep: Reputation: 15
Actually bash reads /etc/bash.bashrc and ~/.bashrc when started as a non-login shell. This is how it would be started with a simple su. With 'su -' you get a login shell. For a login shell bash first reads /etc/profile and then it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile.

I suspect that if there are any undesirable effects of setting LOGNAME=$USER, they are likely to be somewhat subtle, and unlikely to surface soon. That's why I was asking if anybody knew of any reason not to do this.
 
Old 12-06-2004, 07:04 PM   #10
kevinalm
Member
 
Registered: Oct 2003
Location: Iowa
Distribution: LFS 5.0, building 6.3, win98se, multiboot
Posts: 288

Rep: Reputation: 30
Hmm... well that must be distro dependant, as that is not how it works in LFS, my distro. There is no /etc/bash.bashrc. Learn something new all the time. Regards.
 
Old 12-06-2004, 07:40 PM   #11
adrianmariano
Member
 
Registered: Dec 2004
Distribution: Ubuntu Yakkety
Posts: 193

Original Poster
Rep: Reputation: 15
Kind of a weird thing to have vary from distro to distro. I guess it could depend on the version of bash they included. (I have 3.00.)
 
Old 12-06-2004, 10:13 PM   #12
kevinalm
Member
 
Registered: Oct 2003
Location: Iowa
Distribution: LFS 5.0, building 6.3, win98se, multiboot
Posts: 288

Rep: Reputation: 30
Could be, I'm using bash 2.05b . Also might have to do with compile time configure options. I know that it is possible to change config file name and location that way with some packages.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
what is "sticky bit mode" , "SUID" , "SGID" augustus123 Linux - General 10 08-03-2012 04:40 AM
Telling people to use "Google," to "RTFM," or "Use the search feature" Ausar General 77 03-21-2010 11:26 AM
"Xlib: extension "XFree86-DRI" missing on display ":0.0"." zaps Linux - Games 9 05-14-2007 03:07 PM
RH9 NIS login error: "home directory does not exist" airrr Linux - Networking 2 08-06-2003 01:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration