Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1 | /* |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 2 | * |
| 3 | * servconf.c |
| 4 | * |
| 5 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
| 6 | * |
| 7 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
| 8 | * All rights reserved |
| 9 | * |
| 10 | * Created: Mon Aug 21 15:48:58 1995 ylo |
| 11 | * |
| 12 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 13 | |
| 14 | #include "includes.h" |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 15 | RCSID("$Id: servconf.c,v 1.6 1999/11/24 13:26:22 damien Exp $"); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 16 | |
| 17 | #include "ssh.h" |
| 18 | #include "servconf.h" |
| 19 | #include "xmalloc.h" |
| 20 | |
| 21 | /* Initializes the server options to their default values. */ |
| 22 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 23 | void |
| 24 | initialize_server_options(ServerOptions *options) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 25 | { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 26 | memset(options, 0, sizeof(*options)); |
| 27 | options->port = -1; |
| 28 | options->listen_addr.s_addr = htonl(INADDR_ANY); |
| 29 | options->host_key_file = NULL; |
| 30 | options->server_key_bits = -1; |
| 31 | options->login_grace_time = -1; |
| 32 | options->key_regeneration_time = -1; |
| 33 | options->permit_root_login = -1; |
| 34 | options->ignore_rhosts = -1; |
| 35 | options->ignore_user_known_hosts = -1; |
| 36 | options->print_motd = -1; |
| 37 | options->check_mail = -1; |
| 38 | options->x11_forwarding = -1; |
| 39 | options->x11_display_offset = -1; |
| 40 | options->strict_modes = -1; |
| 41 | options->keepalives = -1; |
| 42 | options->log_facility = (SyslogFacility) - 1; |
| 43 | options->log_level = (LogLevel) - 1; |
| 44 | options->rhosts_authentication = -1; |
| 45 | options->rhosts_rsa_authentication = -1; |
| 46 | options->rsa_authentication = -1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 47 | #ifdef KRB4 |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 48 | options->kerberos_authentication = -1; |
| 49 | options->kerberos_or_local_passwd = -1; |
| 50 | options->kerberos_ticket_cleanup = -1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 51 | #endif |
| 52 | #ifdef AFS |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 53 | options->kerberos_tgt_passing = -1; |
| 54 | options->afs_token_passing = -1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 55 | #endif |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 56 | options->password_authentication = -1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 57 | #ifdef SKEY |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 58 | options->skey_authentication = -1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 59 | #endif |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 60 | options->permit_empty_passwd = -1; |
| 61 | options->use_login = -1; |
| 62 | options->num_allow_users = 0; |
| 63 | options->num_deny_users = 0; |
| 64 | options->num_allow_groups = 0; |
| 65 | options->num_deny_groups = 0; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 66 | } |
| 67 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 68 | void |
| 69 | fill_default_server_options(ServerOptions *options) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 70 | { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 71 | if (options->port == -1) { |
| 72 | struct servent *sp; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 73 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 74 | sp = getservbyname(SSH_SERVICE_NAME, "tcp"); |
| 75 | if (sp) |
| 76 | options->port = ntohs(sp->s_port); |
| 77 | else |
| 78 | options->port = SSH_DEFAULT_PORT; |
| 79 | endservent(); |
| 80 | } |
| 81 | if (options->host_key_file == NULL) |
| 82 | options->host_key_file = HOST_KEY_FILE; |
| 83 | if (options->server_key_bits == -1) |
| 84 | options->server_key_bits = 768; |
| 85 | if (options->login_grace_time == -1) |
| 86 | options->login_grace_time = 600; |
| 87 | if (options->key_regeneration_time == -1) |
| 88 | options->key_regeneration_time = 3600; |
| 89 | if (options->permit_root_login == -1) |
| 90 | options->permit_root_login = 1; /* yes */ |
| 91 | if (options->ignore_rhosts == -1) |
| 92 | options->ignore_rhosts = 0; |
| 93 | if (options->ignore_user_known_hosts == -1) |
| 94 | options->ignore_user_known_hosts = 0; |
| 95 | if (options->check_mail == -1) |
| 96 | options->check_mail = 0; |
| 97 | if (options->print_motd == -1) |
| 98 | options->print_motd = 1; |
| 99 | if (options->x11_forwarding == -1) |
| 100 | options->x11_forwarding = 1; |
| 101 | if (options->x11_display_offset == -1) |
| 102 | options->x11_display_offset = 1; |
| 103 | if (options->strict_modes == -1) |
| 104 | options->strict_modes = 1; |
| 105 | if (options->keepalives == -1) |
| 106 | options->keepalives = 1; |
| 107 | if (options->log_facility == (SyslogFacility) (-1)) |
| 108 | options->log_facility = SYSLOG_FACILITY_AUTH; |
| 109 | if (options->log_level == (LogLevel) (-1)) |
| 110 | options->log_level = SYSLOG_LEVEL_INFO; |
| 111 | if (options->rhosts_authentication == -1) |
| 112 | options->rhosts_authentication = 0; |
| 113 | if (options->rhosts_rsa_authentication == -1) |
| 114 | options->rhosts_rsa_authentication = 1; |
| 115 | if (options->rsa_authentication == -1) |
| 116 | options->rsa_authentication = 1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 117 | #ifdef KRB4 |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 118 | if (options->kerberos_authentication == -1) |
| 119 | options->kerberos_authentication = (access(KEYFILE, R_OK) == 0); |
| 120 | if (options->kerberos_or_local_passwd == -1) |
| 121 | options->kerberos_or_local_passwd = 1; |
| 122 | if (options->kerberos_ticket_cleanup == -1) |
| 123 | options->kerberos_ticket_cleanup = 1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 124 | #endif /* KRB4 */ |
| 125 | #ifdef AFS |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 126 | if (options->kerberos_tgt_passing == -1) |
| 127 | options->kerberos_tgt_passing = 0; |
| 128 | if (options->afs_token_passing == -1) |
| 129 | options->afs_token_passing = k_hasafs(); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 130 | #endif /* AFS */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 131 | if (options->password_authentication == -1) |
| 132 | options->password_authentication = 1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 133 | #ifdef SKEY |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 134 | if (options->skey_authentication == -1) |
| 135 | options->skey_authentication = 1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 136 | #endif |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 137 | if (options->permit_empty_passwd == -1) |
| 138 | options->permit_empty_passwd = 1; |
| 139 | if (options->use_login == -1) |
| 140 | options->use_login = 0; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | #define WHITESPACE " \t\r\n" |
| 144 | |
| 145 | /* Keyword tokens. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 146 | typedef enum { |
| 147 | sBadOption, /* == unknown option */ |
| 148 | sPort, sHostKeyFile, sServerKeyBits, sLoginGraceTime, sKeyRegenerationTime, |
| 149 | sPermitRootLogin, sLogFacility, sLogLevel, |
| 150 | sRhostsAuthentication, sRhostsRSAAuthentication, sRSAAuthentication, |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 151 | #ifdef KRB4 |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 152 | sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup, |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 153 | #endif |
| 154 | #ifdef AFS |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 155 | sKerberosTgtPassing, sAFSTokenPassing, |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 156 | #endif |
| 157 | #ifdef SKEY |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 158 | sSkeyAuthentication, |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 159 | #endif |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 160 | sPasswordAuthentication, sListenAddress, |
| 161 | sPrintMotd, sIgnoreRhosts, sX11Forwarding, sX11DisplayOffset, |
| 162 | sStrictModes, sEmptyPasswd, sRandomSeedFile, sKeepAlives, sCheckMail, |
| 163 | sUseLogin, sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups, |
| 164 | sIgnoreUserKnownHosts |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 165 | } ServerOpCodes; |
| 166 | |
| 167 | /* Textual representation of the tokens. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 168 | static struct { |
| 169 | const char *name; |
| 170 | ServerOpCodes opcode; |
| 171 | } keywords[] = { |
| 172 | { "port", sPort }, |
| 173 | { "hostkey", sHostKeyFile }, |
| 174 | { "serverkeybits", sServerKeyBits }, |
| 175 | { "logingracetime", sLoginGraceTime }, |
| 176 | { "keyregenerationinterval", sKeyRegenerationTime }, |
| 177 | { "permitrootlogin", sPermitRootLogin }, |
| 178 | { "syslogfacility", sLogFacility }, |
| 179 | { "loglevel", sLogLevel }, |
| 180 | { "rhostsauthentication", sRhostsAuthentication }, |
| 181 | { "rhostsrsaauthentication", sRhostsRSAAuthentication }, |
| 182 | { "rsaauthentication", sRSAAuthentication }, |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 183 | #ifdef KRB4 |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 184 | { "kerberosauthentication", sKerberosAuthentication }, |
| 185 | { "kerberosorlocalpasswd", sKerberosOrLocalPasswd }, |
| 186 | { "kerberosticketcleanup", sKerberosTicketCleanup }, |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 187 | #endif |
| 188 | #ifdef AFS |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 189 | { "kerberostgtpassing", sKerberosTgtPassing }, |
| 190 | { "afstokenpassing", sAFSTokenPassing }, |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 191 | #endif |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 192 | { "passwordauthentication", sPasswordAuthentication }, |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 193 | #ifdef SKEY |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 194 | { "skeyauthentication", sSkeyAuthentication }, |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 195 | #endif |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 196 | { "checkmail", sCheckMail }, |
| 197 | { "listenaddress", sListenAddress }, |
| 198 | { "printmotd", sPrintMotd }, |
| 199 | { "ignorerhosts", sIgnoreRhosts }, |
| 200 | { "ignoreuserknownhosts", sIgnoreUserKnownHosts }, |
| 201 | { "x11forwarding", sX11Forwarding }, |
| 202 | { "x11displayoffset", sX11DisplayOffset }, |
| 203 | { "strictmodes", sStrictModes }, |
| 204 | { "permitemptypasswords", sEmptyPasswd }, |
| 205 | { "uselogin", sUseLogin }, |
| 206 | { "randomseed", sRandomSeedFile }, |
| 207 | { "keepalive", sKeepAlives }, |
| 208 | { "allowusers", sAllowUsers }, |
| 209 | { "denyusers", sDenyUsers }, |
| 210 | { "allowgroups", sAllowGroups }, |
| 211 | { "denygroups", sDenyGroups }, |
| 212 | { NULL, 0 } |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 213 | }; |
| 214 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 215 | /* Returns the number of the token pointed to by cp of length len. |
| 216 | Never returns if the token is not known. */ |
| 217 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 218 | static ServerOpCodes |
| 219 | parse_token(const char *cp, const char *filename, |
| 220 | int linenum) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 221 | { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 222 | unsigned int i; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 223 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 224 | for (i = 0; keywords[i].name; i++) |
| 225 | if (strcmp(cp, keywords[i].name) == 0) |
| 226 | return keywords[i].opcode; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 227 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 228 | fprintf(stderr, "%s: line %d: Bad configuration option: %s\n", |
| 229 | filename, linenum, cp); |
| 230 | return sBadOption; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | /* Reads the server configuration file. */ |
| 234 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 235 | void |
| 236 | read_server_config(ServerOptions *options, const char *filename) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 237 | { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 238 | FILE *f; |
| 239 | char line[1024]; |
| 240 | char *cp, **charptr; |
| 241 | int linenum, *intptr, value; |
| 242 | int bad_options = 0; |
| 243 | ServerOpCodes opcode; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 244 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 245 | f = fopen(filename, "r"); |
| 246 | if (!f) { |
| 247 | perror(filename); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 248 | exit(1); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 249 | } |
| 250 | linenum = 0; |
| 251 | while (fgets(line, sizeof(line), f)) { |
| 252 | linenum++; |
| 253 | cp = line + strspn(line, WHITESPACE); |
| 254 | if (!*cp || *cp == '#') |
| 255 | continue; |
| 256 | cp = strtok(cp, WHITESPACE); |
| 257 | { |
| 258 | char *t = cp; |
| 259 | for (; *t != 0; t++) |
| 260 | if ('A' <= *t && *t <= 'Z') |
| 261 | *t = *t - 'A' + 'a'; /* tolower */ |
Damien Miller | 3226509 | 1999-11-12 11:33:04 +1100 | [diff] [blame] | 262 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 263 | } |
| 264 | opcode = parse_token(cp, filename, linenum); |
| 265 | switch (opcode) { |
| 266 | case sBadOption: |
| 267 | bad_options++; |
| 268 | continue; |
| 269 | case sPort: |
| 270 | intptr = &options->port; |
| 271 | parse_int: |
| 272 | cp = strtok(NULL, WHITESPACE); |
| 273 | if (!cp) { |
| 274 | fprintf(stderr, "%s line %d: missing integer value.\n", |
| 275 | filename, linenum); |
| 276 | exit(1); |
| 277 | } |
| 278 | value = atoi(cp); |
| 279 | if (*intptr == -1) |
| 280 | *intptr = value; |
| 281 | break; |
Damien Miller | 3226509 | 1999-11-12 11:33:04 +1100 | [diff] [blame] | 282 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 283 | case sServerKeyBits: |
| 284 | intptr = &options->server_key_bits; |
| 285 | goto parse_int; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 286 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 287 | case sLoginGraceTime: |
| 288 | intptr = &options->login_grace_time; |
| 289 | goto parse_int; |
| 290 | |
| 291 | case sKeyRegenerationTime: |
| 292 | intptr = &options->key_regeneration_time; |
| 293 | goto parse_int; |
| 294 | |
| 295 | case sListenAddress: |
| 296 | cp = strtok(NULL, WHITESPACE); |
| 297 | if (!cp) { |
| 298 | fprintf(stderr, "%s line %d: missing inet addr.\n", |
| 299 | filename, linenum); |
| 300 | exit(1); |
| 301 | } |
| 302 | options->listen_addr.s_addr = inet_addr(cp); |
| 303 | break; |
| 304 | |
| 305 | case sHostKeyFile: |
| 306 | charptr = &options->host_key_file; |
| 307 | cp = strtok(NULL, WHITESPACE); |
| 308 | if (!cp) { |
| 309 | fprintf(stderr, "%s line %d: missing file name.\n", |
| 310 | filename, linenum); |
| 311 | exit(1); |
| 312 | } |
| 313 | if (*charptr == NULL) |
| 314 | *charptr = tilde_expand_filename(cp, getuid()); |
| 315 | break; |
| 316 | |
| 317 | case sRandomSeedFile: |
| 318 | fprintf(stderr, "%s line %d: \"randomseed\" option is obsolete.\n", |
| 319 | filename, linenum); |
| 320 | cp = strtok(NULL, WHITESPACE); |
| 321 | break; |
| 322 | |
| 323 | case sPermitRootLogin: |
| 324 | intptr = &options->permit_root_login; |
| 325 | cp = strtok(NULL, WHITESPACE); |
| 326 | if (!cp) { |
| 327 | fprintf(stderr, "%s line %d: missing yes/without-password/no argument.\n", |
| 328 | filename, linenum); |
| 329 | exit(1); |
| 330 | } |
| 331 | if (strcmp(cp, "without-password") == 0) |
| 332 | value = 2; |
| 333 | else if (strcmp(cp, "yes") == 0) |
| 334 | value = 1; |
| 335 | else if (strcmp(cp, "no") == 0) |
| 336 | value = 0; |
| 337 | else { |
| 338 | fprintf(stderr, "%s line %d: Bad yes/without-password/no argument: %s\n", |
| 339 | filename, linenum, cp); |
| 340 | exit(1); |
| 341 | } |
| 342 | if (*intptr == -1) |
| 343 | *intptr = value; |
| 344 | break; |
| 345 | |
| 346 | case sIgnoreRhosts: |
| 347 | intptr = &options->ignore_rhosts; |
| 348 | parse_flag: |
| 349 | cp = strtok(NULL, WHITESPACE); |
| 350 | if (!cp) { |
| 351 | fprintf(stderr, "%s line %d: missing yes/no argument.\n", |
| 352 | filename, linenum); |
| 353 | exit(1); |
| 354 | } |
| 355 | if (strcmp(cp, "yes") == 0) |
| 356 | value = 1; |
| 357 | else if (strcmp(cp, "no") == 0) |
| 358 | value = 0; |
| 359 | else { |
| 360 | fprintf(stderr, "%s line %d: Bad yes/no argument: %s\n", |
| 361 | filename, linenum, cp); |
| 362 | exit(1); |
| 363 | } |
| 364 | if (*intptr == -1) |
| 365 | *intptr = value; |
| 366 | break; |
| 367 | |
| 368 | case sIgnoreUserKnownHosts: |
| 369 | intptr = &options->ignore_user_known_hosts; |
| 370 | goto parse_int; |
| 371 | |
| 372 | case sRhostsAuthentication: |
| 373 | intptr = &options->rhosts_authentication; |
| 374 | goto parse_flag; |
| 375 | |
| 376 | case sRhostsRSAAuthentication: |
| 377 | intptr = &options->rhosts_rsa_authentication; |
| 378 | goto parse_flag; |
| 379 | |
| 380 | case sRSAAuthentication: |
| 381 | intptr = &options->rsa_authentication; |
| 382 | goto parse_flag; |
| 383 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 384 | #ifdef KRB4 |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 385 | case sKerberosAuthentication: |
| 386 | intptr = &options->kerberos_authentication; |
| 387 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 388 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 389 | case sKerberosOrLocalPasswd: |
| 390 | intptr = &options->kerberos_or_local_passwd; |
| 391 | goto parse_flag; |
| 392 | |
| 393 | case sKerberosTicketCleanup: |
| 394 | intptr = &options->kerberos_ticket_cleanup; |
| 395 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 396 | #endif |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 397 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 398 | #ifdef AFS |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 399 | case sKerberosTgtPassing: |
| 400 | intptr = &options->kerberos_tgt_passing; |
| 401 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 402 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 403 | case sAFSTokenPassing: |
| 404 | intptr = &options->afs_token_passing; |
| 405 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 406 | #endif |
| 407 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 408 | case sPasswordAuthentication: |
| 409 | intptr = &options->password_authentication; |
| 410 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 411 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 412 | case sCheckMail: |
| 413 | intptr = &options->check_mail; |
| 414 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 415 | |
| 416 | #ifdef SKEY |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 417 | case sSkeyAuthentication: |
| 418 | intptr = &options->skey_authentication; |
| 419 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 420 | #endif |
| 421 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 422 | case sPrintMotd: |
| 423 | intptr = &options->print_motd; |
| 424 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 425 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 426 | case sX11Forwarding: |
| 427 | intptr = &options->x11_forwarding; |
| 428 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 429 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 430 | case sX11DisplayOffset: |
| 431 | intptr = &options->x11_display_offset; |
| 432 | goto parse_int; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 433 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 434 | case sStrictModes: |
| 435 | intptr = &options->strict_modes; |
| 436 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 437 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 438 | case sKeepAlives: |
| 439 | intptr = &options->keepalives; |
| 440 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 441 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 442 | case sEmptyPasswd: |
| 443 | intptr = &options->permit_empty_passwd; |
| 444 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 445 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 446 | case sUseLogin: |
| 447 | intptr = &options->use_login; |
| 448 | goto parse_flag; |
Damien Miller | 5ce662a | 1999-11-11 17:57:39 +1100 | [diff] [blame] | 449 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 450 | case sLogFacility: |
| 451 | intptr = (int *) &options->log_facility; |
| 452 | cp = strtok(NULL, WHITESPACE); |
| 453 | value = log_facility_number(cp); |
| 454 | if (value == (SyslogFacility) - 1) |
| 455 | fatal("%.200s line %d: unsupported log facility '%s'\n", |
| 456 | filename, linenum, cp ? cp : "<NONE>"); |
| 457 | if (*intptr == -1) |
| 458 | *intptr = (SyslogFacility) value; |
| 459 | break; |
| 460 | |
| 461 | case sLogLevel: |
| 462 | intptr = (int *) &options->log_level; |
| 463 | cp = strtok(NULL, WHITESPACE); |
| 464 | value = log_level_number(cp); |
| 465 | if (value == (LogLevel) - 1) |
| 466 | fatal("%.200s line %d: unsupported log level '%s'\n", |
| 467 | filename, linenum, cp ? cp : "<NONE>"); |
| 468 | if (*intptr == -1) |
| 469 | *intptr = (LogLevel) value; |
| 470 | break; |
| 471 | |
| 472 | case sAllowUsers: |
| 473 | while ((cp = strtok(NULL, WHITESPACE))) { |
| 474 | if (options->num_allow_users >= MAX_ALLOW_USERS) { |
| 475 | fprintf(stderr, "%s line %d: too many allow users.\n", |
| 476 | filename, linenum); |
| 477 | exit(1); |
| 478 | } |
| 479 | options->allow_users[options->num_allow_users++] = xstrdup(cp); |
| 480 | } |
| 481 | break; |
| 482 | |
| 483 | case sDenyUsers: |
| 484 | while ((cp = strtok(NULL, WHITESPACE))) { |
| 485 | if (options->num_deny_users >= MAX_DENY_USERS) { |
| 486 | fprintf(stderr, "%s line %d: too many deny users.\n", |
| 487 | filename, linenum); |
| 488 | exit(1); |
| 489 | } |
| 490 | options->deny_users[options->num_deny_users++] = xstrdup(cp); |
| 491 | } |
| 492 | break; |
| 493 | |
| 494 | case sAllowGroups: |
| 495 | while ((cp = strtok(NULL, WHITESPACE))) { |
| 496 | if (options->num_allow_groups >= MAX_ALLOW_GROUPS) { |
| 497 | fprintf(stderr, "%s line %d: too many allow groups.\n", |
| 498 | filename, linenum); |
| 499 | exit(1); |
| 500 | } |
| 501 | options->allow_groups[options->num_allow_groups++] = xstrdup(cp); |
| 502 | } |
| 503 | break; |
| 504 | |
| 505 | case sDenyGroups: |
| 506 | while ((cp = strtok(NULL, WHITESPACE))) { |
| 507 | if (options->num_deny_groups >= MAX_DENY_GROUPS) { |
| 508 | fprintf(stderr, "%s line %d: too many deny groups.\n", |
| 509 | filename, linenum); |
| 510 | exit(1); |
| 511 | } |
| 512 | options->deny_groups[options->num_deny_groups++] = xstrdup(cp); |
| 513 | } |
| 514 | break; |
| 515 | |
| 516 | default: |
| 517 | fprintf(stderr, "%s line %d: Missing handler for opcode %s (%d)\n", |
| 518 | filename, linenum, cp, opcode); |
| 519 | exit(1); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 520 | } |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 521 | if (strtok(NULL, WHITESPACE) != NULL) { |
| 522 | fprintf(stderr, "%s line %d: garbage at end of line.\n", |
| 523 | filename, linenum); |
| 524 | exit(1); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 525 | } |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 526 | } |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 527 | fclose(f); |
| 528 | if (bad_options > 0) { |
| 529 | fprintf(stderr, "%s: terminating, %d bad configuration options\n", |
| 530 | filename, bad_options); |
| 531 | exit(1); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 532 | } |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 533 | } |