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