The branch main has been updated by glebius:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3c29b47bbc0a107c2bda0c103fc8c6de2cbddee8

commit 3c29b47bbc0a107c2bda0c103fc8c6de2cbddee8
Author:     Gleb Smirnoff <gleb...@freebsd.org>
AuthorDate: 2025-07-17 16:00:44 +0000
Commit:     Gleb Smirnoff <gleb...@freebsd.org>
CommitDate: 2025-07-17 16:00:44 +0000

    bsnmpd: in debugging mode (-d) use default library print/error functions
    
    We want to see debugging on stderr in non-daemon mode, otherwise this
    mode has little value.
    
    Reviewed by:            harti
    Differential Revision:  https://reviews.freebsd.org/D51356
---
 contrib/bsnmp/snmpd/main.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/contrib/bsnmp/snmpd/main.c b/contrib/bsnmp/snmpd/main.c
index 928b84121f82..c77572934d24 100644
--- a/contrib/bsnmp/snmpd/main.c
+++ b/contrib/bsnmp/snmpd/main.c
@@ -42,6 +42,7 @@
 #include <sys/un.h>
 #include <sys/ucred.h>
 #include <sys/uio.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stddef.h>
@@ -1509,7 +1510,7 @@ main(int argc, char *argv[])
 {
        int opt;
        FILE *fp;
-       int background = 1;
+       bool background = true;
        struct tport *p;
        const char *prefix = "snmpd";
        struct lmodule *m;
@@ -1526,11 +1527,6 @@ main(int argc, char *argv[])
                NULL
        };
 
-       snmp_printf = snmp_printf_func;
-       snmp_error = snmp_error_func;
-       snmp_debug = snmp_debug_func;
-       asn_error = asn_error_func;
-
        while ((opt = getopt(argc, argv, "c:dD:e:hI:l:m:p:")) != EOF)
                switch (opt) {
 
@@ -1539,7 +1535,7 @@ main(int argc, char *argv[])
                        break;
 
                  case 'd':
-                       background = 0;
+                       background = false;
                        break;
 
                  case 'D':
@@ -1601,6 +1597,13 @@ main(int argc, char *argv[])
                        break;
                }
 
+       if (background) {
+               snmp_printf = snmp_printf_func;
+               snmp_error = snmp_error_func;
+               snmp_debug = snmp_debug_func;
+               asn_error = asn_error_func;
+       }
+
        openlog(prefix, LOG_PID | (background ? 0 : LOG_PERROR), LOG_USER);
        setlogmask(LOG_UPTO(debug.logpri - 1));
 

Reply via email to