[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Jan 18 14:14:03 MST 2013


The branch, master has been updated
       via  63a7d38 nsswitch: Fix two bitfield constants being the same.
       via  d814cfa Sort winbind request flags. Ira saw we have a duplicate.
       via  a8fe624 smbtorture: Satisfy a linker dependency
       via  15596a8 winbind: Handle child requests in a tevent_fd
       via  5e75564 winbind: Introduce "struct child_handler_state"
       via  3e830e4 winbind: Use standard tevent_context_init
      from  4f9cffb BUG 9378: Add extra attributes for AD printer publishing.

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


- Log -----------------------------------------------------------------
commit 63a7d3817fae3ec190a7919521cc0f5dbdea3b64
Author: Ira Cooper <ira at samba.org>
Date:   Wed Jan 16 11:33:31 2013 -0800

    nsswitch: Fix two bitfield constants being the same.
    
    WBFLAG_PAM_AUTH_PAC and WBFLAG_BIG_NTLMV2_BLOB
    are the same causing errors in NTLMv2 authentication.
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Jan 18 22:13:09 CET 2013 on sn-devel-104

commit d814cfac017039ae8fc0d1311b15cc03f4c8b2ba
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Jan 16 11:31:32 2013 -0800

    Sort winbind request flags. Ira saw we have a duplicate.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed by: Ira Cooper <ira at wakeful.net>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit a8fe624948f06e76aeb147ce0e47326f2d753f93
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jan 17 15:22:32 2013 +0100

    smbtorture: Satisfy a linker dependency
    
    Reviewed by: Jeremy Allison <jra at samba.org>

commit 15596a8d9c5a578fa98e110350d15265c90e8f03
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jan 17 14:34:35 2013 +0100

    winbind: Handle child requests in a tevent_fd
    
    This enables the use of standard tevent_loop_once in the child, which
    now also uses epoll where available.
    
    Reviewed by: Jeremy Allison <jra at samba.org>

commit 5e755643772d4615410599961859102f7c679d1c
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jan 17 13:49:08 2013 +0100

    winbind: Introduce "struct child_handler_state"
    
    This will make the next patch simpler. child_handler_state contains the
    information that the handler for the parent fde needs to pass to
    process_child_request
    
    Reviewed by: Jeremy Allison <jra at samba.org>

commit 3e830e44d3eb23325fbda6f2053e58926ee2136e
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Jan 16 12:00:00 2013 +0100

    winbind: Use standard tevent_context_init
    
    This makes winbind use epoll instead of poll
    
    Reviewed by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 nsswitch/winbind_struct_protocol.h |   16 ++--
 source3/torture/torture.c          |    9 ++-
 source3/winbindd/winbindd.c        |   38 +++++++-
 source3/winbindd/winbindd.h        |    2 -
 source3/winbindd/winbindd_dual.c   |  186 +++++++++++++++---------------------
 source3/winbindd/winbindd_proto.h  |    1 +
 6 files changed, 126 insertions(+), 126 deletions(-)


Changeset truncated at 500 lines:

diff --git a/nsswitch/winbind_struct_protocol.h b/nsswitch/winbind_struct_protocol.h
index c1704c8..4a41ba3 100644
--- a/nsswitch/winbind_struct_protocol.h
+++ b/nsswitch/winbind_struct_protocol.h
@@ -205,27 +205,25 @@ typedef struct winbindd_gr {
 	uint32_t gr_mem_ofs;   /* offset to group membership */
 } WINBINDD_GR;
 
-/* PAM specific request flags */
+/* Request flags */
 #define WBFLAG_PAM_INFO3_NDR		0x00000001
 #define WBFLAG_PAM_INFO3_TEXT		0x00000002
 #define WBFLAG_PAM_USER_SESSION_KEY	0x00000004
 #define WBFLAG_PAM_LMKEY		0x00000008
 #define WBFLAG_PAM_CONTACT_TRUSTDOM	0x00000010
+#define WBFLAG_QUERY_ONLY		0x00000020	/* not used */
+#define WBFLAG_PAM_AUTH_PAC		0x00000040
 #define WBFLAG_PAM_UNIX_NAME		0x00000080
 #define WBFLAG_PAM_AFS_TOKEN		0x00000100
 #define WBFLAG_PAM_NT_STATUS_SQUASH	0x00000200
-#define WBFLAG_PAM_KRB5			0x00001000
-#define WBFLAG_PAM_FALLBACK_AFTER_KRB5	0x00002000
-#define WBFLAG_PAM_CACHED_LOGIN		0x00004000
-#define WBFLAG_PAM_GET_PWD_POLICY	0x00008000
-#define WBFLAG_PAM_AUTH_PAC		0x00010000
-
-/* generic request flags */
-#define WBFLAG_QUERY_ONLY		0x00000020	/* not used */
 /* This is a flag that can only be sent from parent to child */
 #define WBFLAG_IS_PRIVILEGED		0x00000400	/* not used */
 /* Flag to say this is a winbindd internal send - don't recurse. */
 #define WBFLAG_RECURSE			0x00000800
+#define WBFLAG_PAM_KRB5			0x00001000
+#define WBFLAG_PAM_FALLBACK_AFTER_KRB5	0x00002000
+#define WBFLAG_PAM_CACHED_LOGIN		0x00004000
+#define WBFLAG_PAM_GET_PWD_POLICY	0x00008000
 /* Flag to tell winbind the NTLMv2 blob is too big for the struct and is in the
  * extra_data field */
 #define WBFLAG_BIG_NTLMV2_BLOB		0x00010000
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index d31c907..799c911 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -9153,7 +9153,14 @@ static struct {
 	{ "LOCAL-DBWRAP-CTDB", run_local_dbwrap_ctdb, 0 },
 	{NULL, NULL, 0}};
 
-
+/*
+ * dummy function to satisfy linker dependency
+ */
+struct tevent_context *winbind_event_context(void);
+struct tevent_context *winbind_event_context(void)
+{
+	return NULL;
+}
 
 /****************************************************************************
 run a specified test or "ALL"
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 698c96c..ebaa080 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -49,14 +49,42 @@ static bool interactive = False;
 
 extern bool override_logfile;
 
+struct tevent_context *winbind_event_context(void)
+{
+	static struct tevent_context *ev = NULL;
+
+	if (ev != NULL) {
+		return ev;
+	}
+
+	/*
+	 * Note we MUST use the NULL context here, not the autofree context,
+	 * to avoid side effects in forked children exiting.
+	 */
+	ev = tevent_context_init(NULL);
+	if (ev == NULL) {
+		smb_panic("Could not init winbindd's messaging context.\n");
+	}
+	return ev;
+}
+
 struct messaging_context *winbind_messaging_context(void)
 {
-	struct messaging_context *msg_ctx = server_messaging_context();
-	if (likely(msg_ctx != NULL)) {
-		return msg_ctx;
+	static struct messaging_context *msg = NULL;
+
+	if (msg != NULL) {
+		return msg;
+	}
+
+	/*
+	 * Note we MUST use the NULL context here, not the autofree context,
+	 * to avoid side effects in forked children exiting.
+	 */
+	msg = messaging_init(NULL, winbind_event_context());
+	if (msg == NULL) {
+		smb_panic("Could not init winbindd's messaging context.\n");
 	}
-	smb_panic("Could not init winbindd's messaging context.\n");
-	return NULL;
+	return msg;
 }
 
 /* Reload configuration */
diff --git a/source3/winbindd/winbindd.h b/source3/winbindd/winbindd.h
index 33c7bbe..c01cac7 100644
--- a/source3/winbindd/winbindd.h
+++ b/source3/winbindd/winbindd.h
@@ -396,6 +396,4 @@ struct WINBINDD_CCACHE_ENTRY {
 #define WINBINDD_PAM_AUTH_KRB5_RENEW_TIME 2592000 /* one month */
 #define DOM_SEQUENCE_NONE ((uint32)-1)
 
-#define winbind_event_context server_event_context
-
 #endif /* _WINBINDD_H */
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index 60b15e3..14e60f5 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -1289,15 +1289,73 @@ struct winbindd_domain *wb_child_domain(void)
 	return child_domain;
 }
 
+struct child_handler_state {
+	struct winbindd_child *child;
+	struct winbindd_cli_state cli;
+};
+
+static void child_handler(struct tevent_context *ev, struct tevent_fd *fde,
+			  uint16_t flags, void *private_data)
+{
+	struct child_handler_state *state =
+		(struct child_handler_state *)private_data;
+	NTSTATUS status;
+	struct iovec iov[2];
+	int iov_count;
+
+	/* fetch a request from the main daemon */
+	status = child_read_request(&state->cli);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		/* we lost contact with our parent */
+		_exit(0);
+	}
+
+	DEBUG(4,("child daemon request %d\n",
+		 (int)state->cli.request->cmd));
+
+	ZERO_STRUCTP(state->cli.response);
+	state->cli.request->null_term = '\0';
+	state->cli.mem_ctx = talloc_tos();
+	child_process_request(state->child, &state->cli);
+
+	DEBUG(4, ("Finished processing child request %d\n",
+		  (int)state->cli.request->cmd));
+
+	SAFE_FREE(state->cli.request->extra_data.data);
+
+	iov[0].iov_base = (void *)state->cli.response;
+	iov[0].iov_len = sizeof(struct winbindd_response);
+	iov_count = 1;
+
+	if (state->cli.response->length >
+	    sizeof(struct winbindd_response)) {
+		iov[1].iov_base =
+			(void *)state->cli.response->extra_data.data;
+		iov[1].iov_len = state->cli.response->length-iov[0].iov_len;
+		iov_count = 2;
+	}
+
+	DEBUG(10, ("Writing %d bytes to parent\n",
+		   (int)state->cli.response->length));
+
+	if (write_data_iov(state->cli.sock, iov, iov_count) !=
+	    state->cli.response->length) {
+		DEBUG(0, ("Could not write result\n"));
+		exit(1);
+	}
+}
+
 static bool fork_domain_child(struct winbindd_child *child)
 {
 	int fdpair[2];
-	struct winbindd_cli_state state;
+	struct child_handler_state state;
 	struct winbindd_request request;
 	struct winbindd_response response;
 	struct winbindd_domain *primary_domain = NULL;
 	NTSTATUS status;
 	ssize_t nwritten;
+	struct tevent_fd *fde;
 
 	if (child->domain) {
 		DEBUG(10, ("fork_domain_child called for domain '%s'\n",
@@ -1313,9 +1371,10 @@ static bool fork_domain_child(struct winbindd_child *child)
 	}
 
 	ZERO_STRUCT(state);
-	state.pid = getpid();
-	state.request = &request;
-	state.response = &response;
+	state.child = child;
+	state.cli.pid = getpid();
+	state.cli.request = &request;
+	state.cli.response = &response;
 
 	child->pid = fork();
 
@@ -1356,12 +1415,12 @@ static bool fork_domain_child(struct winbindd_child *child)
 
 	DEBUG(10, ("Child process %d\n", (int)getpid()));
 
-	state.sock = fdpair[0];
+	state.cli.sock = fdpair[0];
 	close(fdpair[1]);
 
 	status = winbindd_reinit_after_fork(child, child->logfilename);
 
-	nwritten = sys_write(state.sock, &status, sizeof(status));
+	nwritten = sys_write(state.cli.sock, &status, sizeof(status));
 	if (nwritten != sizeof(status)) {
 		DEBUG(1, ("fork_domain_child: Could not write status: "
 			  "nwritten=%d, error=%s\n", (int)nwritten,
@@ -1459,21 +1518,23 @@ static bool fork_domain_child(struct winbindd_child *child)
 		}
 	}
 
+	fde = tevent_add_fd(winbind_event_context(), NULL, state.cli.sock,
+			    TEVENT_FD_READ, child_handler, &state);
+	if (fde == NULL) {
+		DEBUG(1, ("tevent_add_fd failed\n"));
+		_exit(1);
+	}
+
 	while (1) {
 
 		int ret;
-		struct pollfd *pfds;
-		int num_pfds;
-		int timeout;
-		struct timeval t;
-		struct timeval *tp;
 		TALLOC_CTX *frame = talloc_stackframe();
-		struct iovec iov[2];
-		int iov_count;
 
-		if (run_events_poll(winbind_event_context(), 0, NULL, 0)) {
-			TALLOC_FREE(frame);
-			continue;
+		ret = tevent_loop_once(winbind_event_context());
+		if (ret != 0) {
+			DEBUG(1, ("tevent_loop_once failed: %s\n",
+				  strerror(errno)));
+			_exit(1);
 		}
 
 		if (child->domain && child->domain->startup &&
@@ -1484,99 +1545,6 @@ static bool fork_domain_child(struct winbindd_child *child)
 			child->domain->startup = False;
 		}
 
-		pfds = talloc_zero(talloc_tos(), struct pollfd);
-		if (pfds == NULL) {
-			DEBUG(1, ("talloc failed\n"));
-			_exit(1);
-		}
-
-		pfds->fd = state.sock;
-		pfds->events = POLLIN|POLLHUP;
-		num_pfds = 1;
-
-		timeout = INT_MAX;
-
-		if (!event_add_to_poll_args(
-			    winbind_event_context(), talloc_tos(),
-			    &pfds, &num_pfds, &timeout)) {
-			DEBUG(1, ("event_add_to_poll_args failed\n"));
-			_exit(1);
-		}
-		tp = get_timed_events_timeout(winbind_event_context(), &t);
-		if (tp) {
-			DEBUG(11,("select will use timeout of %u.%u seconds\n",
-				(unsigned int)tp->tv_sec, (unsigned int)tp->tv_usec ));
-		}
-
-		ret = poll(pfds, num_pfds, timeout);
-
-		if (run_events_poll(winbind_event_context(), ret,
-				    pfds, num_pfds)) {
-			/* We got a signal - continue. */
-			TALLOC_FREE(frame);
-			continue;
-		}
-
-		TALLOC_FREE(pfds);
-
-		if (ret == 0) {
-			DEBUG(11,("nothing is ready yet, continue\n"));
-			TALLOC_FREE(frame);
-			continue;
-		}
-
-		if (ret == -1 && errno == EINTR) {
-			/* We got a signal - continue. */
-			TALLOC_FREE(frame);
-			continue;
-		}
-
-		if (ret == -1 && errno != EINTR) {
-			DEBUG(0,("poll error occured\n"));
-			TALLOC_FREE(frame);
-			perror("poll");
-			_exit(1);
-		}
-
-		/* fetch a request from the main daemon */
-		status = child_read_request(&state);
-
-		if (!NT_STATUS_IS_OK(status)) {
-			/* we lost contact with our parent */
-			_exit(0);
-		}
-
-		DEBUG(4,("child daemon request %d\n", (int)state.request->cmd));
-
-		ZERO_STRUCTP(state.response);
-		state.request->null_term = '\0';
-		state.mem_ctx = frame;
-		child_process_request(child, &state);
-
-		DEBUG(4, ("Finished processing child request %d\n",
-			  (int)state.request->cmd));
-
-		SAFE_FREE(state.request->extra_data.data);
-
-		iov[0].iov_base = (void *)state.response;
-		iov[0].iov_len = sizeof(struct winbindd_response);
-		iov_count = 1;
-
-		if (state.response->length > sizeof(struct winbindd_response)) {
-			iov[1].iov_base =
-				(void *)state.response->extra_data.data;
-			iov[1].iov_len = state.response->length-iov[0].iov_len;
-			iov_count = 2;
-		}
-
-		DEBUG(10, ("Writing %d bytes to parent\n",
-			   (int)state.response->length));
-
-		if (write_data_iov(state.sock, iov, iov_count) !=
-		    state.response->length) {
-			DEBUG(0, ("Could not write result\n"));
-			exit(1);
-		}
 		TALLOC_FREE(frame);
 	}
 }
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 44693d7..33b0f01 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -34,6 +34,7 @@ bool winbindd_use_idmap_cache(void);
 bool winbindd_use_cache(void);
 const char *get_winbind_pipe_dir(void);
 char *get_winbind_priv_pipe_dir(void);
+struct tevent_context *winbind_event_context(void);
 int main(int argc, char **argv, char **envp);
 
 /* The following definitions come from winbindd/winbindd_ads.c  */


-- 
Samba Shared Repository


More information about the samba-cvs mailing list