LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Running X programs as root. (https://www.linuxquestions.org/questions/slackware-14/running-x-programs-as-root-537693/)

gbowden 03-15-2007 08:21 AM

Running X programs as root.
 
Is there anything wrong with doing the following to run X programs as root:

xauth -f /home/[user]/.Xauthority extract - :0 | xauth merge -
export DISPLAY=:0

Regards,

Greg

anomie 03-15-2007 09:47 AM

It seems like a lot of extra work. Have you tried simply:
Code:

$ su -m
# ./x-app-here

?

Alien Bob 03-15-2007 10:05 AM

Quote:

Originally Posted by anomie
It seems like a lot of extra work. Have you tried simply:
Code:

$ su -m
# ./x-app-here

?

That does not work in Slackware.
What I usually do to get X apps to run on my display after su-ing to root:
Code:

echo $DISPLAY                  # you'll be needing this value 3 lines below
sudo -i                        # or "su -" on older Slackwares
xauth merge ~alien/.Xauthority # use your own username here instead of "alien"
export DISPLAY=:0.0            # use the value of DISPLAY you've seen 3 lines before

Eric

gbowden 03-15-2007 10:07 AM

Thanks for your help everyone.

SpelledJ 03-16-2007 10:12 AM

Eric -
Can you give a quick explanation (or link to some info) of what's different about Slackware's X configuration that prevents anomie's suggestion from working? It seems like I've been able to just su to root and run an X program on other distros, but not Slack.

General Maximus 03-16-2007 10:44 AM

Erm, what about kdesu (or gksu in GNOME)?

Alien Bob 03-16-2007 11:26 AM

Quote:

Originally Posted by SpelledJ
Eric -
Can you give a quick explanation (or link to some info) of what's different about Slackware's X configuration that prevents anomie's suggestion from working? It seems like I've been able to just su to root and run an X program on other distros, but not Slack.

This is because Slackware uses the "su" program that is part of the "shadow" utilities. Other distros probably are using the "su" that comes with the coreutils package, and which knows about the "-m" option.

Eric

SpelledJ 03-16-2007 02:02 PM

I never realized there were any differences in the low-level utilities. I assumed they were all GNU-based, and every distro used the same ones. I looked up the man page for the coreutils 'su', and sure enough, its -m flag prevents the environment variables from being reset when you change users. The manpage for 'su' on my Slackware box doesn't include that flag. I also didn't know that the same package (shadow) provides all of the useradd/groupadd/etc scripts. Thanks for the info, Eric.

Justin


All times are GMT -5. The time now is 12:05 AM.