mirror of
https://github.com/ovh/the-bastion.git
synced 2025-02-26 00:24:12 +08:00
fix: osh-lingering-sessions-reaper.sh: tocttou on kill could terminate the script early
This commit is contained in:
parent
e7e045a40d
commit
361c6a37a2
1 changed files with 4 additions and 2 deletions
|
@ -23,8 +23,9 @@ do
|
|||
fi
|
||||
done < <(ps -C ttyrec -o etimes,pid,tty --no-header)
|
||||
if [ -n "$tokill" ]; then
|
||||
# add || true to avoid script termination due to TOCTTOU and set -e
|
||||
# shellcheck disable=SC2086
|
||||
kill $tokill
|
||||
kill $tokill || true
|
||||
_log "Terminated $nb orphan ttyrec sessions (pids$tokill)"
|
||||
fi
|
||||
|
||||
|
@ -41,8 +42,9 @@ do
|
|||
fi
|
||||
done < <(ps -C sshd --no-header -o etimes,pid,tty,user)
|
||||
if [ -n "$tokill" ]; then
|
||||
# add || true to avoid script termination due to TOCTTOU and set -e
|
||||
# shellcheck disable=SC2086
|
||||
kill $tokill
|
||||
kill $tokill || true
|
||||
_log "Terminated $nb orphan sshd sessions (pids$tokill)"
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue