Make apt-get-update able to be terminated securely

This commit is contained in:
Aaron Rainbolt 2024-11-21 20:03:42 -06:00
parent af43472d0c
commit d7475e252a
No known key found for this signature in database
GPG Key ID: A709160D73C79109

View File

@ -3,6 +3,13 @@
## Copyright (C) 2012 - 2024 ENCRYPTED SUPPORT LP <adrelanos@whonix.org> ## Copyright (C) 2012 - 2024 ENCRYPTED SUPPORT LP <adrelanos@whonix.org>
## See the file COPYING for copying conditions. ## See the file COPYING for copying conditions.
write_pid_file() {
safe-rm -rf /tmp/security-misc-apt-get-update-pid;
install -m644 /dev/null /tmp/security-misc-apt-get-update-pid \
|| exit 1
echo "$$" > /tmp/security-misc-apt-get-update-pid
}
sigterm_trap() { sigterm_trap() {
if [ "$lastpid" = "" ]; then if [ "$lastpid" = "" ]; then
exit 143 exit 143
@ -21,6 +28,8 @@ trap "sigterm_trap" SIGTERM SIGINT
[ -n "$timeout_after" ] || timeout_after="600" [ -n "$timeout_after" ] || timeout_after="600"
[ -n "$kill_after" ] || kill_after="10" [ -n "$kill_after" ] || kill_after="10"
write_pid_file
timeout \ timeout \
--kill-after="$kill_after" \ --kill-after="$kill_after" \
"$timeout_after" \ "$timeout_after" \