blob: 4fc9e54b4970868f5e343fd7c9ce94e5d323b958 [file] [log] [blame]
William A. Kennington III49e95662021-09-15 16:19:36 -07001From 94ca941e06bef157bf0e13251f8ca1471daa9393 Mon Sep 17 00:00:00 2001
2From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
3Date: Fri, 27 Aug 2021 14:21:45 +0300
4Subject: [PATCH] snmpd: always exit after displaying usage
5
6Currently, viewing the help text with -h results in snmpd being started
7in the background, whereas this does not happen with --help. Similarly,
8when an error is detected in command line syntax, the help text is
9displayed but sometimes snmpd gets started anyway, depending on the
10execution path.
11
12This patch makes snmpd consistently terminate whenever the usage
13function gets called. It also removes the goto statements no longer
14needed.
15
16Upstream-Status: Backport
17[https://github.com/net-snmp/net-snmp/commit/94ca941e06bef157bf0e13251f8ca1471daa9393]
18
19Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
20---
21 agent/snmpd.c | 4 ++--
22 1 file changed, 2 insertions(+), 2 deletions(-)
23
24diff --git a/agent/snmpd.c b/agent/snmpd.c
25index f5aab0af8..90de12d99 100644
26--- a/agent/snmpd.c
27+++ b/agent/snmpd.c
28@@ -289,6 +289,8 @@ usage(char *prog)
29 " -S d|i|0-7\t\tuse -Ls <facility> instead\n"
30 "\n"
31 );
32+ SOCK_CLEANUP;
33+ exit(1);
34 }
35
36 static void
37@@ -494,7 +496,6 @@ main(int argc, char *argv[])
38 case '-':
39 if (strcasecmp(optarg, "help") == 0) {
40 usage(argv[0]);
41- goto out;
42 }
43 if (strcasecmp(optarg, "version") == 0) {
44 version();
45@@ -783,7 +784,6 @@ main(int argc, char *argv[])
46 fprintf(stderr, "%s: Illegal argument -X:"
47 "AgentX support not compiled in.\n", argv[0]);
48 usage(argv[0]);
49- goto out;
50 #endif
51 break;
52
53--
542.25.1
55