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