]> andersk Git - openssh.git/blobdiff - readconf.c
- (dtucker) [auth-pam.c scard-opensc.c] Tinderbox says auth-pam.c uses
[openssh.git] / readconf.c
index ce0d1f7532b20e78125bc84bab89b429cd9f50ef..f4710e833f39c87b60911c200a9b96bd6d96a007 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: readconf.c,v 1.128 2004/03/05 10:53:58 markus Exp $");
+RCSID("$OpenBSD: readconf.c,v 1.130 2004/04/27 09:46:36 djm Exp $");
 
 #include "ssh.h"
 #include "xmalloc.h"
@@ -106,6 +106,7 @@ typedef enum {
        oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,
        oAddressFamily, oGssAuthentication, oGssDelegateCreds,
        oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
+       oSendEnv,
        oDeprecated, oUnsupported
 } OpCodes;
 
@@ -193,6 +194,7 @@ static struct {
        { "addressfamily", oAddressFamily },
        { "serveraliveinterval", oServerAliveInterval },
        { "serveralivecountmax", oServerAliveCountMax },
+       { "sendenv", oSendEnv },
        { NULL, oBadOption }
 };
 
@@ -749,6 +751,19 @@ parse_int:
                intptr = &options->server_alive_count_max;
                goto parse_int;
 
+       case oSendEnv:
+               while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
+                       if (strchr(arg, '=') != NULL)
+                               fatal("%s line %d: Invalid environment name.",
+                                   filename, linenum);
+                       if (options->num_send_env >= MAX_SEND_ENV)
+                               fatal("%s line %d: too many send env.",
+                                   filename, linenum);
+                       options->send_env[options->num_send_env++] =
+                           xstrdup(arg);
+               }
+               break;
+
        case oDeprecated:
                debug("%s line %d: Deprecated option \"%s\"",
                    filename, linenum, keyword);
@@ -779,7 +794,8 @@ parse_int:
  */
 
 int
-read_config_file(const char *filename, const char *host, Options *options)
+read_config_file(const char *filename, const char *host, Options *options, 
+    int checkperm)
 {
        FILE *f;
        char line[1024];
@@ -787,10 +803,24 @@ read_config_file(const char *filename, const char *host, Options *options)
        int bad_options = 0;
 
        /* Open the file. */
-       f = fopen(filename, "r");
-       if (!f)
+       if ((f = fopen(filename, "r")) == NULL)
                return 0;
 
+       if (checkperm) {
+               struct stat sb;
+               
+               if (fstat(fileno(f), &sb) == -1) {
+                       fatal("fstat %s: %s", filename, strerror(errno));
+                       fclose(f);
+                       return (0);
+               }
+               if (((sb.st_uid != 0 && sb.st_uid != getuid()) ||
+                   (sb.st_mode & 022) != 0)) {
+                       fatal("Bad owner or permissions on %s", filename);
+                       return 0;
+               }
+       }
+
        debug("Reading configuration data %.200s", filename);
 
        /*
@@ -879,6 +909,7 @@ initialize_options(Options * options)
        options->verify_host_key_dns = -1;
        options->server_alive_interval = -1;
        options->server_alive_count_max = -1;
+       options->num_send_env = 0;
 }
 
 /*
This page took 0.038561 seconds and 4 git commands to generate.