Skip to content

Commit

Permalink
Fixes for scp/sftp/ssh interactive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Holzschuch committed Apr 24, 2021
1 parent 46a6507 commit 57e220e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
4 changes: 2 additions & 2 deletions ssh_keygen/scp.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,15 +613,15 @@ scp_main(int argc, char **argv)
(void) close(remin);
if (remout != -1)
(void) close(remout);
#if !TARGET_OS_IPHONE
//#if !TARGET_OS_IPHONE
// Experimental: don't wait for ssh to finish because ssh waits for scp to finish.
if (waitpid(do_cmd_pid, &status, 0) == -1)
errs = 1;
else {
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
errs = 1;
}
#endif
//#endif
}
exit(errs != 0);
}
Expand Down
12 changes: 6 additions & 6 deletions ssh_keygen/sftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2229,6 +2229,10 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
setvbuf(infile, NULL, _IOLBF, 0);

interactive = !batchmode && isatty(STDIN_FILENO);
#if TARGET_OS_IPHONE
if (interactive)
ios_stopInteractive();
#endif

err = 0;
for (;;) {
Expand Down Expand Up @@ -2600,10 +2604,6 @@ sftp_main(int argc, char **argv)

}

#if TARGET_OS_IPHONE
ios_stopInteractive();
#endif

err = interactive_loop(conn, file1, file2);

#if !defined(USE_PIPES)
Expand All @@ -2617,11 +2617,11 @@ sftp_main(int argc, char **argv)
fclose(infile);

// ssh waits for sftp in ios_system::cleanup_function, so this ends in an infinite loop
#if !TARGET_OS_IPHONE
//#if !TARGET_OS_IPHONE
while (waitpid(sshpid, NULL, 0) == -1 && sshpid > 1)
if (errno != EINTR)
fatal("Couldn't wait for ssh process: %s",
strerror(errno));
#endif
//#endif
exit(err == 0 ? 0 : 1);
}
5 changes: 0 additions & 5 deletions ssh_keygen/ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1716,11 +1716,6 @@ ssh_main(int ac, char **av)

/* Kill ProxyCommand if it is running. */
ssh_kill_proxy_command();
#if TARGET_OS_IPHONE
if (fileno(thread_stdout) != fileno(thread_stderr))
fclose(thread_stderr);
fclose(thread_stdout);
#endif
return exit_status;
}

Expand Down

0 comments on commit 57e220e

Please sign in to comment.