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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
10-25-2008, 11:25 PM
|
#1
|
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078
Rep:
|
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
|
|
|
10-26-2008, 04:11 PM
|
#2
|
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083
|
Quote:
Originally Posted by ta0kira
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.
|
|
|
10-26-2008, 06:58 PM
|
#3
|
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078
Original Poster
Rep:
|
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.
|
|
|
10-26-2008, 07:59 PM
|
#4
|
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083
|
Quote:
Originally Posted by ta0kira
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
|
|
|
10-26-2008, 10:02 PM
|
#5
|
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078
Original Poster
Rep:
|
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
|
|
|
10-26-2008, 10:12 PM
|
#6
|
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083
|
Oh, sorry, I didn't notice.
|
|
|
12-08-2008, 01:35 AM
|
#7
|
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078
Original Poster
Rep:
|
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
|
|
|
12-08-2008, 03:34 AM
|
#8
|
Member
Registered: Mar 2008
Location: Deep in the Jango(Africa)
Distribution: Slackware 12, Fedora 8
Posts: 46
Rep:
|
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)
|
|
|
12-09-2008, 06:50 PM
|
#9
|
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078
Original Poster
Rep:
|
Quote:
Originally Posted by slack12ware
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
|
|
|
12-11-2008, 12:51 AM
|
#10
|
Member
Registered: Mar 2008
Location: Deep in the Jango(Africa)
Distribution: Slackware 12, Fedora 8
Posts: 46
Rep:
|
Quote:
Originally Posted by ta0kira
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.
|
|
|
12-12-2008, 03:49 AM
|
#11
|
Member
Registered: Mar 2008
Location: Deep in the Jango(Africa)
Distribution: Slackware 12, Fedora 8
Posts: 46
Rep:
|
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
|
|
|
All times are GMT -5. The time now is 07:16 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|