From: casper@fwi.uva.nl (Casper H.S. Dik)
Subject: Re: Remote client works in X11, not NeWS - auth problem?
Organization: FWI, University of Amsterdam
Date: Fri, 28 Aug 1992 19:41:29 GMT

weinri@athena.cs.uga.edu (Kevin Weinrich) writes:

>I have a problem that I *think* is an XNeWS authorization problem.
>I'm hoping someone has seen this before.

>If I run xauth, it responds:
>  Using authority file /home/kbw/.Xauthority
>  xauth>
>I type:
>  list
>it responds:
>  #ffff##:  MIT-MAGIC-COOKIE-1  debf8cd. . .
>That first field looks mangled (it should say something about helios),
>but the servers seem to accept it.

This is the entry that is generated by news. It is usually in the
file .xnews.$DISPLAY or some such.
This entry is a so called ``wild card'' entry (matches any DISPLAY).
I wrote a script that will take a #ffff## entry from
a .xnews.$DISPLAY and put a hostname/unix:0 and hostname:0 in
your .Xauthority file. Run it at the start of your ~/.xinitrc or
after mkcookie in the openwin startup script. Xnews will need
the #ffff## entry, so you better leave the mkcookie stuff alone.

Shar file with ``openwinauthmerge'' appended.

Casper

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  openwinauthmerge
# Wrapped by casper@fwi.uva.nl on Fri Aug 28 21:38:58 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'openwinauthmerge' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'openwinauthmerge'\"
else
echo shar: Extracting \"'openwinauthmerge'\" \(1922 characters\)
sed "s/^X//" >'openwinauthmerge' <<'END_OF_FILE'
X#!/bin/sh
X#
X# Merge the openwin ``wildcard'' authority cookie with the user's
X# ~/.Xauthority file. Don't add the wild card to ~/.Xauthority as
X# X clients will prefer the explicit entries that might exist from
X# previous X sessions and we also might want to be able to run multiple
X# X sessions on multiple displays at the same time.
X#
X# This programs should be the first to run in ~/.xinitrc.
X# E.g.,
X# openwinauthmerge
X# XAUTHORITY=$HOME/.Xauthority; export XAUTHORITY
X#
X# Casper Dik (casper@fwi.uva.nl)
X#
X
X
Xif [ "$DISPLAY" = "" ]
Xthen
X    echo '$DISPLAY not set.' 1>&2
X    exit 1
Xfi
XHOST=`hostname`
XDISP=`expr $DISPLAY : '.*\(:[0-9]*\)\.*'`
XNEWSAUTH=$HOME/.xnews.$HOST$DISP
XXAUTH=$HOME/.Xauthority
Xif [ ! -r "$NEWSAUTH" ]
Xthen
X    echo "Can't read NeWS authority file." 1>&2
X    exit 1
Xfi
X
X
X# Does your xauth has the R4/openwin 2 bug that destroys hex numbers containing
X# a-f or A-F?
Xxauth -q -f $XAUTH add ${HOST}${DISP} . abcd
Xval=`set \`xauth -i -q -f $XAUTH list ${HOST}${DISP}\`; echo $3`
Xif [ "$val" != abcd ]
Xthen
X    # has bug, must use numerical values.
X    # A numerical x auth entry looks like:
X    # type length [ address ] length [ number ] length name length cookie
X    #
X    # the address and number field are non existant if the length field are 0
X    #
X    # Merging (we don't want to pass the cookie as argument)
X    #
X    # TCP/IP socket
X    xauth -q -f $XAUTH add ${HOST}${DISP} . 00
X    # Unix socket
X    xauth -q -f $XAUTH add ${DISP} . 00
X    ( 
X	xauth -i -q -f $NEWSAUTH nlist 2>/dev/null
X	xauth -i -q -f $XAUTH nlist ${HOST}${DISP} ${DISP}
X    ) | awk 'NR == 1 { cookie = " " $4 " " $5 " " $6 " " $7 }
X	     NR > 1 { print $1 " " $2 " " $3 " " $4 " " $5  cookie }' |
X    xauth -q -f $XAUTH nmerge -
Xelse
X    # It's so easy:
X    xauth -i -q -f $NEWSAUTH list 2> /dev/null|
X    awk '{ print "add '${HOST}${DISP}' " $2 " " $3;
X	   print "add '${DISP}' " $2 " " $3 }' |
X    xauth -q -f $XAUTH
Xfi
END_OF_FILE
if test 1922 -ne `wc -c <'openwinauthmerge'`; then
    echo shar: \"'openwinauthmerge'\" unpacked with wrong size!
fi
chmod +x 'openwinauthmerge'
# end of 'openwinauthmerge'
fi
echo shar: End of shell archive.
exit 0
-- 
						|	Casper H.S. Dik
						|	casper@fwi.uva.nl