summaryrefslogtreecommitdiffstats
path: root/core/modules/remote-access
diff options
context:
space:
mode:
authorSimon Rettberg2022-03-04 16:04:47 +0100
committerSimon Rettberg2022-03-04 16:04:47 +0100
commit5f87974748f5b84a9e61d933a72bf6c55d0fecbc (patch)
tree041319b6ef16944de65524fcac7a3f4bc35f0350 /core/modules/remote-access
parent[run-virt-docker] fix docker load for archives without repotag (diff)
downloadmltk-5f87974748f5b84a9e61d933a72bf6c55d0fecbc.tar.gz
mltk-5f87974748f5b84a9e61d933a72bf6c55d0fecbc.tar.xz
mltk-5f87974748f5b84a9e61d933a72bf6c55d0fecbc.zip
[remoteaccess] Delay submission of VNC password to avoid race
If for some reason the ~poweron POST arrives/gets processed later on the server than our VNC data submission, the password would get set to NULL again immediately, making this client inaccessible.
Diffstat (limited to 'core/modules/remote-access')
-rwxr-xr-xcore/modules/remote-access/data/etc/X11/Xsetup.d/50-launch-vncserver16
1 files changed, 11 insertions, 5 deletions
diff --git a/core/modules/remote-access/data/etc/X11/Xsetup.d/50-launch-vncserver b/core/modules/remote-access/data/etc/X11/Xsetup.d/50-launch-vncserver
index 4449a0fa..ae48a87f 100755
--- a/core/modules/remote-access/data/etc/X11/Xsetup.d/50-launch-vncserver
+++ b/core/modules/remote-access/data/etc/X11/Xsetup.d/50-launch-vncserver
@@ -29,11 +29,6 @@
# dd since busybox head doesn't know -c
passwd="$( < /dev/urandom tr -c -d 'a-zA-Z0-9#&/=()[]{}' | dd bs=8 count=1 status=none )"
printf "%s" "$passwd" > "/tmp/vnc-passwd"
- url="http://${SLX_PXE_SERVER_IP}/slx-admin/api.php?do=remoteaccess"
- curl -s -S -L --retry 4 --retry-connrefused --max-time 3 --retry-max-time 10 \
- --data-urlencode "password=$passwd" \
- --data-urlencode "vncport=$vnc_port" \
- "$url" > /dev/null
(
# Make a copy of xauth, so if the xserver restarts, we'll use the old one and fail to connect
if [ -n "$XAUTHORITY" ]; then
@@ -60,6 +55,17 @@
done
) &> "/tmp/x11vnc-log-$$" &
vncpid=$!
+ # Delay this a bit until x11vnc is ready, and since we might potentially have had a race
+ # with the ~poweron event, which would reset the password in the database.
+ (
+ url="http://${SLX_PXE_SERVER_IP}/slx-admin/api.php?do=remoteaccess"
+ sleep 6
+ [ -d "/proc/${vncpid}" ] || exit 1 # Something is wrong, bail
+ curl -s -S -L --retry 4 --retry-connrefused --max-time 3 --retry-max-time 10 \
+ --data-urlencode "password=$passwd" \
+ --data-urlencode "vncport=$vnc_port" \
+ "$url" > /dev/null
+ ) &
gotone=false
vmvnc=false
idle=0