[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Mon May 31 13:37:52 MDT 2010


The branch, master has been updated
       via  d33c41f... s3:winbindd move reinit_after_fork() back out of winbindd_register_handlers
       via  19f4229... s3:winbind Make state->mem_ctx a talloc child of state
       via  61eb56b... s3:winbind tidy up connecting the winbind sockets.
       via  e5ebc52... Revert "s3:winbindd Split helper functions to allow s3compat to call them"
      from  fca69a9... s3-netlogon: Fix crash bug in _netr_NetrEnumerateTrustedDomains().

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


- Log -----------------------------------------------------------------
commit d33c41fbf5bd48fe32d82174d8bd25d1651ee374
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu May 13 17:07:15 2010 +1000

    s3:winbindd move reinit_after_fork() back out of winbindd_register_handlers
    
    This particular init function needs to be done in a native Samba3
    build, but it turns out to be difficult for s3compat, which has other
    code listening on the sockets.
    
    Andrew Bartlett

commit 19f4229fff0f0e350d0eb6e91f674c48c744d214
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon May 24 10:11:23 2010 +1000

    s3:winbind Make state->mem_ctx a talloc child of state
    
    This way everything is destoryed at the conclusion of
    the connection correctly.
    
    Andrew Bartlett
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 61eb56be4ea1f4eb26f63b985aeb52cdb1183328
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon May 17 19:34:32 2010 +1000

    s3:winbind tidy up connecting the winbind sockets.
    
    By putting this code inline in winbindd_setup_listeners() we remove 2
    static variables and simplify the code.
    
    By putting the get_winbind_priv_pipe_dir() in the same file, we allow
    it to be reimplemented in s3compat.
    
    Andrew Bartlett
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit e5ebc52e9fd45346a74e2c421f2471b5e6cab998
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri May 14 13:11:48 2010 +1000

    Revert "s3:winbindd Split helper functions to allow s3compat to call them"
    
    I'm experimenting with a different entry point
    
    This reverts commit f5c0f90da5f5372ca6b7a72daa8d073a2444a068.

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

Summary of changes:
 source3/winbindd/winbindd.c       |   97 ++++++++++++++++++++-----------------
 source3/winbindd/winbindd_proto.h |    7 +--
 source3/winbindd/winbindd_util.c  |   43 ----------------
 3 files changed, 55 insertions(+), 92 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 1c87a14..fcd3145 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -574,7 +574,7 @@ static void process_request(struct winbindd_cli_state *state)
 	struct winbindd_dispatch_table *table = dispatch_table;
 	struct winbindd_async_dispatch_table *atable;
 
-	state->mem_ctx = talloc_init("winbind request");
+	state->mem_ctx = talloc_named(state, 0, "winbind request");
 	if (state->mem_ctx == NULL)
 		return;
 
@@ -763,23 +763,40 @@ void request_ok(struct winbindd_cli_state *state)
 
 /* Process a new connection by adding it to the client connection list */
 
-void winbindd_accepted_new_connection(int accepted_sock, bool privileged)
+static void new_connection(int listen_sock, bool privileged)
 {
+	struct sockaddr_un sunaddr;
 	struct winbindd_cli_state *state;
 	struct tevent_req *req;
+	socklen_t len;
+	int sock;
+
+	/* Accept connection */
+
+	len = sizeof(sunaddr);
+
+	do {
+		sock = accept(listen_sock, (struct sockaddr *)(void *)&sunaddr,
+			      &len);
+	} while (sock == -1 && errno == EINTR);
+
+	if (sock == -1)
+		return;
+
+	DEBUG(6,("accepted socket %d\n", sock));
 
 	/* Create new connection structure */
 
 	if ((state = TALLOC_ZERO_P(NULL, struct winbindd_cli_state)) == NULL) {
-		close(accepted_sock);
+		close(sock);
 		return;
 	}
 
-	state->sock = accepted_sock;
+	state->sock = sock;
 
 	state->out_queue = tevent_queue_create(state, "winbind client reply");
 	if (state->out_queue == NULL) {
-		close(accepted_sock);
+		close(sock);
 		TALLOC_FREE(state);
 		return;
 	}
@@ -792,40 +809,16 @@ void winbindd_accepted_new_connection(int accepted_sock, bool privileged)
 			       WINBINDD_MAX_EXTRA_DATA);
 	if (req == NULL) {
 		TALLOC_FREE(state);
-		close(accepted_sock);
+		close(sock);
 		return;
 	}
 	tevent_req_set_callback(req, winbind_client_request_read, state);
 
 	/* Add to connection list */
 
-	/* Once the client is added here, we can be sure something will close it eventually */
 	winbindd_add_client(state);
 }
 
-static void new_connection(int listen_sock, bool privileged)
-{
-	struct sockaddr_un sunaddr;
-	socklen_t len;
-	int sock;
-
-	/* Accept connection */
-
-	len = sizeof(sunaddr);
-
-	do {
-		sock = accept(listen_sock, (struct sockaddr *)(void *)&sunaddr,
-			      &len);
-	} while (sock == -1 && errno == EINTR);
-
-	if (sock == -1)
-		return;
-
-	DEBUG(6,("accepted socket %d\n", sock));
-
-	winbindd_accepted_new_connection(sock, privileged);
-}
-
 static void winbind_client_request_read(struct tevent_req *req)
 {
 	struct winbindd_cli_state *state = tevent_req_callback_data(
@@ -945,6 +938,20 @@ static void winbindd_listen_fde_handler(struct tevent_context *ev,
 	new_connection(s->fd, s->privileged);
 }
 
+/*
+ * Winbindd socket accessor functions
+ */
+
+const char *get_winbind_pipe_dir(void)
+{
+	return lp_parm_const_string(-1, "winbindd", "socket dir", WINBINDD_SOCKET_DIR);
+}
+
+char *get_winbind_priv_pipe_dir(void)
+{
+	return lock_path(WINBINDD_PRIV_SOCKET_SUBDIR);
+}
+
 static bool winbindd_setup_listeners(void)
 {
 	struct winbindd_listen_state *pub_state = NULL;
@@ -958,7 +965,8 @@ static bool winbindd_setup_listeners(void)
 	}
 
 	pub_state->privileged = false;
-	pub_state->fd = open_winbindd_socket();
+	pub_state->fd = create_pipe_sock(
+		get_winbind_pipe_dir(), WINBINDD_SOCKET_NAME, 0755);
 	if (pub_state->fd == -1) {
 		goto failed;
 	}
@@ -979,7 +987,8 @@ static bool winbindd_setup_listeners(void)
 	}
 
 	priv_state->privileged = true;
-	priv_state->fd = open_winbindd_priv_socket();
+	priv_state->fd = create_pipe_sock(
+		get_winbind_priv_pipe_dir(), WINBINDD_SOCKET_NAME, 0750);
 	if (priv_state->fd == -1) {
 		goto failed;
 	}
@@ -1013,18 +1022,6 @@ bool winbindd_use_cache(void)
 void winbindd_register_handlers(void)
 {
 	struct tevent_timer *te;
-	/* Don't use winbindd_reinit_after_fork here as
-	 * we're just starting up and haven't created any
-	 * winbindd-specific resources we must free yet. JRA.
-	 */
-
-	if (!NT_STATUS_IS_OK(reinit_after_fork(winbind_messaging_context(),
-					       winbind_event_context(),
-					       false))) {
-		DEBUG(0,("reinit_after_fork() failed\n"));
-		exit(1);
-	}
-
 	/* Setup signal handlers */
 
 	if (!winbindd_setup_sig_term_handler(true))
@@ -1289,6 +1286,18 @@ int main(int argc, char **argv, char **envp)
 
 	TimeInit();
 
+	/* Don't use winbindd_reinit_after_fork here as
+	 * we're just starting up and haven't created any
+	 * winbindd-specific resources we must free yet. JRA.
+	 */
+
+	if (!NT_STATUS_IS_OK(reinit_after_fork(winbind_messaging_context(),
+					       winbind_event_context(),
+					       false))) {
+		DEBUG(0,("reinit_after_fork() failed\n"));
+		exit(1);
+	}
+
 	winbindd_register_handlers();
 
 	/* setup listen sockets */
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 8ebbb2a..49e66f2 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -44,7 +44,6 @@ void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
 struct event_context *winbind_event_context(void);
 
 /* The following definitions come from winbindd/winbindd.c  */
-void winbindd_accepted_new_connection(int accepted_sock, bool privileged);
 struct messaging_context *winbind_messaging_context(void);
 void request_error(struct winbindd_cli_state *state);
 void request_ok(struct winbindd_cli_state *state);
@@ -53,6 +52,8 @@ bool winbindd_setup_sig_hup_handler(const char *lfile);
 bool winbindd_use_idmap_cache(void);
 bool winbindd_use_cache(void);
 void winbindd_register_handlers(void);
+const char *get_winbind_pipe_dir(void);
+char *get_winbind_priv_pipe_dir(void);
 int main(int argc, char **argv, char **envp);
 
 /* The following definitions come from winbindd/winbindd_ads.c  */
@@ -417,10 +418,6 @@ char *fill_domain_username_talloc(TALLOC_CTX *ctx,
 				  const char *domain,
 				  const char *user,
 				  bool can_assume);
-const char *get_winbind_pipe_dir(void) ;
-char *get_winbind_priv_pipe_dir(void) ;
-int open_winbindd_socket(void);
-int open_winbindd_priv_socket(void);
 struct winbindd_cli_state *winbindd_client_list(void);
 void winbindd_add_client(struct winbindd_cli_state *cli);
 void winbindd_remove_client(struct winbindd_cli_state *cli);
diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c
index 970e599..735a446 100644
--- a/source3/winbindd/winbindd_util.c
+++ b/source3/winbindd/winbindd_util.c
@@ -1029,49 +1029,6 @@ char *fill_domain_username_talloc(TALLOC_CTX *mem_ctx,
 }
 
 /*
- * Winbindd socket accessor functions
- */
-
-const char *get_winbind_pipe_dir(void)
-{
-	return lp_parm_const_string(-1, "winbindd", "socket dir", WINBINDD_SOCKET_DIR);
-}
-
-char *get_winbind_priv_pipe_dir(void)
-{
-	return lock_path(WINBINDD_PRIV_SOCKET_SUBDIR);
-}
-
-/* Open the winbindd socket */
-
-static int _winbindd_socket = -1;
-static int _winbindd_priv_socket = -1;
-
-int open_winbindd_socket(void)
-{
-	if (_winbindd_socket == -1) {
-		_winbindd_socket = create_pipe_sock(
-			get_winbind_pipe_dir(), WINBINDD_SOCKET_NAME, 0755);
-		DEBUG(10, ("open_winbindd_socket: opened socket fd %d\n",
-			   _winbindd_socket));
-	}
-
-	return _winbindd_socket;
-}
-
-int open_winbindd_priv_socket(void)
-{
-	if (_winbindd_priv_socket == -1) {
-		_winbindd_priv_socket = create_pipe_sock(
-			get_winbind_priv_pipe_dir(), WINBINDD_SOCKET_NAME, 0750);
-		DEBUG(10, ("open_winbindd_priv_socket: opened socket fd %d\n",
-			   _winbindd_priv_socket));
-	}
-
-	return _winbindd_priv_socket;
-}
-
-/*
  * Client list accessor functions
  */
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list