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