]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Handle relative paths in novnc_proxy
authorPierre Ossman <ossman@cendio.se>
Tue, 5 Dec 2023 10:33:15 +0000 (11:33 +0100)
committerPierre Ossman <ossman@cendio.se>
Tue, 5 Dec 2023 10:33:15 +0000 (11:33 +0100)
websockify changes the working directory before it starts looking for
files, so we must give it relative paths for things to work reliably.

utils/novnc_proxy

index f805db236c1032bf3f66dda0bf3560dac90bcc36..4b2e3032d97a5d433fe2764536892c8927490eb5 100755 (executable)
@@ -56,7 +56,7 @@ KEY=""
 WEB=""
 proxy_pid=""
 SSLONLY=""
-RECORD_ARG=""
+RECORD=""
 SYSLOG_ARG=""
 HEARTBEAT_ARG=""
 IDLETIMEOUT_ARG=""
@@ -95,7 +95,7 @@ while [ "$*" ]; do
     --web)     WEB="${OPTARG}"; shift            ;;
     --ssl-only) SSLONLY="--ssl-only"             ;;
     --file-only) FILEONLY_ARG="--file-only"      ;;
-    --record) RECORD_ARG="--record ${OPTARG}"; shift ;;
+    --record) RECORD="${OPTARG}"; shift ;;
     --syslog) SYSLOG_ARG="--syslog ${OPTARG}"; shift ;;
     --heartbeat) HEARTBEAT_ARG="--heartbeat ${OPTARG}"; shift ;;
     --idle-timeout) IDLETIMEOUT_ARG="--idle-timeout ${OPTARG}"; shift ;;
@@ -202,8 +202,14 @@ else
     fi
 fi
 
+# Make all file paths absolute as websockify changes working directory
+WEB=`realpath "${WEB}"`
+[ -n "${CERT}" ] && CERT=`realpath "${CERT}"`
+[ -n "${KEY}" ] && KEY=`realpath "${KEY}"`
+[ -n "${RECORD}" ] && RECORD=`realpath "${RECORD}"`
+
 echo "Starting webserver and WebSockets proxy on${HOST:+ host ${HOST}} port ${PORT}"
-${WEBSOCKIFY} ${SYSLOG_ARG} ${SSLONLY} ${FILEONLY_ARG} --web ${WEB} ${CERT:+--cert ${CERT}} ${KEY:+--key ${KEY}} ${LISTEN} ${VNC_DEST} ${HEARTBEAT_ARG} ${IDLETIMEOUT_ARG} ${RECORD_ARG} ${TIMEOUT_ARG} ${WEBAUTH_ARG} ${AUTHPLUGIN_ARG} ${AUTHSOURCE_ARG} &
+${WEBSOCKIFY} ${SYSLOG_ARG} ${SSLONLY} ${FILEONLY_ARG} --web ${WEB} ${CERT:+--cert ${CERT}} ${KEY:+--key ${KEY}} ${LISTEN} ${VNC_DEST} ${HEARTBEAT_ARG} ${IDLETIMEOUT_ARG} ${RECORD:+--record ${RECORD}} ${TIMEOUT_ARG} ${WEBAUTH_ARG} ${AUTHPLUGIN_ARG} ${AUTHSOURCE_ARG} &
 proxy_pid="$!"
 sleep 1
 if [ -z "$proxy_pid" ] || ! ps -eo pid= | grep -w "$proxy_pid" > /dev/null; then