diff options
author | Darren Tucker <dtucker@zip.com.au> | 2004-06-22 12:29:23 +1000 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2004-06-22 12:29:23 +1000 |
commit | 365433f883b8cc3f7f16572278340849413e6d49 (patch) | |
tree | b1aea895a41198a8db05cf709115ef054c95dda9 /ssh.c | |
parent | f7ba8f67b7e53150ff3f6f33879dd483f61ab5fc (diff) |
- djm@cvs.openbsd.org 2004/06/20 17:36:59
[ssh.c]
filter passed env vars at slave in connection sharing case; ok markus@
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 44 |
1 files changed, 36 insertions, 8 deletions
@@ -40,7 +40,7 @@ | |||
40 | */ | 40 | */ |
41 | 41 | ||
42 | #include "includes.h" | 42 | #include "includes.h" |
43 | RCSID("$OpenBSD: ssh.c,v 1.219 2004/06/18 10:55:43 markus Exp $"); | 43 | RCSID("$OpenBSD: ssh.c,v 1.220 2004/06/20 17:36:59 djm Exp $"); |
44 | 44 | ||
45 | #include <openssl/evp.h> | 45 | #include <openssl/evp.h> |
46 | #include <openssl/err.h> | 46 | #include <openssl/err.h> |
@@ -1227,11 +1227,30 @@ control_client_sigrelay(int signo) | |||
1227 | kill(control_server_pid, signo); | 1227 | kill(control_server_pid, signo); |
1228 | } | 1228 | } |
1229 | 1229 | ||
1230 | static int | ||
1231 | env_permitted(char *env) | ||
1232 | { | ||
1233 | int i; | ||
1234 | char name[1024], *cp; | ||
1235 | |||
1236 | strlcpy(name, env, sizeof(name)); | ||
1237 | if ((cp = strchr(name, '=')) == NULL) | ||
1238 | return (0); | ||
1239 | |||
1240 | *cp = '\0'; | ||
1241 | |||
1242 | for (i = 0; i < options.num_send_env; i++) | ||
1243 | if (match_pattern(name, options.send_env[i])) | ||
1244 | return (1); | ||
1245 | |||
1246 | return (0); | ||
1247 | } | ||
1248 | |||
1230 | static void | 1249 | static void |
1231 | control_client(const char *path) | 1250 | control_client(const char *path) |
1232 | { | 1251 | { |
1233 | struct sockaddr_un addr; | 1252 | struct sockaddr_un addr; |
1234 | int i, r, sock, exitval, addr_len; | 1253 | int i, r, sock, exitval, num_env, addr_len; |
1235 | Buffer m; | 1254 | Buffer m; |
1236 | char *cp; | 1255 | char *cp; |
1237 | extern char **environ; | 1256 | extern char **environ; |
@@ -1274,12 +1293,21 @@ control_client(const char *path) | |||
1274 | buffer_append(&command, "\0", 1); | 1293 | buffer_append(&command, "\0", 1); |
1275 | buffer_put_cstring(&m, buffer_ptr(&command)); | 1294 | buffer_put_cstring(&m, buffer_ptr(&command)); |
1276 | 1295 | ||
1277 | /* Pass environment */ | 1296 | if (options.num_send_env == 0 || environ == NULL) { |
1278 | for (i = 0; environ != NULL && environ[i] != NULL; i++) | 1297 | buffer_put_int(&m, 0); |
1279 | ; | 1298 | } else { |
1280 | buffer_put_int(&m, i); | 1299 | /* Pass environment */ |
1281 | for (i = 0; environ != NULL && environ[i] != NULL; i++) | 1300 | num_env = 0; |
1282 | buffer_put_cstring(&m, environ[i]); | 1301 | for (i = 0; environ[i] != NULL; i++) |
1302 | if (env_permitted(environ[i])) | ||
1303 | num_env++; /* Count */ | ||
1304 | |||
1305 | buffer_put_int(&m, num_env); | ||
1306 | |||
1307 | for (i = 0; environ[i] != NULL && num_env >= 0; i++, num_env--) | ||
1308 | if (env_permitted(environ[i])) | ||
1309 | buffer_put_cstring(&m, environ[i]); | ||
1310 | } | ||
1283 | 1311 | ||
1284 | if (ssh_msg_send(sock, /* version */0, &m) == -1) | 1312 | if (ssh_msg_send(sock, /* version */0, &m) == -1) |
1285 | fatal("%s: msg_send", __func__); | 1313 | fatal("%s: msg_send", __func__); |