Bug 13462

Summary: startx xauth "unknown command" error
Product: xorg Reporter: Nick White <freedesktop-bugs>
Component: App/xinitAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED INVALID QA Contact: Xorg Project Team <xorg-team>
Severity: minor    
Priority: medium CC: mmokrejs, pachoramos1, remi, sergey.filkin
Version: 7.2 (2007.02)Keywords: janitor, patch
Hardware: All   
OS: Linux (All)   
Whiteboard: 2011BRB_Reviewed
i915 platform: i915 features:
Attachments:
Description Flags
startx patch none

Description Nick White 2007-11-30 08:16:02 UTC
When running xauth I would always get the error message:

xauth: (stdin):2:  unknown command: "7ef....." <where 7ef was the start of a nice magic cookie>

, though all would start fine regardless.

This is as the "xauth list localhost:0" command used to ascertain the magic cookie in use returns 2 lines, while the sed involved only expects one. This is I expect not expected behaviour (I don't understand X very well), but nevertheless startx should handle it better.

Following is a one line patch to startx to only grab and use the first line with xauth. Something more complex could perhaps be crafted, but not by me with my limited working knowledge of X. 

--- startx     2007-11-17 20:54:13.000000000 +0000
+++ startx      2007-11-30 15:55:25.000000000 +0000
@@ -118,6 +118,7 @@ serverargs=${serverargs}" -auth "${xserv
 # server man need it. Add them to the '$xserverauthfile' instead.
 for displayname in $authdisplay $hostname$authdisplay; do
      authcookie=`xauth list "$displayname" \
+       | tail -n 1 \
        | sed -n "s/.*$displayname[[:space:]*].*[[:space:]*]//p"` 2>/dev/null;
     if [ "z${authcookie}" = "z" ] ; then
         xauth -q << EOF

Tested on my x86 Gentoo 2007.0 box without problem.
Comment 1 Martin Mokrejs 2009-02-21 11:37:19 UTC
Same issue at http://bugs.gentoo.org/show_bug.cgi?id=131308 .
Comment 2 Sergey Filkin 2011-08-02 04:33:22 UTC
I encountered this bug too on ArchLinux.
I have played around with /etc/hosts and "xauth list" and have concluded that xauth DOES make a difference between IPv4 and IPv6 addresses. My /etc/hosts looks like

127.0.0.1	localhost.localdomain	localhost arch
::1		localhost.localdomain	localhost

And "xauth list localhost:0" give me TWO identical lines whereas "xauth list arch:0" gives me ONE line with contents identical to the localhost case.

If I add "arch" hostname to ::1 in /etc/hostname, "xauth list arch:0" gives me TWO lines identical to the localhost case.

I think it would be better to improve /usr/bin/startx to take only one of two identical lines. Just as Nick White did in his patch.
Comment 3 Sergey Filkin 2011-08-02 08:15:26 UTC
Created attachment 49839 [details]
startx patch
Comment 4 Sergey Filkin 2011-08-02 08:16:18 UTC
I have had a conversation on irc.freenode.net#xorg-devel with an active contributor of Xorg "ajax". He told me that I need to do $xauth list localhost/unix:0 in startx, i.e. specify that we request info just about unix sockets. After applying the attached startx patch startx works without error messages.
Comment 5 Jeremy Huddleston Sequoia 2011-10-17 04:01:18 UTC
Can you please send your patch to xorg-devel for review.
Comment 6 Adam Jackson 2018-06-12 19:09:16 UTC
Mass closure: This bug has been untouched for more than six years, and is not
obviously still valid. Please reopen this bug or file a new report if you continue to experience issues with current releases.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.