aboutsummaryrefslogtreecommitdiff
path: root/nexgb/auth.go
diff options
context:
space:
mode:
authoraarzilli <alessandro.arzilli@gmail.com>2016-03-21 18:50:49 +0100
committerPřemysl Janouch <p@janouch.name>2018-09-08 16:49:25 +0200
commit8d343cfd3a12d910d6a663f2d5f2cd4a41d88ce2 (patch)
treec1fdecc74ca23a41870537ca224fd7b2e717de64 /nexgb/auth.go
parentbecaf43dcb3e9832c3eb951ff9908ed697868152 (diff)
downloadhaven-8d343cfd3a12d910d6a663f2d5f2cd4a41d88ce2.tar.gz
haven-8d343cfd3a12d910d6a663f2d5f2cd4a41d88ce2.tar.xz
haven-8d343cfd3a12d910d6a663f2d5f2cd4a41d88ce2.zip
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 'nexgb/auth.go')
-rw-r--r--nexgb/auth.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/nexgb/auth.go b/nexgb/auth.go
index a6fad90..62a9b35 100644
--- a/nexgb/auth.go
+++ b/nexgb/auth.go
@@ -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
}
}