Michael Salmon wrote:
+----- On Thu, 17 Dec 1998 12:25:04 -0100, serguei chabanov writes: | | I've never worked with multi-user systems before and I don't have yet | any feel for that kind of thing. If I'm in X (not as root) and open a | root shell, I cannot call any x apps from the root shell, it says | "couldn't connect to xserver". Am I doing something that goes against | the will of the linux gods? Or am I just not doing it well? Could | somebody please help me?
When you start up an Xserver one of the options is to restrict those who can connect, basically every application needs to know a password or be run on a specified set of hosts. The password is usually stored in a file in your home account called .Xauthority, any program that can read your Xserver's password can connect to the server. As root you can read any local file but of course root's home directory isn't the same as your own and you need to set 2 variables to point out the information needed, DISPLAY should point to the desired server, usually :0 and XAUTHORITY which should be ~<you>/.Xauthority.
I had this problem too and the above hint showed me the way: The /root/.bashrc provided by SuSE already sets the DISPLAY variable like this: # # try to set DISPLAY smart (from Hans) :) # if test -z "$DISPLAY" -a "$TERM" = "xterm" -a -x /usr/bin/who ; then WHOAMI="`/usr/bin/who am i`" _DISPLAY="`expr "$WHOAMI" : '.*(\([^\.][^\.]*\).*)'`:0.0" if [ "${_DISPLAY}" != ":0:0.0" -a "${_DISPLAY}" != " :0.0" \ -a "${_DISPLAY}" != ":0.0" ]; then export DISPLAY="${_DISPLAY}"; fi unset WHOAMI _DISPLAY fi Now all that remains is to put this into /root/.bashrc as well: # # this allows a user to su to root and open a window under X # # note the separate quoting for the shell variable, with no intervening spaces PARENTUID=`ps lax | awk '$3 == '"${PPID}"' {print $2 }'` PARENTHOME=`awk -F: '$3 == '"${PARENTUID}"' {print $6}' /etc/passwd` export XAUTHORITY="${PARENTHOME}/.Xauthority" unset PARENTHOME PARENTUID and it works; any user running an X session on the console can now 'su' to root and launch an X client without running 'xhost'. Thanks Michael ;-) Ralph -- rclark@virgosolutions.demon.co.uk Ralph Clark, Virgo Solutions Ltd (UK) __ _ / / (_)__ __ ____ __ * Powerful * Flexible * Compatible * Reliable * / /__/ / _ \/ // /\ \/ / *Well Supported * Thousands of New Users Every Day* /____/_/_//_/\_,_/ /_/\_\ The Cost Effective Choice - Linux Means Business! - To get out of this list, please send email to majordomo@suse.com with this text in its body: unsubscribe suse-linux-e Check out the SuSE-FAQ at <A HREF="http://www.suse.com/Support/Doku/FAQ/"><A HREF="http://www.suse.com/Support/Doku/FAQ/</A">http://www.suse.com/Support/Doku/FAQ/</A</A>> and the archiv at <A HREF="http://www.suse.com/Mailinglists/suse-linux-e/index.html"><A HREF="http://www.suse.com/Mailinglists/suse-linux-e/index.html</A">http://www.suse.com/Mailinglists/suse-linux-e/index.html</A</A>>