[SCM] Samba Shared Repository - branch v4-2-test updated

Karolin Seeger kseeger at samba.org
Thu May 21 12:07:09 MDT 2015


The branch, v4-2-test has been updated
       via  c78585f s4: libcli/finddcs_cldap: continue processing CLDAP until all addresses are used
       via  c7e4454 torture: Add smb2.notify.rmdir
       via  b3e3e41 smbd: Cancel pending notifies if the directory goes away
       via  bd09b15 smbd: Remove bool arg from set_delete_on_close_lck
       via  e41c7a7 smbd: Use reset_delete_on_close_lck directly
       via  d754099 smbd: Introduce reset_delete_on_close_lck
       via  fa55c75 s3:winbindd: make sure we remove pending io requests before closing client sockets
      from  60f1f76 libads: record service ticket endtime for sealed ldap connections

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-2-test


- Log -----------------------------------------------------------------
commit c78585f5e2382097523693b564e49155bde85673
Author: Alexander Bokovoy <ab at samba.org>
Date:   Wed May 20 11:17:38 2015 +0300

    s4: libcli/finddcs_cldap: continue processing CLDAP until all addresses are used
    
    This is a subtle bug that causes CLDAP pings to fail if SRV records
    discovered cannot be resolved or connection to them cannot be
    established. The code that fires up CLDAP ping will silently cancel
    the whole tevent request without going to the next server in the queue.
    
    This may happen, for example, when connection to IPv6 addresses couldn't
    be established, or when IPv4 address is not online or blocked by
    firewall.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11284
    
    Signed-off-by: Alexander Bokovoy <ab at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit eb029b32e95c9e7382488f3a1b033cdbe3237c1c)
    
    Autobuild-User(v4-2-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-2-test): Thu May 21 20:06:21 CEST 2015 on sn-devel-104

commit c7e44549a756f79a5267e22bd187bd94fa851e03
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 20 10:44:07 2015 +0000

    torture: Add smb2.notify.rmdir
    
    We need to cancel a pending FileChangeNotify with DELETE_PENDING if the
    directory watched is about to be deleted.
    
    I know I just deleted a bool parameter, but to me torture is different :-)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11257
    
    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 23 01:36:48 CEST 2015 on sn-devel-104
    
    (cherry picked from commit 79dc084dcb6e28211addfc5d75b817cc735d67c1)

commit b3e3e41c3633e6f6c48a775ac83e53ab92ea7b85
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Apr 21 10:16:16 2015 +0200

    smbd: Cancel pending notifies if the directory goes away
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11257
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 50a1247927cb68303701a11517811deda10364f7)

commit bd09b1569107721ea3065807e47f2caeb580c3b9
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Apr 21 11:41:45 2015 +0200

    smbd: Remove bool arg from set_delete_on_close_lck
    
    We now have reset_delete_on_close_lck, this was called with "true"
    everywhere now.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11257
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit b0d4a7daa149cfc9ef697dd7fae4524a35078126)

commit e41c7a77b5fd10a768589b684219fd62be031db1
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Apr 21 11:38:32 2015 +0200

    smbd: Use reset_delete_on_close_lck directly
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11257
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 1f3735a28c3e6cbe2ca6c8e3bf312b3ea8c1754e)

commit d7540992f2156392033046b33c21df5b3ec8a9a5
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Apr 21 11:36:30 2015 +0200

    smbd: Introduce reset_delete_on_close_lck
    
    Boolean flags passed down make things more complex than necessary...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11257
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit d75a0a589f477e4541badfc1a6ba939e281a5582)

commit fa55c75bf4e4cdee327f80f203a9b2cd3e6ca339
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon May 18 13:17:40 2015 +0200

    s3:winbindd: make sure we remove pending io requests before closing client sockets
    
    This avoids a crash inside the tevent epoll backend.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11141
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Wed May 20 22:16:54 CEST 2015 on sn-devel-104
    
    (cherry picked from commit 435ddd8223eaa6fafb62cead0399bdd042d998e8)

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

Summary of changes:
 source3/librpc/idl/messaging.idl |   3 ++
 source3/locking/locking.c        | 101 ++++++++++++++++++++++-------------
 source3/locking/proto.h          |   3 +-
 source3/smbd/close.c             |   6 +--
 source3/smbd/notify.c            |  43 +++++++++++++++
 source3/smbd/proto.h             |   3 ++
 source3/smbd/service.c           |   4 ++
 source3/winbindd/winbindd.c      |  26 +++++++++
 source3/winbindd/winbindd.h      |   1 +
 source4/libcli/finddcs_cldap.c   |  42 +++++++++++----
 source4/torture/smb2/notify.c    | 110 +++++++++++++++++++++++++++++++++++++++
 11 files changed, 291 insertions(+), 51 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/librpc/idl/messaging.idl b/source3/librpc/idl/messaging.idl
index ce40a7b..847dc25 100644
--- a/source3/librpc/idl/messaging.idl
+++ b/source3/librpc/idl/messaging.idl
@@ -96,6 +96,9 @@ interface messaging
 		MSG_SMB_TELL_NUM_CHILDREN       = 0x0317,
 		MSG_SMB_NUM_CHILDREN            = 0x0318,
 
+		/* Cancel a notify, directory got deleted */
+		MSG_SMB_NOTIFY_CANCEL_DELETED   = 0x0319,
+
 		/* winbind messages */
 		MSG_WINBIND_FINISHED		= 0x0401,
 		MSG_WINBIND_FORGET_STATE	= 0x0402,
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 221d6ee..ce595e1 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -46,6 +46,7 @@
 #include "messages.h"
 #include "util_tdb.h"
 #include "../librpc/gen_ndr/ndr_open_files.h"
+#include "librpc/gen_ndr/ndr_file_id.h"
 #include "locking/leases_db.h"
 
 #undef DBGC_CLASS
@@ -1081,6 +1082,27 @@ static bool add_delete_on_close_token(struct share_mode_data *d,
 	return true;
 }
 
+void reset_delete_on_close_lck(files_struct *fsp,
+			       struct share_mode_lock *lck)
+{
+	struct share_mode_data *d = lck->data;
+	uint32_t i;
+
+	for (i=0; i<d->num_delete_tokens; i++) {
+		struct delete_token *dt = &d->delete_tokens[i];
+
+		if (dt->name_hash == fsp->name_hash) {
+			d->modified = true;
+
+			/* Delete this entry. */
+			TALLOC_FREE(dt->delete_nt_token);
+			TALLOC_FREE(dt->delete_token);
+			*dt = d->delete_tokens[d->num_delete_tokens-1];
+			d->num_delete_tokens -= 1;
+		}
+	}
+}
+
 /****************************************************************************
  Sets the delete on close flag over all share modes on this file.
  Modify the share mode entry for all files open
@@ -1094,54 +1116,63 @@ static bool add_delete_on_close_token(struct share_mode_data *d,
 
 void set_delete_on_close_lck(files_struct *fsp,
 			struct share_mode_lock *lck,
-			bool delete_on_close,
 			const struct security_token *nt_tok,
 			const struct security_unix_token *tok)
 {
+	struct messaging_context *msg_ctx = fsp->conn->sconn->msg_ctx;
 	struct share_mode_data *d = lck->data;
-	int i;
+	uint32_t i;
 	bool ret;
+	DATA_BLOB fid_blob = {};
+	enum ndr_err_code ndr_err;
 
-	if (delete_on_close) {
-		SMB_ASSERT(nt_tok != NULL);
-		SMB_ASSERT(tok != NULL);
-	} else {
-		SMB_ASSERT(nt_tok == NULL);
-		SMB_ASSERT(tok == NULL);
-	}
+	SMB_ASSERT(nt_tok != NULL);
+	SMB_ASSERT(tok != NULL);
 
 	for (i=0; i<d->num_delete_tokens; i++) {
 		struct delete_token *dt = &d->delete_tokens[i];
 		if (dt->name_hash == fsp->name_hash) {
 			d->modified = true;
-			if (delete_on_close == false) {
-				/* Delete this entry. */
-				TALLOC_FREE(dt->delete_nt_token);
-				TALLOC_FREE(dt->delete_token);
-				*dt = d->delete_tokens[
-					d->num_delete_tokens-1];
-				d->num_delete_tokens -= 1;
-			} else {
-				/* Replace this token with the
-				   given tok. */
-				TALLOC_FREE(dt->delete_nt_token);
-				dt->delete_nt_token = dup_nt_token(dt, nt_tok);
-				SMB_ASSERT(dt->delete_nt_token != NULL);
-				TALLOC_FREE(dt->delete_token);
-				dt->delete_token = copy_unix_token(dt, tok);
-				SMB_ASSERT(dt->delete_token != NULL);
-			}
+
+			/* Replace this token with the given tok. */
+			TALLOC_FREE(dt->delete_nt_token);
+			dt->delete_nt_token = dup_nt_token(dt, nt_tok);
+			SMB_ASSERT(dt->delete_nt_token != NULL);
+			TALLOC_FREE(dt->delete_token);
+			dt->delete_token = copy_unix_token(dt, tok);
+			SMB_ASSERT(dt->delete_token != NULL);
+
 			return;
 		}
 	}
 
-	if (!delete_on_close) {
-		/* Nothing to delete - not found. */
-		return;
-	}
-
 	ret = add_delete_on_close_token(lck->data, fsp->name_hash, nt_tok, tok);
 	SMB_ASSERT(ret);
+
+	ndr_err = ndr_push_struct_blob(&fid_blob, talloc_tos(), &fsp->file_id,
+				       (ndr_push_flags_fn_t)ndr_push_file_id);
+	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+		DEBUG(10, ("ndr_push_file_id failed: %s\n",
+			   ndr_errstr(ndr_err)));
+	}
+
+	for (i=0; i<d->num_share_modes; i++) {
+		struct share_mode_entry *e = &d->share_modes[i];
+		NTSTATUS status;
+
+		status = messaging_send(
+			msg_ctx, e->pid, MSG_SMB_NOTIFY_CANCEL_DELETED,
+			&fid_blob);
+
+		if (!NT_STATUS_IS_OK(status)) {
+			struct server_id_buf tmp;
+			DEBUG(10, ("%s: messaging_send to %s returned %s\n",
+				   __func__, server_id_str_buf(e->pid, &tmp),
+				   nt_errstr(status)));
+		}
+	}
+
+	TALLOC_FREE(fid_blob.data);
 }
 
 bool set_delete_on_close(files_struct *fsp, bool delete_on_close,
@@ -1161,13 +1192,9 @@ bool set_delete_on_close(files_struct *fsp, bool delete_on_close,
 	}
 
 	if (delete_on_close) {
-		set_delete_on_close_lck(fsp, lck, true,
-			nt_tok,
-			tok);
+		set_delete_on_close_lck(fsp, lck, nt_tok, tok);
 	} else {
-		set_delete_on_close_lck(fsp, lck, false,
-			NULL,
-			NULL);
+		reset_delete_on_close_lck(fsp, lck);
 	}
 
 	if (fsp->is_directory) {
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index c4ea198..75faa94 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -185,9 +185,10 @@ bool get_delete_on_close_token(struct share_mode_lock *lck,
 				uint32_t name_hash,
 				const struct security_token **pp_nt_tok,
 				const struct security_unix_token **pp_tok);
+void reset_delete_on_close_lck(files_struct *fsp,
+			       struct share_mode_lock *lck);
 void set_delete_on_close_lck(files_struct *fsp,
 			struct share_mode_lock *lck,
-			bool delete_on_close,
 			const struct security_token *nt_tok,
 			const struct security_unix_token *tok);
 bool set_delete_on_close(files_struct *fsp, bool delete_on_close,
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index fc1d380..0e75bf0 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -303,7 +303,7 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
 			became_user = True;
 		}
 		fsp->delete_on_close = true;
-		set_delete_on_close_lck(fsp, lck, True,
+		set_delete_on_close_lck(fsp, lck,
 				get_current_nttok(conn),
 				get_current_utok(conn));
 		if (became_user) {
@@ -461,7 +461,7 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
  	 */
 
 	fsp->delete_on_close = false;
-	set_delete_on_close_lck(fsp, lck, false, NULL, NULL);
+	reset_delete_on_close_lck(fsp, lck);
 
  done:
 
@@ -1083,7 +1083,7 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
 		}
 		send_stat_cache_delete_message(fsp->conn->sconn->msg_ctx,
 					       fsp->fsp_name->base_name);
-		set_delete_on_close_lck(fsp, lck, true,
+		set_delete_on_close_lck(fsp, lck,
 				get_current_nttok(fsp->conn),
 				get_current_utok(fsp->conn));
 		fsp->delete_on_close = true;
diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c
index 0e4969d..90b3ac0 100644
--- a/source3/smbd/notify.c
+++ b/source3/smbd/notify.c
@@ -23,6 +23,7 @@
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "../librpc/gen_ndr/ndr_notify.h"
+#include "librpc/gen_ndr/ndr_file_id.h"
 
 struct notify_change_event {
 	struct timespec when;
@@ -439,6 +440,48 @@ void smbd_notify_cancel_by_smbreq(const struct smb_request *smbreq)
 	smbd_notify_cancel_by_map(map);
 }
 
+static struct files_struct *smbd_notify_cancel_deleted_fn(
+	struct files_struct *fsp, void *private_data)
+{
+	struct file_id *fid = talloc_get_type_abort(
+		private_data, struct file_id);
+
+	if (file_id_equal(&fsp->file_id, fid)) {
+		remove_pending_change_notify_requests_by_fid(
+			fsp, NT_STATUS_DELETE_PENDING);
+	}
+	return NULL;
+}
+
+void smbd_notify_cancel_deleted(struct messaging_context *msg,
+				void *private_data, uint32_t msg_type,
+				struct server_id server_id, DATA_BLOB *data)
+{
+	struct smbd_server_connection *sconn = talloc_get_type_abort(
+		private_data, struct smbd_server_connection);
+	struct file_id *fid;
+	enum ndr_err_code ndr_err;
+
+	fid = talloc(talloc_tos(), struct file_id);
+	if (fid == NULL) {
+		DEBUG(1, ("talloc failed\n"));
+		return;
+	}
+
+	ndr_err = ndr_pull_struct_blob_all(
+		data, fid, fid, (ndr_pull_flags_fn_t)ndr_pull_file_id);
+	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+		DEBUG(10, ("%s: ndr_pull_file_id failed: %s\n", __func__,
+			   ndr_errstr(ndr_err)));
+		goto done;
+	}
+
+	files_forall(sconn, smbd_notify_cancel_deleted_fn, fid);
+
+done:
+	TALLOC_FREE(fid);
+}
+
 /****************************************************************************
  Delete entries by fnum from the change notify pending queue.
 *****************************************************************************/
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 259a109..abfb543 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -519,6 +519,9 @@ NTSTATUS change_notify_add_request(struct smb_request *req,
 				void (*reply_fn)(struct smb_request *req,
 					NTSTATUS error_code,
 					uint8_t *buf, size_t len));
+void smbd_notify_cancel_deleted(struct messaging_context *msg,
+				void *private_data, uint32_t msg_type,
+				struct server_id server_id, DATA_BLOB *data);
 void remove_pending_change_notify_requests_by_mid(
 	struct smbd_server_connection *sconn, uint64_t mid);
 void remove_pending_change_notify_requests_by_fid(files_struct *fsp,
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index ada2d07..d11987e 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -682,6 +682,10 @@ static NTSTATUS make_connection_snum(struct smbXsrv_connection *xconn,
 		if (sconn->notify_ctx == NULL) {
 			sconn->notify_ctx = notify_init(
 				sconn, sconn->msg_ctx, sconn->ev_ctx);
+			status = messaging_register(
+				sconn->msg_ctx, sconn,
+				MSG_SMB_NOTIFY_CANCEL_DELETED,
+				smbd_notify_cancel_deleted);
 		}
 		if (sconn->sys_notify_ctx == NULL) {
 			sconn->sys_notify_ctx = sys_notify_context_create(
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index caa9ed1..09ca278 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -824,6 +824,7 @@ static void request_finished(struct winbindd_cli_state *state)
 		return;
 	}
 	tevent_req_set_callback(req, winbind_client_response_written, state);
+	state->io_req = req;
 }
 
 static void winbind_client_response_written(struct tevent_req *req)
@@ -833,6 +834,8 @@ static void winbind_client_response_written(struct tevent_req *req)
 	ssize_t ret;
 	int err;
 
+	state->io_req = NULL;
+
 	ret = wb_resp_write_recv(req, &err);
 	TALLOC_FREE(req);
 	if (ret == -1) {
@@ -859,6 +862,7 @@ static void winbind_client_response_written(struct tevent_req *req)
 		return;
 	}
 	tevent_req_set_callback(req, winbind_client_request_read, state);
+	state->io_req = req;
 }
 
 void request_error(struct winbindd_cli_state *state)
@@ -929,6 +933,7 @@ static void new_connection(int listen_sock, bool privileged)
 		return;
 	}
 	tevent_req_set_callback(req, winbind_client_request_read, state);
+	state->io_req = req;
 
 	/* Add to connection list */
 
@@ -942,6 +947,8 @@ static void winbind_client_request_read(struct tevent_req *req)
 	ssize_t ret;
 	int err;
 
+	state->io_req = NULL;
+
 	ret = wb_req_read_recv(req, state, &state->request, &err);
 	TALLOC_FREE(req);
 	if (ret == -1) {
@@ -973,6 +980,25 @@ static void remove_client(struct winbindd_cli_state *state)
 		return;
 	}
 
+	/*
+	 * We need to remove a pending wb_req_read_*
+	 * or wb_resp_write_* request before closing the
+	 * socket.
+	 *
+	 * This is important as they might have used tevent_add_fd() and we
+	 * use the epoll * backend on linux. So we must remove the tevent_fd
+	 * before closing the fd.
+	 *
+	 * Otherwise we might hit a race with close_conns_after_fork() (via
+	 * winbindd_reinit_after_fork()) where a file description
+	 * is still open in a child, which means it's still active in
+	 * the parents epoll queue, but the related tevent_fd is already
+	 * already gone in the parent.
+	 *
+	 * See bug #11141.
+	 */
+	TALLOC_FREE(state->io_req);
+
 	if (state->sock != -1) {
 		/* tell client, we are closing ... */
 		nwritten = write(state->sock, &c, sizeof(c));
diff --git a/source3/winbindd/winbindd.h b/source3/winbindd/winbindd.h
index db5dac8..d9adb96 100644
--- a/source3/winbindd/winbindd.h
+++ b/source3/winbindd/winbindd.h
@@ -67,6 +67,7 @@ struct winbindd_cli_state {
 	struct winbindd_request *request;         /* Request from client */
 	struct tevent_queue *out_queue;
 	struct winbindd_response *response;        /* Respose to client */
+	struct tevent_req *io_req; /* wb_req_read_* or wb_resp_write_* */
 
 	struct getpwent_state *pwent_state; /* State for getpwent() */
 	struct getgrent_state *grent_state; /* State for getgrent() */
diff --git a/source4/libcli/finddcs_cldap.c b/source4/libcli/finddcs_cldap.c
index ce0e1c7..b385b1c 100644
--- a/source4/libcli/finddcs_cldap.c
+++ b/source4/libcli/finddcs_cldap.c
@@ -42,6 +42,7 @@ struct finddcs_cldap_state {
 	uint32_t srv_address_index;
 	struct cldap_socket *cldap;
 	struct cldap_netlogon *netlogon;
+	NTSTATUS status;
 };
 
 static void finddcs_cldap_srv_resolved(struct composite_context *ctx);
@@ -245,10 +246,15 @@ static void finddcs_cldap_next_server(struct finddcs_cldap_state *state)
 	struct tevent_req *subreq;
 	struct tsocket_address *dest;
 	int ret;
-	NTSTATUS status;
+
+	TALLOC_FREE(state->cldap);
 
 	if (state->srv_addresses[state->srv_address_index] == NULL) {
-		tevent_req_nterror(state->req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
+		if (NT_STATUS_IS_OK(state->status)) {
+			tevent_req_nterror(state->req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
+		} else {
+			tevent_req_nterror(state->req, state->status);
+		}
 		DEBUG(2,("finddcs: No matching CLDAP server found\n"));
 		return;
 	}
@@ -259,22 +265,29 @@ static void finddcs_cldap_next_server(struct finddcs_cldap_state *state)
 						389,
 						&dest);
 	if (ret == 0) {
-		status = NT_STATUS_OK;
+		state->status = NT_STATUS_OK;
 	} else {
-		status = map_nt_error_from_unix_common(errno);
+		state->status = map_nt_error_from_unix_common(errno);
 	}
-	if (tevent_req_nterror(state->req, status)) {
+	if (!NT_STATUS_IS_OK(state->status)) {
+		state->srv_address_index++;
+		finddcs_cldap_next_server(state);
 		return;
 	}
 
-	status = cldap_socket_init(state, NULL, dest, &state->cldap);
-	if (tevent_req_nterror(state->req, status)) {
+	state->status = cldap_socket_init(state, NULL, dest, &state->cldap);
+	if (!NT_STATUS_IS_OK(state->status)) {
+		state->srv_address_index++;
+		finddcs_cldap_next_server(state);
 		return;
 	}
 
 	TALLOC_FREE(state->netlogon);
 	state->netlogon = talloc_zero(state, struct cldap_netlogon);
-	if (tevent_req_nomem(state->netlogon, state->req)) {
+	if (state->netlogon == NULL) {
+		state->status = NT_STATUS_NO_MEMORY;
+		state->srv_address_index++;
+		finddcs_cldap_next_server(state);
 		return;
 	}
 
@@ -283,7 +296,10 @@ static void finddcs_cldap_next_server(struct finddcs_cldap_state *state)
 	}
 	if (state->domain_sid) {
 		state->netlogon->in.domain_sid = dom_sid_string(state, state->domain_sid);
-		if (tevent_req_nomem(state->netlogon->in.domain_sid, state->req)) {
+		if (state->netlogon->in.domain_sid == NULL) {
+			state->status = NT_STATUS_NO_MEMORY;
+			state->srv_address_index++;
+			finddcs_cldap_next_server(state);
 			return;
 		}
 	}
@@ -299,7 +315,10 @@ static void finddcs_cldap_next_server(struct finddcs_cldap_state *state)
 
 	subreq = cldap_netlogon_send(state, state->ev,
 				     state->cldap, state->netlogon);
-	if (tevent_req_nomem(subreq, state->req)) {
+	if (subreq == NULL) {
+		state->status = NT_STATUS_NO_MEMORY;
+		state->srv_address_index++;
+		finddcs_cldap_next_server(state);
 		return;
 	}
 
@@ -321,6 +340,7 @@ static void finddcs_cldap_netlogon_replied(struct tevent_req *subreq)
 	TALLOC_FREE(subreq);
 	TALLOC_FREE(state->cldap);
 	if (!NT_STATUS_IS_OK(status)) {
+		state->status = status;
 		state->srv_address_index++;
 		finddcs_cldap_next_server(state);
 		return;
@@ -364,6 +384,7 @@ static void finddcs_cldap_name_resolved(struct composite_context *ctx)
 
 	state->srv_address_index = 0;
 
+	state->status = NT_STATUS_OK;
 	finddcs_cldap_next_server(state);
 }
 
@@ -416,6 +437,7 @@ static void finddcs_cldap_srv_resolved(struct composite_context *ctx)
 
 	state->srv_address_index = 0;
 
+	state->status = NT_STATUS_OK;
 	finddcs_cldap_next_server(state);
 }
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list