summaryrefslogtreecommitdiff
path: root/auth.go
diff options
context:
space:
mode:
authorAndrew Gallant <[email protected]>2016-03-21 14:00:40 -0400
committerAndrew Gallant <[email protected]>2016-03-21 14:00:40 -0400
commit5d9015c16e326c446bad9da7b29698d659069af5 (patch)
treeff0cf35265db2855a0c49317c47dc794b6f2ab4f /auth.go
parent56af75205239a12628849f64adcc6d04801f6b81 (diff)
parent934eb207ff43af6b4ea287c05ec8f5bdd3fec97b (diff)
Merge pull request #35 from aarzilli/xauthwild
Handle wildcard values in Xauthority file
Diffstat (limited to 'auth.go')
-rw-r--r--auth.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/auth.go b/auth.go
index a6fad90..62a9b35 100644
--- a/auth.go
+++ b/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
}
}