Xauthority 缺少显示号码

Xauthority 缺少显示号码

当我在本地机器(Ubuntu 18.10)上运行时,xauth list输出没有显示显示数字:

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

我的环境$DISPLAY变量包含以下值:1

$ echo $DISPLAY
:1

所以我期望看到1以下内容c7h/unix:

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

$XAUTHORITY如果我使用 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))

我如何才能确定哪一个身份验证与所报告的值相关联$DISPLAY

相关内容