]> andersk Git - openssh.git/blobdiff - servconf.c
- (djm) Make portable build with MIT krb5 (some issues remain)
[openssh.git] / servconf.c
index e772cd46b5fac6084a2f01027c67352d98f4f6c9..8e2839085b08a4be114a0cfbe19711b289014be5 100644 (file)
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: servconf.c,v 1.96 2002/01/04 17:59:17 stevesk Exp $");
+RCSID("$OpenBSD: servconf.c,v 1.118 2003/04/09 08:23:52 hin Exp $");
 
-#if defined(KRB4) || defined(KRB5)
+#if defined(KRB4)
 #include <krb.h>
 #endif
+
+#if defined(KRB5)
+# ifdef HEIMDAL
+#  include <krb.h>
+# else
+/*
+ * XXX: 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>
 #endif
@@ -36,6 +49,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 +78,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;
@@ -89,7 +105,9 @@ initialize_server_options(ServerOptions *options)
        options->kbd_interactive_authentication = -1;
        options->challenge_response_authentication = -1;
        options->permit_empty_passwd = -1;
+       options->permit_user_env = -1;
        options->use_login = -1;
+       options->compression = -1;
        options->allow_tcp_forwarding = -1;
        options->num_allow_users = 0;
        options->num_deny_users = 0;
@@ -104,11 +122,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 +145,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;
@@ -137,7 +163,7 @@ fill_default_server_options(ServerOptions *options)
        if (options->server_key_bits == -1)
                options->server_key_bits = 768;
        if (options->login_grace_time == -1)
-               options->login_grace_time = 600;
+               options->login_grace_time = 120;
        if (options->key_regeneration_time == -1)
                options->key_regeneration_time = 3600;
        if (options->permit_root_login == PERMIT_NOT_SET)
@@ -154,15 +180,17 @@ fill_default_server_options(ServerOptions *options)
                options->x11_forwarding = 0;
        if (options->x11_display_offset == -1)
                options->x11_display_offset = 10;
+       if (options->x11_use_localhost == -1)
+               options->x11_use_localhost = 1;
        if (options->xauth_location == NULL)
                options->xauth_location = _PATH_XAUTH;
        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;
@@ -178,7 +206,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,7 +218,7 @@ fill_default_server_options(ServerOptions *options)
 #endif
 #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;
@@ -200,8 +228,12 @@ fill_default_server_options(ServerOptions *options)
                options->challenge_response_authentication = 1;
        if (options->permit_empty_passwd == -1)
                options->permit_empty_passwd = 0;
+       if (options->permit_user_env == -1)
+               options->permit_user_env = 0;
        if (options->use_login == -1)
                options->use_login = 0;
+       if (options->compression == -1)
+               options->compression = 1;
        if (options->allow_tcp_forwarding == -1)
                options->allow_tcp_forwarding = 1;
        if (options->gateway_ports == -1)
@@ -212,8 +244,8 @@ 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;
        if (options->client_alive_count_max == -1)
@@ -227,6 +259,20 @@ 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;
+
+#ifndef HAVE_MMAP
+       if (use_privsep && options->compression == 1) {
+               error("This platform does not support both privilege "
+                   "separation and compression");
+               error("Compression disabled");
+               options->compression = 0;
+       }
+#endif
+
 }
 
 /* Keyword tokens. */
@@ -250,15 +296,16 @@ typedef enum {
        sChallengeResponseAuthentication,
        sPasswordAuthentication, sKbdInteractiveAuthentication, sListenAddress,
        sPrintMotd, sPrintLastLog, sIgnoreRhosts,
-       sX11Forwarding, sX11DisplayOffset,
+       sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost,
        sStrictModes, sEmptyPasswd, sKeepAlives,
-       sUseLogin, sAllowTcpForwarding,
+       sPermitUserEnvironment, sUseLogin, sAllowTcpForwarding, sCompression,
        sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
        sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile,
        sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, sMaxStartups,
-       sBanner, sReverseMappingCheck, sHostbasedAuthentication,
+       sBanner, sVerifyReverseMapping, sHostbasedAuthentication,
        sHostbasedUsesNameFromPacketOnly, sClientAliveInterval,
        sClientAliveCountMax, sAuthorizedKeysFile, sAuthorizedKeysFile2,
+       sUsePrivilegeSeparation,
        sDeprecated
 } ServerOpCodes;
 
@@ -310,10 +357,13 @@ static struct {
        { "ignoreuserknownhosts", sIgnoreUserKnownHosts },
        { "x11forwarding", sX11Forwarding },
        { "x11displayoffset", sX11DisplayOffset },
+       { "x11uselocalhost", sX11UseLocalhost },
        { "xauthlocation", sXAuthLocation },
        { "strictmodes", sStrictModes },
        { "permitemptypasswords", sEmptyPasswd },
+       { "permituserenvironment", sPermitUserEnvironment },
        { "uselogin", sUseLogin },
+       { "compression", sCompression },
        { "keepalive", sKeepAlives },
        { "allowtcpforwarding", sAllowTcpForwarding },
        { "allowusers", sAllowUsers },
@@ -327,11 +377,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 }
 };
 
@@ -379,7 +431,7 @@ add_one_listen_addr(ServerOptions *options, char *addr, u_short port)
        hints.ai_family = IPv4or6;
        hints.ai_socktype = SOCK_STREAM;
        hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0;
-       snprintf(strport, sizeof strport, "%d", port);
+       snprintf(strport, sizeof strport, "%u", port);
        if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0)
                fatal("bad addr or host: %s (%s)",
                    addr ? addr : "<NULL>",
@@ -395,9 +447,8 @@ process_server_config_line(ServerOptions *options, char *line,
     const char *filename, int linenum)
 {
        char *cp, **charptr, *arg, *p;
-       int *intptr, value;
+       int *intptr, value, i, n;
        ServerOpCodes opcode;
-       int i, n;
 
        cp = line;
        arg = strdelim(&cp);
@@ -424,7 +475,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);
@@ -650,6 +701,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;
@@ -666,23 +721,31 @@ parse_flag:
                intptr = &options->permit_empty_passwd;
                goto parse_flag;
 
+       case sPermitUserEnvironment:
+               intptr = &options->permit_user_env;
+               goto parse_flag;
+
        case sUseLogin:
                intptr = &options->use_login;
                goto parse_flag;
 
+       case sCompression:
+               intptr = &options->compression;
+               goto parse_flag;
+
        case sGatewayPorts:
                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)
@@ -693,7 +756,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)
@@ -704,12 +767,17 @@ 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)
                                fatal("%s line %d: too many allow users.",
                                    filename, linenum);
-                       options->allow_users[options->num_allow_users++] = xstrdup(arg);
+                       options->allow_users[options->num_allow_users++] =
+                           xstrdup(arg);
                }
                break;
 
@@ -718,7 +786,8 @@ parse_flag:
                        if (options->num_deny_users >= MAX_DENY_USERS)
                                fatal( "%s line %d: too many deny users.",
                                    filename, linenum);
-                       options->deny_users[options->num_deny_users++] = xstrdup(arg);
+                       options->deny_users[options->num_deny_users++] =
+                           xstrdup(arg);
                }
                break;
 
@@ -727,7 +796,8 @@ parse_flag:
                        if (options->num_allow_groups >= MAX_ALLOW_GROUPS)
                                fatal("%s line %d: too many allow groups.",
                                    filename, linenum);
-                       options->allow_groups[options->num_allow_groups++] = xstrdup(arg);
+                       options->allow_groups[options->num_allow_groups++] =
+                           xstrdup(arg);
                }
                break;
 
@@ -844,7 +914,7 @@ parse_flag:
                goto parse_int;
 
        case sDeprecated:
-               log("%s line %d: Deprecated option %s",
+               logit("%s line %d: Deprecated option %s",
                    filename, linenum, arg);
                while (arg)
                    arg = strdelim(&cp);
@@ -865,11 +935,11 @@ parse_flag:
 void
 read_server_config(ServerOptions *options, const char *filename)
 {
-       FILE *f;
+       int linenum, bad_options = 0;
        char line[1024];
-       int linenum;
-       int bad_options = 0;
+       FILE *f;
 
+       debug2("read_server_config: filename %s", filename);
        f = fopen(filename, "r");
        if (!f) {
                perror(filename);
This page took 0.174956 seconds and 4 git commands to generate.