summaryrefslogtreecommitdiffstats
path: root/ssh.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2004-05-02 14:11:30 +0200
committerDarren Tucker <dtucker@zip.com.au>2004-05-02 14:11:30 +0200
commit46bc075474211c711b102f6278783bb68d7530a8 (patch)
tree5f099d7bdc006926bf393dfc51f7545d0787b33e /ssh.c
parent - djm@cvs.openbsd.org 2004/04/22 11:56:57 (diff)
downloadopenssh-46bc075474211c711b102f6278783bb68d7530a8.tar.xz
openssh-46bc075474211c711b102f6278783bb68d7530a8.zip
- djm@cvs.openbsd.org 2004/04/27 09:46:37
[readconf.c readconf.h servconf.c servconf.h session.c session.h ssh.c ssh_config.5 sshd_config.5] bz #815: implement ability to pass specified environment variables from the client to the server; ok markus@
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/ssh.c b/ssh.c
index 9658e4afc..df3b64b1c 100644
--- a/ssh.c
+++ b/ssh.c
@@ -40,7 +40,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.211 2004/04/19 21:51:49 djm Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.212 2004/04/27 09:46:37 djm Exp $");
#include <openssl/evp.h>
#include <openssl/err.h>
@@ -68,6 +68,7 @@ RCSID("$OpenBSD: ssh.c,v 1.211 2004/04/19 21:51:49 djm Exp $");
#include "kex.h"
#include "mac.h"
#include "sshtty.h"
+#include "match.h"
#ifdef SMARTCARD
#include "scard.h"
@@ -1057,6 +1058,44 @@ ssh_session2_setup(int id, void *arg)
packet_send();
}
+ /* Transfer any environment variables from client to server */
+ if (options.num_send_env != 0) {
+ int i, j, matched;
+ extern char **environ;
+ char *name, *val;
+
+ debug("Sending environment.");
+ for (i = 0; environ && environ[i] != NULL; i++) {
+ /* Split */
+ name = xstrdup(environ[i]);
+ if ((val = strchr(name, '=')) == NULL) {
+ free(name);
+ continue;
+ }
+ *val++ = '\0';
+
+ matched = 0;
+ for (j = 0; j < options.num_send_env; j++) {
+ if (match_pattern(name, options.send_env[j])) {
+ matched = 1;
+ break;
+ }
+ }
+ if (!matched) {
+ debug3("Ignored env %s", name);
+ free(name);
+ continue;
+ }
+
+ debug("Sending env %s = %s", name, val);
+ channel_request_start(id, "env", 0);
+ packet_put_cstring(name);
+ packet_put_cstring(val);
+ packet_send();
+ free(name);
+ }
+ }
+
len = buffer_len(&command);
if (len > 0) {
if (len > 900)