File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -163,10 +163,16 @@ func (h *sshHandler) Exit(err error) error {
163
163
return err
164
164
}
165
165
166
+ type EnvVar struct {
167
+ Name , Value string
168
+ }
169
+
166
170
func (h * sshHandler ) Request (req * ssh.Request ) {
167
171
switch req .Type {
168
172
case "exec" :
169
173
h .handleExec (req )
174
+ case "env" :
175
+ h .handleEnv (req )
170
176
case "pty-req" :
171
177
h .handlePty (req )
172
178
case "window-change" :
@@ -178,6 +184,14 @@ func (h *sshHandler) Request(req *ssh.Request) {
178
184
}
179
185
}
180
186
187
+ func (h * sshHandler ) handleEnv (req * ssh.Request ) {
188
+ var pair EnvVar
189
+ ssh .Unmarshal (req .Payload , & pair )
190
+ envvar := fmt .Sprintf ("%s=%s" , pair .Name , pair .Value )
191
+ h .Env = append (h .Env , envvar )
192
+ req .Reply (true , nil )
193
+ }
194
+
181
195
func (h * sshHandler ) handleExec (req * ssh.Request ) {
182
196
h .Lock ()
183
197
defer h .Unlock ()
You can’t perform that action at this time.
0 commit comments