rpm: disable account creation for Fedora >= 42

In Fedora >= 42, support for user/group account creation based on
sysusers files has been enabled in RPM. Manually running useradd/
groupadd is thus obsolete.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2025-01-29 15:52:02 +00:00
parent 2dd4f594ea
commit cf32953f5b

View File

@ -44,6 +44,12 @@
%define with_qemu_kvm 0 %define with_qemu_kvm 0
%endif %endif
%if 0%{?fedora} >= 42
%define with_account_add 0
%else
%define with_account_add 1
%endif
%define with_qemu_tcg %{with_qemu} %define with_qemu_tcg %{with_qemu}
# RHEL disables TCG on all architectures # RHEL disables TCG on all architectures
@ -535,8 +541,10 @@ Requires(posttrans): /usr/bin/systemctl
Requires(preun): /usr/bin/systemctl Requires(preun): /usr/bin/systemctl
# libvirtd depends on 'messagebus' service # libvirtd depends on 'messagebus' service
Requires: dbus Requires: dbus
%if %{with_account_add}
# For uid creation during pre # For uid creation during pre
Requires(pre): shadow-utils Requires(pre): shadow-utils
%endif
# Needed by /usr/libexec/libvirt-guests.sh script. # Needed by /usr/libexec/libvirt-guests.sh script.
%if 0%{?fedora} %if 0%{?fedora}
Requires: gettext-runtime Requires: gettext-runtime
@ -1095,8 +1103,10 @@ Wireshark dissector plugin for better analysis of libvirt RPC traffic.
%package login-shell %package login-shell
Summary: Login shell for connecting users to an LXC container Summary: Login shell for connecting users to an LXC container
Requires: libvirt-libs = %{version}-%{release} Requires: libvirt-libs = %{version}-%{release}
%if %{with_account_add}
# For uid creation during pre # For uid creation during pre
Requires(pre): shadow-utils Requires(pre): shadow-utils
%endif
%description login-shell %description login-shell
Provides the set-uid virt-login-shell binary that is used to Provides the set-uid virt-login-shell binary that is used to
@ -1796,10 +1806,12 @@ export VIR_TEST_DEBUG=1
%pre daemon-common %pre daemon-common
%libvirt_sysconfig_pre libvirt-guests %libvirt_sysconfig_pre libvirt-guests
%libvirt_systemd_oneshot_pre libvirt-guests %libvirt_systemd_oneshot_pre libvirt-guests
%if %{with_account_add}
# 'libvirt' group is just to allow password-less polkit access to libvirt # 'libvirt' group is just to allow password-less polkit access to libvirt
# daemons. The uid number is irrelevant, so we use dynamic allocation. # daemons. The uid number is irrelevant, so we use dynamic allocation.
getent group libvirt >/dev/null || groupadd -r libvirt getent group libvirt >/dev/null || groupadd -r libvirt
exit 0 exit 0
%endif
%posttrans daemon-common %posttrans daemon-common
%libvirt_sysconfig_posttrans libvirt-guests %libvirt_sysconfig_posttrans libvirt-guests
@ -1922,6 +1934,7 @@ exit 0
%libvirt_sysconfig_pre virtqemud %libvirt_sysconfig_pre virtqemud
%libvirt_systemd_unix_pre virtqemud %libvirt_systemd_unix_pre virtqemud
%if %{with_account_add}
# We want soft static allocation of well-known ids, as disk images # We want soft static allocation of well-known ids, as disk images
# are commonly shared across NFS mounts by id rather than name. # are commonly shared across NFS mounts by id rather than name.
# See https://docs.fedoraproject.org/en-US/packaging-guidelines/UsersAndGroups/ # See https://docs.fedoraproject.org/en-US/packaging-guidelines/UsersAndGroups/
@ -1937,6 +1950,7 @@ if ! getent passwd 'qemu' >/dev/null; then
fi fi
fi fi
exit 0 exit 0
%endif
%posttrans daemon-driver-qemu %posttrans daemon-driver-qemu
%libvirt_sysconfig_posttrans virtqemud %libvirt_sysconfig_posttrans virtqemud
@ -2063,8 +2077,10 @@ done
%if %{with_lxc} %if %{with_lxc}
%pre login-shell %pre login-shell
%if %{with_account_add}
getent group virtlogin >/dev/null || groupadd -r virtlogin getent group virtlogin >/dev/null || groupadd -r virtlogin
exit 0 exit 0
%endif
%endif %endif
%endif %endif