]> andersk Git - openssh.git/blobdiff - servconf.c
- itojun@cvs.openbsd.org 2001/06/23 15:12:20
[openssh.git] / servconf.c
index f978c632b30c5cfad10f001aca04da51b009d566..55b0b0039731ba73fb93c33f6a9270eb447e4c80 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: servconf.c,v 1.77 2001/04/13 22:46:53 beck Exp $");
+RCSID("$OpenBSD: servconf.c,v 1.84 2001/06/23 15:12:19 itojun Exp $");
 
 #ifdef KRB4
 #include <krb.h>
@@ -31,8 +31,8 @@ RCSID("$OpenBSD: servconf.c,v 1.77 2001/04/13 22:46:53 beck Exp $");
 #include "kex.h"
 #include "mac.h"
 
-void add_listen_addr(ServerOptions *options, char *addr, u_short port);
-void add_one_listen_addr(ServerOptions *options, char *addr, u_short port);
+static void add_listen_addr(ServerOptions *, char *, u_short);
+static void add_one_listen_addr(ServerOptions *, char *, u_short);
 
 /* AF_UNSPEC or AF_INET or AF_INET6 */
 extern int IPv4or6;
@@ -81,7 +81,7 @@ initialize_server_options(ServerOptions *options)
 #endif
        options->password_authentication = -1;
        options->kbd_interactive_authentication = -1;
-       options->challenge_reponse_authentication = -1;
+       options->challenge_response_authentication = -1;
        options->permit_empty_passwd = -1;
        options->use_login = -1;
        options->allow_tcp_forwarding = -1;
@@ -101,6 +101,9 @@ initialize_server_options(ServerOptions *options)
        options->reverse_mapping_check = -1;
        options->client_alive_interval = -1;
        options->client_alive_count_max = -1;
+       options->authorized_keys_file = NULL;
+       options->authorized_keys_file2 = NULL;
+       options->pam_authentication_via_kbd_int = -1;
 }
 
 void
@@ -143,10 +146,10 @@ fill_default_server_options(ServerOptions *options)
                options->x11_forwarding = 0;
        if (options->x11_display_offset == -1)
                options->x11_display_offset = 10;
-#ifdef XAUTH_PATH
+#ifdef _PATH_XAUTH
        if (options->xauth_location == NULL)
-               options->xauth_location = XAUTH_PATH;
-#endif /* XAUTH_PATH */
+               options->xauth_location = _PATH_XAUTH;
+#endif
        if (options->strict_modes == -1)
                options->strict_modes = 1;
        if (options->keepalives == -1)
@@ -185,8 +188,8 @@ fill_default_server_options(ServerOptions *options)
                options->password_authentication = 1;
        if (options->kbd_interactive_authentication == -1)
                options->kbd_interactive_authentication = 0;
-       if (options->challenge_reponse_authentication == -1)
-               options->challenge_reponse_authentication = 1;
+       if (options->challenge_response_authentication == -1)
+               options->challenge_response_authentication = 1;
        if (options->permit_empty_passwd == -1)
                options->permit_empty_passwd = 0;
        if (options->use_login == -1)
@@ -207,6 +210,12 @@ fill_default_server_options(ServerOptions *options)
                options->client_alive_interval = 0;  
        if (options->client_alive_count_max == -1)
                options->client_alive_count_max = 3;
+       if (options->authorized_keys_file == NULL)
+               options->authorized_keys_file = _PATH_SSH_USER_PERMITTED_KEYS;  
+       if (options->authorized_keys_file2 == NULL)
+               options->authorized_keys_file2 = _PATH_SSH_USER_PERMITTED_KEYS2;
+       if (options->pam_authentication_via_kbd_int == -1)
+               options->pam_authentication_via_kbd_int = 0;
 }
 
 /* Keyword tokens. */
@@ -232,7 +241,8 @@ typedef enum {
        sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, sMaxStartups,
        sBanner, sReverseMappingCheck, sHostbasedAuthentication,
        sHostbasedUsesNameFromPacketOnly, sClientAliveInterval, 
-       sClientAliveCountMax
+       sClientAliveCountMax, sAuthorizedKeysFile, sAuthorizedKeysFile2,
+       sPAMAuthenticationViaKbdInt
 } ServerOpCodes;
 
 /* Textual representation of the tokens. */
@@ -298,6 +308,9 @@ static struct {
        { "reversemappingcheck", sReverseMappingCheck },
        { "clientaliveinterval", sClientAliveInterval },
        { "clientalivecountmax", sClientAliveCountMax },
+       { "authorizedkeysfile", sAuthorizedKeysFile },
+       { "authorizedkeysfile2", sAuthorizedKeysFile2 },
+       { "PAMAuthenticationViaKbdInt", sPAMAuthenticationViaKbdInt },
        { NULL, 0 }
 };
 
@@ -315,12 +328,12 @@ parse_token(const char *cp, const char *filename,
                if (strcasecmp(cp, keywords[i].name) == 0)
                        return keywords[i].opcode;
 
-       fprintf(stderr, "%s: line %d: Bad configuration option: %s\n",
-               filename, linenum, cp);
+       error("%s: line %d: Bad configuration option: %s",
+           filename, linenum, cp);
        return sBadOption;
 }
 
-void
+static void
 add_listen_addr(ServerOptions *options, char *addr, u_short port)
 {
        int i;
@@ -334,7 +347,7 @@ add_listen_addr(ServerOptions *options, char *addr, u_short port)
                add_one_listen_addr(options, addr, port);
 }
 
-void
+static void
 add_one_listen_addr(ServerOptions *options, char *addr, u_short port)
 {
        struct addrinfo hints, *ai, *aitop;
@@ -397,7 +410,7 @@ read_server_config(ServerOptions *options, const char *filename)
                                continue;
                        if (options->listen_addrs != NULL)
                                fatal("%s line %d: ports must be specified before "
-                                   "ListenAdress.\n", filename, linenum);
+                                   "ListenAdress.", filename, linenum);
                        if (options->num_ports >= MAX_PORTS)
                                fatal("%s line %d: too many ports.",
                                    filename, linenum);
@@ -415,11 +428,9 @@ read_server_config(ServerOptions *options, const char *filename)
                        intptr = &options->server_key_bits;
 parse_int:
                        arg = strdelim(&cp);
-                       if (!arg || *arg == '\0') {
-                               fprintf(stderr, "%s line %d: missing integer value.\n",
-                                       filename, linenum);
-                               exit(1);
-                       }
+                       if (!arg || *arg == '\0')
+                               fatal("%s line %d: missing integer value.",
+                                   filename, linenum);
                        value = atoi(arg);
                        if (*intptr == -1)
                                *intptr = value;
@@ -427,11 +438,21 @@ parse_int:
 
                case sLoginGraceTime:
                        intptr = &options->login_grace_time;
-                       goto parse_int;
+parse_time:
+                       arg = strdelim(&cp);
+                       if (!arg || *arg == '\0')
+                               fatal("%s line %d: missing time value.",
+                                   filename, linenum);
+                       if ((value = convtime(arg)) == -1)
+                               fatal("%s line %d: invalid time value.",
+                                   filename, linenum);
+                       if (*intptr == -1)
+                               *intptr = value;
+                       break;
 
                case sKeyRegenerationTime:
                        intptr = &options->key_regeneration_time;
-                       goto parse_int;
+                       goto parse_time;
 
                case sListenAddress:
                        arg = strdelim(&cp);
@@ -472,20 +493,15 @@ parse_int:
 
                case sHostKeyFile:
                        intptr = &options->num_host_key_files;
-                       if (*intptr >= MAX_HOSTKEYS) {
-                               fprintf(stderr,
-                                   "%s line %d: too many host keys specified (max %d).\n",
+                       if (*intptr >= MAX_HOSTKEYS)
+                               fatal("%s line %d: too many host keys specified (max %d).",
                                    filename, linenum, MAX_HOSTKEYS);
-                               exit(1);
-                       }
                        charptr = &options->host_key_files[*intptr];
 parse_filename:
                        arg = strdelim(&cp);
-                       if (!arg || *arg == '\0') {
-                               fprintf(stderr, "%s line %d: missing file name.\n",
+                       if (!arg || *arg == '\0')
+                               fatal("%s line %d: missing file name.",
                                    filename, linenum);
-                               exit(1);
-                       }
                        if (*charptr == NULL) {
                                *charptr = tilde_expand_filename(arg, getuid());
                                /* increase optional counter */
@@ -501,12 +517,11 @@ parse_filename:
                case sPermitRootLogin:
                        intptr = &options->permit_root_login;
                        arg = strdelim(&cp);
-                       if (!arg || *arg == '\0') {
-                               fprintf(stderr, "%s line %d: missing yes/"
+                       if (!arg || *arg == '\0')
+                               fatal("%s line %d: missing yes/"
                                    "without-password/forced-commands-only/no "
-                                   "argument.\n", filename, linenum);
-                               exit(1);
-                       }
+                                   "argument.", filename, linenum);
+                       value = 0;      /* silence compiler */
                        if (strcmp(arg, "without-password") == 0)
                                value = PERMIT_NO_PASSWD;
                        else if (strcmp(arg, "forced-commands-only") == 0)
@@ -515,12 +530,10 @@ parse_filename:
                                value = PERMIT_YES;
                        else if (strcmp(arg, "no") == 0)
                                value = PERMIT_NO;
-                       else {
-                               fprintf(stderr, "%s line %d: Bad yes/"
+                       else
+                               fatal("%s line %d: Bad yes/"
                                    "without-password/forced-commands-only/no "
-                                   "argument: %s\n", filename, linenum, arg);
-                               exit(1);
-                       }
+                                   "argument: %s", filename, linenum, arg);
                        if (*intptr == -1)
                                *intptr = value;
                        break;
@@ -529,20 +542,17 @@ parse_filename:
                        intptr = &options->ignore_rhosts;
 parse_flag:
                        arg = strdelim(&cp);
-                       if (!arg || *arg == '\0') {
-                               fprintf(stderr, "%s line %d: missing yes/no argument.\n",
-                                       filename, linenum);
-                               exit(1);
-                       }
+                       if (!arg || *arg == '\0')
+                               fatal("%s line %d: missing yes/no argument.",
+                                   filename, linenum);
+                       value = 0;      /* silence compiler */
                        if (strcmp(arg, "yes") == 0)
                                value = 1;
                        else if (strcmp(arg, "no") == 0)
                                value = 0;
-                       else {
-                               fprintf(stderr, "%s line %d: Bad yes/no argument: %s\n",
+                       else
+                               fatal("%s line %d: Bad yes/no argument: %s",
                                        filename, linenum, arg);
-                               exit(1);
-                       }
                        if (*intptr == -1)
                                *intptr = value;
                        break;
@@ -612,7 +622,7 @@ parse_flag:
                        goto parse_flag;
 
                case sChallengeResponseAuthentication:
-                       intptr = &options->challenge_reponse_authentication;
+                       intptr = &options->challenge_response_authentication;
                        goto parse_flag;
 
                case sPrintMotd:
@@ -801,28 +811,41 @@ parse_flag:
                case sBanner:
                        charptr = &options->banner;
                        goto parse_filename;
+               /*
+                * These options can contain %X options expanded at
+                * connect time, so that you can specify paths like:
+                *
+                * AuthorizedKeysFile   /etc/ssh_keys/%u
+                */
+               case sAuthorizedKeysFile:
+               case sAuthorizedKeysFile2:
+                       charptr = (opcode == sAuthorizedKeysFile ) ?
+                           &options->authorized_keys_file :
+                           &options->authorized_keys_file2;
+                       goto parse_filename;
+
                case sClientAliveInterval:
                        intptr = &options->client_alive_interval;
-                       goto parse_int;
+                       goto parse_time;
+
                case sClientAliveCountMax:
                        intptr = &options->client_alive_count_max;
                        goto parse_int;
+
+               case sPAMAuthenticationViaKbdInt:
+                       intptr = &options->pam_authentication_via_kbd_int;
+                       goto parse_flag;
+
                default:
-                       fprintf(stderr, "%s line %d: Missing handler for opcode %s (%d)\n",
-                               filename, linenum, arg, opcode);
-                       exit(1);
-               }
-               if ((arg = strdelim(&cp)) != NULL && *arg != '\0') {
-                       fprintf(stderr,
-                               "%s line %d: garbage at end of line; \"%.200s\".\n",
-                               filename, linenum, arg);
-                       exit(1);
+                       fatal("%s line %d: Missing handler for opcode %s (%d)",
+                           filename, linenum, arg, opcode);
                }
+               if ((arg = strdelim(&cp)) != NULL && *arg != '\0')
+                       fatal("%s line %d: garbage at end of line; \"%.200s\".",
+                           filename, linenum, arg);
        }
        fclose(f);
-       if (bad_options > 0) {
-               fprintf(stderr, "%s: terminating, %d bad configuration options\n",
-                       filename, bad_options);
-               exit(1);
-       }
+       if (bad_options > 0)
+               fatal("%s: terminating, %d bad configuration options",
+                   filename, bad_options);
 }
This page took 0.05619 seconds and 4 git commands to generate.