1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
#! /bin/sh
set -e
grepconf () {
w=" " # space tab
# sed is cool.
res=`squid -k parse 2>&1 |
grep "Processing:" |
sed s/.*Processing:\ // |
sed -ne '
s/^'$1'['"$w"']\+\([^'"$w"']\+\).*$/\1/p;
t end;
d;
:end q'`
[ -n "$res" ] || res=$2
echo "$res"
}
grepconf2 () {
w=" " # space tab
# sed is cool.
res=`squid -k parse 2>&1 |
grep "Processing:" |
sed s/.*Processing:\ // |
sed -ne '
s/^'$1'['"$w"']\+[^'"$w"']\+['"$w"']\+\([^'"$w"']\+\).*$/\1/p;
t end;
d;
:end q'`
[ -n "$res" ] || res=$2
echo "$res"
}
case "$1" in
configure)
#
# Chown the directories.
#
log_dir=/var/log/squid
cache_dir=`grepconf2 cache_dir /var/spool/squid`
usr=`grepconf cache_effective_user proxy`
grp=`grepconf cache_effective_group proxy`
# Workaround for Bug 5388 - SMP: wrong output for -k parse cache_dir
if [ -d $cache_dir ] ; then
if [ "$(stat -c %U $cache_dir)" != "$usr" ] ||
[ "$(stat -c %G $cache_dir)" != "$grp" ] ; then
chown $usr:$grp $cache_dir
fi
if [ "$(stat -c %U $log_dir)" != "$usr" ] ||
[ "$(stat -c %G $log_dir)" != "$grp" ] ; then
if [ "$(dpkg-statoverride --list $log_dir)" = "" ] ; then
chown $usr:$grp $log_dir
fi
fi
fi
# If we have setcap is installed, try setting cap_net_raw+ep,
# which allows us to install our binaries without the setuid
# bit.
PINGER=/usr/lib/squid/pinger
if command -v setcap > /dev/null; then
if setcap cap_net_raw+ep $PINGER; then
echo "Setcap worked! $PINGER is not suid!"
else
echo "Setcap failed on $PINGER, falling back to setuid" >&2
chmod u+s $PINGER
fi
else
echo "Setcap is not installed, falling back to setuid" >&2
chmod u+s $PINGER
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
#
# Unknown action - do nothing.
#
exit 0
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
|