]> andersk Git - openssh.git/blobdiff - servconf.c
- markus@cvs.openbsd.org 2001/03/23 14:28:32
[openssh.git] / servconf.c
index 5fa41e028e9dca4bbf3c98c1b99dd2bb7fc74406..075eed400e856bcfb2ea4b0e15fc8d282dce5e73 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: servconf.c,v 1.64 2001/02/03 10:08:37 markus Exp $");
+RCSID("$OpenBSD: servconf.c,v 1.71 2001/03/05 15:44:51 stevesk Exp $");
 
 #ifdef KRB4
 #include <krb.h>
@@ -28,6 +28,8 @@ RCSID("$OpenBSD: servconf.c,v 1.64 2001/02/03 10:08:37 markus Exp $");
 #include "tildexpand.h"
 #include "misc.h"
 #include "cipher.h"
+#include "kex.h"
+#include "mac.h"
 
 /* add listen address */
 void add_listen_addr(ServerOptions *options, char *addr);
@@ -49,7 +51,7 @@ initialize_server_options(ServerOptions *options)
        options->server_key_bits = -1;
        options->login_grace_time = -1;
        options->key_regeneration_time = -1;
-       options->permit_root_login = -1;
+       options->permit_root_login = PERMIT_NOT_SET;
        options->ignore_rhosts = -1;
        options->ignore_user_known_hosts = -1;
        options->print_motd = -1;
@@ -85,6 +87,7 @@ initialize_server_options(ServerOptions *options)
        options->num_allow_groups = 0;
        options->num_deny_groups = 0;
        options->ciphers = NULL;
+       options->macs = NULL;
        options->protocol = SSH_PROTO_UNKNOWN;
        options->gateway_ports = -1;
        options->num_subsystems = 0;
@@ -119,8 +122,8 @@ fill_default_server_options(ServerOptions *options)
                options->login_grace_time = 600;
        if (options->key_regeneration_time == -1)
                options->key_regeneration_time = 3600;
-       if (options->permit_root_login == -1)
-               options->permit_root_login = 1;                 /* yes */
+       if (options->permit_root_login == PERMIT_NOT_SET)
+               options->permit_root_login = PERMIT_YES;
        if (options->ignore_rhosts == -1)
                options->ignore_rhosts = 1;
        if (options->ignore_user_known_hosts == -1)
@@ -206,10 +209,10 @@ typedef enum {
        sChallengeResponseAuthentication,
        sPasswordAuthentication, sKbdInteractiveAuthentication, sListenAddress,
        sPrintMotd, sIgnoreRhosts, sX11Forwarding, sX11DisplayOffset,
-       sStrictModes, sEmptyPasswd, sRandomSeedFile, sKeepAlives, sCheckMail,
+       sStrictModes, sEmptyPasswd, sKeepAlives, sCheckMail,
        sUseLogin, sAllowTcpForwarding,
        sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
-       sIgnoreUserKnownHosts, sCiphers, sProtocol, sPidFile,
+       sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile,
        sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, sMaxStartups,
        sBanner, sReverseMappingCheck
 } ServerOpCodes;
@@ -222,7 +225,7 @@ static struct {
        { "port", sPort },
        { "hostkey", sHostKeyFile },
        { "hostdsakey", sHostKeyFile },                                 /* alias */
-       { "pidfile", sPidFile },
+       { "pidfile", sPidFile },
        { "serverkeybits", sServerKeyBits },
        { "logingracetime", sLoginGraceTime },
        { "keyregenerationinterval", sKeyRegenerationTime },
@@ -258,7 +261,6 @@ static struct {
        { "strictmodes", sStrictModes },
        { "permitemptypasswords", sEmptyPasswd },
        { "uselogin", sUseLogin },
-       { "randomseed", sRandomSeedFile },
        { "keepalive", sKeepAlives },
        { "allowtcpforwarding", sAllowTcpForwarding },
        { "allowusers", sAllowUsers },
@@ -266,6 +268,7 @@ static struct {
        { "allowgroups", sAllowGroups },
        { "denygroups", sDenyGroups },
        { "ciphers", sCiphers },
+       { "macs", sMacs },
        { "protocol", sProtocol },
        { "gatewayports", sGatewayPorts },
        { "subsystem", sSubsystem },
@@ -315,7 +318,7 @@ add_listen_addr(ServerOptions *options, char *addr)
                hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0;
                snprintf(strport, sizeof strport, "%d", options->ports[i]);
                if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0)
-                       fatal("bad addr or host: %s (%s)\n",
+                       fatal("bad addr or host: %s (%s)",
                            addr ? addr : "<NULL>",
                            gai_strerror(gaierr));
                for (ai = aitop; ai->ai_next; ai = ai->ai_next)
@@ -368,11 +371,11 @@ read_server_config(ServerOptions *options, const char *filename)
                                fatal("%s line %d: ports must be specified before "
                                    "ListenAdress.\n", filename, linenum);
                        if (options->num_ports >= MAX_PORTS)
-                               fatal("%s line %d: too many ports.\n",
+                               fatal("%s line %d: too many ports.",
                                    filename, linenum);
                        arg = strdelim(&cp);
                        if (!arg || *arg == '\0')
-                               fatal("%s line %d: missing port number.\n",
+                               fatal("%s line %d: missing port number.",
                                    filename, linenum);
                        options->ports[options->num_ports++] = atoi(arg);
                        break;
@@ -402,7 +405,7 @@ parse_int:
                case sListenAddress:
                        arg = strdelim(&cp);
                        if (!arg || *arg == '\0')
-                               fatal("%s line %d: missing inet addr.\n",
+                               fatal("%s line %d: missing inet addr.",
                                    filename, linenum);
                        add_listen_addr(options, arg);
                        break;
@@ -410,7 +413,8 @@ parse_int:
                case sHostKeyFile:
                        intptr = &options->num_host_key_files;
                        if (*intptr >= MAX_HOSTKEYS) {
-                               fprintf(stderr, "%s line %d: to many host keys specified (max %d).\n",
+                               fprintf(stderr,
+                                   "%s line %d: too many host keys specified (max %d).\n",
                                    filename, linenum, MAX_HOSTKEYS);
                                exit(1);
                        }
@@ -434,29 +438,27 @@ parse_filename:
                        charptr = &options->pid_file;
                        goto parse_filename;
 
-               case sRandomSeedFile:
-                       fprintf(stderr, "%s line %d: \"randomseed\" option is obsolete.\n",
-                               filename, linenum);
-                       arg = strdelim(&cp);
-                       break;
-
                case sPermitRootLogin:
                        intptr = &options->permit_root_login;
                        arg = strdelim(&cp);
                        if (!arg || *arg == '\0') {
-                               fprintf(stderr, "%s line %d: missing yes/without-password/no argument.\n",
-                                       filename, linenum);
+                               fprintf(stderr, "%s line %d: missing yes/"
+                                   "without-password/forced-commands-only/no "
+                                   "argument.\n", filename, linenum);
                                exit(1);
                        }
                        if (strcmp(arg, "without-password") == 0)
-                               value = 2;
+                               value = PERMIT_NO_PASSWD;
+                       else if (strcmp(arg, "forced-commands-only") == 0)
+                               value = PERMIT_FORCED_ONLY;
                        else if (strcmp(arg, "yes") == 0)
-                               value = 1;
+                               value = PERMIT_YES;
                        else if (strcmp(arg, "no") == 0)
-                               value = 0;
+                               value = PERMIT_NO;
                        else {
-                               fprintf(stderr, "%s line %d: Bad yes/without-password/no argument: %s\n",
-                                       filename, linenum, arg);
+                               fprintf(stderr, "%s line %d: Bad yes/"
+                                   "without-password/forced-commands-only/no "
+                                   "argument: %s\n", filename, linenum, arg);
                                exit(1);
                        }
                        if (*intptr == -1)
@@ -560,7 +562,7 @@ parse_flag:
                case sXAuthLocation:
                        charptr = &options->xauth_location;
                        goto parse_filename;
-                       
+
                case sStrictModes:
                        intptr = &options->strict_modes;
                        goto parse_flag;
@@ -590,7 +592,7 @@ parse_flag:
                        arg = strdelim(&cp);
                        value = log_facility_number(arg);
                        if (value == (SyslogFacility) - 1)
-                               fatal("%.200s line %d: unsupported log facility '%s'\n",
+                               fatal("%.200s line %d: unsupported log facility '%s'",
                                    filename, linenum, arg ? arg : "<NONE>");
                        if (*intptr == -1)
                                *intptr = (SyslogFacility) value;
@@ -601,7 +603,7 @@ parse_flag:
                        arg = strdelim(&cp);
                        value = log_level_number(arg);
                        if (value == (LogLevel) - 1)
-                               fatal("%.200s line %d: unsupported log level '%s'\n",
+                               fatal("%.200s line %d: unsupported log level '%s'",
                                    filename, linenum, arg ? arg : "<NONE>");
                        if (*intptr == -1)
                                *intptr = (LogLevel) value;
@@ -614,7 +616,7 @@ parse_flag:
                case sAllowUsers:
                        while ((arg = strdelim(&cp)) && *arg != '\0') {
                                if (options->num_allow_users >= MAX_ALLOW_USERS)
-                                       fatal("%s line %d: too many allow users.\n",
+                                       fatal("%s line %d: too many allow users.",
                                            filename, linenum);
                                options->allow_users[options->num_allow_users++] = xstrdup(arg);
                        }
@@ -623,7 +625,7 @@ parse_flag:
                case sDenyUsers:
                        while ((arg = strdelim(&cp)) && *arg != '\0') {
                                if (options->num_deny_users >= MAX_DENY_USERS)
-                                       fatal( "%s line %d: too many deny users.\n",
+                                       fatal( "%s line %d: too many deny users.",
                                            filename, linenum);
                                options->deny_users[options->num_deny_users++] = xstrdup(arg);
                        }
@@ -632,7 +634,7 @@ parse_flag:
                case sAllowGroups:
                        while ((arg = strdelim(&cp)) && *arg != '\0') {
                                if (options->num_allow_groups >= MAX_ALLOW_GROUPS)
-                                       fatal("%s line %d: too many allow groups.\n",
+                                       fatal("%s line %d: too many allow groups.",
                                            filename, linenum);
                                options->allow_groups[options->num_allow_groups++] = xstrdup(arg);
                        }
@@ -641,7 +643,7 @@ parse_flag:
                case sDenyGroups:
                        while ((arg = strdelim(&cp)) && *arg != '\0') {
                                if (options->num_deny_groups >= MAX_DENY_GROUPS)
-                                       fatal("%s line %d: too many deny groups.\n",
+                                       fatal("%s line %d: too many deny groups.",
                                            filename, linenum);
                                options->deny_groups[options->num_deny_groups++] = xstrdup(arg);
                        }
@@ -658,6 +660,17 @@ parse_flag:
                                options->ciphers = xstrdup(arg);
                        break;
 
+               case sMacs:
+                       arg = strdelim(&cp);
+                       if (!arg || *arg == '\0')
+                               fatal("%s line %d: Missing argument.", filename, linenum);
+                       if (!mac_valid(arg))
+                               fatal("%s line %d: Bad SSH2 mac spec '%s'.",
+                                   filename, linenum, arg ? arg : "<NONE>");
+                       if (options->macs == NULL)
+                               options->macs = xstrdup(arg);
+                       break;
+
                case sProtocol:
                        intptr = &options->protocol;
                        arg = strdelim(&cp);
@@ -716,14 +729,14 @@ parse_flag:
                case sBanner:
                        charptr = &options->banner;
                        goto parse_filename;
-                       
+
                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, 
+                       fprintf(stderr,
                                "%s line %d: garbage at end of line; \"%.200s\".\n",
                                filename, linenum, arg);
                        exit(1);
This page took 0.046226 seconds and 4 git commands to generate.