]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
spec: proper soft static allocation of qemu uid
authorEric Blake <eblake@redhat.com>
Wed, 1 May 2013 20:28:43 +0000 (14:28 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 6 May 2013 20:57:38 +0000 (14:57 -0600)
https://bugzilla.redhat.com/show_bug.cgi?id=924501 tracks a
problem that occurs if uid 107 is already in use at the time
libvirt is first installed.  In response that problem, Fedora
packaging guidelines were recently updated.  This fixes the
spec file to comply with the new guidelines:
https://fedoraproject.org/wiki/Packaging:UsersAndGroups

* libvirt.spec.in (daemon): Follow updated Fedora guidelines.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit a2584d58f6f7d941b960f996c8e26df8294b79b9)

Conflicts:
libvirt.spec.in - no backport of c8f79c9b %if reindents

libvirt.spec.in

index b3893df53cd6aee54a99c1a9c275507ed080c0f5..888779a4801a763bd31acb2e3a2f6bc861278d6c 100644 (file)
@@ -697,6 +697,10 @@ Requires(postun): systemd-units
 %if %{with_numad}
 Requires: numad
 %endif
+# libvirtd depends on 'messagebus' service
+Requires: dbus
+# For uid creation during pre
+Requires(pre): shadow-utils
 
 %description daemon
 Server side daemon required to manage the virtualization capabilities
@@ -1417,16 +1421,21 @@ make check
 
 %if %{with_libvirtd}
 %pre daemon
-%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
-# Normally 'setup' adds this in /etc/passwd, but this is
-# here for case of upgrades from earlier Fedora/RHEL. This
-# UID/GID pair is reserved for qemu:qemu
-getent group kvm >/dev/null || groupadd -g 36 -r kvm
-getent group qemu >/dev/null || groupadd -g 107 -r qemu
-getent passwd qemu >/dev/null || \
-  useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
-    -c "qemu user" qemu
-%endif
+    %if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
+# We want soft static allocation of well-known ids, as disk images
+# are commonly shared across NFS mounts by id rather than name; see
+# https://fedoraproject.org/wiki/Packaging:UsersAndGroups
+getent group kvm >/dev/null || groupadd -f -g 36 -r kvm
+getent group qemu >/dev/null || groupadd -f -g 107 -r qemu
+if ! getent passwd qemu >/dev/null; then
+  if ! getent passwd 107 >/dev/null; then
+    useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" qemu
+  else
+    useradd -r -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" qemu
+  fi
+fi
+exit 0
+    %endif
 
 %post daemon