[Pkg-libvirt-maintainers] Bug#844339: [PATCH v2 2/4] libvirt-daemon-system.{config, templates, postinst}: warn if allocated uid/gid cannot be used

Mauricio Faria de Oliveira mauricfo at linux.vnet.ibm.com
Thu Nov 17 12:51:40 UTC 2016


If the libvirt-qemu user/group already exists with different
uid/gid than the allocated numeric ID (64055), or if this ID
is already in use by another user/group, stop/ask user if it
is OK to continue (e.g., no plans to perform guest migration
over NFS) or abort to go fix the problem.

Signed-off-by: Mauricio Faria de Oliveira <mauricfo at linux.vnet.ibm.com>
---
 debian/libvirt-daemon-system.config    | 30 ++++++++++++++++++++++++++++++
 debian/libvirt-daemon-system.postinst  |  3 +++
 debian/libvirt-daemon-system.templates | 19 +++++++++++++++++++
 debian/rules                           |  1 +
 4 files changed, 53 insertions(+)
 create mode 100755 debian/libvirt-daemon-system.config
 create mode 100644 debian/libvirt-daemon-system.templates

diff --git a/debian/libvirt-daemon-system.config b/debian/libvirt-daemon-system.config
new file mode 100755
index 0000000..27ce292
--- /dev/null
+++ b/debian/libvirt-daemon-system.config
@@ -0,0 +1,30 @@
+#!/bin/sh -e
+
+# Source debconf library.
+. /usr/share/debconf/confmodule
+
+# Allocated UID and GID for libvirt-qemu
+LIBVIRT_QEMU_UID=64055
+LIBVIRT_QEMU_GID=64055
+
+# Check if libvirt-qemu user/group is assigned a different UID/GID or vice-versa.
+NAME_TO_UID="$(getent passwd libvirt-qemu | cut -d: -f3)"
+NAME_TO_GID="$(getent group  libvirt-qemu | cut -d: -f3)"
+UID_TO_NAME="$(getent passwd $LIBVIRT_QEMU_UID | cut -d: -f1)"
+GID_TO_NAME="$(getent group  $LIBVIRT_QEMU_GID | cut -d: -f1)"
+
+if ( [ -n "$NAME_TO_UID" ] && [ "$NAME_TO_UID" != "$LIBVIRT_QEMU_UID" ] ) \
+|| ( [ -n "$NAME_TO_GID" ] && [ "$NAME_TO_GID" != "$LIBVIRT_QEMU_GID" ] ) \
+|| ( [ -n "$UID_TO_NAME" ] && [ "$UID_TO_NAME" != 'libvirt-qemu' ] ) \
+|| ( [ -n "$GID_TO_NAME" ] && [ "$GID_TO_NAME" != 'libvirt-qemu' ] ) \
+then
+	# Ask if the user would like to continue or abort installation.
+	db_input high libvirt-daemon-system/id_warning || true
+	db_go
+	db_get libvirt-daemon-system/id_warning
+	if [ "$RET" = "false" ]; then
+		exit 1
+	fi
+fi
+
+exit 0
diff --git a/debian/libvirt-daemon-system.postinst b/debian/libvirt-daemon-system.postinst
index 99e9fec..f36b806 100644
--- a/debian/libvirt-daemon-system.postinst
+++ b/debian/libvirt-daemon-system.postinst
@@ -17,6 +17,9 @@ set -e
 # for details, see http://www.debian.org/doc/debian-policy/ or
 # the debian-policy package
 
+# Source debconf library.
+. /usr/share/debconf/confmodule
+
 add_users_groups()
 {
     if ! getent group libvirt >/dev/null; then
diff --git a/debian/libvirt-daemon-system.templates b/debian/libvirt-daemon-system.templates
new file mode 100644
index 0000000..57193b0
--- /dev/null
+++ b/debian/libvirt-daemon-system.templates
@@ -0,0 +1,19 @@
+Template: libvirt-daemon-system/id_warning
+Type: boolean
+Default: false
+Description: Continue with incorrect libvirt-qemu user/group ID(s)?
+  This system seems to already have a libvirt-qemu user and/or
+  group with different ID(s) than the allocated (64055) or the
+  numeric ID is already taken by another user/group.
+ .
+  The migration of guests with disk image files shared over NFS
+  requires a static libvirt-qemu user and group ID (uid and gid)
+  between the source and destination host systems.
+ .
+  If guest migration over NFS is not required you can continue
+  the installation.
+ .
+  In order to resolve this problem, do not continue the installation,
+  remove the libvirt-qemu user/group and/or the 64055 uid/gid (which
+  might involve changing permissions for its owned files) and try to
+  install this package again.
diff --git a/debian/rules b/debian/rules
index 6e0a416..ec9d90d 100755
--- a/debian/rules
+++ b/debian/rules
@@ -159,6 +159,7 @@ override_dh_auto_test:
 	fi
 
 override_dh_install-arch:
+	dh_installdebconf
 	dh_install
 
 	# Copy upstream files to debian/ so dh_* can find them
-- 
2.10.2



More information about the Pkg-libvirt-maintainers mailing list