Tue, 25 Jan 2022 10:11:01 -0800 Andrea Bolognani <abologna(a)redhat.com>:
Do you mean that if the user has passed
-Dqemu_user=... -Dqemu_group=...
to meson we could skip the detection logic? That'd be nice, but I'm
afraid it might make the code less readable for very little gain.
The whole thing will be just a whitespace change because it goes into its own block:
qemu_user = get_option('qemu_user')
qemu_group = get_option('qemu_group')
if qemu_user == '' or qemu_group == ''
if host_machine.system() in [ 'freebsd', 'darwin' ]
default_qemu_user = 'root'
default_qemu_group = 'wheel'
else
os_release = run_command('grep', '^ID=',
'/etc/os-release', check: true).stdout()
if os_release.contains('arch')
default_qemu_user = 'nobody'
default_qemu_group = 'nobody'
elif (os_release.contains('centos') or
os_release.contains('fedora') or
os_release.contains('gentoo') or
os_release.contains('rhel') or
os_release.contains('sles') or
os_release.contains('suse'))
default_qemu_user = 'qemu'
default_qemu_group = 'qemu'
elif os_release.contains('debian')
default_qemu_user = 'libvirt-qemu'
default_qemu_group = 'libvirt-qemu'
elif os_release.contains('ubuntu')
default_qemu_user = 'libvirt-qemu'
default_qemu_group = 'kvm'
else
default_qemu_user = 'root'
default_qemu_group = 'root'
endif
# If the expected user and group don't exist, or we haven't hit any
# of the cases above bacuse we're running on an unknown OS, the only
# sensible fallback is root:root
if (run_command('getent', 'passwd', default_qemu_user, check:
false).returncode() != 0 and
run_command('getent', 'group', default_qemu_group, check:
false).returncode() != 0)
default_qemu_user = 'root'
default_qemu_group = 'root'
endif
endif
qemu_group = default_qemu_group
qemu_user = default_qemu_user
endif
conf.set_quoted('QEMU_USER', qemu_user)
conf.set_quoted('QEMU_GROUP', qemu_group)
This looks like an opportunity to get rid of default_qemu_user/group.
The getent part is bogus because it forces the user/group to be present on the system
which is building libvirt. This build system is usually not the system which runs
libvirt.
Please fix bug this as well.
Olaf