#!/bin/sh # postinst script for polkitd # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-remove' # * `abort-deconfigure' `in-favour' # `removing' # # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package reboot_required() { echo "Upgrading to this polkitd version requires a reboot, please reboot the system when convenient." >&2 # Trigger an update notification that recommends a reboot. touch /run/reboot-required || true if ! grep -Fqsx polkitd /run/reboot-required.pkgs; then echo polkitd >> /run/reboot-required.pkgs || true fi } set_perms() { USER=$1 GROUP=$2 MODE=$3 FILE=$4 if ! dpkg-statoverride --list "$FILE" > /dev/null 2>&1; then chown "$USER:$GROUP" "$FILE" chmod "$MODE" "$FILE" fi } stop_polkitd () { if [ -n "${DPKG_ROOT-}" ]; then return fi if [ -d /run/systemd/system ]; then deb-systemd-invoke stop polkit.service >/dev/null || true else # On non-systemd systems, polkitd is started as a traditional D-Bus # system service and is not managed by a service manager, so this is # the best we can do start-stop-daemon --stop --oknodo --quiet --exec /usr/lib/polkit-1/polkitd || true fi } case "$1" in configure) if ! getent passwd polkitd >/dev/null; then user_changed=yes else user_changed= fi # Intentionally not using dh_installsysusers: we need enough control # over sequencing to reload dbus-daemon after doing this, but before # restarting polkitd systemd-sysusers ${DPKG_ROOT:+--root="$DPKG_ROOT"} polkit.conf # When running with systemd (default) there's no need for SUID anymore # as the socket-activated service takes care of privilege escalation safely if ! dpkg -s systemd-sysv > /dev/null 2>&1; then set_perms root root 4755 /usr/lib/polkit-1/polkit-agent-helper-1 fi # If the polkitd user was newly created or newly added to the polkitd # group, the dbus-daemon might not know about that until reloaded. # dbus-broker's service has a dbus.service alias, so this will reload # either dbus-daemon or dbus-broker, whichever is used. if [ -z "${DPKG_ROOT-}" ] && [ -n "$user_changed" ]; then invoke-rc.d dbus reload || true fi # begin-remove-after: released:forky # If GNOME is already running when upgrading from a pre-socket activated agent # version, then the desktop might break, ask for a reboot if [ -d /run/systemd/system ] && [ -n "$2" ] && dpkg --compare-versions "$2" lt 127~; then reboot_required fi # end-remove-after ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# # If dpkg renamed a sysadmin-modified /etc/pam.d/polkit-1 to .dpkg-bak, # rename it back to the original name so PAM will still load it. # (Workaround for missing dpkg feature requested in # https://bugs.debian.org/1006655) if [ -e /etc/pam.d/polkit-1.dpkg-bak ]; then echo "Moving /etc/pam.d/polkit-1.dpkg-bak back to /etc/pam.d/polkit-1 ..." mv /etc/pam.d/polkit-1.dpkg-bak /etc/pam.d/polkit-1 fi # On non-systemd systems, polkitd is started as a traditional D-Bus # system service and is not managed by a service manager, so the # closest thing we can do to a restart operation is to terminate it # and let dbus-daemon restart it. if ! [ -d /run/systemd/system ]; then stop_polkitd fi exit 0 # vim:set sw=4 sts=4 et: