summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2004-05-02 22:11:30 +1000
committerDarren Tucker <dtucker@zip.com.au>2004-05-02 22:11:30 +1000
commit46bc075474211c711b102f6278783bb68d7530a8 (patch)
tree5f099d7bdc006926bf393dfc51f7545d0787b33e /ssh.c
parent47abce45b20ba52c0eb7f19240851f45bc1babc2 (diff)
- 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 @@
40 */ 40 */
41 41
42#include "includes.h" 42#include "includes.h"
43RCSID("$OpenBSD: ssh.c,v 1.211 2004/04/19 21:51:49 djm Exp $"); 43RCSID("$OpenBSD: ssh.c,v 1.212 2004/04/27 09:46:37 djm Exp $");
44 44
45#include <openssl/evp.h> 45#include <openssl/evp.h>
46#include <openssl/err.h> 46#include <openssl/err.h>
@@ -68,6 +68,7 @@ RCSID("$OpenBSD: ssh.c,v 1.211 2004/04/19 21:51:49 djm Exp $");
68#include "kex.h" 68#include "kex.h"
69#include "mac.h" 69#include "mac.h"
70#include "sshtty.h" 70#include "sshtty.h"
71#include "match.h"
71 72
72#ifdef SMARTCARD 73#ifdef SMARTCARD
73#include "scard.h" 74#include "scard.h"
@@ -1057,6 +1058,44 @@ ssh_session2_setup(int id, void *arg)
1057 packet_send(); 1058 packet_send();
1058 } 1059 }
1059 1060
1061 /* Transfer any environment variables from client to server */
1062 if (options.num_send_env != 0) {
1063 int i, j, matched;
1064 extern char **environ;
1065 char *name, *val;
1066
1067 debug("Sending environment.");
1068 for (i = 0; environ && environ[i] != NULL; i++) {
1069 /* Split */
1070 name = xstrdup(environ[i]);
1071 if ((val = strchr(name, '=')) == NULL) {
1072 free(name);
1073 continue;
1074 }
1075 *val++ = '\0';
1076
1077 matched = 0;
1078 for (j = 0; j < options.num_send_env; j++) {
1079 if (match_pattern(name, options.send_env[j])) {
1080 matched = 1;
1081 break;
1082 }
1083 }
1084 if (!matched) {
1085 debug3("Ignored env %s", name);
1086 free(name);
1087 continue;
1088 }
1089
1090 debug("Sending env %s = %s", name, val);
1091 channel_request_start(id, "env", 0);
1092 packet_put_cstring(name);
1093 packet_put_cstring(val);
1094 packet_send();
1095 free(name);
1096 }
1097 }
1098
1060 len = buffer_len(&command); 1099 len = buffer_len(&command);
1061 if (len > 0) { 1100 if (len > 0) {
1062 if (len > 900) 1101 if (len > 900)