[SCM] Samba Shared Repository - branch v3-2-test updated - release-3-2-0pre2-3068-g4dc2eb7

Jeremy Allison jra at samba.org
Fri Oct 3 21:57:45 GMT 2008


The branch, v3-2-test has been updated
       via  4dc2eb7f42bad6812d21bf4577e2901b04a5ca83 (commit)
      from  2fb742e127f725b56f308538852d7b10b86f29c1 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 4dc2eb7f42bad6812d21bf4577e2901b04a5ca83
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Oct 3 14:56:30 2008 -0700

    Correctly fix smbclient to terminate on eof from server.
    Jeremy.

-----------------------------------------------------------------------

Summary of changes:
 source/client/client.c |   13 +++++++++++--
 source/lib/readline.c  |   13 ++++++++++++-
 2 files changed, 23 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/client/client.c b/source/client/client.c
index d794f8f..dc5e0f5 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -4342,6 +4342,8 @@ cleanup:
 	}
 }
 
+static bool finished;
+
 /****************************************************************************
  Make sure we swallow keepalives during idle time.
 ****************************************************************************/
@@ -4388,6 +4390,8 @@ static void readline_callback(void)
 			DEBUG(0, ("Read from server failed, maybe it closed "
 				  "the connection\n"));
 
+			finished = true;
+			smb_readline_done();
 			if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
 				set_smb_read_error(&cli->smb_rw_error,
 						   SMB_READ_EOF);
@@ -4416,7 +4420,12 @@ static void readline_callback(void)
 	{
 		unsigned char garbage[16];
 		memset(garbage, 0xf0, sizeof(garbage));
-		cli_echo(cli, 1, garbage, sizeof(garbage));
+		if (!cli_echo(cli, 1, garbage, sizeof(garbage))) {
+			DEBUG(0, ("SMBecho failed. Maybe server has closed "
+				  "the connection\n"));
+			smb_readline_done();
+			finished = true;
+		}
 	}
 }
 
@@ -4428,7 +4437,7 @@ static int process_stdin(void)
 {
 	int rc = 0;
 
-	while (1) {
+	while (!finished) {
 		TALLOC_CTX *frame = talloc_stackframe();
 		char *tok = NULL;
 		char *the_prompt = NULL;
diff --git a/source/lib/readline.c b/source/lib/readline.c
index 254f55c..fd57799 100644
--- a/source/lib/readline.c
+++ b/source/lib/readline.c
@@ -45,6 +45,16 @@
 #  define RL_COMPLETION_CAST
 #endif /* HAVE_NEW_LIBREADLINE */
 
+static bool smb_rl_done;
+
+void smb_readline_done(void)
+{
+	smb_rl_done = true;
+#if HAVE_LIBREADLINE
+	rl_done = 1;
+#endif
+}
+
 /****************************************************************************
  Display the prompt and wait for input. Call callback() regularly
 ****************************************************************************/
@@ -69,7 +79,7 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void)
 		return NULL;
 	}
 
-	while (1) {
+	while (!smb_rl_done) {
 		timeout.tv_sec = 5;
 		timeout.tv_usec = 0;
 
@@ -87,6 +97,7 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void)
 			callback();
 		}
 	}
+	return NULL;
 }
 
 /****************************************************************************


-- 
Samba Shared Repository


More information about the samba-cvs mailing list