]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
dnsmasq: Fix parsing of the version number
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 6 Dec 2012 12:48:11 +0000 (13:48 +0100)
committerCole Robinson <crobinso@redhat.com>
Sun, 9 Dec 2012 20:27:39 +0000 (15:27 -0500)
If debugging is enabled, the debug messages are sent to stderr.
Moreover, if a command has catching of stderr set, the messages
gets mixed with stdout output (assuming both outputs are stored
in the same variable). The resulting string then doesn't
necessarily have to start with desired prefix then. This bug
exposes itself when parsing dnsmasq output:

2012-12-06 11:18:11.445+0000: 18491: error :
dnsmasqCapsSetFromBuffer:664 : internal error cannot parse
/usr/sbin/dnsmasq version number in '2012-12-06
11:11:02.232+0000: 18492: debug : virFileClose:72 : Closed fd 22'

We can clearly see that the output of dnsmasq --version doesn't
start with expected "Dnsmasq version " string but a libvirt debug
output.
(cherry picked from commit ff33f807739dc2950e4df8c1d4007ce9f8b290c0)

src/util/dnsmasq.c

index 71e960d9900c065be4e25cf806b6b829d7be45dd..0cb3cc61e7f1ac9ad0a9e0938eaa0c5c1d14a670 100644 (file)
@@ -701,7 +701,6 @@ dnsmasqCapsRefreshInternal(dnsmasqCapsPtr caps, bool force)
 
     cmd = virCommandNewArgList(caps->binaryPath, "--version", NULL);
     virCommandSetOutputBuffer(cmd, &version);
-    virCommandSetErrorBuffer(cmd, &version);
     virCommandAddEnvPassCommon(cmd);
     virCommandClearCaps(cmd);
     if (virCommandRun(cmd, NULL) < 0) {
@@ -713,7 +712,6 @@ dnsmasqCapsRefreshInternal(dnsmasqCapsPtr caps, bool force)
 
     cmd = virCommandNewArgList(caps->binaryPath, "--help", NULL);
     virCommandSetOutputBuffer(cmd, &help);
-    virCommandSetErrorBuffer(cmd, &help);
     virCommandAddEnvPassCommon(cmd);
     virCommandClearCaps(cmd);
     if (virCommandRun(cmd, NULL) < 0) {