6

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?

0 Answers0