From dd7fee44b126636d6c3edd9e325ce411e3ae5d78 Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Wed, 20 Apr 2005 17:54:12 +0000 Subject: Separate server auth and client .Xautority file in startx. .Xautority might have credentials from other Xservers which we might not want to enable on ours Bugzilla #3078). --- startx.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/startx.cpp b/startx.cpp index 5684cc0..8507f2a 100644 --- a/startx.cpp +++ b/startx.cpp @@ -162,14 +162,34 @@ esac authdisplay=${display:-:0} mcookie=`MK_COOKIE` +dummy=0 + +XCOMM create a file with auth information for the server. ':0' is a dummy. +xserverauthfile=$HOME/.serverauth.$$ +xauth -q -f $xserverauthfile << EOF +add :$dummy . $mcookie +EOF +serverargs=${serverargs}" -auth "${xserverauthfile} + +XCOMM now add the same credentials to the client authority file +XCOMM if '$displayname' already exists don't overwrite it as another +XCOMM server man need it. Add them to the '$xserverauthfile' instead. for displayname in $authdisplay $hostname$authdisplay; do - if ! xauth list "$displayname" | grep "$displayname " >/dev/null 2>&1; then + authcookie=`xauth list "$displayname" @@ + | sed -n "s/.*$displayname[[:space:]*].*[[:space:]*]//p"` 2>/dev/null; + if [ "z${authcookie}" == "z" ] ; then xauth -q << EOF add $displayname . $mcookie EOF removelist="$displayname $removelist" + else + dummy=$((dummy+1)); + xauth -q -f $xserverauthfile << EOF +add :$dummy . $authcookie +EOF fi done + #endif xinit $client $clientargs -- $server $display $serverargs @@ -177,7 +197,10 @@ xinit $client $clientargs -- $server $display $serverargs if [ x"$removelist" != x ]; then xauth remove $removelist fi - +if [ x"$xserverauthfile" != x ]; then + rm -f $xserverauthfile +fi + /* * various machines need special cleaning up */ -- cgit v1.2.3