
On Tue, Apr 29, 2025 at 02:57:13PM +0200, Ján Tomko wrote:
On a Tuesday in 2025, Daniel P. Berrangé via Devel wrote:
Over the years we've made various changes to stop hardcoding paths at build time, but the work is incomplete.
This bit us significantly in Fedora 42 where they have merged the 'sbin' and 'bin' dirs together. In the build environment we have a clean install where '/sbin' and '/usr/sbin' are simply symlinks to '/usr/bin'.
Our meson.build logic preferentially looks in '/sbin' and '/usr/sbin' to find programs, and thus it finds *all* binaries in '/sbin' and then hardcodes this path. This happens even for binaries that have always been in '/usr/bin' and NEVER '/sbin' or '/usr/sbin'
On fresh Fedora installs this is fine as the symlinks match the build environment.
On upgraded Fedora installs, however, '/sbin' and '/usr/sbin' remain separate directories and inside they symlink individual binaries, if-and-only-if the binary was in '/sbin' in Fedora 41.
Thus many of the binaries we found in /sbin don't actually exist and libvirt thus breaks.
There is really no reason why we should be harcoding any paths at build time. virCommand happily uses virFindFileInPath for any paths which are not already absolute. $PATH includes '/sbin' and '/usr/sbin' when we're running privileged, and when unprivileged we shouldn't need to run binaries from there.
Does anyone happen to remember the original reason?
The only thing I can think of is saving the lookup time, but that has to be negligible compared to the cost of fork and the command actually doing something
I've not checked, but I expect that a very very very long time ago virCommand would not lookup binaries in $PATH, and then we just cargo-culted the configure.ac checks, later meson.build checks, without thinking about it more. Yes, we've got the cost of a few stat() calls, but as you say, it isn't worth worrying about that in the context of a heavy fork+exec. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|