William A. Kennington III | 49e9566 | 2021-09-15 16:19:36 -0700 | [diff] [blame] | 1 | From 94ca941e06bef157bf0e13251f8ca1471daa9393 Mon Sep 17 00:00:00 2001 |
| 2 | From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> |
| 3 | Date: Fri, 27 Aug 2021 14:21:45 +0300 |
| 4 | Subject: [PATCH] snmpd: always exit after displaying usage |
| 5 | |
| 6 | Currently, viewing the help text with -h results in snmpd being started |
| 7 | in the background, whereas this does not happen with --help. Similarly, |
| 8 | when an error is detected in command line syntax, the help text is |
| 9 | displayed but sometimes snmpd gets started anyway, depending on the |
| 10 | execution path. |
| 11 | |
| 12 | This patch makes snmpd consistently terminate whenever the usage |
| 13 | function gets called. It also removes the goto statements no longer |
| 14 | needed. |
| 15 | |
| 16 | Upstream-Status: Backport |
| 17 | [https://github.com/net-snmp/net-snmp/commit/94ca941e06bef157bf0e13251f8ca1471daa9393] |
| 18 | |
| 19 | Signed-off-by: Yi Zhao <yi.zhao@windriver.com> |
| 20 | --- |
| 21 | agent/snmpd.c | 4 ++-- |
| 22 | 1 file changed, 2 insertions(+), 2 deletions(-) |
| 23 | |
| 24 | diff --git a/agent/snmpd.c b/agent/snmpd.c |
| 25 | index 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 | -- |
| 54 | 2.25.1 |
| 55 | |