diff options
| author | aarzilli <[email protected]> | 2016-03-21 18:50:49 +0100 |
|---|---|---|
| committer | aarzilli <[email protected]> | 2016-03-21 18:52:58 +0100 |
| commit | 934eb207ff43af6b4ea287c05ec8f5bdd3fec97b (patch) | |
| tree | a8f94f521df7f73bb876b425f7987c36854af91a /auth.go | |
| parent | d3d84afd14161dc1c07449d8f9feb2dca6ccc10b (diff) | |
Handle wildcard values in Xauthority file
Some field values in the Xauthority file have special meanings:
- a value of 65535 in the 'family' field means that the entry will
match a connection of any family on any address
- an empty string in the 'display number' field means that the entry
will match a connection on any display number
This behaviour is documented at:
https://cgit.freedesktop.org/xorg/lib/libXau/tree/AuGetBest.c#n109
Diffstat (limited to 'auth.go')
| -rw-r--r-- | auth.go | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -25,6 +25,7 @@ func readAuthority(hostname, display string) ( // As per /usr/include/X11/Xauth.h. const familyLocal = 256 + const familyWild = 65535 if len(hostname) == 0 || hostname == "localhost" { hostname, err = os.Hostname() @@ -75,7 +76,10 @@ func readAuthority(hostname, display string) ( return "", nil, err } - if family == familyLocal && addr == hostname && disp == display { + addrmatch := (family == familyWild) || (family == familyLocal && addr == hostname) + dispmatch := (disp == "") || (disp == display) + + if addrmatch && dispmatch { return name0, data0, nil } } |
