scp log out session after successful completion

Matt Johnston matt at ucc.asn.au
Tue Mar 1 01:02:32 WST 2005


On Sun, Feb 20, 2005 at 12:07:20AM -0800, Brent Roman wrote:
> Hi,
> 
> I'm running dropbear on an embedded ARM from Technologics.
> It's your v0.44 with the 2.4x linux kernel and busybox v1.0
> 
> ... when I invoke dropbear's scp interactively, it appears
> to close stdin (or redirect it ot /dev/null somehow)
> for the shell after completing successfully.
> This causes the shell to logout.

This looks similar to a bug which I thought I'd fixed,
related to setting stdin to be non-blocking. 

Could you try the attached patch, which does the same thing
with stdout and stderr?

Cheers,
Matt

> brent at ESPhost$ scp -v -i .ssh/id_rsa .irbrc bufflehead:irbrc
> Executing: program /usr/bin/dbclient host bufflehead, user 
> (unspecified), command scp -v -t irbrc
> WARNING: Ignoring unknown argument '-x'
> WARNING: Ignoring unknown argument '-oForwardAgent no'
> WARNING: Ignoring unknown argument '-oClearAllForwardings yes'
> WARNING: Ignoring unknown argument '-v'
> Sending file modes: C0644 825 .irbrc
> Sink: C0644 825 .irbrc
> brent at ESPhost$
> Use "exit" to leave shell.
> brent at ESPhost$
> Use "exit" to leave shell.
> brent at ESPhost$
-------------- next part --------------
# 
# patch "cli-session.c"
#  from [044e633a29f6fea152646a63193851598f5d0b4d]
#    to [456ed9269b52604e2d0c8aa700ba987974d0fd7b]
# 
# patch "session.h"
#  from [cc4c1b731836950406593afc60fedd35a59f9adb]
#    to [8b1677ad8f52c19aa94571211683d6ef04de2d6a]
# 
--- cli-session.c
+++ cli-session.c
@@ -113,10 +113,14 @@
 	cli_ses.tty_raw_mode = 0;
 	cli_ses.winchange = 0;
 
-	/* We store stdin's flags, so we can set them back on exit (otherwise
-	 * busybox's ash isn't happy */
+	/* We store std{in,out,err}'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);
+	cli_ses.stdoutcopy = dup(STDOUT_FILENO);
+	cli_ses.stdoutflags = fcntl(STDOUT_FILENO, F_GETFL, 0);
+	cli_ses.stderrcopy = dup(STDERR_FILENO);
+	cli_ses.stderrflags = fcntl(STDERR_FILENO, F_GETFL, 0);
 
 	cli_ses.retval = EXIT_SUCCESS; /* Assume it's clean if we don't get a
 									  specific exit status */
@@ -250,9 +254,11 @@
 		return;
 	}
 
-	/* Set stdin back to non-blocking - busybox ash dies nastily
-	 * if we don't revert the flags */
+	/* Set std{in,out,err} back to non-blocking - busybox ash dies nastily if
+	 * we don't revert the flags */
 	fcntl(cli_ses.stdincopy, F_SETFL, cli_ses.stdinflags);
+	fcntl(cli_ses.stdoutcopy, F_SETFL, cli_ses.stdoutflags);
+	fcntl(cli_ses.stderrcopy, F_SETFL, cli_ses.stderrflags);
 
 	cli_tty_cleanup();
 
--- session.h
+++ session.h
@@ -218,6 +218,10 @@
 	struct termios saved_tio;
 	int stdincopy;
 	int stdinflags;
+	int stdoutcopy;
+	int stdoutflags;
+	int stderrcopy;
+	int stderrflags;
 
 	int winchange; /* Set to 1 when a windowchange signal happens */
 


More information about the Dropbear mailing list