summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2004-08-18 12:42:21 +0000
committerMatt Johnston <matt@ucc.asn.au>2004-08-18 12:42:21 +0000
commit24bae0f1e7cc14a0c4e095212c6844570c27a18d (patch)
tree6aa2566c70c15dfa903cbaa0cfa58e091785c6dd
parentdf5133fc31eb5867198ff661be2df05b64e12c5f (diff)
downloaddropbear-24bae0f1e7cc14a0c4e095212c6844570c27a18d.tar.gz
Don't leave the stdin FD non-blocking on exit - busybox doesn't like it.
-rw-r--r--cli-chansession.c9
-rw-r--r--session.h2
2 files changed, 11 insertions, 0 deletions
diff --git a/cli-chansession.c b/cli-chansession.c
index c6855a3..267a07f 100644
--- a/cli-chansession.c
+++ b/cli-chansession.c
@@ -63,6 +63,10 @@ static void cli_closechansess(struct Channel *channel) {
cli_tty_cleanup(); /* Restore tty modes etc */
+ /* Set stdin back to non-blocking - busybox ash dies nastily
+ * if we don't revert the flags */
+ fcntl(cli_ses.stdincopy, F_SETFL, cli_ses.stdinflags);
+
}
static void start_channel_request(struct Channel *channel,
@@ -313,6 +317,11 @@ static void send_chansess_shell_req(struct Channel *channel) {
static int cli_initchansess(struct Channel *channel) {
+ /* We store stdin's flags, so we can set them back on exit (otherwise
+ * busybox's ash isn't happy */
+ cli_ses.stdincopy = dup(STDIN_FILENO);
+ cli_ses.stdinflags = fcntl(STDIN_FILENO, F_GETFL, 0);
+
channel->infd = STDOUT_FILENO;
//channel->outfd = STDIN_FILENO;
//channel->errfd = STDERR_FILENO;
diff --git a/session.h b/session.h
index 6a6ed07..6afca85 100644
--- a/session.h
+++ b/session.h
@@ -212,6 +212,8 @@ struct clientsession {
int tty_raw_mode; /* Whether we're in raw mode (and have to clean up) */
struct termios saved_tio;
+ int stdincopy;
+ int stdinflags;
int winchange; /* Set to 1 when a windowchange signal happens */