5

When I run on my local machine (Ubuntu 18.10) xauth list the output is not showing the display number:

$ xauth list
c7h/unix:  MIT-MAGIC-COOKIE-1  37bb744d95232b4e29aea1320b0a0e2d
#ffff#633768#:  MIT-MAGIC-COOKIE-1  37bb744d95232b4e29aea1320b0a0e2d

My env $DISPLAY variable contains the value :1:

$ echo $DISPLAY
:1

So I was expecting to see 1 after c7h/unix::

c7h/unix:1  MIT-MAGIC-COOKIE-1  37bb744d95232b4e29aea1320b0a0e2d

The value is also missing if I manually parse the file inside the env variable $XAUTHORITY with Python:

if filename is None:
    filename = os.environ.get('XAUTHORITY')

if filename is None:
    try:
        filename = os.path.join(os.environ['HOME'], '.Xauthority')
    except KeyError:
        raise XConnectionError("$HOME not set, can't find ~/.Xauthority")

try:
    xaf = open(filename, 'rb')
    raw = xaf.read()
    xaf.close()
except IOError as err:
    raise XConnectionError("Can't read ~/.Xauthority: %s" % err[1])
    return []

n = 0
entries = []
try:
    while n < len(raw):
        family, = struct.unpack('>H', raw[n:n + 2])
        n = n + 2

        length, = struct.unpack('>H', raw[n:n + 2])
        n = n + length + 2
        addr = raw[n - length: n]

        length, = struct.unpack('>H', raw[n:n + 2])
        n = n + length + 2
        num = raw[n - length: n]

        length, = struct.unpack('>H', raw[n:n + 2])
        n = n + length + 2
        name = raw[n - length: n]

        length, = struct.unpack('>H', raw[n:n + 2])
        n = n + length + 2
        data = raw[n - length: n]

        if len(data) != length:
            break

        entries.append((family, addr.decode('utf-8'), num.decode('utf-8'), name.decode('utf-8'), data))

How can I figure out which of the auth is the one associated with the value reported by $DISPLAY?

  • @grawity I'm using Ubuntu 18.10. Standard installation with GDM and Gnome Shell. – Roberto Leinardi Jan 05 '19 at 11:17
  • Your second cookie also looks not quite right. What happens when you `xauth extract some_file :1` and then `xauth -f some_file list`? If you get the first line again, I don't understand what's happening. If you get a different line, my guess would be "auth file corrupt; remove it, log out, log in, see if it gets better". – dirkt Jan 05 '19 at 12:03
  • Unfortunately the result is exactly the same as the `$XAUTHORITY` one. – Roberto Leinardi Jan 05 '19 at 12:23

0 Answers0