From 829725b30e3d3486991e34db0c86406e556ebf98 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 5 Dec 2023 11:33:15 +0100 Subject: [PATCH] Handle relative paths in novnc_proxy 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 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/utils/novnc_proxy b/utils/novnc_proxy index f805db236..4b2e3032d 100755 --- a/utils/novnc_proxy +++ b/utils/novnc_proxy @@ -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