bin/x2x-privsep: Add (souped-up) version of this handy script.
[profile] / bin / x2x-privsep
diff --git a/bin/x2x-privsep b/bin/x2x-privsep
new file mode 100755 (executable)
index 0000000..6d578e8
--- /dev/null
@@ -0,0 +1,22 @@
+#! /bin/sh -ex
+
+dir=west bogus=nil
+usage () { echo "usage: $0 [-ensw] HOST:RDPY/LDPY"; }
+while getopts "hensw" opt; do
+  case $opt in
+    h) usage; exit ;;
+    e) dir=east ;;
+    n) dir=north ;;
+    s) dir=south ;;
+    w) dir=west ;;
+    *) bogus=t ;;
+  esac
+done
+shift $(( $OPTIND - 1))
+case $bogus,$#,$1 in nil,1,*:*/*) ;; *) usage >&2; exit 2 ;; esac
+host=${1%:*} dpy=${1##*:}; rdpy=${dpy%%/*} ldpy=${dpy#*/}
+control=ControlPath=~/.ssh/sock-%l/control-%r@%h.x2x
+ssh -o$control -L"/tmp/.X11-unix/X$ldpy:/tmp/.X11-unix/X$rdpy" -Nafx "$host"
+sleep 1
+trap 'trap - INT QUIT HUP EXIT; ssh -o$control -Oexit "$host"; rm -f "/tmp/.X11-unix/X$ldpy"' INT QUIT HUP EXIT
+x2x -$dir -to ":$ldpy"