LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 07-27-2007, 07:10 AM   #1
iiv
Member
 
Registered: Jun 2007
Location: Russia, Moscow Region
Distribution: Slackware
Posts: 167

Rep: Reputation: 30
launching graphical programs from root as $USER


Code:
su - $USER -c "export DISPLAY=:0.0 ; amarok"
gets
Code:
: cannot connect to X server 0:0
Why this happens? This should work.
 
Old 07-27-2007, 08:44 AM   #2
bertlef
Member
 
Registered: Dec 2004
Location: Costa Rica
Distribution: Ubuntu
Posts: 69

Rep: Reputation: 17
Are you sure the display number is 0?
Try with other numbers 0.1 0.2 0.3...

I suppose you are running X already.
 
Old 07-27-2007, 08:45 AM   #3
Mark Havel
Member
 
Registered: May 2004
Location: Lyon, France
Distribution: Slackware
Posts: 85

Rep: Reputation: 15
It's a setting I've only seen on Slackware and I don't know how to change it in the Xorg.conf file. However, there's still a workaroung which is typing "xhost +" in a console before typing your command.
 
Old 07-27-2007, 03:01 PM   #4
iiv
Member
 
Registered: Jun 2007
Location: Russia, Moscow Region
Distribution: Slackware
Posts: 167

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by bertlef
Are you sure the display number is 0?
Yes, I am.

Quote:
Originally Posted by bertlef
I suppose you are running X already.
Yes, I am running. $USER returns user, currently running X. So, if user is running X, the command, i issued below should work.
Quote:
Originally Posted by Mark Havel
It's a setting I've only seen on Slackware and I don't know how to change it in the Xorg.conf file. However, there's still a workaroung which is typing "xhost +" in a console before typing your command.
xhost+ should not be used. Instead a magic cookie should be imported. But, I repeat, the $USER is already running X an has the privileges to run graphical programs on X.

Last edited by iiv; 07-27-2007 at 03:02 PM.
 
Old 07-30-2007, 12:47 AM   #5
evilDagmar
Member
 
Registered: Mar 2005
Location: Right behind you.
Distribution: NBG, then randomed.
Posts: 480

Rep: Reputation: 31
Quote:
Originally Posted by Mark Havel
It's a setting I've only seen on Slackware and I don't know how to change it in the Xorg.conf file. However, there's still a workaroung which is typing "xhost +" in a console before typing your command.
If the answer to the question appears to be "xhost +" then the question was a very stupid one. Always. Doing so is right up there with simply removing the front door to your house because the doorbell needs new batteries. Never, ever do this on a machine that's connected to a network or has more than one user account.

Not using the dash argument to su should allow the process to change UID without ditching the variables that contain the authentication tokens and information about where the display is.
 
Old 07-30-2007, 02:44 AM   #6
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Try like this:
"unset XAUTHORITY ; export DISPLAY=:0.0 ; amarok"

There's a nice little shell program called sux that will do this job for you. Look for the debian version sux-1.0.1 (sux_1.0.1-3.2.tar.gz)
 
Old 07-30-2007, 02:58 AM   #7
Mark Havel
Member
 
Registered: May 2004
Location: Lyon, France
Distribution: Slackware
Posts: 85

Rep: Reputation: 15
Then, if xhost + is Evil, what's the solution to launch graphical programs as root on a console under a normal user? It was possible on Mandriva and this was the only solution I found to do the same on a Slackware...
 
Old 07-30-2007, 12:21 PM   #8
SCerovec
Senior Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware on x86 and arm
Posts: 2,471
Blog Entries: 2

Rep: Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980
The magic solution on KDE session is:
Code:
kdesu -c amarok
once You type the password, it runs amarok even with root's KDe preferences and theme.
 
Old 07-31-2007, 01:51 AM   #9
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
su - $USER -c "unset XAUTHORITY ; DISPLAY=:0.0 ; amarok"
 
Old 07-31-2007, 02:16 AM   #10
mRgOBLIN
Slackware Contributor
 
Registered: Jun 2002
Location: New Zealand
Distribution: Slackware
Posts: 999

Rep: Reputation: 231Reputation: 231Reputation: 231
ssh -Y user@localhost

Last edited by mRgOBLIN; 07-31-2007 at 02:46 AM.
 
Old 07-31-2007, 02:45 AM   #11
SCerovec
Senior Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware on x86 and arm
Posts: 2,471
Blog Entries: 2

Rep: Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980
BTW is there a reason to run amarok as root?
What's the gain? Latency?
 
Old 07-31-2007, 12:33 PM   #12
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
He's not trying to run the application as root. He's trying to get root to start the program for the user and have the program belong to the user.
 
Old 07-31-2007, 02:22 PM   #13
SCerovec
Senior Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware on x86 and arm
Posts: 2,471
Blog Entries: 2

Rep: Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980
Did You mean:
root is trying to start an plication for a non-root user who's running X?

Like,
a phantom (non-X-running root) root launches windows across a users session?

sure I would like that, but there must be a way to authenticate to X as a valid user who has permissions to open windows?
 
Old 08-01-2007, 03:14 AM   #14
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
I know my suggestion works because it it the method I use to display icons on a users desktop when usbstorage devices are connected to my system. Connecting devices triggers udev(or hotplug) events which are run as root. That makes it easy for root to start a process on the users desktop. But if the process belongs to root the user cannot control it. By starting the process as the user(using su - $USER), the user can control it.
You can use xauth to get the credentials of the user and apply them to the new process or transfer the credentials of root which is probably very bad. But unsetting XAUTHORITY is much easier and may be safer assuming the root account is safe - the user is already authenticated if he already has a DISPLAY so XAUTHORITY can be ignored.
Some programs may still not do all of what you want unless you discover and export extra environmental variables associated with the desktop being used.
 
Old 08-01-2007, 03:26 AM   #15
SCerovec
Senior Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware on x86 and arm
Posts: 2,471
Blog Entries: 2

Rep: Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980Reputation: 980
So, as gnashley states, presuming all users have passwords, one could do that. Not that is bulletproof, but it's acceptable for a good reason.

Otherways, couldn't the user have own startup scripts?
Isn't there a way with hall / dbus? how des Bluetooth make it?
We all see that even PV puts HAL in Vanilla-slack.
 
  


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
Can't run gui (X) programs as root user nazdrowie Linux - General 25 12-02-2008 01:24 AM
I can not login to SuSE 10 as root user in graphical mode Voroojack SUSE / openSUSE 4 04-27-2006 09:58 PM
How to enable root to run graphical application in user log in xgreen Slackware 4 03-07-2005 06:39 AM
Launching apps under Root User Name MDBlueIce Linux - Software 2 08-20-2004 05:15 AM
programs won't run on user (non-root) accounts....? once here Slackware 16 12-02-2003 08:44 AM

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

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