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

Jeremy Allison jra at samba.org
Fri Oct 3 21:59:46 GMT 2008


The branch, v3-3-test has been updated
       via  d8e629864a53d603c1bb2b08ec853d178d2d9dd3 (commit)
      from  8674c683e37b13554b6f0f121198bd4746c78796 (commit)

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


- Log -----------------------------------------------------------------
commit d8e629864a53d603c1bb2b08ec853d178d2d9dd3
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Oct 3 14:59:03 2008 -0700

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

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

Summary of changes:
 source/client/client.c |   13 +++++++++++--
 source/include/proto.h |    1 +
 source/lib/readline.c  |   13 ++++++++++++-
 3 files changed, 24 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/client/client.c b/source/client/client.c
index f5207e4..3048d95 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -4343,6 +4343,8 @@ cleanup:
 	}
 }
 
+static bool finished;
+
 /****************************************************************************
  Make sure we swallow keepalives during idle time.
 ****************************************************************************/
@@ -4389,6 +4391,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);
@@ -4417,7 +4421,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;
+		}
 	}
 }
 
@@ -4429,7 +4438,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/include/proto.h b/source/include/proto.h
index 6066ce2..fb2d0c8 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -728,6 +728,7 @@ bool privilege_set_to_se_priv( SE_PRIV *mask, struct lsa_PrivilegeSet *privset )
 
 /* The following definitions come from lib/readline.c  */
 
+void smb_readline_done(void);
 char *smb_readline(const char *prompt, void (*callback)(void),
 		   char **(completion_fn)(const char *text, int start, int end));
 const char *smb_readline_get_line_buffer(void);
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