svn commit: samba r22507 - in branches/SAMBA_3_0/source: . nsswitch

jpeach at samba.org jpeach at samba.org
Tue Apr 24 18:19:14 GMT 2007


Author: jpeach
Date: 2007-04-24 18:19:13 +0000 (Tue, 24 Apr 2007)
New Revision: 22507

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22507

Log:
Wrap the method of obtaining sockets to listen on.

Added:
   branches/SAMBA_3_0/source/nsswitch/winbindd_sockinit.c
Modified:
   branches/SAMBA_3_0/source/Makefile.in
   branches/SAMBA_3_0/source/nsswitch/winbindd.c
   branches/SAMBA_3_0/source/nsswitch/winbindd_util.c


Changeset:
Modified: branches/SAMBA_3_0/source/Makefile.in
===================================================================
--- branches/SAMBA_3_0/source/Makefile.in	2007-04-24 18:02:23 UTC (rev 22506)
+++ branches/SAMBA_3_0/source/Makefile.in	2007-04-24 18:19:13 UTC (rev 22507)
@@ -811,6 +811,7 @@
 
 WINBINDD_OBJ1 = \
 		nsswitch/winbindd.o       \
+		nsswitch/winbindd_sockinit.o \
 		nsswitch/winbindd_user.o  \
 		nsswitch/winbindd_group.o \
 		nsswitch/winbindd_util.o  \

Modified: branches/SAMBA_3_0/source/nsswitch/winbindd.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/winbindd.c	2007-04-24 18:02:23 UTC (rev 22506)
+++ branches/SAMBA_3_0/source/nsswitch/winbindd.c	2007-04-24 18:19:13 UTC (rev 22507)
@@ -26,7 +26,6 @@
 
 #include "includes.h"
 #include "winbindd.h"
-#include "smb_launchd.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_WINBIND
@@ -34,7 +33,6 @@
 BOOL opt_nocache = False;
 
 extern BOOL override_logfile;
-static BOOL unlink_winbindd_socket = True;
 
 struct event_context *winbind_event_context(void)
 {
@@ -121,15 +119,8 @@
 
 static void terminate(void)
 {
-	pstring path;
 
-	/* Remove socket file */
-	if (unlink_winbindd_socket) {
-		pstr_sprintf(path, "%s/%s",
-			 WINBINDD_SOCKET_DIR, WINBINDD_SOCKET_NAME);
-		unlink(path);
-	}
-
+	winbindd_release_sockets();
 	idmap_close();
 	
 	trustdom_cache_shutdown();
@@ -719,43 +710,6 @@
 	return False;
 }
 
-static BOOL winbindd_init_sockets(int *public_sock, int *priv_sock,
-				int *idle_timeout_sec)
-{
-	struct smb_launch_info linfo;
-
-	if (smb_launchd_checkin_names(&linfo, "WinbindPublicPipe",
-		    "WinbindPrivilegedPipe", NULL)) {
-		if (linfo.num_sockets != 2) {
-			DEBUG(0, ("invalid launchd configuration, "
-				"expected 2 sockets but got %d\n",
-				linfo.num_sockets));
-			return False;
-		}
-
-		*public_sock = linfo.socket_list[0];
-		*priv_sock = linfo.socket_list[1];
-		*idle_timeout_sec = linfo.idle_timeout_secs;
-
-		unlink_winbindd_socket = False;
-
-		smb_launchd_checkout(&linfo);
-		return True;
-	} else {
-		*public_sock = open_winbindd_socket();
-		*priv_sock = open_winbindd_priv_socket();
-		*idle_timeout_sec = -1;
-
-		if (*public_sock == -1 || *priv_sock == -1) {
-			DEBUG(0, ("failed to open winbindd pipes: %s\n",
-			    errno ? strerror(errno) : "unknown error"));
-			return False;
-		}
-
-		return True;
-	}
-}
-
 /* Process incoming clients on listen_sock.  We use a tricky non-blocking,
    non-forking, non-threaded model which allows us to handle many
    simultaneous connections while remaining impervious to many denial of

Added: branches/SAMBA_3_0/source/nsswitch/winbindd_sockinit.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/winbindd_sockinit.c	2007-04-24 18:02:23 UTC (rev 22506)
+++ branches/SAMBA_3_0/source/nsswitch/winbindd_sockinit.c	2007-04-24 18:19:13 UTC (rev 22507)
@@ -0,0 +1,127 @@
+/* 
+   Unix SMB/CIFS implementation.
+   Copyright (C) Tim Potter 2000-2001
+   Copyright (C) 2001 by Martin Pool <mbp at samba.org>
+   Copyright (C) James Peach 2007
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "winbindd.h"
+#include "smb_launchd.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_WINBIND
+
+/* Open the winbindd socket */
+
+static int _winbindd_socket = -1;
+static int _winbindd_priv_socket = -1;
+static BOOL unlink_winbindd_socket = True;
+
+static int open_winbindd_socket(void)
+{
+	if (_winbindd_socket == -1) {
+		_winbindd_socket = create_pipe_sock(
+			WINBINDD_SOCKET_DIR, WINBINDD_SOCKET_NAME, 0755);
+		DEBUG(10, ("open_winbindd_socket: opened socket fd %d\n",
+			   _winbindd_socket));
+	}
+
+	return _winbindd_socket;
+}
+
+static 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;
+}
+
+/* Close the winbindd socket */
+
+static void close_winbindd_socket(void)
+{
+	if (_winbindd_socket != -1) {
+		DEBUG(10, ("close_winbindd_socket: closing socket fd %d\n",
+			   _winbindd_socket));
+		close(_winbindd_socket);
+		_winbindd_socket = -1;
+	}
+	if (_winbindd_priv_socket != -1) {
+		DEBUG(10, ("close_winbindd_socket: closing socket fd %d\n",
+			   _winbindd_priv_socket));
+		close(_winbindd_priv_socket);
+		_winbindd_priv_socket = -1;
+	}
+}
+
+BOOL winbindd_init_sockets(int *public_sock, int *priv_sock,
+				int *idle_timeout_sec)
+{
+	struct smb_launch_info linfo;
+
+	if (smb_launchd_checkin_names(&linfo, "WinbindPublicPipe",
+		    "WinbindPrivilegedPipe", NULL)) {
+		if (linfo.num_sockets != 2) {
+			DEBUG(0, ("invalid launchd configuration, "
+				"expected 2 sockets but got %d\n",
+				linfo.num_sockets));
+			return False;
+		}
+
+		*public_sock = _winbindd_socket = linfo.socket_list[0];
+		*priv_sock = _winbindd_priv_socket = linfo.socket_list[1];
+		*idle_timeout_sec = linfo.idle_timeout_secs;
+
+		unlink_winbindd_socket = False;
+
+		smb_launchd_checkout(&linfo);
+		return True;
+	} else {
+		*public_sock = open_winbindd_socket();
+		*priv_sock = open_winbindd_priv_socket();
+		*idle_timeout_sec = -1;
+
+		if (*public_sock == -1 || *priv_sock == -1) {
+			DEBUG(0, ("failed to open winbindd pipes: %s\n",
+			    errno ? strerror(errno) : "unknown error"));
+			return False;
+		}
+
+		return True;
+	}
+}
+
+void winbindd_release_sockets(void)
+{
+	pstring path;
+
+	close_winbindd_socket();
+
+	/* Remove socket file */
+	if (unlink_winbindd_socket) {
+		pstr_sprintf(path, "%s/%s",
+			 WINBINDD_SOCKET_DIR, WINBINDD_SOCKET_NAME);
+		unlink(path);
+	}
+}
+

Modified: branches/SAMBA_3_0/source/nsswitch/winbindd_util.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/winbindd_util.c	2007-04-24 18:02:23 UTC (rev 22506)
+++ branches/SAMBA_3_0/source/nsswitch/winbindd_util.c	2007-04-24 18:19:13 UTC (rev 22507)
@@ -36,15 +36,6 @@
  * Winbind daemon for NT domain authentication nss module.
  **/
 
-
-/**
- * Used to clobber name fields that have an undefined value.
- *
- * Correct code should never look at a field that has this value.
- **/
-
-static const fstring name_deadbeef = "<deadbeef>";
-
 /* The list of trusted domains.  Note that the list can be deleted and
    recreated using the init_domain_list() function so pointers to
    individual winbindd_domain structures cannot be made.  Keep a copy of
@@ -915,53 +906,6 @@
 	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(
-			WINBINDD_SOCKET_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;
-}
-
-/* Close the winbindd socket */
-
-void close_winbindd_socket(void)
-{
-	if (_winbindd_socket != -1) {
-		DEBUG(10, ("close_winbindd_socket: closing socket fd %d\n",
-			   _winbindd_socket));
-		close(_winbindd_socket);
-		_winbindd_socket = -1;
-	}
-	if (_winbindd_priv_socket != -1) {
-		DEBUG(10, ("close_winbindd_socket: closing socket fd %d\n",
-			   _winbindd_priv_socket));
-		close(_winbindd_priv_socket);
-		_winbindd_priv_socket = -1;
-	}
-}
-
 /*
  * Client list accessor functions
  */



More information about the samba-cvs mailing list