| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
# summary of how this script can be called: |
| 6 |
# |
| 7 |
# * <postinst> `configure' <most-recently-configured-version> |
| 8 |
# * <old-postinst> `abort-upgrade' <new-version> |
| 9 |
# * <conflictor's-postinst> `abort-remove' `in-favour' <package> <new-version> |
| 10 |
# * <postinst> `abort-remove' |
| 11 |
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour' <failed-install-package> |
| 12 |
# <version> `removing' <conflicting-package> <version> |
| 13 |
# |
| 14 |
# for details, see https://www.debian.org/doc/debian-policy/ or |
| 15 |
# the debian-policy package |
| 16 |
|
| 17 |
case "$1" in |
| 18 |
configure) |
| 19 |
if [ -z "$2" ]; then |
| 20 |
adduser --quiet \ |
| 21 |
--system \ |
| 22 |
--group \ |
| 23 |
--disabled-login \ |
| 24 |
--home /nonexistent \ |
| 25 |
--no-create-home \ |
| 26 |
--gecos "libvirt-dbus user" \ |
| 27 |
libvirtdbus |
| 28 |
fi |
| 29 |
|
| 30 |
# Debian, like upstream, uses polkit to control access to libvirt: |
| 31 |
# specifically, /run/libvirt/libvirt-sock has ownership root:root and |
| 32 |
# permissions 666, but the policy defined in |
| 33 |
# /usr/share/polkit-1/rules.d/libvirt-dbus.rules prevents users other |
| 34 |
# than those in the libvirt group to actually perform management |
| 35 |
# operations. |
| 36 |
# |
| 37 |
# Ubuntu doesn't use polkit for this, and relies on standard Unix |
| 38 |
# permissions instead: specifically, the socket has ownership |
| 39 |
# root:libvirt and permissions 660. |
| 40 |
# |
| 41 |
# The end result is the same, in that only root and users that are in |
| 42 |
# the libvirt group can perform privileged operations. |
| 43 |
# |
| 44 |
# For libvirt-dbus to work, the libvirtdbus user that the daemon runs |
| 45 |
# as needs to be able to open a privileged connection to libvirt. |
| 46 |
# |
| 47 |
# Once again, Debian achieves this through polkit by installing a |
| 48 |
# special rule, whereas Ubuntu needs to add the user to the libvirt |
| 49 |
# group, which is what we do here. Note that the user is only added to |
| 50 |
# the group on fresh installs or upgrades from old versions of |
| 51 |
# libvirt-dbus, because we don't want to accidentally override local |
| 52 |
# changes to group membership. |
| 53 |
if [ -z "$2" ] || dpkg --compare-versions -- "$2" lt "1.4.1-1"; then |
| 54 |
if grep -qs 'ubuntu' /etc/os-release || grep -qs ubuntu /usr/lib/os-release; then |
| 55 |
if getent group libvirt >/dev/null 2>&1; then |
| 56 |
adduser libvirtdbus libvirt |
| 57 |
fi |
| 58 |
fi |
| 59 |
fi |
| 60 |
;; |
| 61 |
|
| 62 |
abort-upgrade|abort-remove|abort-deconfigure) |
| 63 |
;; |
| 64 |
|
| 65 |
*) |
| 66 |
echo "postinst called with unknown argument \`$1'" >&2 |
| 67 |
exit 1 |
| 68 |
;; |
| 69 |
esac |
| 70 |
|
| 71 |
#DEBHELPER# |
| 72 |
|
| 73 |
exit 0 |