]> andersk Git - openssh.git/blobdiff - servconf.c
- djm@cvs.openbsd.org 2010/01/30 02:54:53
[openssh.git] / servconf.c
index 659a1eb21b319853ca2bda615c7de65cccd0f56e..09296c9cfa3a0a4456833374ceeb33b0d58f2aaf 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: servconf.c,v 1.192 2008/11/11 02:58:09 stevesk Exp $ */
+/* $OpenBSD: servconf.c,v 1.202 2010/01/13 03:48:12 djm Exp $ */
 /*
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
  *                    All rights reserved
@@ -42,8 +42,8 @@
 #include "channels.h"
 #include "groupaccess.h"
 
-static void add_listen_addr(ServerOptions *, char *, u_short);
-static void add_one_listen_addr(ServerOptions *, char *, u_short);
+static void add_listen_addr(ServerOptions *, char *, int);
+static void add_one_listen_addr(ServerOptions *, char *, int);
 
 /* Use of privilege separation or not */
 extern int use_privsep;
@@ -139,7 +139,7 @@ fill_default_server_options(ServerOptions *options)
 
        /* Standard Options */
        if (options->protocol == SSH_PROTO_UNKNOWN)
-               options->protocol = SSH_PROTO_1|SSH_PROTO_2;
+               options->protocol = SSH_PROTO_2;
        if (options->num_host_key_files == 0) {
                /* fill default hostkeys for protocols */
                if (options->protocol & SSH_PROTO_1)
@@ -343,7 +343,7 @@ static struct {
        { "hostbasedusesnamefrompacketonly", sHostbasedUsesNameFromPacketOnly, SSHCFG_GLOBAL },
        { "rsaauthentication", sRSAAuthentication, SSHCFG_ALL },
        { "pubkeyauthentication", sPubkeyAuthentication, SSHCFG_ALL },
-       { "dsaauthentication", sPubkeyAuthentication, SSHCFG_GLOBAL },  /* alias */
+       { "dsaauthentication", sPubkeyAuthentication, SSHCFG_GLOBAL }, /* alias */
 #ifdef KRB5
        { "kerberosauthentication", sKerberosAuthentication, SSHCFG_ALL },
        { "kerberosorlocalpasswd", sKerberosOrLocalPasswd, SSHCFG_GLOBAL },
@@ -417,10 +417,10 @@ static struct {
        { "clientalivecountmax", sClientAliveCountMax, SSHCFG_GLOBAL },
        { "authorizedkeysfile", sAuthorizedKeysFile, SSHCFG_GLOBAL },
        { "authorizedkeysfile2", sAuthorizedKeysFile2, SSHCFG_GLOBAL },
-       { "useprivilegeseparation", sUsePrivilegeSeparation, SSHCFG_GLOBAL },
+       { "useprivilegeseparation", sUsePrivilegeSeparation, SSHCFG_GLOBAL},
        { "acceptenv", sAcceptEnv, SSHCFG_GLOBAL },
        { "permittunnel", sPermitTunnel, SSHCFG_GLOBAL },
-       { "match", sMatch, SSHCFG_ALL },
+       { "match", sMatch, SSHCFG_ALL },
        { "permitopen", sPermitOpen, SSHCFG_ALL },
        { "forcecommand", sForceCommand, SSHCFG_ALL },
        { "chrootdirectory", sChrootDirectory, SSHCFG_ALL },
@@ -459,8 +459,24 @@ parse_token(const char *cp, const char *filename,
        return sBadOption;
 }
 
+char *
+derelativise_path(const char *path)
+{
+       char *expanded, *ret, *cwd;
+
+       expanded = tilde_expand_filename(path, getuid());
+       if (*expanded == '/')
+               return expanded;
+       if ((cwd = getcwd(NULL, 0)) == NULL)
+               fatal("%s: getcwd: %s", __func__, strerror(errno));
+       xasprintf(&ret, "%s/%s", cwd, expanded);
+       xfree(cwd);
+       xfree(expanded);
+       return ret;
+}
+
 static void
-add_listen_addr(ServerOptions *options, char *addr, u_short port)
+add_listen_addr(ServerOptions *options, char *addr, int port)
 {
        u_int i;
 
@@ -476,7 +492,7 @@ add_listen_addr(ServerOptions *options, char *addr, u_short port)
 }
 
 static void
-add_one_listen_addr(ServerOptions *options, char *addr, u_short port)
+add_one_listen_addr(ServerOptions *options, char *addr, int port)
 {
        struct addrinfo hints, *ai, *aitop;
        char strport[NI_MAXSERV];
@@ -486,7 +502,7 @@ add_one_listen_addr(ServerOptions *options, char *addr, u_short port)
        hints.ai_family = options->address_family;
        hints.ai_socktype = SOCK_STREAM;
        hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0;
-       snprintf(strport, sizeof strport, "%u", port);
+       snprintf(strport, sizeof strport, "%d", port);
        if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0)
                fatal("bad addr or host: %s (%s)",
                    addr ? addr : "<NULL>",
@@ -642,7 +658,7 @@ process_server_config_line(ServerOptions *options, char *line,
        SyslogFacility *log_facility_ptr;
        LogLevel *log_level_ptr;
        ServerOpCodes opcode;
-       u_short port;
+       int port;
        u_int i, flags = 0;
        size_t len;
 
@@ -699,7 +715,7 @@ process_server_config_line(ServerOptions *options, char *line,
                        fatal("%s line %d: missing port number.",
                            filename, linenum);
                options->ports[options->num_ports++] = a2port(arg);
-               if (options->ports[options->num_ports-1] == 0)
+               if (options->ports[options->num_ports-1] <= 0)
                        fatal("%s line %d: Badly formatted port number.",
                            filename, linenum);
                break;
@@ -752,7 +768,7 @@ process_server_config_line(ServerOptions *options, char *line,
                p = cleanhostname(p);
                if (arg == NULL)
                        port = 0;
-               else if ((port = a2port(arg)) == 0)
+               else if ((port = a2port(arg)) <= 0)
                        fatal("%s line %d: bad port number", filename, linenum);
 
                add_listen_addr(options, p, port);
@@ -793,7 +809,7 @@ process_server_config_line(ServerOptions *options, char *line,
                        fatal("%s line %d: missing file name.",
                            filename, linenum);
                if (*activep && *charptr == NULL) {
-                       *charptr = tilde_expand_filename(arg, getuid());
+                       *charptr = derelativise_path(arg);
                        /* increase optional counter */
                        if (intptr != NULL)
                                *intptr = *intptr + 1;
@@ -1265,7 +1281,7 @@ process_server_config_line(ServerOptions *options, char *line,
                                fatal("%s line %d: missing host in PermitOpen",
                                    filename, linenum);
                        p = cleanhostname(p);
-                       if (arg == NULL || (port = a2port(arg)) == 0)
+                       if (arg == NULL || (port = a2port(arg)) <= 0)
                                fatal("%s line %d: bad port number in "
                                    "PermitOpen", filename, linenum);
                        if (*activep && n == -1)
@@ -1376,7 +1392,7 @@ parse_server_match_config(ServerOptions *options, const char *user,
 /*
  * Copy any supported values that are set.
  *
- * If the preauth flag is set, we do not bother copying the the string or
+ * If the preauth flag is set, we do not bother copying the string or
  * array values that are not used pre-authentication, because any that we
  * do use must be explictly sent in mm_getpwnamallow().
  */
@@ -1626,6 +1642,7 @@ dump_config(ServerOptions *o)
        dump_cfg_string(sAuthorizedKeysFile, o->authorized_keys_file);
        dump_cfg_string(sAuthorizedKeysFile2, o->authorized_keys_file2);
        dump_cfg_string(sForceCommand, o->adm_forced_command);
+       dump_cfg_string(sChrootDirectory, o->chroot_directory);
 
        /* string arguments requiring a lookup */
        dump_cfg_string(sLogLevel, log_level_name(o->log_level));
@@ -1655,7 +1672,5 @@ dump_config(ServerOptions *o)
                }
        dump_cfg_string(sPermitTunnel, s);
 
-       printf("permitopen");
        channel_print_adm_permitted_opens();
-       printf("\n");
 }
This page took 0.107021 seconds and 4 git commands to generate.