Skip to content

Commit 2b3e89c

Browse files
committed
sanitize locked_at_timestamp to ensure a number
1 parent 9e86c41 commit 2b3e89c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

systemd/system/codam-web-greeter-idler.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ while IFS= read -r line; do
2929
if [ -f "/tmp/codam_web_greeter_lock_timestamp_$USERNAME" ]; then
3030
# Get the locked_at_timestamp from the file
3131
LOCKED_AT_TIMESTAMP=$(/usr/bin/awk '{print $1}' "/tmp/codam_web_greeter_lock_timestamp_$USERNAME")
32-
# Calculate the time since the session was locked
33-
TIME_SINCE_LOCK=$((($(date +%s) - LOCKED_AT_TIMESTAMP) * 1000))
32+
# Sanitize the timestamp to ensure it's a number
33+
if [[ "$LOCKED_AT_TIMESTAMP" =~ ^[0-9]+$ ]]; then
34+
# Calculate the time since the session was locked
35+
TIME_SINCE_LOCK=$((($(date +%s) - LOCKED_AT_TIMESTAMP) * 1000))
36+
else
37+
echo "Warning: Invalid timestamp in /tmp/codam_web_greeter_lock_timestamp_$USERNAME: $LOCKED_AT_TIMESTAMP" >&2
38+
TIME_SINCE_LOCK=0
39+
fi
3440
fi
3541

3642
# Check if session has been idle for long enough

0 commit comments

Comments
 (0)