summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--display.myr19
1 files changed, 19 insertions, 0 deletions
diff --git a/display.myr b/display.myr
index 70d99d4..d82c13f 100644
--- a/display.myr
+++ b/display.myr
@@ -1,6 +1,7 @@
use std
use iter
use fileutil
+use sys
use "xproto-gen"
use "types"
@@ -146,6 +147,7 @@ const handshake = {dpy
var req : byte[512]
var auth, zauth, valid, sz
var buf, setup
+ var rightaddr
zauth = [
.family=0,
@@ -155,11 +157,15 @@ const handshake = {dpy
.data=""
]
auth = &zauth
+ rightaddr = getrightaddr(dpy)
for a : iter.byref(dpy.auth)
match std.intparse(a.num)
| `std.None: /* skip */
| `std.Some n:
valid = false
+ if a.family != AuthfamWild && !std.sleq(a.addr, rightaddr)
+ continue
+ ;;
match a.family
| AuthfamWild: valid = true
| AuthfamLocal: valid = std.sleq(dpy.host, "")
@@ -173,6 +179,7 @@ const handshake = {dpy
;;
;;
;;
+ std.slfree(rightaddr)
/*
packed by hand because our donemsg function overwrites the assumed
@@ -237,6 +244,18 @@ const handshake = {dpy
-> `std.Ok setup
}
+const getrightaddr = {dpy
+ if dpy.host.len > 0
+ -> std.sldup(dpy.host)
+ ;;
+
+ var u : sys.utsname
+ sys.uname(&u)
+ match std.strfind(u.node[:], "\0")
+ | `std.Some l: -> std.sldup(u.node[:l])
+ | `std.None: -> std.sldup(u.node[:])
+ ;;
+}
const parsemagic = {path -> auth[:]
var data, buf, auth, ret