Run an X app as another user (e.g. spot)

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
rssnow
Posts: 1
Joined: Sat 01 Oct 2005, 16:09

Run an X app as another user (e.g. spot)

#1 Post by rssnow »

Code: Select all

#!/bin/sh

if [ $# -lt 2 ]
then echo "usage: `basename $0` clientuser command" >&2
     exit 2
     fi
     
     CLIENTUSER="$1"
     shift
     
     # FD 4 becomes stdin too
     exec 4>&0
     
     xauth list "$DISPLAY" | sed -e 's/^/add /' | {
     
         # FD 3 becomes xauth output
             # FD 0 becomes stdin again
                 # FD 4 is closed
                     exec 3>&0 0>&4 4>&-
                     
                         exec su - "$CLIENTUSER" -c \
                                  "xauth -q <&3
                                            exec env DISPLAY='$DISPLAY' "'"$SHELL"'" -c '$*' 3>&-"
                                            
                                            }

This script, saved as su.sh, and chmod +x su.sh can be used for example
to run xchat as user spot:

./su.sh spot xchat

Richard Snow

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#2 Post by GuestToo »

that's a useful script ... but Puppy does not have xauth ... and it won't run rxvt as spot

informix
Posts: 2
Joined: Tue 28 Mar 2006, 09:26
Contact:

xauth missing

#3 Post by informix »

Hey .... and where do I get a dotpup that includes xauth ?

It damn neccessary for e.g. nxclient.

And I also wonder why there is no libstdc++-6.X already in puppylinux. I found a package that is 88Kb big and should fit into the def. distribution.

Post Reply