summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2022-07-18 16:12:38 +0200
committerSimon Rettberg2022-07-18 16:12:38 +0200
commit959f56e2f36b1e853e95121d458fcd489509ebf6 (patch)
tree247b1975134b6ba2679cfe06039dceace35a234e
parent[pam-bwidm] Try UID gen 10 times, invert counting to simplify check (diff)
downloadmltk-959f56e2f36b1e853e95121d458fcd489509ebf6.tar.gz
mltk-959f56e2f36b1e853e95121d458fcd489509ebf6.tar.xz
mltk-959f56e2f36b1e853e95121d458fcd489509ebf6.zip
[idleaction/xscreensaver] Disllow locking for exam mode/browser logins
-rwxr-xr-xcore/modules/idleaction/data/etc/X11/Xsession.d/95-xscreensaver10
-rwxr-xr-xcore/modules/xscreensaver/data/opt/openslx/pvs2/lockDesktop.sh35
2 files changed, 25 insertions, 20 deletions
diff --git a/core/modules/idleaction/data/etc/X11/Xsession.d/95-xscreensaver b/core/modules/idleaction/data/etc/X11/Xsession.d/95-xscreensaver
index 5cdeeac5..441d9243 100755
--- a/core/modules/idleaction/data/etc/X11/Xsession.d/95-xscreensaver
+++ b/core/modules/idleaction/data/etc/X11/Xsession.d/95-xscreensaver
@@ -3,6 +3,7 @@
if command -v xscreensaver; then
DPMS=False
AUTOLOCK=True
+ NEVER_LOCK=
secsToTime() {
local NUM SECS MINS HRS
NUM="$1"
@@ -23,6 +24,7 @@ if command -v xscreensaver; then
if [ -n "${SLX_EXAM}" ]; then
SLX_SCREEN_SAVER_GRACE_TIME=
AUTOLOCK=False
+ NEVER_LOCK=True
SBY=0
SVR=0
elif [ -z "$SBY" ]; then
@@ -32,6 +34,12 @@ if command -v xscreensaver; then
elif ! [ "$SBY" -ge 0 ]; then # isNumeric?
SBY=0
fi
+ # If web based login, we can't authenticate again as we don't have the password - never lock
+ if [ -z "$NEVER_LOCK" ]; then
+ usrname="$( < "/etc/passwd" awk -v "uid=$UID" -F ':' '$3 == uid {print $5; exit}' )"
+ # Yes, this really checks if $usrname ends in @browser, and sets NEVER_LOCK to true if so
+ [ "${usrname%"@browser"}" != "${usrname}" ] && NEVER_LOCK=True
+ fi
# Create config value for standby timeout
if [ "$SBY" -gt 0 ]; then
DPMS=True
@@ -79,7 +87,7 @@ EOF
# HACK: This env vars prevent xscreensaver from ever locking
# Only one would be needed but set both in case one of them
# gets removed in the future.
- if [ -n "$SLX_EXAM" ]; then
+ if [ -n "$NEVER_LOCK" ]; then
export RUNNING_UNDER_GDM="not really but yea"
export WAYLAND_DISPLAY="none, haha"
fi
diff --git a/core/modules/xscreensaver/data/opt/openslx/pvs2/lockDesktop.sh b/core/modules/xscreensaver/data/opt/openslx/pvs2/lockDesktop.sh
index 2796de8f..8b759e3c 100755
--- a/core/modules/xscreensaver/data/opt/openslx/pvs2/lockDesktop.sh
+++ b/core/modules/xscreensaver/data/opt/openslx/pvs2/lockDesktop.sh
@@ -1,25 +1,22 @@
#!/bin/ash
-# Problem: While any application (e.g. VMware) is holding the mouse and
-# keyboard grab, xscreensaver couldn't grab them, so it will ignore the
-# locking request. Without the keyboard grab, all input would still go
-# to the vmware window below the black screen, which is, you know, bad,
-# since you cannot enter your password to unlock the workstation again.
+[ -z "$UID" ] && UID="$( id -u )"
-# So we minimize vmware, lock the screen, and then restore vmware.
-# TODO: Add other virtualizers (vbox, kvm) later if needed.
-WINDOWS=$(xdotool search --onlyvisible --class vmplayer)
-for window in $WINDOWS; do
- xdotool windowminimize $window
-done
-# move mouse pointer to the center of the screen to avoid some problems with ghost clicks
-xdotool mousemove --sync --polar 0 0
+usrname="$( < "/etc/passwd" awk -v "uid=$UID" -F ':' '$3 == uid {print $5; exit}' )"
+# Yes, this really checks if $usrname ends in @browser, and sets NEVER_LOCK to true if so
+if [ "${usrname%"@browser"}" != "${usrname}" ]; then
+ xmessage "Web-Basierte Logins koennen die Sitzung leider nicht sperren."
+ exit 0
+else
+ . /opt/openslx/config
+ if [ -n "$SLX_EXAM" ]; then
+ xmessage "Im Klausurmodus nicht moeglich"
+ exit 0
+ fi
+fi
-# now actually lock
-xscreensaver-command --lock
+# Any mouse-ungrab logic is embedded in our modded xscreensaver now,
+# via external ungrab script
-# above lock call is blocking, so now xscreensaver should be active - let's restore vmware
-for window in $WINDOWS; do
- xdotool windowmap $window
-done
+xscreensaver-command --lock