LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-18-2013, 03:42 AM   #1
CollieJim
Member
 
Registered: Mar 2005
Distribution: Gentoo, Kubuntu
Posts: 582

Rep: Reputation: 28
Ubuntu's kdesu does not pass full environment


Since starting to use Kubuntu, environment variables I set have not been passed on to emacs. Lisp functions that work with Gentoo/KDE4 fail.

I have narrowed the problem to kdesu, which I use to start emacs. Kubuntu's version seriously restricts what it passes to programs it starts. I'm using
Code:
/etc/alternatives/kdesu -> /usr/lib/kde4/libexec/kdesu-distrib/kdesu
rather than the default kdesudo because it provides an Ignore button, and kdesudo passes far less that kdesu.

Short of compiling my own version, how do I get kdesu to pass the full environment? --help is no help.

Thanks
Jim
 
Old 08-18-2013, 07:41 AM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
To select what environment variables are passed by sudo, you can edit "/etc/sudoers" (by visudo of course). kdesu nor kdesudo does not decide about that. There should be "env_reset" flag set, so you could set if off (some security complications) or add your own variables to be passed by
Code:
Defaults env_keep += "SOME_VAR_A SOME_VAR_B SOME_VAR_C"

Last edited by eSelix; 08-18-2013 at 07:48 AM.
 
1 members found this post helpful.
Old 08-18-2013, 09:00 AM   #3
CollieJim
Member
 
Registered: Mar 2005
Distribution: Gentoo, Kubuntu
Posts: 582

Original Poster
Rep: Reputation: 28
Thanks.

It works, but not quite what I'm looking for. kdesudo uses /etc/sudoers but kdesu does not appear to. Using kdesudo means having 2 menu items and 2 icons rather than singles with an option.

At least it works from the command line in konsole, but I'm still looking.

I have just determined that using kdesudo from the command line works, but it does not work in the menu.

Last edited by CollieJim; 08-18-2013 at 09:54 AM.
 
Old 08-18-2013, 12:12 PM   #4
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
You should be able to specify which backend is used by kdesu by this command
Code:
kwriteconfig --file kdesurc --group super-user-command --key super-user-command sudo
For not working command in menu, can you paste here its desktop file?
 
Old 08-18-2013, 11:12 PM   #5
CollieJim
Member
 
Registered: Mar 2005
Distribution: Gentoo, Kubuntu
Posts: 582

Original Poster
Rep: Reputation: 28
Desktop file created when emacs was installed:
Code:
[Desktop Entry]
Categories=Utility;Development;TextEditor;
Comment=View and edit files
Exec=/usr/bin/emacs23 %F
GenericName=Text Editor
Icon=emacs23
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Name=GNU Emacs 23
NoDisplay=false
Path[$e]=
StartupNotify=true
StartupWMClass=Emacs23
Terminal=0
TerminalOptions=
TryExec=emacs23
Type=Application
Version=1.0
X-KDE-SubstituteUID=false
X-KDE-Username=
Desktop file for root from menu entry I added:
Code:
[Desktop Entry]
Comment=
Exec=kdesudo emacs
Icon=emacs22
Name=Emacs(r)
NoDisplay=false
Path[$e]=
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=
 
Old 08-19-2013, 03:42 AM   #6
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
In first exec is "/usr/bin/emacs23 %F", and you have just "kdesudo emacs", are you sure there is a program with that name, maybe try "kdesudo /usr/bin/emacs23 %F".
 
Old 08-19-2013, 06:09 AM   #7
CollieJim
Member
 
Registered: Mar 2005
Distribution: Gentoo, Kubuntu
Posts: 582

Original Poster
Rep: Reputation: 28
emacs and emacs23 both link to the same executable.
Code:
225 16:21:07 ~ $ file `which emacs`
/usr/bin/emacs: symbolic link to `/etc/alternatives/emacs'
$ file `which emacs23`
/usr/bin/emacs23: symbolic link to `emacs23-x'
$ file `which emacs23-x`
/usr/bin/emacs23-x: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xce7af5c7ef306f506b7076879687d88fa467e305, stripped
$ ls -al /etc/alternatives/emacs
lrwxrwxrwx 1 root root 18 Aug  7 23:29 /etc/alternatives/emacs -> /usr/bin/emacs23-x
The problem is not whether the second version works (it does) but the passing of environment variables, which klauncher does not.
 
Old 08-19-2013, 07:04 AM   #8
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
So, if "kdesudo from the command line works, but it does not work in the menu", how you set these environment variables? Settings in /etc/environment or these exported by ~/.profile should be passed.
 
Old 08-19-2013, 07:43 AM   #9
CollieJim
Member
 
Registered: Mar 2005
Distribution: Gentoo, Kubuntu
Posts: 582

Original Poster
Rep: Reputation: 28
When using the KDE desktop, I have 2 ways to start emacs.
The first is to select it from the Start menu.
The second is to start Konsole and enter 'emacs' as a command.

The first does not pass environment variables while the second does.

This applies to both 'emacs' and 'kdesudo emacs'.
 
Old 08-19-2013, 02:21 PM   #10
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
Yes, I understand, but you must somewhere set these environment variables. Can you explain how you do that? I just check how behave my Kubuntu and it pass my variables to program launched from menu.
 
Old 08-21-2013, 04:04 AM   #11
CollieJim
Member
 
Registered: Mar 2005
Distribution: Gentoo, Kubuntu
Posts: 582

Original Poster
Rep: Reputation: 28
I have this code in /etc/bash.bashrc
Code:
if [ -e /mnt/NAS-Share/data ] ; then
  NAS_SHARE=net
  NAS_PATH=/mnt/NetWolf/jeh
  touch ~/.net-available
else
  NAS_SHARE=no
  NAS_PATH=/usr/local/share/emacs/site-lisp/jeh
  rm -f ~/.net-available
fi

export NAS_SHARE NAS_PATH
 
Old 08-21-2013, 07:33 AM   #12
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
I think this file is only executed when you run bash. I have on top of it
Quote:
System-wide .bashrc file for interactive bash(1) shells.
For setting global environment variable you can use "/etc/environment"
 
1 members found this post helpful.
Old 08-22-2013, 08:54 AM   #13
CollieJim
Member
 
Registered: Mar 2005
Distribution: Gentoo, Kubuntu
Posts: 582

Original Poster
Rep: Reputation: 28
Finally!
I shifted the code to /etc/environment and all is well now.

Thanks
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] I need to pass environment variables to emacs CollieJim Programming 1 06-04-2012 07:45 AM
[SOLVED] strace kdesu konqueror & > ./strace_kdesu (diagnosing failing kdesu) GrapefruiTgirl Linux - Desktop 23 11-02-2009 05:03 PM
How to pass an environment variable to an xterm session Leo Simon Linux - Software 6 05-18-2009 05:49 PM
Debugging WPA; ifup doesn't pass environment variables! jagmarz Linux - Wireless Networking 1 07-29-2008 05:50 PM
How can I get the full list of environment variables (RedHat 7.2)? yuzuohong Linux - General 1 06-07-2003 03:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:16 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
Open Source Consulting | Domain Registration