[wplug] dropping root privileges in shell script

Alexandros Papadopoulos apapadop at cmu.edu
Sun Mar 30 15:40:03 EST 2003


-----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.

Cheers

- -A
- -- 
http://andrew.cmu.edu/~apapadop/pub_key.asc
3DAD 8435 DB52 F17B 640F  D78C 8260 0CC1 0B75 8265
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+h1YpgmAMwQt1gmURAncZAJ4lo+jqbNFDLuZuTjX8p35VR40+bgCeNzte
Uri2mpqu4NmZuqmAnax+9Fg=
=g9GE
-----END PGP SIGNATURE-----




More information about the wplug mailing list