summaryrefslogtreecommitdiff
path: root/servconf.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2015-04-23 04:59:10 +0000
committerDamien Miller <djm@mindrot.org>2015-04-29 18:14:36 +1000
commit1108ae242fdd2c304307b68ddf46aebe43ebffaa (patch)
tree4238cf5cfe27bd8a7158befffd0c53b250b09c2a /servconf.c
parentbd902b8473e1168f19378d5d0ae68d0c203525df (diff)
upstream commit
Two small fixes for sshd -T: ListenAddress'es are added to a list head so reverse the order when printing them to ensure the behaviour remains the same, and print StreamLocalBindMask as octal with leading zero. ok deraadt@
Diffstat (limited to 'servconf.c')
-rw-r--r--servconf.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/servconf.c b/servconf.c
index 3014361ea..fb1d024ef 100644
--- a/servconf.c
+++ b/servconf.c
@@ -1,5 +1,5 @@
1 1
2/* $OpenBSD: servconf.c,v 1.262 2015/04/23 04:53:53 dtucker Exp $ */ 2/* $OpenBSD: servconf.c,v 1.263 2015/04/23 04:59:10 dtucker 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
@@ -2028,6 +2028,12 @@ dump_cfg_int(ServerOpCodes code, int val)
2028} 2028}
2029 2029
2030static void 2030static void
2031dump_cfg_oct(ServerOpCodes code, int val)
2032{
2033 printf("%s 0%o\n", lookup_opcode_name(code), val);
2034}
2035
2036static void
2031dump_cfg_fmtint(ServerOpCodes code, int val) 2037dump_cfg_fmtint(ServerOpCodes code, int val)
2032{ 2038{
2033 printf("%s %s\n", lookup_opcode_name(code), fmt_intarg(code, val)); 2039 printf("%s %s\n", lookup_opcode_name(code), fmt_intarg(code, val));
@@ -2071,6 +2077,7 @@ dump_config(ServerOptions *o)
2071 int ret; 2077 int ret;
2072 struct addrinfo *ai; 2078 struct addrinfo *ai;
2073 char addr[NI_MAXHOST], port[NI_MAXSERV], *s = NULL; 2079 char addr[NI_MAXHOST], port[NI_MAXSERV], *s = NULL;
2080 char *laddr1 = xstrdup(""), *laddr2 = NULL;
2074 2081
2075 /* these are usually at the top of the config */ 2082 /* these are usually at the top of the config */
2076 for (i = 0; i < o->num_ports; i++) 2083 for (i = 0; i < o->num_ports; i++)
@@ -2078,7 +2085,11 @@ dump_config(ServerOptions *o)
2078 dump_cfg_fmtint(sProtocol, o->protocol); 2085 dump_cfg_fmtint(sProtocol, o->protocol);
2079 dump_cfg_fmtint(sAddressFamily, o->address_family); 2086 dump_cfg_fmtint(sAddressFamily, o->address_family);
2080 2087
2081 /* ListenAddress must be after Port */ 2088 /*
2089 * ListenAddress must be after Port. add_one_listen_addr pushes
2090 * addresses onto a stack, so to maintain ordering we need to
2091 * print these in reverse order.
2092 */
2082 for (ai = o->listen_addrs; ai; ai = ai->ai_next) { 2093 for (ai = o->listen_addrs; ai; ai = ai->ai_next) {
2083 if ((ret = getnameinfo(ai->ai_addr, ai->ai_addrlen, addr, 2094 if ((ret = getnameinfo(ai->ai_addr, ai->ai_addrlen, addr,
2084 sizeof(addr), port, sizeof(port), 2095 sizeof(addr), port, sizeof(port),
@@ -2087,12 +2098,18 @@ dump_config(ServerOptions *o)
2087 (ret != EAI_SYSTEM) ? gai_strerror(ret) : 2098 (ret != EAI_SYSTEM) ? gai_strerror(ret) :
2088 strerror(errno)); 2099 strerror(errno));
2089 } else { 2100 } else {
2101 laddr2 = laddr1;
2090 if (ai->ai_family == AF_INET6) 2102 if (ai->ai_family == AF_INET6)
2091 printf("listenaddress [%s]:%s\n", addr, port); 2103 xasprintf(&laddr1, "listenaddress [%s]:%s\n%s",
2104 addr, port, laddr2);
2092 else 2105 else
2093 printf("listenaddress %s:%s\n", addr, port); 2106 xasprintf(&laddr1, "listenaddress %s:%s\n%s",
2107 addr, port, laddr2);
2108 free(laddr2);
2094 } 2109 }
2095 } 2110 }
2111 printf("%s", laddr1);
2112 free(laddr1);
2096 2113
2097 /* integer arguments */ 2114 /* integer arguments */
2098#ifdef USE_PAM 2115#ifdef USE_PAM
@@ -2106,7 +2123,7 @@ dump_config(ServerOptions *o)
2106 dump_cfg_int(sMaxSessions, o->max_sessions); 2123 dump_cfg_int(sMaxSessions, o->max_sessions);
2107 dump_cfg_int(sClientAliveInterval, o->client_alive_interval); 2124 dump_cfg_int(sClientAliveInterval, o->client_alive_interval);
2108 dump_cfg_int(sClientAliveCountMax, o->client_alive_count_max); 2125 dump_cfg_int(sClientAliveCountMax, o->client_alive_count_max);
2109 dump_cfg_int(sStreamLocalBindMask, o->fwd_opts.streamlocal_bind_mask); 2126 dump_cfg_oct(sStreamLocalBindMask, o->fwd_opts.streamlocal_bind_mask);
2110 2127
2111 /* formatted integer arguments */ 2128 /* formatted integer arguments */
2112 dump_cfg_fmtint(sPermitRootLogin, o->permit_root_login); 2129 dump_cfg_fmtint(sPermitRootLogin, o->permit_root_login);