diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2011-06-22 21:47:29 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2011-06-22 21:47:29 +0000 |
commit | dba0caec152609e89254d23c36072ef4d714b633 (patch) | |
tree | a40c178870f988ba6393757a1f24a3e315dd607a /usr.bin | |
parent | 665d791bfb080da28f724b96240b6ab50edd208b (diff) |
reuse the multistate option arrays to pretty-print options for "sshd -T"
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/servconf.c | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/usr.bin/ssh/servconf.c b/usr.bin/ssh/servconf.c index ddb11961e34..eaa127f86aa 100644 --- a/usr.bin/ssh/servconf.c +++ b/usr.bin/ssh/servconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: servconf.c,v 1.220 2011/06/17 21:47:35 djm Exp $ */ +/* $OpenBSD: servconf.c,v 1.221 2011/06/22 21:47:28 djm Exp $ */ /* * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * All rights reserved @@ -1504,31 +1504,32 @@ parse_server_config(ServerOptions *options, const char *filename, Buffer *conf, } static const char * -fmt_intarg(ServerOpCodes code, int val) +fmt_multistate_int(int val, const struct multistate *m) { - if (code == sAddressFamily) { - switch (val) { - case AF_INET: - return "inet"; - case AF_INET6: - return "inet6"; - case AF_UNSPEC: - return "any"; - default: - return "UNKNOWN"; - } - } - if (code == sPermitRootLogin) { - switch (val) { - case PERMIT_NO_PASSWD: - return "without-password"; - case PERMIT_FORCED_ONLY: - return "forced-commands-only"; - case PERMIT_YES: - return "yes"; - } + u_int i; + + for (i = 0; m[i].key != NULL; i++) { + if (m[i].value == val) + return m[i].key; } - if (code == sProtocol) { + return "UNKNOWN"; +} + +static const char * +fmt_intarg(ServerOpCodes code, int val) +{ + if (val == -1) + return "unset"; + switch (code) { + case sAddressFamily: + return fmt_multistate_int(val, multistate_addressfamily); + case sPermitRootLogin: + return fmt_multistate_int(val, multistate_permitrootlogin); + case sGatewayPorts: + return fmt_multistate_int(val, multistate_gatewayports); + case sCompression: + return fmt_multistate_int(val, multistate_compression); + case sProtocol: switch (val) { case SSH_PROTO_1: return "1"; @@ -1539,20 +1540,16 @@ fmt_intarg(ServerOpCodes code, int val) default: return "UNKNOWN"; } + default: + switch (val) { + case 0: + return "no"; + case 1: + return "yes"; + default: + return "UNKNOWN"; + } } - if (code == sGatewayPorts && val == 2) - return "clientspecified"; - if (code == sCompression && val == COMP_DELAYED) - return "delayed"; - switch (val) { - case -1: - return "unset"; - case 0: - return "no"; - case 1: - return "yes"; - } - return "UNKNOWN"; } static const char * |