Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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?
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?
Distribution: LFS 5.0, building 6.3, win98se, multiboot
Posts: 288
Rep:
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.
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.
Distribution: LFS 5.0, building 6.3, win98se, multiboot
Posts: 288
Rep:
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.
Distribution: LFS 5.0, building 6.3, win98se, multiboot
Posts: 288
Rep:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.