RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2095429 - [RFE] libvirt use systemd-sysusers
Summary: [RFE] libvirt use systemd-sysusers
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: CentOS Stream
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Virtualization Maintenance
QA Contact: yafu
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-06-09 17:34 UTC by Pat Riehecky
Modified: 2023-03-14 18:32 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-10-07 12:31:20 UTC
Type: Feature Request
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-124864 0 None None None 2022-06-09 17:45:15 UTC

Description Pat Riehecky 2022-06-09 17:34:30 UTC
Description of problem:
libvirt is using static useradd scripts

Version-Release number of selected component (if applicable):
 	libvirt-8.4.0-1.el9

How reproducible:
100%

Steps to Reproduce:
1.review %pre
2.
3.

Actual results:
# 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

Expected results:
use of system-sysusers 

Additional info:
https://www.freedesktop.org/software/systemd/man/systemd-sysusers.html
https://fedoraproject.org/wiki/Changes/Adopting_sysusers.d_format

Comment 2 Peter Krempa 2022-07-13 08:49:07 UTC
I had a look at this and while conversion of the users to a 'sysusers' file and it's distribution is trivial, it's incompatible with libvirt distributing the 'spec' file as part of the upstream project and including it in the release tarball.

The problem originates from the need to use the '%sysusers_create_compat' macro which re-expands the sysuser file into commands to actually add the user. The macro takes a path to the sysusers file but that file, when included in the tarball can't be referenced by 'rpmbuild' at that point.

This would fundamendally break the way e.g. CI builds packages.

I see only 3 options for now:
1) we keep the script to create users
2) the macro is reworked somehow to work properly even for packages wanting to use 'rpmbuild -tb' way to extrac the spec from a tarball
3) libvirt's sysusers file will be distributed as part of the dirstribution so we can rely on it being already installed

For reference I'm attaching the sysusers file I've made for libvirt and a comparison of the scripts generated by %sysusers_create_compat and what we have now:

$ cat src/qemu/libvirt-qemu.sysusers
# This file is part of libvirt's qemu VM driver
#
# Libvirt requires soft static allocation of well-known ids, as disk images
# are commonly shared across NFS mounts by id rather than name.
#
# This config:
# - creates a 'kvm' group with gid 36
# - creates a 'qemu' user and group with uid 107 and gid 107
# - adds the 'qemu' user to the 'kvm' group
g kvm  36
u qemu 107 "qemu user"
m qemu kvm
$ /usr/lib/rpm/sysusers.generate-pre.sh src/qemu/libvirt-qemu.sysusers
# generated from libvirt-qemu.sysusers
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' -d '/' -s /sbin/nologin -c 'qemu user' 'qemu' || :
    else
        useradd -r -g 'qemu' -d '/' -s /sbin/nologin -c 'qemu user' 'qemu' || :
    fi
fi

getent group 'kvm' >/dev/null || groupadd -r 'kvm' || :
getent passwd 'qemu' >/dev/null || \
    useradd -r -g 'kvm' -d '/' -s '/sbin/nologin' -c '' 'qemu' || :

Now we have:

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

Comment 3 Peter Krempa 2022-09-20 10:10:41 UTC
Pat,

are you involved by any means in the effort to use the 'sysuser' files or can point somebody to this bug?

Based on my above comment it currently doesn't seem that libvirt will be able to use what you suggested without breaking builds from tarball which doesn't seem acceptable.

Comment 4 Pat Riehecky 2022-09-20 13:50:53 UTC
Alas, I'm not really involved in the larger scale effort to move to systemd-sysusers.

Neal might know what the larger plans are for this type of scenario....

Comment 5 Pat Riehecky 2022-09-20 13:51:55 UTC
Neal, any ideas on building from tarball with systemd-sysusers and RPM, or who we should add to the CC list?

Comment 6 Peter Krempa 2022-10-07 12:31:20 UTC
As outlined in Comment #2 it's currently impossible for libvirt to use the new approach requested in this BZ. Please reopen this bug if it will become possible in the future.


Note You need to log in before you can comment on or make changes to this bug.