aboutsummaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-snmpd-always-exit-after-displaying-usage.patch
blob: 4fc9e54b4970868f5e343fd7c9ce94e5d323b958 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From 94ca941e06bef157bf0e13251f8ca1471daa9393 Mon Sep 17 00:00:00 2001
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Date: Fri, 27 Aug 2021 14:21:45 +0300
Subject: [PATCH] snmpd: always exit after displaying usage

Currently, viewing the help text with -h results in snmpd being started
in the background, whereas this does not happen with --help. Similarly,
when an error is detected in command line syntax, the help text is
displayed but sometimes snmpd gets started anyway, depending on the
execution path.

This patch makes snmpd consistently terminate whenever the usage
function gets called. It also removes the goto statements no longer
needed.

Upstream-Status: Backport
[https://github.com/net-snmp/net-snmp/commit/94ca941e06bef157bf0e13251f8ca1471daa9393]

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
 agent/snmpd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/agent/snmpd.c b/agent/snmpd.c
index f5aab0af8..90de12d99 100644
--- a/agent/snmpd.c
+++ b/agent/snmpd.c
@@ -289,6 +289,8 @@ usage(char *prog)
            "  -S d|i|0-7\t\tuse -Ls <facility> instead\n"
            "\n"
            );
+    SOCK_CLEANUP;
+    exit(1);
 }
 
 static void
@@ -494,7 +496,6 @@ main(int argc, char *argv[])
         case '-':
             if (strcasecmp(optarg, "help") == 0) {
                 usage(argv[0]);
-                goto out;
             }
             if (strcasecmp(optarg, "version") == 0) {
                 version();
@@ -783,7 +784,6 @@ main(int argc, char *argv[])
             fprintf(stderr, "%s: Illegal argument -X:"
 		            "AgentX support not compiled in.\n", argv[0]);
             usage(argv[0]);
-            goto out;
 #endif
             break;
 
-- 
2.25.1