spec: proper soft static allocation of qemu uid

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>
This commit is contained in:
Eric Blake
2013-05-06 14:05:05 -06:00
parent c21c38d71b
commit a2584d58f6
+15 -8
View File
@@ -718,6 +718,8 @@ Requires: numad
%endif %endif
# libvirtd depends on 'messagebus' service # libvirtd depends on 'messagebus' service
Requires: dbus Requires: dbus
# For uid creation during pre
Requires(pre): shadow-utils
%description daemon %description daemon
Server side daemon required to manage the virtualization capabilities Server side daemon required to manage the virtualization capabilities
@@ -1444,14 +1446,19 @@ make check
%if %{with_libvirtd} %if %{with_libvirtd}
%pre daemon %pre daemon
%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6 %if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
# Normally 'setup' adds this in /etc/passwd, but this is # We want soft static allocation of well-known ids, as disk images
# here for case of upgrades from earlier Fedora/RHEL. This # are commonly shared across NFS mounts by id rather than name; see
# UID/GID pair is reserved for qemu:qemu # https://fedoraproject.org/wiki/Packaging:UsersAndGroups
getent group kvm >/dev/null || groupadd -g 36 -r kvm getent group kvm >/dev/null || groupadd -f -g 36 -r kvm
getent group qemu >/dev/null || groupadd -g 107 -r qemu getent group qemu >/dev/null || groupadd -f -g 107 -r qemu
getent passwd qemu >/dev/null || \ if ! getent passwd qemu >/dev/null; then
useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \ if ! getent passwd 107 >/dev/null; then
-c "qemu user" qemu 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 %endif
%post daemon %post daemon