[PATCH libvirt-snmp 3/3] fix startup logic for selecting stderr vs syslog

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This bug was uncovered by coverity during the run that resulted in the
filing of the following bug:

   https://bugzilla.redhat.com/show_bug.cgi?id=732015

use_syslog was initialized to 0, and then if the "Use stderr" option
was selected, it was set to ... "0"!

Rather than simply initializing to 1, I decided to reduce confusion by
renaming the variable to "use_stderr", leave it initialized to 0, then
set to 1 when the user asks for stderr.
---
 src/libvirtMib_subagent.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/libvirtMib_subagent.c b/src/libvirtMib_subagent.c
index f5749be..2ce1509 100644
--- a/src/libvirtMib_subagent.c
+++ b/src/libvirtMib_subagent.c
@@ -60,7 +60,7 @@ main (int argc, char **argv) {
   /* Defs for arg-handling code: handles setting of policy-related variables */
   int          ch;
   extern char *optarg;
-  int dont_fork = 0, use_syslog = 0;
+  int dont_fork = 0, use_stderr = 0;
   char *agentx_socket = NULL;
 
   while ((ch = getopt(argc, argv, "D:fHLMx:")) != EOF)
@@ -85,7 +85,7 @@ main (int argc, char **argv) {
       agentx_subagent = 0;
       break;
     case 'L':
-      use_syslog = 0; /* use stderr */
+      use_stderr = 1;
       break;
     case 'x':
       agentx_socket = optarg;
@@ -134,14 +134,14 @@ main (int argc, char **argv) {
   }
 
   snmp_disable_log();
-  if (use_syslog)
-      snmp_enable_calllog();
-  else
+  if (use_stderr)
       snmp_enable_stderrlog();
+  else
+      snmp_enable_calllog();
 
   /* daemonize */
   if(!dont_fork) {
-    int rc = netsnmp_daemonize(1,!use_syslog);
+    int rc = netsnmp_daemonize(1, use_stderr);
     if(rc)
        exit(-1);
   }
-- 
1.7.6.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]