Skip to content

Commit

Permalink
Request env on channel. Refs blinksh#287
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Sep 12, 2018
1 parent d044f4c commit 596937c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Blink/SSHClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,9 @@ - (int)_start_session_channel {
break;
}


[self _ssh_send_env: channel];

BOOL doRequestPTY = _options[SSHOptionRequestTTY] == SSHOptionValueYES
|| (_options[SSHOptionRequestTTY] == SSHOptionValueAUTO && _isTTY);

Expand Down Expand Up @@ -805,6 +808,35 @@ - (int)_start_session_channel {
return rc;
}

- (void)_ssh_send_env:(ssh_channel) channel {
NSArray *vars = _options[SSHOptionSendEnv];
if (!vars.count) {
return;
}

for (NSString *varName in vars) {
[self _log_verbose:[NSString stringWithFormat:@"Sending env '%@'", varName]];

char *varValue = getenv(varName.UTF8String);
if (!varValue) {
continue;
}

for(;;) {
int rc = ssh_channel_request_env(channel, varName.UTF8String, varValue);
switch (rc) {
case SSH_AGAIN:
[self _poll];
continue;
case SSH_OK:
default:
break;
}
break;
}
}
}

- (int)_start_stdio_forwarding:(NSString *)hostPort {
NSArray *hostAndPort = [hostPort componentsSeparatedByString:@":"];
if (hostAndPort.count != 2) {
Expand Down

0 comments on commit 596937c

Please sign in to comment.