#!/bin/sh set -e . /usr/share/debconf/confmodule case "${1}" in configure) db_version 2.0 db_get gnunet-server/username _USERNAME="${RET:-gnunet}" db_get gnunet-server/groupname _GROUPNAME="${RET:-gnunet}" db_get gnunet-server/autostart _AUTOSTART="${RET}" # boolean db_stop CONFIG_FILE="/etc/default/gnunet-server" # Read default values SERVICEHOME="/var/lib/gnunet" eval $(grep SERVICEHOME /etc/gnunet.conf | tr -d [:blank:]) # Creating gnunet group if needed if ! getent group ${_GROUPNAME} > /dev/null then echo -n "Creating new GNUnet group ${_GROUPNAME}:" addgroup --quiet --system ${_GROUPNAME} echo " done." fi # Creating gnunet user if needed if ! getent passwd ${_USERNAME} > /dev/null then echo -n "Creating new GNUnet user ${_USERNAME}:" adduser --quiet --system --ingroup ${_GROUPNAME} --no-create-home ${_USERNAME} echo " done." fi # Add a special secured group GNUNETDNS_GROUP="gnunetdns" # Creating gnunetdns group if needed if ! getent group ${GNUNETDNS_GROUP} > /dev/null then echo -n "Creating new secured GNUnet group ${GNUNETDNS_GROUP}:" addgroup --quiet --system ${GNUNETDNS_GROUP} echo " done." fi # Update files and directories permissions. # Assuming default values, this *should* not be changed. echo -n "Updating files and directories permissions:" chown -R ${_USERNAME}:${_GROUPNAME} /var/log/gnunetd chown -R ${_USERNAME}:${_GROUPNAME} ${SERVICEHOME} # Secure access to the data directory chmod 0700 "${SERVICEHOME}" || true # Restrict access on setuid binaries for i in /usr/bin/gnunet-helper-exit \ /usr/bin/gnunet-helper-nat-client \ /usr/bin/gnunet-helper-nat-server \ /usr/bin/gnunet-helper-transport-wlan \ /usr/bin/gnunet-helper-vpn do # only do something when no setting exists if ! dpkg-statoverride --list $i >/dev/null 2>&1 then dpkg-statoverride --update --add root ${_GROUPNAME} 4754 $i fi done if ! dpkg-statoverride --list /usr/bin/gnunet-helper-dns >/dev/null 2>&1 then dpkg-statoverride --update --add root ${GNUNETDNS_GROUP} 4754 /usr/bin/gnunet-helper-dns fi if ! dpkg-statoverride --list /usr/bin/gnunet-service-dns >/dev/null 2>&1 then dpkg-statoverride --update --add ${_USERNAME} ${GNUNETDNS_GROUP} 2754 /usr/bin/gnunet-service-dns fi echo " done." # Writing new values to configuration file echo -n "Writing new configuration file:" CONFIG_NEW=$(tempfile) cat > "${CONFIG_NEW}" </dev/null; then dpkg-maintscript-helper rm_conffile /etc/gnunetd.conf 0.9.2-1~ -- "$@" fi # Cleaning rm -f "${CONFIG_NEW}" echo "All done." ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`${1}'" >&2 exit 1 ;; esac #DEBHELPER# exit 0