Re: su and X question
On Wed, 2006-04-12 at 18:49 +0200, Chris wrote:
> Hi I'd like to open X-applications like the in the example below from an su
> Terminal, but get an Xlib connection error. I have set up sudo so that: sudo
> kwrite /etc/fstab works, but how come it doesn't in a normal su Terminal?
> athlon:/home/stoffel# kwrite /etc/fstab
> Xlib: connection to ":0.0" refused by server
> Xlib: No protocol specified
> kwrite: cannot connect to X server :0.0
The credentials for using an X server are found in the .Xauthority file
of each user's home directory. If you run 'xauth list' from the
non-privileged user account, you will see the credentials to the X
server you are working on. However, root does not have appropriate
credentials in its .Xauthority until they are granted.
When sudo is used, the HOME directory is not modified, so even though
root is running the program, the HOME is still that of the original
user, so the .Xauthority contains the appropriate credentials.
However, when using su, the HOME changes to root's home directory, and
the appropriate credentials do not exist in ~root/.Xauthority . 'man
xauth' for more details.
There is a wrapper package for su called sux, which grants the resulting
su user permissions to the current X server when sux is called.