summaryrefslogtreecommitdiff
path: root/readconf.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2005-01-04 13:07:27 +0000
committerColin Watson <cjwatson@debian.org>2005-01-04 13:07:27 +0000
commitfd0f611b70a83d80fe8793af785542ee5541b7cd (patch)
treebededd22bb7eeec52e20083237ab7e4113445a16 /readconf.c
parentc44fe9a5b9d3db96a7249b04d915f17e4a3a3b04 (diff)
parentebd2ce335af5861020c79fddb1ae35c03bf036cf (diff)
Merge 3.9p1 to the trunk.
Diffstat (limited to 'readconf.c')
-rw-r--r--readconf.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/readconf.c b/readconf.c
index 2b8ff58d6..aca5b8eff 100644
--- a/readconf.c
+++ b/readconf.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: readconf.c,v 1.128 2004/03/05 10:53:58 markus Exp $"); 15RCSID("$OpenBSD: readconf.c,v 1.134 2004/07/11 17:48:47 deraadt Exp $");
16 16
17#include "ssh.h" 17#include "ssh.h"
18#include "xmalloc.h" 18#include "xmalloc.h"
@@ -106,6 +106,7 @@ typedef enum {
106 oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout, 106 oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,
107 oAddressFamily, oGssAuthentication, oGssDelegateCreds, 107 oAddressFamily, oGssAuthentication, oGssDelegateCreds,
108 oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly, 108 oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
109 oSendEnv, oControlPath, oControlMaster,
109 oProtocolKeepAlives, oSetupTimeOut, 110 oProtocolKeepAlives, oSetupTimeOut,
110 oDeprecated, oUnsupported 111 oDeprecated, oUnsupported
111} OpCodes; 112} OpCodes;
@@ -194,6 +195,9 @@ static struct {
194 { "addressfamily", oAddressFamily }, 195 { "addressfamily", oAddressFamily },
195 { "serveraliveinterval", oServerAliveInterval }, 196 { "serveraliveinterval", oServerAliveInterval },
196 { "serveralivecountmax", oServerAliveCountMax }, 197 { "serveralivecountmax", oServerAliveCountMax },
198 { "sendenv", oSendEnv },
199 { "controlpath", oControlPath },
200 { "controlmaster", oControlMaster },
197 { "protocolkeepalives", oProtocolKeepAlives }, 201 { "protocolkeepalives", oProtocolKeepAlives },
198 { "setuptimeout", oSetupTimeOut }, 202 { "setuptimeout", oSetupTimeOut },
199 { NULL, oBadOption } 203 { NULL, oBadOption }
@@ -753,6 +757,27 @@ parse_int:
753 intptr = &options->server_alive_count_max; 757 intptr = &options->server_alive_count_max;
754 goto parse_int; 758 goto parse_int;
755 759
760 case oSendEnv:
761 while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
762 if (strchr(arg, '=') != NULL)
763 fatal("%s line %d: Invalid environment name.",
764 filename, linenum);
765 if (options->num_send_env >= MAX_SEND_ENV)
766 fatal("%s line %d: too many send env.",
767 filename, linenum);
768 options->send_env[options->num_send_env++] =
769 xstrdup(arg);
770 }
771 break;
772
773 case oControlPath:
774 charptr = &options->control_path;
775 goto parse_string;
776
777 case oControlMaster:
778 intptr = &options->control_master;
779 goto parse_yesnoask;
780
756 case oSetupTimeOut: 781 case oSetupTimeOut:
757 intptr = &options->setuptimeout; 782 intptr = &options->setuptimeout;
758 goto parse_int; 783 goto parse_int;
@@ -787,7 +812,8 @@ parse_int:
787 */ 812 */
788 813
789int 814int
790read_config_file(const char *filename, const char *host, Options *options) 815read_config_file(const char *filename, const char *host, Options *options,
816 int checkperm)
791{ 817{
792 FILE *f; 818 FILE *f;
793 char line[1024]; 819 char line[1024];
@@ -795,10 +821,19 @@ read_config_file(const char *filename, const char *host, Options *options)
795 int bad_options = 0; 821 int bad_options = 0;
796 822
797 /* Open the file. */ 823 /* Open the file. */
798 f = fopen(filename, "r"); 824 if ((f = fopen(filename, "r")) == NULL)
799 if (!f)
800 return 0; 825 return 0;
801 826
827 if (checkperm) {
828 struct stat sb;
829
830 if (fstat(fileno(f), &sb) == -1)
831 fatal("fstat %s: %s", filename, strerror(errno));
832 if (((sb.st_uid != 0 && sb.st_uid != getuid()) ||
833 (sb.st_mode & 022) != 0))
834 fatal("Bad owner or permissions on %s", filename);
835 }
836
802 debug("Reading configuration data %.200s", filename); 837 debug("Reading configuration data %.200s", filename);
803 838
804 /* 839 /*
@@ -888,6 +923,9 @@ initialize_options(Options * options)
888 options->verify_host_key_dns = -1; 923 options->verify_host_key_dns = -1;
889 options->server_alive_interval = -1; 924 options->server_alive_interval = -1;
890 options->server_alive_count_max = -1; 925 options->server_alive_count_max = -1;
926 options->num_send_env = 0;
927 options->control_path = NULL;
928 options->control_master = -1;
891} 929}
892 930
893/* 931/*
@@ -1013,6 +1051,8 @@ fill_default_options(Options * options)
1013 } 1051 }
1014 if (options->server_alive_count_max == -1) 1052 if (options->server_alive_count_max == -1)
1015 options->server_alive_count_max = 3; 1053 options->server_alive_count_max = 3;
1054 if (options->control_master == -1)
1055 options->control_master = 0;
1016 if (options->setuptimeout == -1) { 1056 if (options->setuptimeout == -1) {
1017 /* in batch mode, default is 5mins */ 1057 /* in batch mode, default is 5mins */
1018 if (options->batch_mode == 1) 1058 if (options->batch_mode == 1)