postinst is in dhcpy6d 0.4-2.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
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 | #!/bin/sh
#
# attempting to create lower privileged user/group for dhcpy6d
# take from http://www.debian.org/doc/manuals/securing-debian-howto/ch9.en.html#s-bpp-lower-privs
#
set -e
case "$1" in
install|upgrade|configure)
# Sane defaults:
[ -z "$SERVER_HOME" ] && SERVER_HOME=/var/lib/dhcpy6d
[ -z "$SERVER_USER" ] && SERVER_USER=dhcpy6d
[ -z "$SERVER_NAME" ] && SERVER_NAME="DHCPv6 server dhcpy6d"
[ -z "$SERVER_GROUP" ] && SERVER_GROUP=dhcpy6d
# Groups that the user will be added to, if undefined, then none.
ADDGROUP=""
# create user to avoid running server as root
# 1. create group if not existing
if ! getent group | grep -q "^$SERVER_GROUP:" ; then
echo -n "Adding group $SERVER_GROUP.."
addgroup --quiet --system $SERVER_GROUP 2>/dev/null ||true
echo "..done"
fi
# 2. create homedir if not existing
test -d $SERVER_HOME || mkdir $SERVER_HOME
# 3. create user if not existing
if ! getent passwd | grep -q "^$SERVER_USER:"; then
echo -n "Adding system user $SERVER_USER.."
adduser --quiet \
--system \
--ingroup $SERVER_GROUP \
--no-create-home \
--disabled-password \
$SERVER_USER 2>/dev/null || true
echo "..done"
fi
# 4. adjust passwd entry
usermod -c "$SERVER_NAME" \
-d $SERVER_HOME \
-g $SERVER_GROUP \
$SERVER_USER 2> /dev/null
# 5. adjust file and directory permissions
chown -R $SERVER_USER:$SERVER_GROUP $SERVER_HOME
chmod -R 0770 $SERVER_HOME
if [ ! -e /var/log/dhcpy6d.log ]; then
touch /var/log/dhcpy6d.log
fi
if [ ! -e /var/lib/dhcpy6d/volatile.sqlite ]; then
cp /usr/share/dhcpy6d/volatile.sqlite /var/lib/dhcpy6d/volatile.sqlite
fi
chown $SERVER_USER:$SERVER_GROUP /var/log/dhcpy6d.log /var/lib/dhcpy6d/volatile.sqlite
chmod 0660 /var/log/dhcpy6d.log /var/lib/dhcpy6d/volatile.sqlite
# 6. add DUID entry to /etc/default/dhcpy6d if not yet existing
TMPFILE=`mktemp`
cat /usr/share/dhcpy6d/default/dhcpy6d > "${TMPFILE}"
echo >> "${TMPFILE}"
echo "# LLT DUID generated by Debian" >> "${TMPFILE}"
if [ ! -e /etc/default/dhcpy6d ] || ! grep -q "DUID=" /etc/default/dhcpy6d; then
echo "DUID=$(dhcpy6d --generate-duid)" >> "${TMPFILE}"
else
egrep "^DUID=" /etc/default/dhcpy6d >> "${TMPFILE}"
fi
ucf "${TMPFILE}" /etc/default/dhcpy6d
ucfr dhcpy6d /etc/default/dhcpy6d
;;
esac
# Automatically added by dhpython:
if which pycompile >/dev/null 2>&1; then
pycompile -p dhcpy6d
fi
# End automatically added section
# Automatically added by dh_installinit
if [ -x "/etc/init.d/dhcpy6d" ]; then
update-rc.d dhcpy6d defaults >/dev/null
fi
if [ -x "/etc/init.d/dhcpy6d" ] || [ -e "/etc/init/dhcpy6d.conf" ]; then
invoke-rc.d dhcpy6d start || exit $?
fi
# End automatically added section
|