Annotation of src/usr.bin/ssh/servconf.c, Revision 1.199
1.199 ! stevesk 1: /* $OpenBSD: servconf.c,v 1.198 2009/12/25 19:40:21 stevesk Exp $ */
1.1 deraadt 2: /*
1.26 deraadt 3: * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4: * All rights reserved
1.34 markus 5: *
1.51 deraadt 6: * As far as I am concerned, the code I have written for this software
7: * can be used freely for any purpose. Any derived versions of this
8: * software must be clearly marked as such, and if the derived work is
9: * incompatible with the protocol description in the RFC file, it must be
10: * called by a name other than "ssh" or "Secure Shell".
1.26 deraadt 11: */
1.1 deraadt 12:
1.152 stevesk 13: #include <sys/types.h>
14: #include <sys/socket.h>
1.179 djm 15: #include <sys/queue.h>
1.154 stevesk 16:
17: #include <netdb.h>
1.165 dtucker 18: #include <pwd.h>
1.162 stevesk 19: #include <stdio.h>
1.161 stevesk 20: #include <stdlib.h>
1.160 stevesk 21: #include <string.h>
1.164 deraadt 22: #include <signal.h>
1.155 stevesk 23: #include <unistd.h>
1.164 deraadt 24: #include <stdarg.h>
1.182 dtucker 25: #include <errno.h>
1.1 deraadt 26:
1.164 deraadt 27: #include "xmalloc.h"
1.1 deraadt 28: #include "ssh.h"
1.62 markus 29: #include "log.h"
1.164 deraadt 30: #include "buffer.h"
1.1 deraadt 31: #include "servconf.h"
1.33 markus 32: #include "compat.h"
1.60 markus 33: #include "pathnames.h"
1.62 markus 34: #include "misc.h"
35: #include "cipher.h"
1.164 deraadt 36: #include "key.h"
1.66 markus 37: #include "kex.h"
38: #include "mac.h"
1.153 dtucker 39: #include "match.h"
1.156 dtucker 40: #include "channels.h"
1.165 dtucker 41: #include "groupaccess.h"
1.1 deraadt 42:
1.194 djm 43: static void add_listen_addr(ServerOptions *, char *, int);
44: static void add_one_listen_addr(ServerOptions *, char *, int);
1.29 markus 45:
1.102 provos 46: /* Use of privilege separation or not */
47: extern int use_privsep;
1.153 dtucker 48: extern Buffer cfg;
1.62 markus 49:
1.1 deraadt 50: /* Initializes the server options to their default values. */
51:
1.34 markus 52: void
1.25 markus 53: initialize_server_options(ServerOptions *options)
1.1 deraadt 54: {
1.25 markus 55: memset(options, 0, sizeof(*options));
1.29 markus 56: options->num_ports = 0;
57: options->ports_from_cmdline = 0;
58: options->listen_addrs = NULL;
1.138 djm 59: options->address_family = -1;
1.54 markus 60: options->num_host_key_files = 0;
1.36 markus 61: options->pid_file = NULL;
1.25 markus 62: options->server_key_bits = -1;
63: options->login_grace_time = -1;
64: options->key_regeneration_time = -1;
1.67 markus 65: options->permit_root_login = PERMIT_NOT_SET;
1.25 markus 66: options->ignore_rhosts = -1;
67: options->ignore_user_known_hosts = -1;
68: options->print_motd = -1;
1.72 stevesk 69: options->print_lastlog = -1;
1.25 markus 70: options->x11_forwarding = -1;
71: options->x11_display_offset = -1;
1.99 stevesk 72: options->x11_use_localhost = -1;
1.42 markus 73: options->xauth_location = NULL;
1.25 markus 74: options->strict_modes = -1;
1.129 markus 75: options->tcp_keep_alive = -1;
1.101 markus 76: options->log_facility = SYSLOG_FACILITY_NOT_SET;
77: options->log_level = SYSLOG_LEVEL_NOT_SET;
1.25 markus 78: options->rhosts_rsa_authentication = -1;
1.75 markus 79: options->hostbased_authentication = -1;
80: options->hostbased_uses_name_from_packet_only = -1;
1.25 markus 81: options->rsa_authentication = -1;
1.54 markus 82: options->pubkey_authentication = -1;
1.25 markus 83: options->kerberos_authentication = -1;
84: options->kerberos_or_local_passwd = -1;
85: options->kerberos_ticket_cleanup = -1;
1.130 jakob 86: options->kerberos_get_afs_token = -1;
1.125 markus 87: options->gss_authentication=-1;
88: options->gss_cleanup_creds = -1;
1.25 markus 89: options->password_authentication = -1;
1.52 markus 90: options->kbd_interactive_authentication = -1;
1.80 markus 91: options->challenge_response_authentication = -1;
1.25 markus 92: options->permit_empty_passwd = -1;
1.113 markus 93: options->permit_user_env = -1;
1.25 markus 94: options->use_login = -1;
1.111 markus 95: options->compression = -1;
1.53 markus 96: options->allow_tcp_forwarding = -1;
1.178 pyr 97: options->allow_agent_forwarding = -1;
1.25 markus 98: options->num_allow_users = 0;
99: options->num_deny_users = 0;
100: options->num_allow_groups = 0;
101: options->num_deny_groups = 0;
1.33 markus 102: options->ciphers = NULL;
1.66 markus 103: options->macs = NULL;
1.33 markus 104: options->protocol = SSH_PROTO_UNKNOWN;
1.38 markus 105: options->gateway_ports = -1;
1.43 jakob 106: options->num_subsystems = 0;
1.50 markus 107: options->max_startups_begin = -1;
108: options->max_startups_rate = -1;
1.46 markus 109: options->max_startups = -1;
1.133 dtucker 110: options->max_authtries = -1;
1.180 djm 111: options->max_sessions = -1;
1.57 markus 112: options->banner = NULL;
1.122 markus 113: options->use_dns = -1;
1.77 beck 114: options->client_alive_interval = -1;
115: options->client_alive_count_max = -1;
1.82 markus 116: options->authorized_keys_file = NULL;
117: options->authorized_keys_file2 = NULL;
1.131 djm 118: options->num_accept_env = 0;
1.145 reyk 119: options->permit_tun = -1;
1.159 dtucker 120: options->num_permitted_opens = -1;
1.158 dtucker 121: options->adm_forced_command = NULL;
1.176 djm 122: options->chroot_directory = NULL;
1.190 djm 123: options->zero_knowledge_password_authentication = -1;
1.197 reyk 124: options->rdomain = -1;
1.1 deraadt 125: }
126:
1.34 markus 127: void
1.25 markus 128: fill_default_server_options(ServerOptions *options)
1.1 deraadt 129: {
1.54 markus 130: if (options->protocol == SSH_PROTO_UNKNOWN)
1.196 markus 131: options->protocol = SSH_PROTO_2;
1.54 markus 132: if (options->num_host_key_files == 0) {
133: /* fill default hostkeys for protocols */
134: if (options->protocol & SSH_PROTO_1)
1.97 stevesk 135: options->host_key_files[options->num_host_key_files++] =
136: _PATH_HOST_KEY_FILE;
137: if (options->protocol & SSH_PROTO_2) {
138: options->host_key_files[options->num_host_key_files++] =
139: _PATH_HOST_RSA_KEY_FILE;
140: options->host_key_files[options->num_host_key_files++] =
141: _PATH_HOST_DSA_KEY_FILE;
142: }
1.54 markus 143: }
1.29 markus 144: if (options->num_ports == 0)
145: options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
146: if (options->listen_addrs == NULL)
1.76 stevesk 147: add_listen_addr(options, NULL, 0);
1.36 markus 148: if (options->pid_file == NULL)
1.60 markus 149: options->pid_file = _PATH_SSH_DAEMON_PID_FILE;
1.25 markus 150: if (options->server_key_bits == -1)
1.185 djm 151: options->server_key_bits = 1024;
1.25 markus 152: if (options->login_grace_time == -1)
1.115 stevesk 153: options->login_grace_time = 120;
1.25 markus 154: if (options->key_regeneration_time == -1)
155: options->key_regeneration_time = 3600;
1.67 markus 156: if (options->permit_root_login == PERMIT_NOT_SET)
157: options->permit_root_login = PERMIT_YES;
1.25 markus 158: if (options->ignore_rhosts == -1)
1.30 markus 159: options->ignore_rhosts = 1;
1.25 markus 160: if (options->ignore_user_known_hosts == -1)
161: options->ignore_user_known_hosts = 0;
162: if (options->print_motd == -1)
163: options->print_motd = 1;
1.72 stevesk 164: if (options->print_lastlog == -1)
165: options->print_lastlog = 1;
1.25 markus 166: if (options->x11_forwarding == -1)
1.30 markus 167: options->x11_forwarding = 0;
1.25 markus 168: if (options->x11_display_offset == -1)
1.30 markus 169: options->x11_display_offset = 10;
1.99 stevesk 170: if (options->x11_use_localhost == -1)
171: options->x11_use_localhost = 1;
1.42 markus 172: if (options->xauth_location == NULL)
1.83 markus 173: options->xauth_location = _PATH_XAUTH;
1.25 markus 174: if (options->strict_modes == -1)
175: options->strict_modes = 1;
1.129 markus 176: if (options->tcp_keep_alive == -1)
177: options->tcp_keep_alive = 1;
1.101 markus 178: if (options->log_facility == SYSLOG_FACILITY_NOT_SET)
1.25 markus 179: options->log_facility = SYSLOG_FACILITY_AUTH;
1.101 markus 180: if (options->log_level == SYSLOG_LEVEL_NOT_SET)
1.58 markus 181: options->log_level = SYSLOG_LEVEL_INFO;
1.25 markus 182: if (options->rhosts_rsa_authentication == -1)
1.30 markus 183: options->rhosts_rsa_authentication = 0;
1.75 markus 184: if (options->hostbased_authentication == -1)
185: options->hostbased_authentication = 0;
186: if (options->hostbased_uses_name_from_packet_only == -1)
187: options->hostbased_uses_name_from_packet_only = 0;
1.25 markus 188: if (options->rsa_authentication == -1)
189: options->rsa_authentication = 1;
1.54 markus 190: if (options->pubkey_authentication == -1)
191: options->pubkey_authentication = 1;
1.25 markus 192: if (options->kerberos_authentication == -1)
1.107 markus 193: options->kerberos_authentication = 0;
1.25 markus 194: if (options->kerberos_or_local_passwd == -1)
195: options->kerberos_or_local_passwd = 1;
196: if (options->kerberos_ticket_cleanup == -1)
197: options->kerberos_ticket_cleanup = 1;
1.130 jakob 198: if (options->kerberos_get_afs_token == -1)
199: options->kerberos_get_afs_token = 0;
1.125 markus 200: if (options->gss_authentication == -1)
201: options->gss_authentication = 0;
202: if (options->gss_cleanup_creds == -1)
203: options->gss_cleanup_creds = 1;
1.25 markus 204: if (options->password_authentication == -1)
205: options->password_authentication = 1;
1.52 markus 206: if (options->kbd_interactive_authentication == -1)
207: options->kbd_interactive_authentication = 0;
1.80 markus 208: if (options->challenge_response_authentication == -1)
209: options->challenge_response_authentication = 1;
1.25 markus 210: if (options->permit_empty_passwd == -1)
1.30 markus 211: options->permit_empty_passwd = 0;
1.113 markus 212: if (options->permit_user_env == -1)
213: options->permit_user_env = 0;
1.25 markus 214: if (options->use_login == -1)
215: options->use_login = 0;
1.111 markus 216: if (options->compression == -1)
1.143 markus 217: options->compression = COMP_DELAYED;
1.53 markus 218: if (options->allow_tcp_forwarding == -1)
219: options->allow_tcp_forwarding = 1;
1.178 pyr 220: if (options->allow_agent_forwarding == -1)
221: options->allow_agent_forwarding = 1;
1.38 markus 222: if (options->gateway_ports == -1)
223: options->gateway_ports = 0;
1.46 markus 224: if (options->max_startups == -1)
225: options->max_startups = 10;
1.50 markus 226: if (options->max_startups_rate == -1)
227: options->max_startups_rate = 100; /* 100% */
228: if (options->max_startups_begin == -1)
229: options->max_startups_begin = options->max_startups;
1.133 dtucker 230: if (options->max_authtries == -1)
231: options->max_authtries = DEFAULT_AUTH_FAIL_MAX;
1.180 djm 232: if (options->max_sessions == -1)
233: options->max_sessions = DEFAULT_SESSIONS_MAX;
1.122 markus 234: if (options->use_dns == -1)
235: options->use_dns = 1;
1.77 beck 236: if (options->client_alive_interval == -1)
1.95 deraadt 237: options->client_alive_interval = 0;
1.77 beck 238: if (options->client_alive_count_max == -1)
239: options->client_alive_count_max = 3;
1.90 markus 240: if (options->authorized_keys_file2 == NULL) {
241: /* authorized_keys_file2 falls back to authorized_keys_file */
242: if (options->authorized_keys_file != NULL)
243: options->authorized_keys_file2 = options->authorized_keys_file;
244: else
245: options->authorized_keys_file2 = _PATH_SSH_USER_PERMITTED_KEYS2;
246: }
247: if (options->authorized_keys_file == NULL)
248: options->authorized_keys_file = _PATH_SSH_USER_PERMITTED_KEYS;
1.145 reyk 249: if (options->permit_tun == -1)
1.146 reyk 250: options->permit_tun = SSH_TUNMODE_NO;
1.190 djm 251: if (options->zero_knowledge_password_authentication == -1)
252: options->zero_knowledge_password_authentication = 0;
1.102 provos 253:
1.110 markus 254: /* Turn privilege separation on by default */
1.102 provos 255: if (use_privsep == -1)
1.110 markus 256: use_privsep = 1;
1.1 deraadt 257: }
258:
259: /* Keyword tokens. */
1.25 markus 260: typedef enum {
261: sBadOption, /* == unknown option */
262: sPort, sHostKeyFile, sServerKeyBits, sLoginGraceTime, sKeyRegenerationTime,
263: sPermitRootLogin, sLogFacility, sLogLevel,
1.124 markus 264: sRhostsRSAAuthentication, sRSAAuthentication,
1.25 markus 265: sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup,
1.130 jakob 266: sKerberosGetAFSToken,
1.123 markus 267: sKerberosTgtPassing, sChallengeResponseAuthentication,
1.138 djm 268: sPasswordAuthentication, sKbdInteractiveAuthentication,
269: sListenAddress, sAddressFamily,
1.72 stevesk 270: sPrintMotd, sPrintLastLog, sIgnoreRhosts,
1.99 stevesk 271: sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost,
1.129 markus 272: sStrictModes, sEmptyPasswd, sTCPKeepAlive,
1.113 markus 273: sPermitUserEnvironment, sUseLogin, sAllowTcpForwarding, sCompression,
1.53 markus 274: sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
1.66 markus 275: sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile,
1.133 dtucker 276: sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem,
1.180 djm 277: sMaxStartups, sMaxAuthTries, sMaxSessions,
1.122 markus 278: sBanner, sUseDNS, sHostbasedAuthentication,
1.95 deraadt 279: sHostbasedUsesNameFromPacketOnly, sClientAliveInterval,
1.89 jakob 280: sClientAliveCountMax, sAuthorizedKeysFile, sAuthorizedKeysFile2,
1.145 reyk 281: sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel,
1.176 djm 282: sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
1.197 reyk 283: sUsePrivilegeSeparation, sAllowAgentForwarding, sRDomain,
1.190 djm 284: sZeroKnowledgePasswordAuthentication,
1.121 jakob 285: sDeprecated, sUnsupported
1.1 deraadt 286: } ServerOpCodes;
287:
1.153 dtucker 288: #define SSHCFG_GLOBAL 0x01 /* allowed in main section of sshd_config */
289: #define SSHCFG_MATCH 0x02 /* allowed inside a Match section */
290: #define SSHCFG_ALL (SSHCFG_GLOBAL|SSHCFG_MATCH)
291:
1.1 deraadt 292: /* Textual representation of the tokens. */
1.25 markus 293: static struct {
294: const char *name;
295: ServerOpCodes opcode;
1.153 dtucker 296: u_int flags;
1.25 markus 297: } keywords[] = {
1.153 dtucker 298: { "port", sPort, SSHCFG_GLOBAL },
299: { "hostkey", sHostKeyFile, SSHCFG_GLOBAL },
300: { "hostdsakey", sHostKeyFile, SSHCFG_GLOBAL }, /* alias */
301: { "pidfile", sPidFile, SSHCFG_GLOBAL },
302: { "serverkeybits", sServerKeyBits, SSHCFG_GLOBAL },
303: { "logingracetime", sLoginGraceTime, SSHCFG_GLOBAL },
304: { "keyregenerationinterval", sKeyRegenerationTime, SSHCFG_GLOBAL },
1.175 dtucker 305: { "permitrootlogin", sPermitRootLogin, SSHCFG_ALL },
1.153 dtucker 306: { "syslogfacility", sLogFacility, SSHCFG_GLOBAL },
307: { "loglevel", sLogLevel, SSHCFG_GLOBAL },
308: { "rhostsauthentication", sDeprecated, SSHCFG_GLOBAL },
1.168 dtucker 309: { "rhostsrsaauthentication", sRhostsRSAAuthentication, SSHCFG_ALL },
310: { "hostbasedauthentication", sHostbasedAuthentication, SSHCFG_ALL },
1.153 dtucker 311: { "hostbasedusesnamefrompacketonly", sHostbasedUsesNameFromPacketOnly, SSHCFG_GLOBAL },
1.168 dtucker 312: { "rsaauthentication", sRSAAuthentication, SSHCFG_ALL },
313: { "pubkeyauthentication", sPubkeyAuthentication, SSHCFG_ALL },
1.153 dtucker 314: { "dsaauthentication", sPubkeyAuthentication, SSHCFG_GLOBAL }, /* alias */
1.123 markus 315: #ifdef KRB5
1.168 dtucker 316: { "kerberosauthentication", sKerberosAuthentication, SSHCFG_ALL },
1.153 dtucker 317: { "kerberosorlocalpasswd", sKerberosOrLocalPasswd, SSHCFG_GLOBAL },
318: { "kerberosticketcleanup", sKerberosTicketCleanup, SSHCFG_GLOBAL },
319: { "kerberosgetafstoken", sKerberosGetAFSToken, SSHCFG_GLOBAL },
1.121 jakob 320: #else
1.168 dtucker 321: { "kerberosauthentication", sUnsupported, SSHCFG_ALL },
1.153 dtucker 322: { "kerberosorlocalpasswd", sUnsupported, SSHCFG_GLOBAL },
323: { "kerberosticketcleanup", sUnsupported, SSHCFG_GLOBAL },
324: { "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL },
1.126 markus 325: #endif
1.153 dtucker 326: { "kerberostgtpassing", sUnsupported, SSHCFG_GLOBAL },
327: { "afstokenpassing", sUnsupported, SSHCFG_GLOBAL },
1.125 markus 328: #ifdef GSSAPI
1.168 dtucker 329: { "gssapiauthentication", sGssAuthentication, SSHCFG_ALL },
1.153 dtucker 330: { "gssapicleanupcredentials", sGssCleanupCreds, SSHCFG_GLOBAL },
1.125 markus 331: #else
1.168 dtucker 332: { "gssapiauthentication", sUnsupported, SSHCFG_ALL },
1.153 dtucker 333: { "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
1.125 markus 334: #endif
1.168 dtucker 335: { "passwordauthentication", sPasswordAuthentication, SSHCFG_ALL },
336: { "kbdinteractiveauthentication", sKbdInteractiveAuthentication, SSHCFG_ALL },
1.170 dtucker 337: { "challengeresponseauthentication", sChallengeResponseAuthentication, SSHCFG_GLOBAL },
1.153 dtucker 338: { "skeyauthentication", sChallengeResponseAuthentication, SSHCFG_GLOBAL }, /* alias */
1.190 djm 339: #ifdef JPAKE
340: { "zeroknowledgepasswordauthentication", sZeroKnowledgePasswordAuthentication, SSHCFG_ALL },
341: #else
342: { "zeroknowledgepasswordauthentication", sUnsupported, SSHCFG_ALL },
343: #endif
1.153 dtucker 344: { "checkmail", sDeprecated, SSHCFG_GLOBAL },
345: { "listenaddress", sListenAddress, SSHCFG_GLOBAL },
346: { "addressfamily", sAddressFamily, SSHCFG_GLOBAL },
347: { "printmotd", sPrintMotd, SSHCFG_GLOBAL },
348: { "printlastlog", sPrintLastLog, SSHCFG_GLOBAL },
349: { "ignorerhosts", sIgnoreRhosts, SSHCFG_GLOBAL },
350: { "ignoreuserknownhosts", sIgnoreUserKnownHosts, SSHCFG_GLOBAL },
1.157 dtucker 351: { "x11forwarding", sX11Forwarding, SSHCFG_ALL },
352: { "x11displayoffset", sX11DisplayOffset, SSHCFG_ALL },
353: { "x11uselocalhost", sX11UseLocalhost, SSHCFG_ALL },
1.153 dtucker 354: { "xauthlocation", sXAuthLocation, SSHCFG_GLOBAL },
355: { "strictmodes", sStrictModes, SSHCFG_GLOBAL },
1.188 djm 356: { "permitemptypasswords", sEmptyPasswd, SSHCFG_ALL },
1.153 dtucker 357: { "permituserenvironment", sPermitUserEnvironment, SSHCFG_GLOBAL },
358: { "uselogin", sUseLogin, SSHCFG_GLOBAL },
359: { "compression", sCompression, SSHCFG_GLOBAL },
360: { "tcpkeepalive", sTCPKeepAlive, SSHCFG_GLOBAL },
361: { "keepalive", sTCPKeepAlive, SSHCFG_GLOBAL }, /* obsolete alias */
362: { "allowtcpforwarding", sAllowTcpForwarding, SSHCFG_ALL },
1.178 pyr 363: { "allowagentforwarding", sAllowAgentForwarding, SSHCFG_ALL },
1.153 dtucker 364: { "allowusers", sAllowUsers, SSHCFG_GLOBAL },
365: { "denyusers", sDenyUsers, SSHCFG_GLOBAL },
366: { "allowgroups", sAllowGroups, SSHCFG_GLOBAL },
367: { "denygroups", sDenyGroups, SSHCFG_GLOBAL },
368: { "ciphers", sCiphers, SSHCFG_GLOBAL },
369: { "macs", sMacs, SSHCFG_GLOBAL },
370: { "protocol", sProtocol, SSHCFG_GLOBAL },
371: { "gatewayports", sGatewayPorts, SSHCFG_ALL },
372: { "subsystem", sSubsystem, SSHCFG_GLOBAL },
373: { "maxstartups", sMaxStartups, SSHCFG_GLOBAL },
1.184 dtucker 374: { "maxauthtries", sMaxAuthTries, SSHCFG_ALL },
1.180 djm 375: { "maxsessions", sMaxSessions, SSHCFG_ALL },
1.168 dtucker 376: { "banner", sBanner, SSHCFG_ALL },
1.153 dtucker 377: { "usedns", sUseDNS, SSHCFG_GLOBAL },
378: { "verifyreversemapping", sDeprecated, SSHCFG_GLOBAL },
379: { "reversemappingcheck", sDeprecated, SSHCFG_GLOBAL },
380: { "clientaliveinterval", sClientAliveInterval, SSHCFG_GLOBAL },
381: { "clientalivecountmax", sClientAliveCountMax, SSHCFG_GLOBAL },
382: { "authorizedkeysfile", sAuthorizedKeysFile, SSHCFG_GLOBAL },
383: { "authorizedkeysfile2", sAuthorizedKeysFile2, SSHCFG_GLOBAL },
384: { "useprivilegeseparation", sUsePrivilegeSeparation, SSHCFG_GLOBAL},
385: { "acceptenv", sAcceptEnv, SSHCFG_GLOBAL },
386: { "permittunnel", sPermitTunnel, SSHCFG_GLOBAL },
387: { "match", sMatch, SSHCFG_ALL },
1.156 dtucker 388: { "permitopen", sPermitOpen, SSHCFG_ALL },
1.158 dtucker 389: { "forcecommand", sForceCommand, SSHCFG_ALL },
1.199 ! stevesk 390: { "routingdomain", sRDomain, SSHCFG_GLOBAL },
1.176 djm 391: { "chrootdirectory", sChrootDirectory, SSHCFG_ALL },
1.153 dtucker 392: { NULL, sBadOption, 0 }
1.1 deraadt 393: };
394:
1.182 dtucker 395: static struct {
396: int val;
397: char *text;
398: } tunmode_desc[] = {
399: { SSH_TUNMODE_NO, "no" },
400: { SSH_TUNMODE_POINTOPOINT, "point-to-point" },
401: { SSH_TUNMODE_ETHERNET, "ethernet" },
402: { SSH_TUNMODE_YES, "yes" },
403: { -1, NULL }
404: };
405:
1.27 markus 406: /*
1.73 stevesk 407: * Returns the number of the token pointed to by cp or sBadOption.
1.27 markus 408: */
1.1 deraadt 409:
1.34 markus 410: static ServerOpCodes
1.25 markus 411: parse_token(const char *cp, const char *filename,
1.153 dtucker 412: int linenum, u_int *flags)
1.1 deraadt 413: {
1.55 markus 414: u_int i;
1.1 deraadt 415:
1.25 markus 416: for (i = 0; keywords[i].name; i++)
1.153 dtucker 417: if (strcasecmp(cp, keywords[i].name) == 0) {
418: *flags = keywords[i].flags;
1.25 markus 419: return keywords[i].opcode;
1.153 dtucker 420: }
1.25 markus 421:
1.78 stevesk 422: error("%s: line %d: Bad configuration option: %s",
423: filename, linenum, cp);
1.25 markus 424: return sBadOption;
1.1 deraadt 425: }
426:
1.84 itojun 427: static void
1.194 djm 428: add_listen_addr(ServerOptions *options, char *addr, int port)
1.74 stevesk 429: {
1.142 djm 430: u_int i;
1.74 stevesk 431:
432: if (options->num_ports == 0)
433: options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
1.138 djm 434: if (options->address_family == -1)
435: options->address_family = AF_UNSPEC;
1.76 stevesk 436: if (port == 0)
1.74 stevesk 437: for (i = 0; i < options->num_ports; i++)
438: add_one_listen_addr(options, addr, options->ports[i]);
439: else
1.76 stevesk 440: add_one_listen_addr(options, addr, port);
1.74 stevesk 441: }
442:
1.84 itojun 443: static void
1.194 djm 444: add_one_listen_addr(ServerOptions *options, char *addr, int port)
1.29 markus 445: {
446: struct addrinfo hints, *ai, *aitop;
447: char strport[NI_MAXSERV];
448: int gaierr;
449:
1.74 stevesk 450: memset(&hints, 0, sizeof(hints));
1.138 djm 451: hints.ai_family = options->address_family;
1.74 stevesk 452: hints.ai_socktype = SOCK_STREAM;
453: hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0;
1.194 djm 454: snprintf(strport, sizeof strport, "%d", port);
1.74 stevesk 455: if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0)
456: fatal("bad addr or host: %s (%s)",
457: addr ? addr : "<NULL>",
1.173 dtucker 458: ssh_gai_strerror(gaierr));
1.74 stevesk 459: for (ai = aitop; ai->ai_next; ai = ai->ai_next)
460: ;
461: ai->ai_next = options->listen_addrs;
462: options->listen_addrs = aitop;
1.29 markus 463: }
464:
1.153 dtucker 465: /*
466: * The strategy for the Match blocks is that the config file is parsed twice.
467: *
468: * The first time is at startup. activep is initialized to 1 and the
469: * directives in the global context are processed and acted on. Hitting a
470: * Match directive unsets activep and the directives inside the block are
471: * checked for syntax only.
472: *
473: * The second time is after a connection has been established but before
474: * authentication. activep is initialized to 2 and global config directives
475: * are ignored since they have already been processed. If the criteria in a
476: * Match block is met, activep is set and the subsequent directives
477: * processed and actioned until EOF or another Match block unsets it. Any
478: * options set are copied into the main server config.
479: *
480: * Potential additions/improvements:
481: * - Add Match support for pre-kex directives, eg Protocol, Ciphers.
482: *
483: * - Add a Tag directive (idea from David Leonard) ala pf, eg:
484: * Match Address 192.168.0.*
485: * Tag trusted
486: * Match Group wheel
487: * Tag trusted
488: * Match Tag trusted
489: * AllowTcpForwarding yes
490: * GatewayPorts clientspecified
491: * [...]
492: *
493: * - Add a PermittedChannelRequests directive
494: * Match Group shell
495: * PermittedChannelRequests session,forwarded-tcpip
496: */
497:
498: static int
1.165 dtucker 499: match_cfg_line_group(const char *grps, int line, const char *user)
500: {
501: int result = 0;
502: struct passwd *pw;
503:
504: if (user == NULL)
505: goto out;
506:
507: if ((pw = getpwnam(user)) == NULL) {
508: debug("Can't match group at line %d because user %.100s does "
509: "not exist", line, user);
510: } else if (ga_init(pw->pw_name, pw->pw_gid) == 0) {
511: debug("Can't Match group because user %.100s not in any group "
512: "at line %d", user, line);
1.186 djm 513: } else if (ga_match_pattern_list(grps) != 1) {
514: debug("user %.100s does not match group list %.100s at line %d",
515: user, grps, line);
1.165 dtucker 516: } else {
1.186 djm 517: debug("user %.100s matched group list %.100s at line %d", user,
518: grps, line);
1.165 dtucker 519: result = 1;
520: }
521: out:
522: ga_free();
523: return result;
524: }
525:
526: static int
1.153 dtucker 527: match_cfg_line(char **condition, int line, const char *user, const char *host,
528: const char *address)
529: {
530: int result = 1;
531: char *arg, *attrib, *cp = *condition;
532: size_t len;
533:
534: if (user == NULL)
535: debug3("checking syntax for 'Match %s'", cp);
536: else
537: debug3("checking match for '%s' user %s host %s addr %s", cp,
538: user ? user : "(null)", host ? host : "(null)",
539: address ? address : "(null)");
540:
541: while ((attrib = strdelim(&cp)) && *attrib != '\0') {
542: if ((arg = strdelim(&cp)) == NULL || *arg == '\0') {
543: error("Missing Match criteria for %s", attrib);
544: return -1;
545: }
546: len = strlen(arg);
547: if (strcasecmp(attrib, "user") == 0) {
548: if (!user) {
549: result = 0;
550: continue;
551: }
552: if (match_pattern_list(user, arg, len, 0) != 1)
553: result = 0;
554: else
555: debug("user %.100s matched 'User %.100s' at "
556: "line %d", user, arg, line);
1.165 dtucker 557: } else if (strcasecmp(attrib, "group") == 0) {
558: switch (match_cfg_line_group(arg, line, user)) {
559: case -1:
560: return -1;
561: case 0:
562: result = 0;
563: }
1.153 dtucker 564: } else if (strcasecmp(attrib, "host") == 0) {
565: if (!host) {
566: result = 0;
567: continue;
568: }
569: if (match_hostname(host, arg, len) != 1)
570: result = 0;
571: else
572: debug("connection from %.100s matched 'Host "
573: "%.100s' at line %d", host, arg, line);
574: } else if (strcasecmp(attrib, "address") == 0) {
1.181 djm 575: switch (addr_match_list(address, arg)) {
576: case 1:
577: debug("connection from %.100s matched 'Address "
578: "%.100s' at line %d", address, arg, line);
579: break;
580: case 0:
1.183 djm 581: case -1:
1.153 dtucker 582: result = 0;
1.181 djm 583: break;
1.183 djm 584: case -2:
1.181 djm 585: return -1;
1.153 dtucker 586: }
587: } else {
588: error("Unsupported Match attribute %s", attrib);
589: return -1;
590: }
591: }
592: if (user != NULL)
593: debug3("match %sfound", result ? "" : "not ");
594: *condition = cp;
595: return result;
596: }
597:
1.158 dtucker 598: #define WHITESPACE " \t\r\n"
599:
1.94 markus 600: int
601: process_server_config_line(ServerOptions *options, char *line,
1.153 dtucker 602: const char *filename, int linenum, int *activep, const char *user,
603: const char *host, const char *address)
1.1 deraadt 604: {
1.74 stevesk 605: char *cp, **charptr, *arg, *p;
1.153 dtucker 606: int cmdline = 0, *intptr, value, n;
1.174 dtucker 607: SyslogFacility *log_facility_ptr;
608: LogLevel *log_level_ptr;
1.25 markus 609: ServerOpCodes opcode;
1.194 djm 610: int port;
1.153 dtucker 611: u_int i, flags = 0;
1.151 djm 612: size_t len;
1.25 markus 613:
1.94 markus 614: cp = line;
1.148 dtucker 615: if ((arg = strdelim(&cp)) == NULL)
1.147 djm 616: return 0;
1.94 markus 617: /* Ignore leading whitespace */
618: if (*arg == '\0')
619: arg = strdelim(&cp);
620: if (!arg || !*arg || *arg == '#')
621: return 0;
622: intptr = NULL;
623: charptr = NULL;
1.153 dtucker 624: opcode = parse_token(arg, filename, linenum, &flags);
625:
626: if (activep == NULL) { /* We are processing a command line directive */
627: cmdline = 1;
628: activep = &cmdline;
629: }
630: if (*activep && opcode != sMatch)
631: debug3("%s:%d setting %s %s", filename, linenum, arg, cp);
632: if (*activep == 0 && !(flags & SSHCFG_MATCH)) {
633: if (user == NULL) {
634: fatal("%s line %d: Directive '%s' is not allowed "
635: "within a Match block", filename, linenum, arg);
636: } else { /* this is a directive we have already processed */
637: while (arg)
638: arg = strdelim(&cp);
639: return 0;
640: }
641: }
642:
1.94 markus 643: switch (opcode) {
644: case sBadOption:
645: return -1;
646: case sPort:
647: /* ignore ports from configfile if cmdline specifies ports */
648: if (options->ports_from_cmdline)
649: return 0;
650: if (options->listen_addrs != NULL)
651: fatal("%s line %d: ports must be specified before "
1.98 stevesk 652: "ListenAddress.", filename, linenum);
1.94 markus 653: if (options->num_ports >= MAX_PORTS)
654: fatal("%s line %d: too many ports.",
655: filename, linenum);
1.48 provos 656: arg = strdelim(&cp);
1.94 markus 657: if (!arg || *arg == '\0')
658: fatal("%s line %d: missing port number.",
659: filename, linenum);
660: options->ports[options->num_ports++] = a2port(arg);
1.194 djm 661: if (options->ports[options->num_ports-1] <= 0)
1.94 markus 662: fatal("%s line %d: Badly formatted port number.",
663: filename, linenum);
664: break;
1.29 markus 665:
1.94 markus 666: case sServerKeyBits:
667: intptr = &options->server_key_bits;
1.180 djm 668: parse_int:
1.94 markus 669: arg = strdelim(&cp);
670: if (!arg || *arg == '\0')
671: fatal("%s line %d: missing integer value.",
672: filename, linenum);
673: value = atoi(arg);
1.153 dtucker 674: if (*activep && *intptr == -1)
1.94 markus 675: *intptr = value;
676: break;
1.25 markus 677:
1.94 markus 678: case sLoginGraceTime:
679: intptr = &options->login_grace_time;
1.180 djm 680: parse_time:
1.94 markus 681: arg = strdelim(&cp);
682: if (!arg || *arg == '\0')
683: fatal("%s line %d: missing time value.",
684: filename, linenum);
685: if ((value = convtime(arg)) == -1)
686: fatal("%s line %d: invalid time value.",
687: filename, linenum);
688: if (*intptr == -1)
689: *intptr = value;
690: break;
691:
692: case sKeyRegenerationTime:
693: intptr = &options->key_regeneration_time;
694: goto parse_time;
695:
696: case sListenAddress:
697: arg = strdelim(&cp);
1.139 djm 698: if (arg == NULL || *arg == '\0')
699: fatal("%s line %d: missing address",
1.94 markus 700: filename, linenum);
1.144 dtucker 701: /* check for bare IPv6 address: no "[]" and 2 or more ":" */
702: if (strchr(arg, '[') == NULL && (p = strchr(arg, ':')) != NULL
703: && strchr(p+1, ':') != NULL) {
704: add_listen_addr(options, arg, 0);
705: break;
706: }
1.139 djm 707: p = hpdelim(&arg);
708: if (p == NULL)
709: fatal("%s line %d: bad address:port usage",
710: filename, linenum);
711: p = cleanhostname(p);
712: if (arg == NULL)
713: port = 0;
1.194 djm 714: else if ((port = a2port(arg)) <= 0)
1.139 djm 715: fatal("%s line %d: bad port number", filename, linenum);
716:
717: add_listen_addr(options, p, port);
1.25 markus 718:
1.138 djm 719: break;
720:
721: case sAddressFamily:
722: arg = strdelim(&cp);
1.141 markus 723: if (!arg || *arg == '\0')
724: fatal("%s line %d: missing address family.",
725: filename, linenum);
1.138 djm 726: intptr = &options->address_family;
727: if (options->listen_addrs != NULL)
728: fatal("%s line %d: address family must be specified before "
729: "ListenAddress.", filename, linenum);
730: if (strcasecmp(arg, "inet") == 0)
731: value = AF_INET;
732: else if (strcasecmp(arg, "inet6") == 0)
733: value = AF_INET6;
734: else if (strcasecmp(arg, "any") == 0)
735: value = AF_UNSPEC;
736: else
737: fatal("%s line %d: unsupported address family \"%s\".",
738: filename, linenum, arg);
739: if (*intptr == -1)
740: *intptr = value;
1.94 markus 741: break;
742:
743: case sHostKeyFile:
744: intptr = &options->num_host_key_files;
745: if (*intptr >= MAX_HOSTKEYS)
746: fatal("%s line %d: too many host keys specified (max %d).",
747: filename, linenum, MAX_HOSTKEYS);
748: charptr = &options->host_key_files[*intptr];
1.180 djm 749: parse_filename:
1.94 markus 750: arg = strdelim(&cp);
751: if (!arg || *arg == '\0')
752: fatal("%s line %d: missing file name.",
753: filename, linenum);
1.153 dtucker 754: if (*activep && *charptr == NULL) {
1.94 markus 755: *charptr = tilde_expand_filename(arg, getuid());
756: /* increase optional counter */
757: if (intptr != NULL)
758: *intptr = *intptr + 1;
759: }
760: break;
1.76 stevesk 761:
1.94 markus 762: case sPidFile:
763: charptr = &options->pid_file;
764: goto parse_filename;
1.25 markus 765:
1.94 markus 766: case sPermitRootLogin:
767: intptr = &options->permit_root_login;
768: arg = strdelim(&cp);
769: if (!arg || *arg == '\0')
770: fatal("%s line %d: missing yes/"
771: "without-password/forced-commands-only/no "
772: "argument.", filename, linenum);
773: value = 0; /* silence compiler */
774: if (strcmp(arg, "without-password") == 0)
775: value = PERMIT_NO_PASSWD;
776: else if (strcmp(arg, "forced-commands-only") == 0)
777: value = PERMIT_FORCED_ONLY;
778: else if (strcmp(arg, "yes") == 0)
779: value = PERMIT_YES;
780: else if (strcmp(arg, "no") == 0)
781: value = PERMIT_NO;
782: else
783: fatal("%s line %d: Bad yes/"
784: "without-password/forced-commands-only/no "
785: "argument: %s", filename, linenum, arg);
1.175 dtucker 786: if (*activep && *intptr == -1)
1.94 markus 787: *intptr = value;
788: break;
1.36 markus 789:
1.94 markus 790: case sIgnoreRhosts:
791: intptr = &options->ignore_rhosts;
1.180 djm 792: parse_flag:
1.94 markus 793: arg = strdelim(&cp);
794: if (!arg || *arg == '\0')
795: fatal("%s line %d: missing yes/no argument.",
796: filename, linenum);
797: value = 0; /* silence compiler */
798: if (strcmp(arg, "yes") == 0)
799: value = 1;
800: else if (strcmp(arg, "no") == 0)
801: value = 0;
802: else
803: fatal("%s line %d: Bad yes/no argument: %s",
804: filename, linenum, arg);
1.153 dtucker 805: if (*activep && *intptr == -1)
1.94 markus 806: *intptr = value;
807: break;
808:
809: case sIgnoreUserKnownHosts:
810: intptr = &options->ignore_user_known_hosts;
811: goto parse_flag;
812:
813: case sRhostsRSAAuthentication:
814: intptr = &options->rhosts_rsa_authentication;
815: goto parse_flag;
816:
817: case sHostbasedAuthentication:
818: intptr = &options->hostbased_authentication;
819: goto parse_flag;
820:
821: case sHostbasedUsesNameFromPacketOnly:
822: intptr = &options->hostbased_uses_name_from_packet_only;
823: goto parse_flag;
824:
825: case sRSAAuthentication:
826: intptr = &options->rsa_authentication;
827: goto parse_flag;
828:
829: case sPubkeyAuthentication:
830: intptr = &options->pubkey_authentication;
831: goto parse_flag;
1.119 jakob 832:
1.94 markus 833: case sKerberosAuthentication:
834: intptr = &options->kerberos_authentication;
835: goto parse_flag;
836:
837: case sKerberosOrLocalPasswd:
838: intptr = &options->kerberos_or_local_passwd;
839: goto parse_flag;
840:
841: case sKerberosTicketCleanup:
842: intptr = &options->kerberos_ticket_cleanup;
1.130 jakob 843: goto parse_flag;
844:
845: case sKerberosGetAFSToken:
846: intptr = &options->kerberos_get_afs_token;
1.125 markus 847: goto parse_flag;
848:
849: case sGssAuthentication:
850: intptr = &options->gss_authentication;
851: goto parse_flag;
852:
853: case sGssCleanupCreds:
854: intptr = &options->gss_cleanup_creds;
1.94 markus 855: goto parse_flag;
856:
857: case sPasswordAuthentication:
858: intptr = &options->password_authentication;
859: goto parse_flag;
860:
1.190 djm 861: case sZeroKnowledgePasswordAuthentication:
862: intptr = &options->zero_knowledge_password_authentication;
863: goto parse_flag;
864:
1.94 markus 865: case sKbdInteractiveAuthentication:
866: intptr = &options->kbd_interactive_authentication;
867: goto parse_flag;
868:
869: case sChallengeResponseAuthentication:
870: intptr = &options->challenge_response_authentication;
871: goto parse_flag;
872:
873: case sPrintMotd:
874: intptr = &options->print_motd;
875: goto parse_flag;
876:
877: case sPrintLastLog:
878: intptr = &options->print_lastlog;
879: goto parse_flag;
880:
881: case sX11Forwarding:
882: intptr = &options->x11_forwarding;
883: goto parse_flag;
884:
885: case sX11DisplayOffset:
886: intptr = &options->x11_display_offset;
887: goto parse_int;
1.99 stevesk 888:
889: case sX11UseLocalhost:
890: intptr = &options->x11_use_localhost;
891: goto parse_flag;
1.94 markus 892:
893: case sXAuthLocation:
894: charptr = &options->xauth_location;
895: goto parse_filename;
896:
897: case sStrictModes:
898: intptr = &options->strict_modes;
899: goto parse_flag;
900:
1.129 markus 901: case sTCPKeepAlive:
902: intptr = &options->tcp_keep_alive;
1.94 markus 903: goto parse_flag;
904:
905: case sEmptyPasswd:
906: intptr = &options->permit_empty_passwd;
1.113 markus 907: goto parse_flag;
908:
909: case sPermitUserEnvironment:
910: intptr = &options->permit_user_env;
1.94 markus 911: goto parse_flag;
912:
913: case sUseLogin:
914: intptr = &options->use_login;
1.111 markus 915: goto parse_flag;
916:
917: case sCompression:
918: intptr = &options->compression;
1.143 markus 919: arg = strdelim(&cp);
920: if (!arg || *arg == '\0')
921: fatal("%s line %d: missing yes/no/delayed "
922: "argument.", filename, linenum);
923: value = 0; /* silence compiler */
924: if (strcmp(arg, "delayed") == 0)
925: value = COMP_DELAYED;
926: else if (strcmp(arg, "yes") == 0)
927: value = COMP_ZLIB;
928: else if (strcmp(arg, "no") == 0)
929: value = COMP_NONE;
930: else
931: fatal("%s line %d: Bad yes/no/delayed "
932: "argument: %s", filename, linenum, arg);
933: if (*intptr == -1)
934: *intptr = value;
935: break;
1.94 markus 936:
937: case sGatewayPorts:
938: intptr = &options->gateway_ports;
1.139 djm 939: arg = strdelim(&cp);
940: if (!arg || *arg == '\0')
941: fatal("%s line %d: missing yes/no/clientspecified "
942: "argument.", filename, linenum);
943: value = 0; /* silence compiler */
944: if (strcmp(arg, "clientspecified") == 0)
945: value = 2;
946: else if (strcmp(arg, "yes") == 0)
947: value = 1;
948: else if (strcmp(arg, "no") == 0)
949: value = 0;
950: else
951: fatal("%s line %d: Bad yes/no/clientspecified "
952: "argument: %s", filename, linenum, arg);
1.169 dtucker 953: if (*activep && *intptr == -1)
1.139 djm 954: *intptr = value;
955: break;
1.25 markus 956:
1.122 markus 957: case sUseDNS:
958: intptr = &options->use_dns;
1.94 markus 959: goto parse_flag;
1.53 markus 960:
1.94 markus 961: case sLogFacility:
1.174 dtucker 962: log_facility_ptr = &options->log_facility;
1.94 markus 963: arg = strdelim(&cp);
964: value = log_facility_number(arg);
1.101 markus 965: if (value == SYSLOG_FACILITY_NOT_SET)
1.94 markus 966: fatal("%.200s line %d: unsupported log facility '%s'",
967: filename, linenum, arg ? arg : "<NONE>");
1.174 dtucker 968: if (*log_facility_ptr == -1)
969: *log_facility_ptr = (SyslogFacility) value;
1.94 markus 970: break;
1.25 markus 971:
1.94 markus 972: case sLogLevel:
1.174 dtucker 973: log_level_ptr = &options->log_level;
1.94 markus 974: arg = strdelim(&cp);
975: value = log_level_number(arg);
1.101 markus 976: if (value == SYSLOG_LEVEL_NOT_SET)
1.94 markus 977: fatal("%.200s line %d: unsupported log level '%s'",
978: filename, linenum, arg ? arg : "<NONE>");
1.174 dtucker 979: if (*log_level_ptr == -1)
980: *log_level_ptr = (LogLevel) value;
1.94 markus 981: break;
982:
983: case sAllowTcpForwarding:
984: intptr = &options->allow_tcp_forwarding;
985: goto parse_flag;
1.102 provos 986:
1.178 pyr 987: case sAllowAgentForwarding:
988: intptr = &options->allow_agent_forwarding;
989: goto parse_flag;
990:
1.102 provos 991: case sUsePrivilegeSeparation:
992: intptr = &use_privsep;
993: goto parse_flag;
1.94 markus 994:
995: case sAllowUsers:
996: while ((arg = strdelim(&cp)) && *arg != '\0') {
997: if (options->num_allow_users >= MAX_ALLOW_USERS)
998: fatal("%s line %d: too many allow users.",
999: filename, linenum);
1.112 deraadt 1000: options->allow_users[options->num_allow_users++] =
1001: xstrdup(arg);
1.94 markus 1002: }
1003: break;
1.25 markus 1004:
1.94 markus 1005: case sDenyUsers:
1006: while ((arg = strdelim(&cp)) && *arg != '\0') {
1007: if (options->num_deny_users >= MAX_DENY_USERS)
1.163 stevesk 1008: fatal("%s line %d: too many deny users.",
1.94 markus 1009: filename, linenum);
1.112 deraadt 1010: options->deny_users[options->num_deny_users++] =
1011: xstrdup(arg);
1.94 markus 1012: }
1013: break;
1.25 markus 1014:
1.94 markus 1015: case sAllowGroups:
1016: while ((arg = strdelim(&cp)) && *arg != '\0') {
1017: if (options->num_allow_groups >= MAX_ALLOW_GROUPS)
1018: fatal("%s line %d: too many allow groups.",
1019: filename, linenum);
1.112 deraadt 1020: options->allow_groups[options->num_allow_groups++] =
1021: xstrdup(arg);
1.94 markus 1022: }
1023: break;
1.33 markus 1024:
1.94 markus 1025: case sDenyGroups:
1026: while ((arg = strdelim(&cp)) && *arg != '\0') {
1027: if (options->num_deny_groups >= MAX_DENY_GROUPS)
1028: fatal("%s line %d: too many deny groups.",
1029: filename, linenum);
1030: options->deny_groups[options->num_deny_groups++] = xstrdup(arg);
1031: }
1032: break;
1.66 markus 1033:
1.94 markus 1034: case sCiphers:
1035: arg = strdelim(&cp);
1036: if (!arg || *arg == '\0')
1037: fatal("%s line %d: Missing argument.", filename, linenum);
1038: if (!ciphers_valid(arg))
1039: fatal("%s line %d: Bad SSH2 cipher spec '%s'.",
1040: filename, linenum, arg ? arg : "<NONE>");
1041: if (options->ciphers == NULL)
1042: options->ciphers = xstrdup(arg);
1043: break;
1.33 markus 1044:
1.94 markus 1045: case sMacs:
1046: arg = strdelim(&cp);
1047: if (!arg || *arg == '\0')
1048: fatal("%s line %d: Missing argument.", filename, linenum);
1049: if (!mac_valid(arg))
1050: fatal("%s line %d: Bad SSH2 mac spec '%s'.",
1051: filename, linenum, arg ? arg : "<NONE>");
1052: if (options->macs == NULL)
1053: options->macs = xstrdup(arg);
1054: break;
1.43 jakob 1055:
1.94 markus 1056: case sProtocol:
1057: intptr = &options->protocol;
1058: arg = strdelim(&cp);
1059: if (!arg || *arg == '\0')
1060: fatal("%s line %d: Missing argument.", filename, linenum);
1061: value = proto_spec(arg);
1062: if (value == SSH_PROTO_UNKNOWN)
1063: fatal("%s line %d: Bad protocol spec '%s'.",
1.95 deraadt 1064: filename, linenum, arg ? arg : "<NONE>");
1.94 markus 1065: if (*intptr == SSH_PROTO_UNKNOWN)
1066: *intptr = value;
1067: break;
1068:
1069: case sSubsystem:
1070: if (options->num_subsystems >= MAX_SUBSYSTEMS) {
1071: fatal("%s line %d: too many subsystems defined.",
1.95 deraadt 1072: filename, linenum);
1.94 markus 1073: }
1074: arg = strdelim(&cp);
1075: if (!arg || *arg == '\0')
1076: fatal("%s line %d: Missing subsystem name.",
1.95 deraadt 1077: filename, linenum);
1.153 dtucker 1078: if (!*activep) {
1079: arg = strdelim(&cp);
1080: break;
1081: }
1.94 markus 1082: for (i = 0; i < options->num_subsystems; i++)
1083: if (strcmp(arg, options->subsystem_name[i]) == 0)
1084: fatal("%s line %d: Subsystem '%s' already defined.",
1.95 deraadt 1085: filename, linenum, arg);
1.94 markus 1086: options->subsystem_name[options->num_subsystems] = xstrdup(arg);
1087: arg = strdelim(&cp);
1088: if (!arg || *arg == '\0')
1089: fatal("%s line %d: Missing subsystem command.",
1.95 deraadt 1090: filename, linenum);
1.94 markus 1091: options->subsystem_command[options->num_subsystems] = xstrdup(arg);
1.151 djm 1092:
1093: /* Collect arguments (separate to executable) */
1094: p = xstrdup(arg);
1095: len = strlen(p) + 1;
1096: while ((arg = strdelim(&cp)) != NULL && *arg != '\0') {
1097: len += 1 + strlen(arg);
1098: p = xrealloc(p, 1, len);
1099: strlcat(p, " ", len);
1100: strlcat(p, arg, len);
1101: }
1102: options->subsystem_args[options->num_subsystems] = p;
1.94 markus 1103: options->num_subsystems++;
1104: break;
1.46 markus 1105:
1.94 markus 1106: case sMaxStartups:
1107: arg = strdelim(&cp);
1108: if (!arg || *arg == '\0')
1109: fatal("%s line %d: Missing MaxStartups spec.",
1.95 deraadt 1110: filename, linenum);
1.94 markus 1111: if ((n = sscanf(arg, "%d:%d:%d",
1112: &options->max_startups_begin,
1113: &options->max_startups_rate,
1114: &options->max_startups)) == 3) {
1115: if (options->max_startups_begin >
1116: options->max_startups ||
1117: options->max_startups_rate > 100 ||
1118: options->max_startups_rate < 1)
1.50 markus 1119: fatal("%s line %d: Illegal MaxStartups spec.",
1.87 stevesk 1120: filename, linenum);
1.94 markus 1121: } else if (n != 1)
1122: fatal("%s line %d: Illegal MaxStartups spec.",
1123: filename, linenum);
1124: else
1125: options->max_startups = options->max_startups_begin;
1126: break;
1.133 dtucker 1127:
1128: case sMaxAuthTries:
1129: intptr = &options->max_authtries;
1130: goto parse_int;
1.94 markus 1131:
1.180 djm 1132: case sMaxSessions:
1133: intptr = &options->max_sessions;
1134: goto parse_int;
1135:
1.94 markus 1136: case sBanner:
1137: charptr = &options->banner;
1138: goto parse_filename;
1.176 djm 1139:
1.94 markus 1140: /*
1141: * These options can contain %X options expanded at
1142: * connect time, so that you can specify paths like:
1143: *
1144: * AuthorizedKeysFile /etc/ssh_keys/%u
1145: */
1146: case sAuthorizedKeysFile:
1147: case sAuthorizedKeysFile2:
1.163 stevesk 1148: charptr = (opcode == sAuthorizedKeysFile) ?
1.94 markus 1149: &options->authorized_keys_file :
1150: &options->authorized_keys_file2;
1151: goto parse_filename;
1152:
1153: case sClientAliveInterval:
1154: intptr = &options->client_alive_interval;
1155: goto parse_time;
1156:
1157: case sClientAliveCountMax:
1158: intptr = &options->client_alive_count_max;
1159: goto parse_int;
1.131 djm 1160:
1161: case sAcceptEnv:
1162: while ((arg = strdelim(&cp)) && *arg != '\0') {
1163: if (strchr(arg, '=') != NULL)
1164: fatal("%s line %d: Invalid environment name.",
1165: filename, linenum);
1166: if (options->num_accept_env >= MAX_ACCEPT_ENV)
1167: fatal("%s line %d: too many allow env.",
1168: filename, linenum);
1.153 dtucker 1169: if (!*activep)
1170: break;
1.131 djm 1171: options->accept_env[options->num_accept_env++] =
1172: xstrdup(arg);
1173: }
1174: break;
1.145 reyk 1175:
1176: case sPermitTunnel:
1177: intptr = &options->permit_tun;
1.146 reyk 1178: arg = strdelim(&cp);
1179: if (!arg || *arg == '\0')
1180: fatal("%s line %d: Missing yes/point-to-point/"
1181: "ethernet/no argument.", filename, linenum);
1.182 dtucker 1182: value = -1;
1183: for (i = 0; tunmode_desc[i].val != -1; i++)
1184: if (strcmp(tunmode_desc[i].text, arg) == 0) {
1185: value = tunmode_desc[i].val;
1186: break;
1187: }
1188: if (value == -1)
1.146 reyk 1189: fatal("%s line %d: Bad yes/point-to-point/ethernet/"
1190: "no argument: %s", filename, linenum, arg);
1191: if (*intptr == -1)
1192: *intptr = value;
1193: break;
1.94 markus 1194:
1.153 dtucker 1195: case sMatch:
1196: if (cmdline)
1197: fatal("Match directive not supported as a command-line "
1198: "option");
1199: value = match_cfg_line(&cp, linenum, user, host, address);
1200: if (value < 0)
1201: fatal("%s line %d: Bad Match condition", filename,
1202: linenum);
1203: *activep = value;
1.156 dtucker 1204: break;
1205:
1206: case sPermitOpen:
1207: arg = strdelim(&cp);
1208: if (!arg || *arg == '\0')
1209: fatal("%s line %d: missing PermitOpen specification",
1210: filename, linenum);
1.167 dtucker 1211: n = options->num_permitted_opens; /* modified later */
1.156 dtucker 1212: if (strcmp(arg, "any") == 0) {
1.167 dtucker 1213: if (*activep && n == -1) {
1.156 dtucker 1214: channel_clear_adm_permitted_opens();
1.159 dtucker 1215: options->num_permitted_opens = 0;
1216: }
1.156 dtucker 1217: break;
1218: }
1.166 dtucker 1219: if (*activep && n == -1)
1220: channel_clear_adm_permitted_opens();
1.159 dtucker 1221: for (; arg != NULL && *arg != '\0'; arg = strdelim(&cp)) {
1222: p = hpdelim(&arg);
1223: if (p == NULL)
1224: fatal("%s line %d: missing host in PermitOpen",
1225: filename, linenum);
1226: p = cleanhostname(p);
1.194 djm 1227: if (arg == NULL || (port = a2port(arg)) <= 0)
1.159 dtucker 1228: fatal("%s line %d: bad port number in "
1229: "PermitOpen", filename, linenum);
1.166 dtucker 1230: if (*activep && n == -1)
1.159 dtucker 1231: options->num_permitted_opens =
1232: channel_add_adm_permitted_opens(p, port);
1233: }
1.153 dtucker 1234: break;
1235:
1.158 dtucker 1236: case sForceCommand:
1237: if (cp == NULL)
1238: fatal("%.200s line %d: Missing argument.", filename,
1239: linenum);
1240: len = strspn(cp, WHITESPACE);
1241: if (*activep && options->adm_forced_command == NULL)
1242: options->adm_forced_command = xstrdup(cp + len);
1243: return 0;
1244:
1.176 djm 1245: case sChrootDirectory:
1246: charptr = &options->chroot_directory;
1.177 djm 1247:
1248: arg = strdelim(&cp);
1249: if (!arg || *arg == '\0')
1250: fatal("%s line %d: missing file name.",
1251: filename, linenum);
1252: if (*activep && *charptr == NULL)
1253: *charptr = xstrdup(arg);
1254: break;
1.176 djm 1255:
1.197 reyk 1256: case sRDomain:
1257: intptr = &options->rdomain;
1.198 stevesk 1258: arg = strdelim(&cp);
1259: if (!arg || *arg == '\0')
1260: fatal("%s line %d: missing rdomain value.",
1261: filename, linenum);
1262: if ((value = a2rdomain(arg)) == -1)
1263: fatal("%s line %d: invalid rdomain value.",
1264: filename, linenum);
1265: if (*intptr == -1)
1266: *intptr = value;
1267: break;
1.197 reyk 1268:
1.94 markus 1269: case sDeprecated:
1.117 itojun 1270: logit("%s line %d: Deprecated option %s",
1.121 jakob 1271: filename, linenum, arg);
1272: while (arg)
1273: arg = strdelim(&cp);
1274: break;
1275:
1276: case sUnsupported:
1277: logit("%s line %d: Unsupported option %s",
1.94 markus 1278: filename, linenum, arg);
1279: while (arg)
1280: arg = strdelim(&cp);
1281: break;
1282:
1283: default:
1284: fatal("%s line %d: Missing handler for opcode %s (%d)",
1285: filename, linenum, arg, opcode);
1286: }
1287: if ((arg = strdelim(&cp)) != NULL && *arg != '\0')
1288: fatal("%s line %d: garbage at end of line; \"%.200s\".",
1289: filename, linenum, arg);
1290: return 0;
1291: }
1292:
1293: /* Reads the server configuration file. */
1.25 markus 1294:
1.94 markus 1295: void
1.134 djm 1296: load_server_config(const char *filename, Buffer *conf)
1.94 markus 1297: {
1.134 djm 1298: char line[1024], *cp;
1.94 markus 1299: FILE *f;
1.81 stevesk 1300:
1.134 djm 1301: debug2("%s: filename %s", __func__, filename);
1302: if ((f = fopen(filename, "r")) == NULL) {
1.94 markus 1303: perror(filename);
1304: exit(1);
1305: }
1.134 djm 1306: buffer_clear(conf);
1307: while (fgets(line, sizeof(line), f)) {
1308: /*
1309: * Trim out comments and strip whitespace
1.135 deraadt 1310: * NB - preserve newlines, they are needed to reproduce
1.134 djm 1311: * line numbers later for error messages
1312: */
1313: if ((cp = strchr(line, '#')) != NULL)
1314: memcpy(cp, "\n", 2);
1315: cp = line + strspn(line, " \t\r");
1316:
1317: buffer_append(conf, cp, strlen(cp));
1318: }
1319: buffer_append(conf, "\0", 1);
1320: fclose(f);
1321: debug2("%s: done config len = %d", __func__, buffer_len(conf));
1322: }
1323:
1324: void
1.153 dtucker 1325: parse_server_match_config(ServerOptions *options, const char *user,
1326: const char *host, const char *address)
1327: {
1328: ServerOptions mo;
1329:
1330: initialize_server_options(&mo);
1331: parse_server_config(&mo, "reprocess config", &cfg, user, host, address);
1.168 dtucker 1332: copy_set_server_options(options, &mo, 0);
1.153 dtucker 1333: }
1334:
1.168 dtucker 1335: /* Helper macros */
1336: #define M_CP_INTOPT(n) do {\
1337: if (src->n != -1) \
1338: dst->n = src->n; \
1339: } while (0)
1340: #define M_CP_STROPT(n) do {\
1341: if (src->n != NULL) { \
1342: if (dst->n != NULL) \
1343: xfree(dst->n); \
1344: dst->n = src->n; \
1345: } \
1346: } while(0)
1347:
1348: /*
1349: * Copy any supported values that are set.
1350: *
1.195 jj 1351: * If the preauth flag is set, we do not bother copying the string or
1.168 dtucker 1352: * array values that are not used pre-authentication, because any that we
1353: * do use must be explictly sent in mm_getpwnamallow().
1354: */
1.153 dtucker 1355: void
1.168 dtucker 1356: copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth)
1.153 dtucker 1357: {
1.168 dtucker 1358: M_CP_INTOPT(password_authentication);
1359: M_CP_INTOPT(gss_authentication);
1360: M_CP_INTOPT(rsa_authentication);
1361: M_CP_INTOPT(pubkey_authentication);
1362: M_CP_INTOPT(kerberos_authentication);
1363: M_CP_INTOPT(hostbased_authentication);
1364: M_CP_INTOPT(kbd_interactive_authentication);
1.190 djm 1365: M_CP_INTOPT(zero_knowledge_password_authentication);
1.175 dtucker 1366: M_CP_INTOPT(permit_root_login);
1.188 djm 1367: M_CP_INTOPT(permit_empty_passwd);
1.168 dtucker 1368:
1369: M_CP_INTOPT(allow_tcp_forwarding);
1.178 pyr 1370: M_CP_INTOPT(allow_agent_forwarding);
1.168 dtucker 1371: M_CP_INTOPT(gateway_ports);
1372: M_CP_INTOPT(x11_display_offset);
1373: M_CP_INTOPT(x11_forwarding);
1374: M_CP_INTOPT(x11_use_localhost);
1.180 djm 1375: M_CP_INTOPT(max_sessions);
1.184 dtucker 1376: M_CP_INTOPT(max_authtries);
1.168 dtucker 1377:
1378: M_CP_STROPT(banner);
1379: if (preauth)
1380: return;
1381: M_CP_STROPT(adm_forced_command);
1.176 djm 1382: M_CP_STROPT(chroot_directory);
1.153 dtucker 1383: }
1.168 dtucker 1384:
1385: #undef M_CP_INTOPT
1386: #undef M_CP_STROPT
1.153 dtucker 1387:
1388: void
1389: parse_server_config(ServerOptions *options, const char *filename, Buffer *conf,
1390: const char *user, const char *host, const char *address)
1.134 djm 1391: {
1.153 dtucker 1392: int active, linenum, bad_options = 0;
1.136 dtucker 1393: char *cp, *obuf, *cbuf;
1.134 djm 1394:
1395: debug2("%s: config %s len %d", __func__, filename, buffer_len(conf));
1396:
1.136 dtucker 1397: obuf = cbuf = xstrdup(buffer_ptr(conf));
1.153 dtucker 1398: active = user ? 0 : 1;
1.137 dtucker 1399: linenum = 1;
1.140 deraadt 1400: while ((cp = strsep(&cbuf, "\n")) != NULL) {
1.134 djm 1401: if (process_server_config_line(options, cp, filename,
1.153 dtucker 1402: linenum++, &active, user, host, address) != 0)
1.94 markus 1403: bad_options++;
1.1 deraadt 1404: }
1.136 dtucker 1405: xfree(obuf);
1.78 stevesk 1406: if (bad_options > 0)
1407: fatal("%s: terminating, %d bad configuration options",
1408: filename, bad_options);
1.182 dtucker 1409: }
1410:
1411: static const char *
1412: fmt_intarg(ServerOpCodes code, int val)
1413: {
1414: if (code == sAddressFamily) {
1415: switch (val) {
1416: case AF_INET:
1417: return "inet";
1418: case AF_INET6:
1419: return "inet6";
1420: case AF_UNSPEC:
1421: return "any";
1422: default:
1423: return "UNKNOWN";
1424: }
1425: }
1426: if (code == sPermitRootLogin) {
1427: switch (val) {
1428: case PERMIT_NO_PASSWD:
1.191 jmc 1429: return "without-password";
1.182 dtucker 1430: case PERMIT_FORCED_ONLY:
1431: return "forced-commands-only";
1432: case PERMIT_YES:
1433: return "yes";
1434: }
1435: }
1436: if (code == sProtocol) {
1437: switch (val) {
1438: case SSH_PROTO_1:
1439: return "1";
1440: case SSH_PROTO_2:
1441: return "2";
1442: case (SSH_PROTO_1|SSH_PROTO_2):
1443: return "2,1";
1444: default:
1445: return "UNKNOWN";
1446: }
1447: }
1448: if (code == sGatewayPorts && val == 2)
1449: return "clientspecified";
1450: if (code == sCompression && val == COMP_DELAYED)
1451: return "delayed";
1452: switch (val) {
1453: case -1:
1454: return "unset";
1455: case 0:
1456: return "no";
1457: case 1:
1458: return "yes";
1459: }
1460: return "UNKNOWN";
1461: }
1462:
1463: static const char *
1464: lookup_opcode_name(ServerOpCodes code)
1465: {
1466: u_int i;
1467:
1468: for (i = 0; keywords[i].name != NULL; i++)
1469: if (keywords[i].opcode == code)
1470: return(keywords[i].name);
1471: return "UNKNOWN";
1472: }
1473:
1474: static void
1475: dump_cfg_int(ServerOpCodes code, int val)
1476: {
1477: printf("%s %d\n", lookup_opcode_name(code), val);
1478: }
1479:
1480: static void
1481: dump_cfg_fmtint(ServerOpCodes code, int val)
1482: {
1483: printf("%s %s\n", lookup_opcode_name(code), fmt_intarg(code, val));
1484: }
1485:
1486: static void
1487: dump_cfg_string(ServerOpCodes code, const char *val)
1488: {
1489: if (val == NULL)
1490: return;
1491: printf("%s %s\n", lookup_opcode_name(code), val);
1492: }
1493:
1494: static void
1495: dump_cfg_strarray(ServerOpCodes code, u_int count, char **vals)
1496: {
1497: u_int i;
1498:
1499: for (i = 0; i < count; i++)
1500: printf("%s %s\n", lookup_opcode_name(code), vals[i]);
1501: }
1502:
1503: void
1504: dump_config(ServerOptions *o)
1505: {
1506: u_int i;
1507: int ret;
1508: struct addrinfo *ai;
1509: char addr[NI_MAXHOST], port[NI_MAXSERV], *s = NULL;
1510:
1511: /* these are usually at the top of the config */
1512: for (i = 0; i < o->num_ports; i++)
1513: printf("port %d\n", o->ports[i]);
1514: dump_cfg_fmtint(sProtocol, o->protocol);
1515: dump_cfg_fmtint(sAddressFamily, o->address_family);
1516:
1517: /* ListenAddress must be after Port */
1518: for (ai = o->listen_addrs; ai; ai = ai->ai_next) {
1519: if ((ret = getnameinfo(ai->ai_addr, ai->ai_addrlen, addr,
1520: sizeof(addr), port, sizeof(port),
1521: NI_NUMERICHOST|NI_NUMERICSERV)) != 0) {
1522: error("getnameinfo failed: %.100s",
1523: (ret != EAI_SYSTEM) ? gai_strerror(ret) :
1524: strerror(errno));
1525: } else {
1526: if (ai->ai_family == AF_INET6)
1527: printf("listenaddress [%s]:%s\n", addr, port);
1528: else
1529: printf("listenaddress %s:%s\n", addr, port);
1530: }
1531: }
1532:
1533: /* integer arguments */
1534: dump_cfg_int(sServerKeyBits, o->server_key_bits);
1535: dump_cfg_int(sLoginGraceTime, o->login_grace_time);
1536: dump_cfg_int(sKeyRegenerationTime, o->key_regeneration_time);
1537: dump_cfg_int(sX11DisplayOffset, o->x11_display_offset);
1538: dump_cfg_int(sMaxAuthTries, o->max_authtries);
1.189 djm 1539: dump_cfg_int(sMaxSessions, o->max_sessions);
1.182 dtucker 1540: dump_cfg_int(sClientAliveInterval, o->client_alive_interval);
1541: dump_cfg_int(sClientAliveCountMax, o->client_alive_count_max);
1.197 reyk 1542: dump_cfg_int(sRDomain, o->rdomain);
1.182 dtucker 1543:
1544: /* formatted integer arguments */
1545: dump_cfg_fmtint(sPermitRootLogin, o->permit_root_login);
1546: dump_cfg_fmtint(sIgnoreRhosts, o->ignore_rhosts);
1547: dump_cfg_fmtint(sIgnoreUserKnownHosts, o->ignore_user_known_hosts);
1548: dump_cfg_fmtint(sRhostsRSAAuthentication, o->rhosts_rsa_authentication);
1549: dump_cfg_fmtint(sHostbasedAuthentication, o->hostbased_authentication);
1550: dump_cfg_fmtint(sHostbasedUsesNameFromPacketOnly,
1551: o->hostbased_uses_name_from_packet_only);
1552: dump_cfg_fmtint(sRSAAuthentication, o->rsa_authentication);
1553: dump_cfg_fmtint(sPubkeyAuthentication, o->pubkey_authentication);
1.187 djm 1554: #ifdef KRB5
1.182 dtucker 1555: dump_cfg_fmtint(sKerberosAuthentication, o->kerberos_authentication);
1556: dump_cfg_fmtint(sKerberosOrLocalPasswd, o->kerberos_or_local_passwd);
1557: dump_cfg_fmtint(sKerberosTicketCleanup, o->kerberos_ticket_cleanup);
1558: dump_cfg_fmtint(sKerberosGetAFSToken, o->kerberos_get_afs_token);
1.187 djm 1559: #endif
1560: #ifdef GSSAPI
1.182 dtucker 1561: dump_cfg_fmtint(sGssAuthentication, o->gss_authentication);
1562: dump_cfg_fmtint(sGssCleanupCreds, o->gss_cleanup_creds);
1.190 djm 1563: #endif
1564: #ifdef JPAKE
1565: dump_cfg_fmtint(sZeroKnowledgePasswordAuthentication,
1566: o->zero_knowledge_password_authentication);
1.187 djm 1567: #endif
1.182 dtucker 1568: dump_cfg_fmtint(sPasswordAuthentication, o->password_authentication);
1569: dump_cfg_fmtint(sKbdInteractiveAuthentication,
1570: o->kbd_interactive_authentication);
1571: dump_cfg_fmtint(sChallengeResponseAuthentication,
1572: o->challenge_response_authentication);
1573: dump_cfg_fmtint(sPrintMotd, o->print_motd);
1574: dump_cfg_fmtint(sPrintLastLog, o->print_lastlog);
1575: dump_cfg_fmtint(sX11Forwarding, o->x11_forwarding);
1576: dump_cfg_fmtint(sX11UseLocalhost, o->x11_use_localhost);
1577: dump_cfg_fmtint(sStrictModes, o->strict_modes);
1578: dump_cfg_fmtint(sTCPKeepAlive, o->tcp_keep_alive);
1579: dump_cfg_fmtint(sEmptyPasswd, o->permit_empty_passwd);
1580: dump_cfg_fmtint(sPermitUserEnvironment, o->permit_user_env);
1581: dump_cfg_fmtint(sUseLogin, o->use_login);
1582: dump_cfg_fmtint(sCompression, o->compression);
1583: dump_cfg_fmtint(sGatewayPorts, o->gateway_ports);
1584: dump_cfg_fmtint(sUseDNS, o->use_dns);
1585: dump_cfg_fmtint(sAllowTcpForwarding, o->allow_tcp_forwarding);
1586: dump_cfg_fmtint(sUsePrivilegeSeparation, use_privsep);
1587:
1588: /* string arguments */
1589: dump_cfg_string(sPidFile, o->pid_file);
1590: dump_cfg_string(sXAuthLocation, o->xauth_location);
1591: dump_cfg_string(sCiphers, o->ciphers);
1592: dump_cfg_string(sMacs, o->macs);
1593: dump_cfg_string(sBanner, o->banner);
1594: dump_cfg_string(sAuthorizedKeysFile, o->authorized_keys_file);
1595: dump_cfg_string(sAuthorizedKeysFile2, o->authorized_keys_file2);
1596: dump_cfg_string(sForceCommand, o->adm_forced_command);
1597:
1598: /* string arguments requiring a lookup */
1599: dump_cfg_string(sLogLevel, log_level_name(o->log_level));
1600: dump_cfg_string(sLogFacility, log_facility_name(o->log_facility));
1601:
1602: /* string array arguments */
1603: dump_cfg_strarray(sHostKeyFile, o->num_host_key_files,
1604: o->host_key_files);
1605: dump_cfg_strarray(sAllowUsers, o->num_allow_users, o->allow_users);
1606: dump_cfg_strarray(sDenyUsers, o->num_deny_users, o->deny_users);
1607: dump_cfg_strarray(sAllowGroups, o->num_allow_groups, o->allow_groups);
1608: dump_cfg_strarray(sDenyGroups, o->num_deny_groups, o->deny_groups);
1609: dump_cfg_strarray(sAcceptEnv, o->num_accept_env, o->accept_env);
1610:
1611: /* other arguments */
1612: for (i = 0; i < o->num_subsystems; i++)
1613: printf("subsystem %s %s\n", o->subsystem_name[i],
1614: o->subsystem_args[i]);
1615:
1616: printf("maxstartups %d:%d:%d\n", o->max_startups_begin,
1617: o->max_startups_rate, o->max_startups);
1618:
1619: for (i = 0; tunmode_desc[i].val != -1; i++)
1620: if (tunmode_desc[i].val == o->permit_tun) {
1621: s = tunmode_desc[i].text;
1622: break;
1623: }
1624: dump_cfg_string(sPermitTunnel, s);
1625:
1626: channel_print_adm_permitted_opens();
1.1 deraadt 1627: }