summaryrefslogtreecommitdiff
path: root/servconf.c
diff options
context:
space:
mode:
authordjm@openbsd.org@openbsd.org <djm@openbsd.org@openbsd.org>2017-11-03 05:18:44 +0000
committerDamien Miller <djm@mindrot.org>2017-11-03 16:20:41 +1100
commit33edb6ebdc2f81ebed1bceadacdfb8910b64fb88 (patch)
tree86d681439a57d23c0f92184200cacfd2c508d969 /servconf.c
parentd52131a98316e76c0caa348f09bf6f7b9b01a1b9 (diff)
upstream commit
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@ OpenBSD-Commit-ID: b2ad1b6086858d5db71c7b11e5a74dba6d60efef
Diffstat (limited to 'servconf.c')
-rw-r--r--servconf.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/servconf.c b/servconf.c
index 44de35367..ccb257843 100644
--- a/servconf.c
+++ b/servconf.c
@@ -1,5 +1,5 @@
1 1
2/* $OpenBSD: servconf.c,v 1.319 2017/11/03 03:18:53 dtucker Exp $ */ 2/* $OpenBSD: servconf.c,v 1.320 2017/11/03 05:18:44 djm Exp $ */
3/* 3/*
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 * All rights reserved 5 * All rights reserved
@@ -1098,6 +1098,11 @@ struct multistate {
1098 char *key; 1098 char *key;
1099 int value; 1099 int value;
1100}; 1100};
1101static const struct multistate multistate_flag[] = {
1102 { "yes", 1 },
1103 { "no", 0 },
1104 { NULL, -1 }
1105};
1101static const struct multistate multistate_addressfamily[] = { 1106static const struct multistate multistate_addressfamily[] = {
1102 { "inet", AF_INET }, 1107 { "inet", AF_INET },
1103 { "inet6", AF_INET6 }, 1108 { "inet6", AF_INET6 },
@@ -1338,21 +1343,8 @@ process_server_config_line(ServerOptions *options, char *line,
1338 case sIgnoreRhosts: 1343 case sIgnoreRhosts:
1339 intptr = &options->ignore_rhosts; 1344 intptr = &options->ignore_rhosts;
1340 parse_flag: 1345 parse_flag:
1341 arg = strdelim(&cp); 1346 multistate_ptr = multistate_flag;
1342 if (!arg || *arg == '\0') 1347 goto parse_multistate;
1343 fatal("%s line %d: missing yes/no argument.",
1344 filename, linenum);
1345 value = 0; /* silence compiler */
1346 if (strcmp(arg, "yes") == 0)
1347 value = 1;
1348 else if (strcmp(arg, "no") == 0)
1349 value = 0;
1350 else
1351 fatal("%s line %d: Bad yes/no argument: %s",
1352 filename, linenum, arg);
1353 if (*activep && *intptr == -1)
1354 *intptr = value;
1355 break;
1356 1348
1357 case sIgnoreUserKnownHosts: 1349 case sIgnoreUserKnownHosts:
1358 intptr = &options->ignore_user_known_hosts; 1350 intptr = &options->ignore_user_known_hosts;