mirror of
https://github.com/Kicksecure/security-misc.git
synced 2024-10-01 08:25:45 -04:00
moved apt-get-update and apt-get-wrapper from whonixcheck to security-misc
This commit is contained in:
parent
7b3ef3a00f
commit
8160cfe1d7
38
usr/lib/security-misc/apt-get-update
Executable file
38
usr/lib/security-misc/apt-get-update
Executable file
@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
## This file is part of Whonix.
|
||||
## Copyright (C) 2012 - 2014 Patrick Schleizer <adrelanos@riseup.net>
|
||||
## See the file COPYING for copying conditions.
|
||||
|
||||
## Required to run apt-get update as user 'whonixcheck' (non-root).
|
||||
## Required for whonixcheck function check_operating_system.
|
||||
## Exception to run /usr/lib/apt-get-update as user 'whonixcheck'.
|
||||
## is defined in /etc/sudoers.d/.
|
||||
|
||||
sigterm_trap() {
|
||||
if [ "$lastpid" = "" ]; then
|
||||
exit 143
|
||||
fi
|
||||
ps -p "$lastpid"
|
||||
if [ ! "$?" = "0" ]; then
|
||||
## Already terminated.
|
||||
exit 143
|
||||
fi
|
||||
kill -sigterm "$lastpid"
|
||||
exit 143
|
||||
}
|
||||
|
||||
trap "sigterm_trap" SIGTERM
|
||||
|
||||
timeout_after="120"
|
||||
kill_after="10"
|
||||
|
||||
timeout \
|
||||
--kill-after="$kill_after" \
|
||||
"$timeout_after" \
|
||||
/usr/lib/apt-get-wrapper update &
|
||||
|
||||
lastpid="$!"
|
||||
wait "$lastpid"
|
||||
|
||||
exit "$?"
|
67
usr/lib/security-misc/apt-get-wrapper
Executable file
67
usr/lib/security-misc/apt-get-wrapper
Executable file
@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
|
||||
## This file is part of Whonix.
|
||||
## Copyright (C) 2012 - 2014 Patrick Schleizer <adrelanos@riseup.net>
|
||||
## See the file COPYING for copying conditions.
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
set -o errtrace
|
||||
|
||||
cleanup() {
|
||||
if [ -d "$temp_dir" ]; then
|
||||
rm --recursive --force "$temp_dir"
|
||||
fi
|
||||
}
|
||||
|
||||
temp_dir="$(mktemp --directory)"
|
||||
|
||||
logfile="$temp_dir/log"
|
||||
tee_fifo="$temp_dir/tee_fifo"
|
||||
|
||||
trap "cleanup" EXIT
|
||||
|
||||
mkfifo "$tee_fifo"
|
||||
|
||||
tee "$logfile" < "$tee_fifo" &
|
||||
tee_pid="$!"
|
||||
|
||||
apt-get \
|
||||
${1+"$@"} \
|
||||
1> "$tee_fifo" \
|
||||
2> "$tee_fifo" \
|
||||
&
|
||||
|
||||
apt_get_pid="$!"
|
||||
|
||||
wait "$tee_pid"
|
||||
wait "$apt_get_pid"
|
||||
apt_get_exit_code="$?"
|
||||
|
||||
if [ ! "$apt_get_exit_code" = "0" ]; then
|
||||
exit "$apt_get_exit_code"
|
||||
fi
|
||||
|
||||
log="$(cat "$logfile")"
|
||||
|
||||
while read -r -d $'\n' line; do
|
||||
line_lower_case="${line,,}"
|
||||
first_two="${line_lower_case:0:2}"
|
||||
if [ "$first_two" = "e:" ]; then
|
||||
exit 125
|
||||
fi
|
||||
if [ "$first_two" = "w:" ]; then
|
||||
first_twelve="${line_lower_case:0:12}"
|
||||
if [ "$first_twelve" = "w: duplicate" ]; then
|
||||
continue
|
||||
fi
|
||||
skip_summary_line="W: You may want to run apt-get update to correct these problems"
|
||||
skip_summary_line_lower_case="${skip_summary_line,,}"
|
||||
if [ "$line_lower_case" = "$skip_summary_line_lower_case" ]; then
|
||||
continue
|
||||
fi
|
||||
exit 125
|
||||
fi
|
||||
done < <( echo "$log" )
|
||||
|
||||
exit "$apt_get_exit_code"
|
Loading…
Reference in New Issue
Block a user