LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 09-06-2006, 07:38 AM   #1
Haz2a
LQ Newbie
 
Registered: May 2006
Distribution: Ubuntu
Posts: 12

Rep: Reputation: 0
gksu and xhost


In Breezy I used to run several apps as another user on the same machine via 'gksu -u <other-username> <cmd>'
(after giving the other user's password to gnome-keyring when prompted). Now I've upgraded to Dapper this fails. No prompt for password, just the errors:-
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified

unable to display ":0.0"
It works if I just do 'gksu <cmd>' to run the cmd as root, but not with '-u <username>' to run the cmd as a different user.

If I do: 'xhost +local:' first (as my main user and sudoer), then I can use 'gksu -u' without any problems. But I need to accomplish this from launchers without having to enter the xhost command first.

I've tried creating /etc/X0.hosts (with a zero) and adding the line: 'local:', then restarting X. This seems to do part of the job. If I then do 'xhost' it shows 'LOCAL:' as needed,
BUT if I do 'gksu -u <otheruser> <cmd>',
or 'sudo -u <otheruser> xhost', I just get the Xlib errors.
I've also tried lots of other possibilities in X0.hosts eg: 'localhost', '<username>', '+local:', etc, etc.

In a terminal I can do:-
'xhost +local:; gksu -u <otheruser> nautilus' on one line, but this won't work from the launcher - it doesn't seem to like the special characters ';' or '&&'.

The only way I can find to do 'xhost +local:' automatically is to put the xhost cmd and the gksu-app cmd into a separate script eg:
Code:
xhost +local:
gksu -u <otheruser> nautilus
then to call the scripts from the launchers.

Since I have several apps to be launched on several different machines, this seems overly complicated and laborious. I don't really want to allow other users to connect from the network via TCP, just other users on the same machine.

Surely there must be a more elegant way to do this!? - eg: via /etc/X0.hosts or similar?
 
Old 09-06-2006, 07:45 PM   #2
binary_y2k2
Member
 
Registered: Jul 2005
Location: England, UK
Distribution: Ubuntu 8.04 Server, Kubuntu 12.04
Posts: 698
Blog Entries: 1

Rep: Reputation: 31
The way I do it is, I have the line "xhost +LOCAL: >/dev/null" in my ~/.bashrc file.
 
Old 09-07-2006, 04:35 AM   #3
Haz2a
LQ Newbie
 
Registered: May 2006
Distribution: Ubuntu
Posts: 12

Original Poster
Rep: Reputation: 0
gksu and xhost - SOLVED

Binary, thanks for your reply - I had mixed results (which I think you hinted at), but it prompted me to find a better way - for me at least. I'm using Gnome by the way.

After putting the xhost cmd into .bashrc as you suggested I found:-
When I do a normal fresh login to a blank desktop, my gksu launchers don't work.
If I restart X via Ctrl-Alt-Bkspc, the desktop opens with Nautilus and Gnome Terminal displayed (I don't know why, but it does this every time) - and in this case the launchers work first time - and no passwords needed!
If I login normally, and then open the terminal but do nothing in the terminal - then the launchers work, again without requesting a password.

I have now put the cmd 'xhost +local:' into Gnome > System > Prefs > Session > Startup Programs, and the launchers now work reliably. Gksu password behaviour seems normal. I guess its something to do with the X session being fully initialized when the xhost cmd is executed.

Haz
 
  


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
gksu or alternative? shame Slackware 4 05-09-2006 04:25 PM
problems with su, gksu nixer4me Debian 1 03-11-2006 04:39 PM
Recent upgrade requires me to use sudo for gksu joffa Debian 5 07-15-2005 04:33 AM
Error while running gksu Ephracis Linux - Software 0 10-27-2004 05:09 AM
xhost invasian Linux - Newbie 3 08-08-2004 08:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

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