2 # Run z-machine interpreter, allowing the user to save their game in a
3 # directory specific to their client cert.
7 [ -n "$TLS_CLIENT_HASH" ] ||
exit 1
9 if [ -n "$INIT_QUERY" ]; then
10 sanitised
="$(tr -dc [:alnum:]_ <<< "$INIT_QUERY")"
11 gamefile
="$var/games/$sanitised"
12 if ! ( [ -n "$sanitised" ] && [ -e "$gamefile" ] ); then
13 echo "Unknown game: $sanitised"
17 echo "Choose your poison:"
21 sanitised
="$(tr -dc [:alnum:]_ <<< "$input")"
22 gamefile
="$var/games/$sanitised"
23 if [ -n "$sanitised" ] && [ -e "$gamefile" ]; then
26 echo "Please enter one of the listed games"
30 echo "Starting $sanitised. Savefiles will be preserved."
33 savesdir
="$var/$TLS_CLIENT_HASH/$sanitised"
35 mkdir
-p "$savesdir" ||
exit 1
36 cd "$savesdir" ||
exit 1
38 # Impose some limits to reduce potential for abuse
43 # using the z-machine interpreter infuse, which has a nice stdio interface:
44 # https://gitlab.com/monkeymind/infuse
45 stdbuf
-i0 -o0 infuse
"$gamefile"
47 # Previous attempt: using dfrotz, but it has some problems.
48 #dfrotz -m -Z0 -R. "$gamefile"