[libvirt] [PATCH] libvirt.spec.in: soft-static allocation of qemu and kvm groups

Jaroslav Suchanek jsuchane at redhat.com
Thu Jul 7 15:41:51 UTC 2016


Follow the same logic for adding qemu user also for kvm and qemu groups. As
is described in https://fedoraproject.org/wiki/Packaging:UsersAndGroups
document there should be preallocated UIDs and GIDs for libvirt. A check for
required group id was added prior groupadd execution.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1351792
---
 libvirt.spec.in | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 2b98836..3dc3193 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1464,8 +1464,20 @@ fi
 # 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 group kvm >/dev/null; then
+  if ! getent group 36 >/dev/null; then
+    groupadd -f -g 36 -r kvm
+  else
+    groupadd -f -r kvm
+  fi
+fi
+if ! getent group qemu >/dev/null; then
+  if ! getent group 107 >/dev/null; then
+    groupadd -f -g 107 -r qemu
+  else
+    groupadd -f -r qemu
+  fi
+fi
 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
-- 
1.8.3.1




More information about the libvir-list mailing list