LinuxQuestions.org
Review your favorite Linux distribution.
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 10-25-2008, 11:25 PM   #1
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
sudo with KDE applications


I have sudo set up so that my two normal user accounts (only used by me) can arbitrarily sudo to each other. I do this because I have one account configured so I can do programming and I have the other configured for all other things, but sometimes I want to run kate, etc. as the other user. I normally use kdesu for that (from the command line,) but I don't want to type the password every time, and sometimes kdesu crashes and doesn't work again until I restart my computer (KDE 4.1.) I actually use XFCE right now, but I still use kate as my GUI text editor. Is there a way to sudo a KDE application in a way that it honors the fact that I have NOPASSWD set in sudoers? Thanks.
ta0kira
 
Old 10-26-2008, 04:11 PM   #2
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by ta0kira View Post
Is there a way to sudo a KDE application in a way that it honors the fact that I have NOPASSWD set in sudoers? Thanks.
ta0kira
Well... use sudo. There should be a problem with that. If there is, try to describe it. Sudo should work the same for text of graphical programs, that's irrelevant to sudo.
 
Old 10-26-2008, 06:58 PM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Original Poster
Rep: Reputation: Disabled
Sorry, I assumed that most people familiar with sudo knew that you can't access X as a non-root user who didn't start it. That's the only reason I ever started using kdesu. kdesu is run as the user "owning" KDE, giving it KDE and X access, then it does setuid to the user you specify; that's how it can start a KDE application as someone else.

Here is the error I get:
Code:
[ta0kira@kPbarry:~]# sudo kate
No protocol specified
kate: cannot connect to X server :0.0
ta0kira

PS I'm looking into gksudo, but it's looking like an upgrade nightmare since Slackware no longer packages Gnome.
 
Old 10-26-2008, 07:59 PM   #4
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by ta0kira View Post
Sorry, I assumed that most people familiar with sudo knew that you can't access X as a non-root user who didn't start it. That's the only reason I ever started using kdesu. kdesu is run as the user "owning" KDE, giving it KDE and X access, then it does setuid to the user you specify; that's how it can start a KDE application as someone else.

Here is the error I get:
Code:
[ta0kira@kPbarry:~]# sudo kate
No protocol specified
kate: cannot connect to X server :0.0
ta0kira

PS I'm looking into gksudo, but it's looking like an upgrade nightmare since Slackware no longer packages Gnome.
I don't know what the problem is. I never had a problem connecting as root to any other user's X server.

The only real problem you can get is that sudo will usually run using the user's config files, instead the root configs. That's what sudo -i is for.

http://jesgue.homelinux.org/other-files/sudo.jpg

In that screenshot you can see many things: the running user is i92guboj, as whoami says. I use sudo -i to change to root and then run konqueror. No password required. You could do a small function to ease this and put it in your .bashrc or .bash_profile, something like this:

Code:
function sukonki() {
  sudo -i << EOF
  konqueror
  EOF
}
Do "exec bash" to reload your shell, from that point, you should be able to use this toy just invoking sukonki. Of course, you need to configure sudo.

As you can see on the screenshot, it runs, and runs as root (look at the owner of the process on htop). So, yep, it runs with sudo, and there's no problem. However, some distros like ubuntu disable the root account for I-don't-know-what-reason, I don't know how they do it, and that might be a problem for this (or not, it depends). But first, you need to find why you can't connect. Maybe you need to tell it the DISPLAY to use on the command line, that might worth a shot.

So, it seems possible, but it might require a bit of tinkering. The only available solutions beside that would be to live with the kdesu annoyance, to install the whole gnome just to use gksudo or whatever it's called, or to find another alternative. I really don't use sudo much so I can't give any better advice. I work mostly on command line and just use su -c.

Last edited by i92guboj; 10-26-2008 at 08:14 PM. Reason: added last paragraph
 
Old 10-26-2008, 10:02 PM   #5
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Original Poster
Rep: Reputation: Disabled
I'm trying to access X as a non-root user. The lack of -u with sudo in my example is probably confusing. I use a default user, though I did specify that I wasn't using root in my other post. Thanks.
ta0kira
 
Old 10-26-2008, 10:12 PM   #6
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Oh, sorry, I didn't notice.
 
Old 12-08-2008, 01:35 AM   #7
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Original Poster
Rep: Reputation: Disabled
I found a partial solution. I enable connection to X by everyone with xhost +localhost and export the display with export DISPLAY=localhost:0.0 from a terminal as the other user, then run the application. This only seems to have one problem and that's connecting to dbus, which incidentally prevents file system browsing. Of course that's a major problem, but at least I'm a step further.
ta0kira
 
Old 12-08-2008, 03:34 AM   #8
slack12ware
Member
 
Registered: Mar 2008
Location: Deep in the Jango(Africa)
Distribution: Slackware 12, Fedora 8
Posts: 46

Rep: Reputation: 15
I am no pro and Dont Know what your problem really is but I have slack 12 and my
/etc/sudoers has :

slack12ware ALL=(ALL) NOPASSWD: ALL

and I can run

run any commands with :
sudo (commandname)
works with no problem.

also try:
su -c "kate" -l
it will run command with roots profile and settings although you will have to provide a password with this method,(but am sure a little stroll through the man pages can solve that too)
 
Old 12-09-2008, 06:50 PM   #9
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by slack12ware View Post
run any commands with :
sudo (commandname)
works with no problem.
Yes, but I doubt you can do sudo xterm, etc. with a target user other than root. That's the problem I'm having.
ta0kira
 
Old 12-11-2008, 12:51 AM   #10
slack12ware
Member
 
Registered: Mar 2008
Location: Deep in the Jango(Africa)
Distribution: Slackware 12, Fedora 8
Posts: 46

Rep: Reputation: 15
Quote:
Originally Posted by ta0kira View Post
Yes, but I doubt you can do sudo xterm, etc. with a target user other than root. That's the problem I'm having.
ta0kira

mmm like I said aint no pro but will have to try it out when am on linux box.
will get back to you.
 
Old 12-12-2008, 03:49 AM   #11
slack12ware
Member
 
Registered: Mar 2008
Location: Deep in the Jango(Africa)
Distribution: Slackware 12, Fedora 8
Posts: 46

Rep: Reputation: 15
Dont know if this will help but I tried xterm last night and here are screenshots of my results (didnt even need sudo or su ):

xterm(no sudo or su)
sudo xterm

su -c "xterm" -l(however gave me errors as you can see)

sudo xterm (once more)

I dont know how you machine is set up but I get the feeling its something to do with /etc/sudoers or group previlages.

J
 
  


Reply


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
LXer: The Ultimate Sudo FAQ — To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
LXer: 10 Best KDE Applications Not Included in KDE LXer Syndicated Linux News 0 06-14-2008 05:40 PM
Kde, Firefox, and Sudo Murdock1979 Linux - General 6 10-04-2006 07:36 PM
Can't start KDE or run some KDE applications Per Mandriva 6 07-05-2006 11:34 AM
KDE applications repository with all KDE apps for Debian vharishankar Debian 2 02-19-2006 07:54 AM

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

All times are GMT -5. The time now is 07:16 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