[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Thu Apr 5 02:06:01 UTC 2018


The branch, master has been updated
       via  1452677 smbclient: Handle ENUM_DIR in "notify" command
       via  abfe482 libsmb: Handle IO_TIMEOUT in cli_smb2_notify properly
       via  91c0f49 libsmb: Handle long-running smb2cli_notify
       via  cc74638 credentials: Fix a typo
       via  90c02ec credentials: Fix CID 1414796 Explicit null dereferenced
      from  e895b6c s3: lib: messages: Don't use the result of sec_init() before calling sec_init().

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1452677ef0044815df0702de5424d4711e18144b
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Oct 30 16:15:03 2017 +0100

    smbclient: Handle ENUM_DIR in "notify" command
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Apr  5 04:05:52 CEST 2018 on sn-devel-144

commit abfe482828e8c1dc233d67657a4d11a91a731f70
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Oct 30 14:36:46 2017 +0100

    libsmb: Handle IO_TIMEOUT in cli_smb2_notify properly
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 91c0f497816bb88d8935a8a79c146c08379ecf53
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Oct 30 14:34:12 2017 +0100

    libsmb: Handle long-running smb2cli_notify
    
    This likely runs into a timeout. Properly cancel the smb2 request,
    allowing the higher-level caller to re-issue this request on an existing
    handle.
    
    I did not see a proper way to achieve this with tevent_req_set_endtime or
    something like that.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit cc746385bf1b6b8a45d66af092f90a6228a93d78
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Apr 4 10:27:21 2018 +0200

    credentials: Fix a typo
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 90c02ec64d0e3c860f8d6906cf849bdd2c7bcc54
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Apr 4 10:26:14 2018 +0200

    credentials: Fix CID 1414796 Explicit null dereferenced
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 auth/credentials/credentials_secrets.c |  7 ++++-
 libcli/smb/smb2cli_notify.c            | 54 ++++++++++++++++++++++++++++------
 source3/client/client.c                |  9 ++++--
 source3/libsmb/cli_smb2_fnum.c         |  9 ++++++
 4 files changed, 67 insertions(+), 12 deletions(-)


Changeset truncated at 500 lines:

diff --git a/auth/credentials/credentials_secrets.c b/auth/credentials/credentials_secrets.c
index ae1d23b..2ae384f 100644
--- a/auth/credentials/credentials_secrets.c
+++ b/auth/credentials/credentials_secrets.c
@@ -106,10 +106,15 @@ static NTSTATUS cli_credentials_set_secrets_lct(struct cli_credentials *cred,
 	}
 
 	password = ldb_msg_find_attr_as_string(msg, "secret", NULL);
+	if (password == NULL) {
+		/* This attribute is mandatory */
+		talloc_free(mem_ctx);
+		return NT_STATUS_NOT_FOUND;
+	}
 
 	whenChanged = ldb_msg_find_ldb_val(msg, "whenChanged");
 	if (!whenChanged || ldb_val_to_time(whenChanged, &lct) != LDB_SUCCESS) {
-		/* This attribute is mandetory */
+		/* This attribute is mandatory */
 		talloc_free(mem_ctx);
 		return NT_STATUS_NOT_FOUND;
 	}
diff --git a/libcli/smb/smb2cli_notify.c b/libcli/smb/smb2cli_notify.c
index 0a23cf9..34329ba 100644
--- a/libcli/smb/smb2cli_notify.c
+++ b/libcli/smb/smb2cli_notify.c
@@ -30,9 +30,12 @@ struct smb2cli_notify_state {
 	struct iovec *recv_iov;
 	uint8_t *data;
 	uint32_t data_length;
+
+	struct tevent_req *subreq;
 };
 
 static void smb2cli_notify_done(struct tevent_req *subreq);
+static void smb2cli_notify_timedout(struct tevent_req *subreq);
 
 struct tevent_req *smb2cli_notify_send(TALLOC_CTX *mem_ctx,
 				       struct tevent_context *ev,
@@ -64,21 +67,50 @@ struct tevent_req *smb2cli_notify_send(TALLOC_CTX *mem_ctx,
 	SIVAL(fixed, 24, completion_filter);
 	SIVAL(fixed, 28, 0); 	/* reserved */
 
-	subreq = smb2cli_req_send(state, ev, conn, SMB2_OP_NOTIFY,
-				  0, 0, /* flags */
-				  timeout_msec,
-				  tcon,
-				  session,
-				  state->fixed, sizeof(state->fixed),
-				  NULL, 0, /* dyn* */
-				  0); /* max_dyn_len */
+	state->subreq = smb2cli_req_send(state, ev, conn, SMB2_OP_NOTIFY,
+					 0, 0, /* flags */
+					 0,	/* timeout_msec */
+					 tcon,
+					 session,
+					 state->fixed, sizeof(state->fixed),
+					 NULL, 0, /* dyn* */
+					 0); /* max_dyn_len */
+	if (tevent_req_nomem(state->subreq, req)) {
+		return tevent_req_post(req, ev);
+	}
+	tevent_req_set_callback(state->subreq, smb2cli_notify_done, req);
+
+	subreq = tevent_wakeup_send(state, ev,
+				    timeval_current_ofs_msec(timeout_msec));
 	if (tevent_req_nomem(subreq, req)) {
 		return tevent_req_post(req, ev);
 	}
-	tevent_req_set_callback(subreq, smb2cli_notify_done, req);
+	tevent_req_set_callback(subreq, smb2cli_notify_timedout, req);
+
 	return req;
 }
 
+static void smb2cli_notify_timedout(struct tevent_req *subreq)
+{
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+	struct smb2cli_notify_state *state = tevent_req_data(
+		req, struct smb2cli_notify_state);
+	bool ok;
+
+	ok = tevent_wakeup_recv(subreq);
+	if (!ok) {
+		tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
+		return;
+	}
+
+	ok = tevent_req_cancel(state->subreq);
+	if (!ok) {
+		tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
+		return;
+	}
+}
+
 static void smb2cli_notify_done(struct tevent_req *subreq)
 {
 	struct tevent_req *req = tevent_req_callback_data(
@@ -98,6 +130,10 @@ static void smb2cli_notify_done(struct tevent_req *subreq)
 	status = smb2cli_req_recv(subreq, state, &iov,
 				  expected, ARRAY_SIZE(expected));
 	TALLOC_FREE(subreq);
+
+	if (NT_STATUS_EQUAL(status, NT_STATUS_CANCELLED)) {
+		status = NT_STATUS_IO_TIMEOUT;
+	}
 	if (tevent_req_nterror(req, status)) {
 		return;
 	}
diff --git a/source3/client/client.c b/source3/client/client.c
index 23ed02d..1429b44 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -4568,12 +4568,17 @@ static int cmd_notify(void)
 	}
 
 	while (1) {
-		uint32_t i, num_changes;
-		struct notify_change *changes;
+		uint32_t i;
+		uint32_t num_changes = 0;
+		struct notify_change *changes = NULL;
 
 		status = cli_notify(cli, fnum, 1000, FILE_NOTIFY_CHANGE_ALL,
 				    true,
 				    talloc_tos(), &num_changes, &changes);
+		if (NT_STATUS_EQUAL(status, STATUS_NOTIFY_ENUM_DIR)) {
+			printf("NOTIFY_ENUM_DIR\n");
+			status = NT_STATUS_OK;
+		}
 		if (!NT_STATUS_IS_OK(status)) {
 			d_printf("notify returned %s\n",
 				 nt_errstr(status));
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 2d87b58..c397b29 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -4192,6 +4192,15 @@ NTSTATUS cli_smb2_notify(struct cli_state *cli, uint16_t fnum,
 				completion_filter, recursive,
 				frame, &base, &len);
 
+	if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
+		len = 0;
+		status = NT_STATUS_OK;
+	}
+
+	if (!NT_STATUS_IS_OK(status)) {
+		goto fail;
+	}
+
 	ofs = 0;
 
 	while (len - ofs >= 12) {


-- 
Samba Shared Repository



More information about the samba-cvs mailing list