LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 12-28-2013, 06:17 PM   #1
NoStressHQ
Member
 
Registered: Apr 2010
Location: Lausanne - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware Leet - 32/64bit
Posts: 317

Rep: Reputation: 109Reputation: 109
Question tmux vs [kde]su[do], HOME directory problem.


Hi,

I'm a bit disappointed as I just figured out (or stumble upon) this problem this week, while I think (but I'm not sure now) that I have used tmux without getting trouble before.

I constantly use tmux, in terminal windows, even on my Graphical Desktop environment.

But then I realize that when I run tmux through a session like su/sudo/kdesu, I get my user's $HOME instead of /root.

This works:
Code:
$ sudo bash -c "echo \"\$HOME\""
/root
While this doesn't work _or not as I expected _:

Code:
$ sudo tmux new "echo \"\$HOME\" ; read"
/home/my-user-home
And strange upon strange, even the way I used to use until recently give the same result:
Code:
$ su
# echo "$HOME"     
/root
# tmux
# echo "$HOME"
/home/my-user-home
Is it supposed to work like that ? Had I hallucinated during the lasts months ?

And anyway, how can I launch a tmux session with the "root" home instead of the user's one, this already broke part of my user's home folder creating files with root permissions. It wasn't too much of a big problem as I sorted this out quickly, but I still have to be able to launch automated scripts through a sudo command/su session.

I know about the "opposite" option of sudo (-E) that should do this behavior at the "sudo session level" (passing the HOME environment to the sudo sessions to run graphical programs).

I also have this behavior with kdesu:

Code:
$ kdesu Terminal
...then in terminal session:
Code:
# echo "$HOME"
/root
# tmux
# echo "$HOME"
/home/my-user-home
Edit: I just test in a VM from a fresh install from "pure text terminal and inside xfce, and I don't see this behavior... So this might be with some sort of "sudo" configuration when I activated it?
Edit 2: I can "cascade" several 'Terminal' session after a kdesu, and the $HOME is still /root, so it seems to me it's some kind of behavior related to tmux. I might be wrong of course.

If someone could give me some enlightment on this, it would be a "life savior" .

Cheers.

Garry.

Last edited by NoStressHQ; 12-28-2013 at 06:35 PM.
 
Old 12-29-2013, 06:41 AM   #2
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 3,517

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
No enlightenment from me I am sorry to say, but I will point out a difference between su and kdesu that I have noticed in Slackware 14.1, involving setting the MAIL environment variable.
Using 'su - <localuser>' then ' echo "$HOME";echo "$MAIL" ' produces
Quote:
/home/<localuser>
/var/spool/mail/<localuser>
whereas using 'kdesu -u <localuser> -c konsole' then ' echo "$HOME";echo "$MAIL" ' produces
Quote:
/home/<localuser>
/var/mail/<loginuser>
If I use ' kdesu -u <localuser> -c 'MAIL=/var/spool/mail/<localuser> konsole' ' then I get the same as using 'su - <localuser>' i.e.
Quote:
/home/<localuser>
/var/spool/mail/<localuser>
 
Old 12-29-2013, 10:59 AM   #3
NoStressHQ
Member
 
Registered: Apr 2010
Location: Lausanne - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware Leet - 32/64bit
Posts: 317

Original Poster
Rep: Reputation: 109Reputation: 109
Yes, that is because kdesu pass through some user's vars in order to allow GUI app to access the Window Manager.

By the way, I also checked and diffed my whole settings on my machine from the time I had no problem with tmux and now, and there's no specific change (at least in /etc/*...). I don't see this behavior on fresh installed system, and I really don't know what has been changed so now tmux drop me back with my "local user home" instead of the root's one...

Also, it's ok with one layer (or several) of "kdesu Terminal", it's only when I launch tmux that my HOME is "broken".

For now I work carefully with su and without tmux on my 'faulty' machine. It's a bit painful but at least I can work.

Thank you allend for your hint. I have looked for this for a week, now, if nobody have a clue, I'll continue to work with care until my next "full install" .

Cheers.

Garry.

PS/ Just to note that when in a kdesu "process", there's a variable KDESU_USER (or something like that) which holds the login user. It might be that tmux (or something) uses this to fall back in that HOME instead of the current UID's one.

Last edited by NoStressHQ; 12-29-2013 at 11:02 AM.
 
  


Reply

Tags
home, kdesu, su, sudo, tmux


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
NFS problem: "Could not chdir to home directory /home/USER: Permission denied" sumanc Linux - Server 4 07-22-2010 05:12 PM
Konqueror and other kde programs cannot see home directory arubin Slackware 2 06-07-2009 01:41 PM
contents of 'home' directory found at sda5: mounted as /home, and also on sda6:/home leswatson Linux - Newbie 4 04-18-2008 05:02 PM
How reset HOME directory in KDE under SuSE? Leon W. Malinofsky Suse/Novell 1 01-12-2008 05:55 PM
Lost home directory and problems starting KDE (SUSE 9.3) Jongi Suse/Novell 3 10-19-2005 02:26 AM


All times are GMT -5. The time now is 10:10 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration