[Libvir] [PATCH] detect path of dnsmasq, brctl

I have found 3 bugs in libvirtd in the way that it runs the external programs dnsmasq and brctl. Bug (1) is that it searches the $PATH to find dnsmasq. This is normally OK when libvirtd is launched from start-up scripts, but it's not very helpful if you run libvirtd by hand because likely-as-not your path won't contain /usr/sbin (the normal location of dnsmasq). Bug (2) is that if libvirtd can't execvp dnsmasq, then it doesn't fail in any obvious way. Bug (3) is that the path to brctl is hard-coded. This patch fixes bugs (1) & (3), but does not fix bug (2). Firstly configure has been changed so that it searches for dnsmasq and brctl programs in the usual places. If it find them then it generates a config.h file which looks like this: -------------------- /* Location or name of the brctl program (see bridge-utils) */ #define BRCTL "/usr/sbin/brctl" /* Location or name of the dnsmasq program */ #define DNSMASQ "/usr/sbin/dnsmasq" -------------------- If it doesn't find them then it just includes the program names, not full paths: -------------------- /* Location or name of the brctl program (see bridge-utils) */ #define BRCTL "brctl" /* Location or name of the dnsmasq program */ #define DNSMASQ "dnsmasq" -------------------- The code continues to use execvp to actually run the programs, so if the program names contain '/' then the absolute paths are used directly, otherwise execvp will do a shell-like search for the program along $PATH. Please nota bene the change to the spec file. Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

On Thu, Sep 20, 2007 at 06:34:21PM +0100, Richard W.M. Jones wrote:
I have found 3 bugs in libvirtd in the way that it runs the external programs dnsmasq and brctl.
Bug (1) is that it searches the $PATH to find dnsmasq. This is normally OK when libvirtd is launched from start-up scripts, but it's not very helpful if you run libvirtd by hand because likely-as-not your path won't contain /usr/sbin (the normal location of dnsmasq).
Bug (2) is that if libvirtd can't execvp dnsmasq, then it doesn't fail in any obvious way.
Yep, I've never been able to figure out a good answer for that. We start the network at boot time, so pretty much best we could ever do is syslog() the problem. Or we could automatically shutdown the virtual network it dnsmasq fails, but i think that would be even more unpleasant
Bug (3) is that the path to brctl is hard-coded.
This patch fixes bugs (1) & (3), but does not fix bug (2).
This patch looks good to apply. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

Daniel P. Berrange wrote:
On Thu, Sep 20, 2007 at 06:34:21PM +0100, Richard W.M. Jones wrote:
I have found 3 bugs in libvirtd in the way that it runs the external programs dnsmasq and brctl.
Bug (1) is that it searches the $PATH to find dnsmasq. This is normally OK when libvirtd is launched from start-up scripts, but it's not very helpful if you run libvirtd by hand because likely-as-not your path won't contain /usr/sbin (the normal location of dnsmasq).
Bug (2) is that if libvirtd can't execvp dnsmasq, then it doesn't fail in any obvious way.
Yep, I've never been able to figure out a good answer for that. We start the network at boot time, so pretty much best we could ever do is syslog() the problem. Or we could automatically shutdown the virtual network it dnsmasq fails, but i think that would be even more unpleasant
Bug (3) is that the path to brctl is hard-coded.
This patch fixes bugs (1) & (3), but does not fix bug (2).
This patch looks good to apply.
Committed. Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903
participants (2)
-
Daniel P. Berrange
-
Richard W.M. Jones