summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/clientloop.c
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2001-10-24 19:57:41 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2001-10-24 19:57:41 +0000
commit43cec2bc5b7578a56f9db092878fefaab36beebb (patch)
treea8e57e2ff81b62f7e2fd6b90e8499e6122641241 /usr.bin/ssh/clientloop.c
parentca6714bf3f937e80a7bf62cb435e689f3e7c172c (diff)
make ~& (backgrounding) work again for proto v1; add support ~& for v2, too
Diffstat (limited to 'usr.bin/ssh/clientloop.c')
-rw-r--r--usr.bin/ssh/clientloop.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/usr.bin/ssh/clientloop.c b/usr.bin/ssh/clientloop.c
index 7e6fe269ab1..e8cd49988f5 100644
--- a/usr.bin/ssh/clientloop.c
+++ b/usr.bin/ssh/clientloop.c
@@ -59,7 +59,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: clientloop.c,v 1.85 2001/10/24 08:51:35 markus Exp $");
+RCSID("$OpenBSD: clientloop.c,v 1.86 2001/10/24 19:57:40 markus Exp $");
#include "ssh.h"
#include "ssh1.h"
@@ -522,36 +522,19 @@ process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len)
continue;
case '&':
- /* XXX does not work yet with proto 2 */
- if (compat20)
- continue;
/*
* Detach the program (continue to serve connections,
* but put in background and no more new connections).
*/
- if (!stdin_eof) {
- /*
- * Sending SSH_CMSG_EOF alone does not always appear
- * to be enough. So we try to send an EOF character
- * first.
- */
- packet_start(SSH_CMSG_STDIN_DATA);
- packet_put_string("\004", 1);
- packet_send();
- /* Close stdin. */
- stdin_eof = 1;
- if (buffer_len(bin) == 0) {
- packet_start(SSH_CMSG_EOF);
- packet_send();
- }
- }
/* Restore tty modes. */
leave_raw_mode();
/* Stop listening for new connections. */
- channel_close_all(); /* proto1 only XXXX */
+ channel_stop_listening();
- printf("%c& [backgrounded]\n", escape_char);
+ snprintf(string, sizeof string,
+ "%c& [backgrounded]\n", escape_char);
+ buffer_append(berr, string, strlen(string));
/* Fork into background. */
pid = fork();
@@ -564,7 +547,27 @@ process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len)
exit(0);
}
/* The child continues serving connections. */
- continue; /*XXX ? */
+ if (compat20) {
+ buffer_append(bin, "\004", 1);
+ /* fake EOF on stdin */
+ return -1;
+ } else if (!stdin_eof) {
+ /*
+ * Sending SSH_CMSG_EOF alone does not always appear
+ * to be enough. So we try to send an EOF character
+ * first.
+ */
+ packet_start(SSH_CMSG_STDIN_DATA);
+ packet_put_string("\004", 1);
+ packet_send();
+ /* Close stdin. */
+ stdin_eof = 1;
+ if (buffer_len(bin) == 0) {
+ packet_start(SSH_CMSG_EOF);
+ packet_send();
+ }
+ }
+ continue;
case '?':
snprintf(string, sizeof string,