sx: drop dependency on openssl
Turns out openssl rand would obnoxiously create a HOME/.rnd dotfile unless told otherwise with the RANDFILE environment. Unfortunately this neither options are compelling and neither can openssl rand be told to not write this file. Instead I'm going to use /dev/urandom which appears to be available on practically every UNIX. This commit also tidies up the timeout kill logic to better express what I am doing.
This commit is contained in:
parent
ef5ed45959
commit
f783766e2c
2
README
2
README
|
@ -37,7 +37,7 @@ REQUIRES
|
||||||
|
|
||||||
* Xorg
|
* Xorg
|
||||||
* xauth
|
* xauth
|
||||||
* openssl (used to generate the MIT-MAGIC-COOKIE-1 value)
|
* /dev/urandom
|
||||||
|
|
||||||
INSTALL
|
INSTALL
|
||||||
|
|
||||||
|
|
20
sx
20
sx
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh --
|
#!/bin/sh --
|
||||||
# sx - start an xserver
|
# sx - start an xserver
|
||||||
|
|
||||||
# requires openssl xauth Xorg
|
# requires xauth Xorg
|
||||||
|
|
||||||
# I'm willing to take advantage of errexit for this script as roughly 85% of
|
# I'm willing to take advantage of errexit for this script as roughly 85% of
|
||||||
# the error checking would just be exiting on command failure.
|
# the error checking would just be exiting on command failure.
|
||||||
|
@ -18,18 +18,17 @@ cleanup() {
|
||||||
# Send SIGKILL after 10 seconds if the xserver is taking too long to
|
# Send SIGKILL after 10 seconds if the xserver is taking too long to
|
||||||
# terminate.
|
# terminate.
|
||||||
interval=10
|
interval=10
|
||||||
until [ "$interval" -le 0 ]; do
|
while kill -0 "$1"; do
|
||||||
if ! kill -0 "$1"; then
|
if [ "$interval" -le 0 ]; then
|
||||||
|
# Make sure the PID is still (probably) an Xorg process.
|
||||||
|
if [ "$(ps -o comm= "$1")" = Xorg ]; then
|
||||||
|
kill -s KILL "$1"
|
||||||
|
fi
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
sleep 1
|
|
||||||
interval=$((interval - 1))
|
interval=$((interval - 1))
|
||||||
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
# Make sure that the PID still refers to an Xorg process
|
|
||||||
if test "$interval" -le 0 -a "$(ps -o comm= "$1")" = Xorg; then
|
|
||||||
kill -s KILL "$1"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! stty "$stty"; then
|
if ! stty "$stty"; then
|
||||||
|
@ -55,7 +54,7 @@ touch "$XAUTHORITY"
|
||||||
|
|
||||||
trap 'cleanup "$pid"' EXIT
|
trap 'cleanup "$pid"' EXIT
|
||||||
|
|
||||||
xauth add :"$tty" MIT-MAGIC-COOKIE-1 "$(openssl rand -hex 16)"
|
xauth add :"$tty" MIT-MAGIC-COOKIE-1 "$(od -An -N16 -tx /dev/urandom | tr -d ' ')"
|
||||||
|
|
||||||
# Xorg will check if SIGUSR1 was set to SIG_IGN in its environment and issue
|
# Xorg will check if SIGUSR1 was set to SIG_IGN in its environment and issue
|
||||||
# its own SIGUSR1 back to the parent process when it is ready to accept
|
# its own SIGUSR1 back to the parent process when it is ready to accept
|
||||||
|
@ -68,5 +67,4 @@ trap 'DISPLAY=:$tty "${@:-$cfgdir/sxrc}"' USR1
|
||||||
trap '' USR1
|
trap '' USR1
|
||||||
exec /usr/lib/xorg-server/Xorg :"$tty" -keeptty vt"$tty" -noreset -auth "$XAUTHORITY"
|
exec /usr/lib/xorg-server/Xorg :"$tty" -keeptty vt"$tty" -noreset -auth "$XAUTHORITY"
|
||||||
) & pid=$!
|
) & pid=$!
|
||||||
|
|
||||||
wait
|
wait
|
||||||
|
|
Loading…
Reference in New Issue