summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2017-11-03 05:18:45 +0000
committerDamien Miller <djm@cvs.openbsd.org>2017-11-03 05:18:45 +0000
commitb94ca35410fe4cc78f783d877ddf7ab22526a8ca (patch)
tree39af1e16a328413183d4738645f88441739b5041 /usr.bin
parentdc30e5d1af8bfc09b56bf532d375f462260839bc (diff)
reuse parse_multistate for parse_flag (yes/no arguments). Saves
a few lines of code and makes the parser more consistent wrt case- sensitivity. bz#2664 ok dtucker@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/servconf.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/usr.bin/ssh/servconf.c b/usr.bin/ssh/servconf.c
index 7c3b74c8b6f..d7fd2d9bf99 100644
--- a/usr.bin/ssh/servconf.c
+++ b/usr.bin/ssh/servconf.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: servconf.c,v 1.319 2017/11/03 03:18:53 dtucker Exp $ */
+/* $OpenBSD: servconf.c,v 1.320 2017/11/03 05:18:44 djm Exp $ */
/*
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
@@ -1041,6 +1041,11 @@ struct multistate {
char *key;
int value;
};
+static const struct multistate multistate_flag[] = {
+ { "yes", 1 },
+ { "no", 0 },
+ { NULL, -1 }
+};
static const struct multistate multistate_addressfamily[] = {
{ "inet", AF_INET },
{ "inet6", AF_INET6 },
@@ -1275,21 +1280,8 @@ process_server_config_line(ServerOptions *options, char *line,
case sIgnoreRhosts:
intptr = &options->ignore_rhosts;
parse_flag:
- arg = strdelim(&cp);
- if (!arg || *arg == '\0')
- fatal("%s line %d: missing yes/no argument.",
- filename, linenum);
- value = 0; /* silence compiler */
- if (strcmp(arg, "yes") == 0)
- value = 1;
- else if (strcmp(arg, "no") == 0)
- value = 0;
- else
- fatal("%s line %d: Bad yes/no argument: %s",
- filename, linenum, arg);
- if (*activep && *intptr == -1)
- *intptr = value;
- break;
+ multistate_ptr = multistate_flag;
+ goto parse_multistate;
case sIgnoreUserKnownHosts:
intptr = &options->ignore_user_known_hosts;