[wplug] dropping root privileges in shell script
Vanco, Donald
VANCOD at PIOS.com
Sun Mar 30 19:45:16 EST 2003
Alexandros Papadopoulos wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi all!
>
> I recently discovered the nice ThinkPadButtons (tpb) utility in
> http://savannah.nongnu.org/projects/tpb
>
> and wish to run it every time my machine boots.
>
> So, in Red Hat the file to do that is /etc/rc.local, but whatever gets
> put in there is executed as root, which won't do. So, I put the
> following in /etc/rc.local:
>
> su - alex -c '/home/alex/bin/thinkpad'
>
> This is the script I want executed, but as user "alex". The script has
> the following in it:
>
> #!/bin/bash
> echo `whoami`
> nohup tpb --osd=on --thinkpad="xterm" &
>
> The result is that whoami returns "alex", in the process list I see
> the nohup command running as "alex", BUT the on screen display
> doesn't work and I get
>
> Xlib: connection to ":0.0" refused by server
> Xlib: No protocol specified
>
> ...messages, which hint that root is trying to open something on the
> display! If I run the script as "alex", all is fine. I don't want to
> just give xhost +localhost to allow root to run stuff, I'd like to
> know why the script does not execute as if "alex" had called it.
Since this sounds like an X only utility, it might be sensible to
add to /etc/X11/xinit/xinitrc or possibly as a script in
/etc/X11/xinit/xinitrc.d
My $.02
Don
More information about the wplug
mailing list