]> andersk Git - openssh.git/blobdiff - servconf.c
- deraadt@cvs.openbsd.org 2002/05/22 23:18:25
[openssh.git] / servconf.c
index 0f0a7396b3749992e1b6711dbdf0c7786b896b33..7a776ac8e8a797a7a5134a72e62eaac42dfa6833 100644 (file)
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: servconf.c,v 1.94 2001/12/06 13:30:05 markus Exp $");
+RCSID("$OpenBSD: servconf.c,v 1.110 2002/05/15 21:56:38 markus Exp $");
 
-#if defined(KRB4) || defined(KRB5)
+#if defined(KRB4)
+#include <krb.h>
+#endif
+#if defined(KRB5)
+#ifdef HEIMDAL
 #include <krb.h>
+#else
+/* Bodge - but then, so is using the kerberos IV KEYFILE to get a Kerberos V
+ * keytab */
+#define KEYFILE "/etc/krb5.keytab"
+#endif
 #endif
 #ifdef AFS
 #include <kafs.h>
@@ -36,6 +45,8 @@ static void add_one_listen_addr(ServerOptions *, char *, u_short);
 
 /* AF_UNSPEC or AF_INET or AF_INET6 */
 extern int IPv4or6;
+/* Use of privilege separation or not */
+extern int use_privsep;
 
 /* Initializes the server options to their default values. */
 
@@ -63,11 +74,12 @@ initialize_server_options(ServerOptions *options)
        options->print_lastlog = -1;
        options->x11_forwarding = -1;
        options->x11_display_offset = -1;
+       options->x11_use_localhost = -1;
        options->xauth_location = NULL;
        options->strict_modes = -1;
        options->keepalives = -1;
-       options->log_facility = (SyslogFacility) - 1;
-       options->log_level = (LogLevel) - 1;
+       options->log_facility = SYSLOG_FACILITY_NOT_SET;
+       options->log_level = SYSLOG_LEVEL_NOT_SET;
        options->rhosts_authentication = -1;
        options->rhosts_rsa_authentication = -1;
        options->hostbased_authentication = -1;
@@ -104,11 +116,14 @@ initialize_server_options(ServerOptions *options)
        options->max_startups_rate = -1;
        options->max_startups = -1;
        options->banner = NULL;
-       options->reverse_mapping_check = -1;
+       options->verify_reverse_mapping = -1;
        options->client_alive_interval = -1;
        options->client_alive_count_max = -1;
        options->authorized_keys_file = NULL;
        options->authorized_keys_file2 = NULL;
+
+       /* Needs to be accessable in many places */
+       use_privsep = -1;
 }
 
 void
@@ -124,9 +139,14 @@ fill_default_server_options(ServerOptions *options)
        if (options->num_host_key_files == 0) {
                /* fill default hostkeys for protocols */
                if (options->protocol & SSH_PROTO_1)
-                       options->host_key_files[options->num_host_key_files++] = _PATH_HOST_KEY_FILE;
-               if (options->protocol & SSH_PROTO_2)
-                       options->host_key_files[options->num_host_key_files++] = _PATH_HOST_DSA_KEY_FILE;
+                       options->host_key_files[options->num_host_key_files++] =
+                           _PATH_HOST_KEY_FILE;
+               if (options->protocol & SSH_PROTO_2) {
+                       options->host_key_files[options->num_host_key_files++] =
+                           _PATH_HOST_RSA_KEY_FILE;
+                       options->host_key_files[options->num_host_key_files++] =
+                           _PATH_HOST_DSA_KEY_FILE;
+               }
        }
        if (options->num_ports == 0)
                options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
@@ -154,17 +174,17 @@ fill_default_server_options(ServerOptions *options)
                options->x11_forwarding = 0;
        if (options->x11_display_offset == -1)
                options->x11_display_offset = 10;
-#ifdef _PATH_XAUTH
+       if (options->x11_use_localhost == -1)
+               options->x11_use_localhost = 1;
        if (options->xauth_location == NULL)
                options->xauth_location = _PATH_XAUTH;
-#endif
        if (options->strict_modes == -1)
                options->strict_modes = 1;
        if (options->keepalives == -1)
                options->keepalives = 1;
-       if (options->log_facility == (SyslogFacility) (-1))
+       if (options->log_facility == SYSLOG_FACILITY_NOT_SET)
                options->log_facility = SYSLOG_FACILITY_AUTH;
-       if (options->log_level == (LogLevel) (-1))
+       if (options->log_level == SYSLOG_LEVEL_NOT_SET)
                options->log_level = SYSLOG_LEVEL_INFO;
        if (options->rhosts_authentication == -1)
                options->rhosts_authentication = 0;
@@ -180,7 +200,7 @@ fill_default_server_options(ServerOptions *options)
                options->pubkey_authentication = 1;
 #if defined(KRB4) || defined(KRB5)
        if (options->kerberos_authentication == -1)
-               options->kerberos_authentication = (access(KEYFILE, R_OK) == 0);
+               options->kerberos_authentication = 0;
        if (options->kerberos_or_local_passwd == -1)
                options->kerberos_or_local_passwd = 1;
        if (options->kerberos_ticket_cleanup == -1)
@@ -190,9 +210,9 @@ fill_default_server_options(ServerOptions *options)
        if (options->kerberos_tgt_passing == -1)
                options->kerberos_tgt_passing = 0;
 #endif
-#ifdef AFS     
+#ifdef AFS
        if (options->afs_token_passing == -1)
-               options->afs_token_passing = k_hasafs();
+               options->afs_token_passing = 0;
 #endif
        if (options->password_authentication == -1)
                options->password_authentication = 1;
@@ -214,10 +234,10 @@ fill_default_server_options(ServerOptions *options)
                options->max_startups_rate = 100;               /* 100% */
        if (options->max_startups_begin == -1)
                options->max_startups_begin = options->max_startups;
-       if (options->reverse_mapping_check == -1)
-               options->reverse_mapping_check = 0;
+       if (options->verify_reverse_mapping == -1)
+               options->verify_reverse_mapping = 0;
        if (options->client_alive_interval == -1)
-               options->client_alive_interval = 0;  
+               options->client_alive_interval = 0;
        if (options->client_alive_count_max == -1)
                options->client_alive_count_max = 3;
        if (options->authorized_keys_file2 == NULL) {
@@ -229,6 +249,10 @@ fill_default_server_options(ServerOptions *options)
        }
        if (options->authorized_keys_file == NULL)
                options->authorized_keys_file = _PATH_SSH_USER_PERMITTED_KEYS;
+
+       /* Turn privilege separation on by default */
+       if (use_privsep == -1)
+               use_privsep = 1;
 }
 
 /* Keyword tokens. */
@@ -252,15 +276,16 @@ typedef enum {
        sChallengeResponseAuthentication,
        sPasswordAuthentication, sKbdInteractiveAuthentication, sListenAddress,
        sPrintMotd, sPrintLastLog, sIgnoreRhosts,
-       sX11Forwarding, sX11DisplayOffset,
+       sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost,
        sStrictModes, sEmptyPasswd, sKeepAlives,
        sUseLogin, sAllowTcpForwarding,
        sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
        sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile,
        sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, sMaxStartups,
-       sBanner, sReverseMappingCheck, sHostbasedAuthentication,
-       sHostbasedUsesNameFromPacketOnly, sClientAliveInterval, 
+       sBanner, sVerifyReverseMapping, sHostbasedAuthentication,
+       sHostbasedUsesNameFromPacketOnly, sClientAliveInterval,
        sClientAliveCountMax, sAuthorizedKeysFile, sAuthorizedKeysFile2,
+       sUsePrivilegeSeparation,
        sDeprecated
 } ServerOpCodes;
 
@@ -312,6 +337,7 @@ static struct {
        { "ignoreuserknownhosts", sIgnoreUserKnownHosts },
        { "x11forwarding", sX11Forwarding },
        { "x11displayoffset", sX11DisplayOffset },
+       { "x11uselocalhost", sX11UseLocalhost },
        { "xauthlocation", sXAuthLocation },
        { "strictmodes", sStrictModes },
        { "permitemptypasswords", sEmptyPasswd },
@@ -329,11 +355,13 @@ static struct {
        { "subsystem", sSubsystem },
        { "maxstartups", sMaxStartups },
        { "banner", sBanner },
-       { "reversemappingcheck", sReverseMappingCheck },
+       { "verifyreversemapping", sVerifyReverseMapping },
+       { "reversemappingcheck", sVerifyReverseMapping },
        { "clientaliveinterval", sClientAliveInterval },
        { "clientalivecountmax", sClientAliveCountMax },
        { "authorizedkeysfile", sAuthorizedKeysFile },
        { "authorizedkeysfile2", sAuthorizedKeysFile2 },
+       { "useprivilegeseparation", sUsePrivilegeSeparation},
        { NULL, sBadOption }
 };
 
@@ -426,7 +454,7 @@ process_server_config_line(ServerOptions *options, char *line,
                        return 0;
                if (options->listen_addrs != NULL)
                        fatal("%s line %d: ports must be specified before "
-                           "ListenAdress.", filename, linenum);
+                           "ListenAddress.", filename, linenum);
                if (options->num_ports >= MAX_PORTS)
                        fatal("%s line %d: too many ports.",
                            filename, linenum);
@@ -652,6 +680,10 @@ parse_flag:
                intptr = &options->x11_display_offset;
                goto parse_int;
 
+       case sX11UseLocalhost:
+               intptr = &options->x11_use_localhost;
+               goto parse_flag;
+
        case sXAuthLocation:
                charptr = &options->xauth_location;
                goto parse_filename;
@@ -676,15 +708,15 @@ parse_flag:
                intptr = &options->gateway_ports;
                goto parse_flag;
 
-       case sReverseMappingCheck:
-               intptr = &options->reverse_mapping_check;
+       case sVerifyReverseMapping:
+               intptr = &options->verify_reverse_mapping;
                goto parse_flag;
 
        case sLogFacility:
                intptr = (int *) &options->log_facility;
                arg = strdelim(&cp);
                value = log_facility_number(arg);
-               if (value == (SyslogFacility) - 1)
+               if (value == SYSLOG_FACILITY_NOT_SET)
                        fatal("%.200s line %d: unsupported log facility '%s'",
                            filename, linenum, arg ? arg : "<NONE>");
                if (*intptr == -1)
@@ -695,7 +727,7 @@ parse_flag:
                intptr = (int *) &options->log_level;
                arg = strdelim(&cp);
                value = log_level_number(arg);
-               if (value == (LogLevel) - 1)
+               if (value == SYSLOG_LEVEL_NOT_SET)
                        fatal("%.200s line %d: unsupported log level '%s'",
                            filename, linenum, arg ? arg : "<NONE>");
                if (*intptr == -1)
@@ -706,6 +738,10 @@ parse_flag:
                intptr = &options->allow_tcp_forwarding;
                goto parse_flag;
 
+       case sUsePrivilegeSeparation:
+               intptr = &use_privsep;
+               goto parse_flag;
+
        case sAllowUsers:
                while ((arg = strdelim(&cp)) && *arg != '\0') {
                        if (options->num_allow_users >= MAX_ALLOW_USERS)
@@ -772,7 +808,7 @@ parse_flag:
                value = proto_spec(arg);
                if (value == SSH_PROTO_UNKNOWN)
                        fatal("%s line %d: Bad protocol spec '%s'.",
-                             filename, linenum, arg ? arg : "<NONE>");
+                           filename, linenum, arg ? arg : "<NONE>");
                if (*intptr == SSH_PROTO_UNKNOWN)
                        *intptr = value;
                break;
@@ -780,21 +816,21 @@ parse_flag:
        case sSubsystem:
                if (options->num_subsystems >= MAX_SUBSYSTEMS) {
                        fatal("%s line %d: too many subsystems defined.",
-                             filename, linenum);
+                           filename, linenum);
                }
                arg = strdelim(&cp);
                if (!arg || *arg == '\0')
                        fatal("%s line %d: Missing subsystem name.",
-                             filename, linenum);
+                           filename, linenum);
                for (i = 0; i < options->num_subsystems; i++)
                        if (strcmp(arg, options->subsystem_name[i]) == 0)
                                fatal("%s line %d: Subsystem '%s' already defined.",
-                                     filename, linenum, arg);
+                                   filename, linenum, arg);
                options->subsystem_name[options->num_subsystems] = xstrdup(arg);
                arg = strdelim(&cp);
                if (!arg || *arg == '\0')
                        fatal("%s line %d: Missing subsystem command.",
-                             filename, linenum);
+                           filename, linenum);
                options->subsystem_command[options->num_subsystems] = xstrdup(arg);
                options->num_subsystems++;
                break;
@@ -803,7 +839,7 @@ parse_flag:
                arg = strdelim(&cp);
                if (!arg || *arg == '\0')
                        fatal("%s line %d: Missing MaxStartups spec.",
-                             filename, linenum);
+                           filename, linenum);
                if ((n = sscanf(arg, "%d:%d:%d",
                    &options->max_startups_begin,
                    &options->max_startups_rate,
This page took 0.056154 seconds and 4 git commands to generate.