summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-11-12 10:52:25 +1100
committerDamien Miller <djm@mindrot.org>2001-11-12 10:52:25 +1100
commit96507ef53542a805095319432c5108fa8ac3fa67 (patch)
treec117019f7fe69b92e00ea1b8cd49318ea16ec98b
parent07cd5897f9854e2f835614027dd321ba17910013 (diff)
- markus@cvs.openbsd.org 2001/10/24 19:57:40
[clientloop.c] make ~& (backgrounding) work again for proto v1; add support ~& for v2, too
-rw-r--r--ChangeLog5
-rw-r--r--clientloop.c49
2 files changed, 30 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index b11fb7c9..29671088 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,9 @@
- markus@cvs.openbsd.org 2001/10/24 08:51:35
[clientloop.c ssh.c]
ignore SIGPIPE early, makes ssh work if agent dies, netbsd-pr via itojun@
+ - markus@cvs.openbsd.org 2001/10/24 19:57:40
+ [clientloop.c]
+ make ~& (backgrounding) work again for proto v1; add support ~& for v2, too
20011109
- (stevesk) auth-pam.c: use do_pam_authenticate(PAM_DISALLOW_NULL_AUTHTOK)
@@ -6820,4 +6823,4 @@
- Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1
-$Id: ChangeLog,v 1.1637 2001/11/11 23:52:03 djm Exp $
+$Id: ChangeLog,v 1.1638 2001/11/11 23:52:25 djm Exp $
diff --git a/clientloop.c b/clientloop.c
index 7e6fe269..e8cd4998 100644
--- a/clientloop.c
+++ b/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,