mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemu: Add sysusers config file for qemu & kvm user/groups
Install a systemd sysusers config file for the qemu & kvm user/groups. We can not use the sysusers_create_compat macro in the RPM specfile to create those users as we want to keep the specfile standalone and not relying on additionnal files. Update the specfile to make the commands closer to what is generated by the current macro. See: https://src.fedoraproject.org/rpms/libvirt/pull-request/22 See: https://gitlab.com/libvirt/libvirt/-/merge_requests/319 See: https://bugzilla.redhat.com/show_bug.cgi?id=2095429 See: https://docs.fedoraproject.org/en-US/packaging-guidelines/UsersAndGroups/ Based on previous work by: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Timothée Ravier <tim@siosm.fr> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
21b62329f3
commit
a2c3e390f7
@ -1473,6 +1473,7 @@ chmod 600 $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/nwfilter/*.xml
|
|||||||
%if ! %{with_qemu}
|
%if ! %{with_qemu}
|
||||||
rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/libvirtd_qemu.aug
|
rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/libvirtd_qemu.aug
|
||||||
rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/tests/test_libvirtd_qemu.aug
|
rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/tests/test_libvirtd_qemu.aug
|
||||||
|
rm -f $RPM_BUILD_ROOT%{_sysusersdir}/libvirt-qemu.conf
|
||||||
%endif
|
%endif
|
||||||
%find_lang %{name}
|
%find_lang %{name}
|
||||||
|
|
||||||
@ -1834,16 +1835,19 @@ exit 0
|
|||||||
%pre daemon-driver-qemu
|
%pre daemon-driver-qemu
|
||||||
%libvirt_sysconfig_pre virtqemud
|
%libvirt_sysconfig_pre virtqemud
|
||||||
%libvirt_systemd_unix_pre virtqemud
|
%libvirt_systemd_unix_pre virtqemud
|
||||||
|
|
||||||
# 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; see
|
# are commonly shared across NFS mounts by id rather than name.
|
||||||
# https://fedoraproject.org/wiki/Packaging:UsersAndGroups
|
# See https://docs.fedoraproject.org/en-US/packaging-guidelines/UsersAndGroups/
|
||||||
getent group kvm >/dev/null || groupadd -f -g 36 -r kvm
|
# We can not use the sysusers_create_compat macro here as we want to keep the
|
||||||
getent group qemu >/dev/null || groupadd -f -g 107 -r qemu
|
# specfile standalone and not relying on additionnal files.
|
||||||
if ! getent passwd qemu >/dev/null; then
|
getent group 'kvm' >/dev/null || groupadd -f -g '36' -r 'kvm' || :
|
||||||
if ! getent passwd 107 >/dev/null; then
|
getent group 'qemu' >/dev/null || groupadd -f -g '107' -r 'qemu' || :
|
||||||
useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" 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
|
else
|
||||||
useradd -r -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" qemu
|
useradd -r -g 'qemu' -G 'kvm' -d '/' -s '/sbin/nologin' -c 'qemu user' 'qemu' || :
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
@ -2246,6 +2250,7 @@ exit 0
|
|||||||
%{_bindir}/virt-qemu-run
|
%{_bindir}/virt-qemu-run
|
||||||
%{_mandir}/man1/virt-qemu-run.1*
|
%{_mandir}/man1/virt-qemu-run.1*
|
||||||
%{_mandir}/man8/virtqemud.8*
|
%{_mandir}/man8/virtqemud.8*
|
||||||
|
%{_sysusersdir}/libvirt-qemu.conf
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%if %{with_lxc}
|
%if %{with_lxc}
|
||||||
|
4
src/qemu/libvirt-qemu.sysusers.conf
Normal file
4
src/qemu/libvirt-qemu.sysusers.conf
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
g kvm 36
|
||||||
|
g qemu 107
|
||||||
|
u qemu 107:qemu "qemu user" - -
|
||||||
|
m qemu kvm
|
@ -160,6 +160,13 @@ if conf.has('WITH_QEMU')
|
|||||||
configuration: qemu_user_group_hack_conf,
|
configuration: qemu_user_group_hack_conf,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Install the sysuser config for the qemu driver
|
||||||
|
install_data(
|
||||||
|
'libvirt-qemu.sysusers.conf',
|
||||||
|
install_dir: prefix / 'lib' / 'sysusers.d',
|
||||||
|
rename: [ 'libvirt-qemu.conf' ],
|
||||||
|
)
|
||||||
|
|
||||||
virt_conf_files += qemu_conf
|
virt_conf_files += qemu_conf
|
||||||
virt_aug_files += files('libvirtd_qemu.aug')
|
virt_aug_files += files('libvirtd_qemu.aug')
|
||||||
virt_test_aug_files += {
|
virt_test_aug_files += {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user