Commit 0a090a4a authored by Tails developers's avatar Tails developers
Browse files

Refactor chroot browsers' cleanup().

parent b47dc236
#!/bin/sh
# Import the TBB_EXT variable.
. /usr/local/lib/tails-shell-library/tor-browser.sh
# Break down the chroot and kill all of its processes
try_cleanup_browser_chroot () {
local chroot="${1}"
local cow="${2}"
local user="${3}"
local counter=0
local ret=0
while [ "${counter}" -le 10 ] && \
pgrep -u ${user} 1>/dev/null 2>&1; do
pkill -u ${user} 1>/dev/null 2>&1
ret=${?}
sleep 1
counter=$((${counter}+1))
done
[ ${ret} -eq 0 ] || pkill -9 -u ${user} 1>/dev/null 2>&1
for mnt in ${chroot}/dev ${chroot}/proc ${chroot} ${cow}; do
counter=0
while [ "${counter}" -le 10 ] && mountpoint -q ${mnt} 2>/dev/null; do
umount ${mnt} 2>/dev/null
sleep 1
counter=$((${counter}+1))
done
done
rmdir ${cow} ${chroot} 2>/dev/null
}
......@@ -27,6 +27,8 @@ START_PAGE="http://127.0.0.1:7657"
# guess_best_tor_browser_locale()
. /usr/local/lib/tails-shell-library/tor-browser.sh
. /usr/local/lib/tails-shell-library/chroot-browser.sh
NOSCRIPT="${TBB_EXT}/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi"
TORBUTTON="${TBB_EXT}/torbutton@torproject.org"
NAME="`gettext \"I2P Browser\"`"
......@@ -36,26 +38,7 @@ if [ -e /var/lib/gdm3/tails.camouflage ]; then
fi
cleanup () {
# Break down the chroot and kill all of its processes
local counter=0
local ret=0
while [ "${counter}" -le 10 ] && \
pgrep -u ${BROWSER_USER} 1>/dev/null 2>&1; do
pkill -u ${BROWSER_USER} 1>/dev/null 2>&1
ret=${?}
sleep 1
counter=$((${counter}+1))
done
[ ${ret} -eq 0 ] || pkill -9 -u ${BROWSER_USER} 1>/dev/null 2>&1
for mnt in ${CHROOT}/dev ${CHROOT}/proc ${CHROOT} ${COW}; do
counter=0
while [ "${counter}" -le 10 ] && mountpoint -q ${mnt} 2>/dev/null; do
umount ${mnt} 2>/dev/null
sleep 1
counter=$((${counter}+1))
done
done
rmdir ${COW} ${CHROOT} 2>/dev/null
try_cleanup_browser_chroot ${CHROOT} ${COW} ${BROWSER_USER}
}
error () {
......
......@@ -23,6 +23,8 @@ CLEARNET_USER=clearnet
# guess_best_tor_browser_locale()
. /usr/local/lib/tails-shell-library/tor-browser.sh
. /usr/local/lib/tails-shell-library/chroot-browser.sh
WARNING_PAGE='/usr/share/doc/tails/website/misc/unsafe_browser_warning'
LANG_CODE="$(echo ${LANG} | head -c 2)"
if [ -r "${WARNING_PAGE}.${LANG_CODE}.html" ]; then
......@@ -36,26 +38,7 @@ if [ -e /var/lib/gdm3/tails.camouflage ]; then
fi
cleanup () {
# Break down the chroot and kill all of its processes
local counter=0
local ret=0
while [ "${counter}" -le 10 ] && \
pgrep -u ${CLEARNET_USER} 1>/dev/null 2>&1; do
pkill -u ${CLEARNET_USER} 1>/dev/null 2>&1
ret=${?}
sleep 1
counter=$((${counter}+1))
done
[ ${ret} -eq 0 ] || pkill -9 -u ${CLEARNET_USER} 1>/dev/null 2>&1
for mnt in ${CHROOT}/dev ${CHROOT}/proc ${CHROOT} ${COW}; do
counter=0
while [ "${counter}" -le 10 ] && mountpoint -q ${mnt} 2>/dev/null; do
umount ${mnt} 2>/dev/null
sleep 1
counter=$((${counter}+1))
done
done
rmdir ${COW} ${CHROOT} 2>/dev/null
try_cleanup_browser_chroot ${CHROOT} ${COW} ${CLEARNET_USER}
}
error () {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment