Use less 'magic' environment variables

Andrew Bartlett abartlet at samba.org
Fri Aug 16 04:25:01 GMT 2002


I don't like 'magic' stuff - particularly 'user controlled' magic.

As such, the environment variables that control the actions of the
winbind clients (and by extention/design, the winbindd server) seem
particularly ugly.

So, I would like to get rid of them - slowly.

This patch removes WINBINDD_DOMAIN, and some of the misguided (and
fruitless) attempts to prevent winbind from calling smbd recursivly.  (I
fixed that the 'proper' way, and the worst case is a pipe timeout of 30
sec, not a lockup).

(For reference, WINBINDD_DOMAIN allows the user to specify what domains
winbind will return entries in - instead of all trusted domains)

This does not remove the _NO_WINBIND variable (yet), but I'm looking at
a 'getpid()' based replacement to prevent recursion and lockups on that
one.

So, what do people think?  (Naturally, I'll also remove the manpage
reference in a final patch).

Andrew Bartlett
-- 
Andrew Bartlett                                 abartlet at pcug.org.au
Manager, Authentication Subsystems, Samba Team  abartlet at samba.org
Student Network Administrator, Hawker College   abartlet at hawkerc.net
http://samba.org     http://build.samba.org     http://hawkerc.net
-------------- next part --------------
? nsswitch/.libs
? nsswitch/ntlmauth.c
Index: smbd/server.c
===================================================================
RCS file: /data/cvs/samba/source/smbd/server.c,v
retrieving revision 1.386
diff -u -r1.386 server.c
--- smbd/server.c	16 Aug 2002 00:25:47 -0000	1.386
+++ smbd/server.c	16 Aug 2002 08:16:17 -0000
@@ -808,11 +808,6 @@
 
 	init_structs();
 
-	/* don't call winbind for our domain if we are the DC */
-	if (lp_domain_logons()) {
-		winbind_exclude_domain(lp_workgroup());
-	}
-	
 #ifdef WITH_PROFILE
 	if (!profile_setup(False)) {
 		DEBUG(0,("ERROR: failed to setup profiling\n"));
Index: nsswitch/wb_common.c
===================================================================
RCS file: /data/cvs/samba/source/nsswitch/wb_common.c,v
retrieving revision 1.16
diff -u -r1.16 wb_common.c
--- nsswitch/wb_common.c	1 Jul 2002 09:12:39 -0000	1.16
+++ nsswitch/wb_common.c	16 Aug 2002 08:16:18 -0000
@@ -28,7 +28,6 @@
 /* Global variables.  These are effectively the client state information */
 
 int winbindd_fd = -1;           /* fd for winbindd socket */
-static char *excluded_domain;
 
 /* Free a response structure */
 
@@ -40,39 +39,15 @@
 		SAFE_FREE(response->extra_data);
 }
 
-/*
-  smbd needs to be able to exclude lookups for its own domain
-*/
-void winbind_exclude_domain(const char *domain)
-{
-	SAFE_FREE(excluded_domain);
-	excluded_domain = strdup(domain);
-}
-
-
 /* Initialise a request structure */
 
 void init_request(struct winbindd_request *request, int request_type)
 {
-        static char *domain_env;
-        static BOOL initialised;
-
 	request->length = sizeof(struct winbindd_request);
 
 	request->cmd = (enum winbindd_cmd)request_type;
 	request->pid = getpid();
-	request->domain[0] = '\0';
 
-	if (!initialised) {
-		initialised = True;
-		domain_env = getenv(WINBINDD_DOMAIN_ENV);
-	}
-
-	if (domain_env) {
-		strncpy(request->domain, domain_env,
-			sizeof(request->domain) - 1);
-		request->domain[sizeof(request->domain) - 1] = '\0';
-	}
 }
 
 /* Initialise a response structure */
@@ -322,12 +297,6 @@
 	/* Check for our tricky environment variable */
 
 	if (getenv(WINBINDD_DONT_ENV)) {
-		return NSS_STATUS_NOTFOUND;
-	}
-
-	/* smbd may have excluded this domain */
-	if (excluded_domain && 
-	    strcasecmp(excluded_domain, request->domain) == 0) {
 		return NSS_STATUS_NOTFOUND;
 	}
 
Index: nsswitch/winbindd.c
===================================================================
RCS file: /data/cvs/samba/source/nsswitch/winbindd.c,v
retrieving revision 1.64
diff -u -r1.64 winbindd.c
--- nsswitch/winbindd.c	16 Aug 2002 00:25:47 -0000	1.64
+++ nsswitch/winbindd.c	16 Aug 2002 08:16:18 -0000
@@ -376,7 +376,7 @@
 	/* Process request */
 	
 	/* Ensure null termination of entire request */
-	state->request.domain[sizeof(state->request.domain)-1]='\0';
+	state->request.null_term = '\0';
 
 	state->pid = state->request.pid;
 	
Index: nsswitch/winbindd_group.c
===================================================================
RCS file: /data/cvs/samba/source/nsswitch/winbindd_group.c,v
retrieving revision 1.56
diff -u -r1.56 winbindd_group.c
--- nsswitch/winbindd_group.c	31 Jul 2002 12:05:29 -0000	1.56
+++ nsswitch/winbindd_group.c	16 Aug 2002 08:16:18 -0000
@@ -356,13 +356,6 @@
 	for (domain = domain_list(); domain != NULL; domain = domain->next) {
 		struct getent_state *domain_state;
 		
-		/* Skip domains other than WINBINDD_DOMAIN environment 
-		   variable */
-		
-		if ((strcmp(state->request.domain, "") != 0) &&
-		    !check_domain_env(state->request.domain, domain->name))
-			continue;
-		
 		/* Create a state record for this domain */
 		
 		if ((domain_state = (struct getent_state *)
@@ -706,12 +699,6 @@
 		struct getent_state groups;
 
 		ZERO_STRUCT(groups);
-
-		/* Skip domains other than WINBINDD_DOMAIN environment
-		   variable */ 
-		if ((strcmp(state->request.domain, "") != 0) &&
-		    !check_domain_env(state->request.domain, domain->name))
-			continue;
 
 		/* Get list of sam groups */
 		ZERO_STRUCT(groups);
Index: nsswitch/winbindd_nss.h
===================================================================
RCS file: /data/cvs/samba/source/nsswitch/winbindd_nss.h,v
retrieving revision 1.23
diff -u -r1.23 winbindd_nss.h
--- nsswitch/winbindd_nss.h	31 Jul 2002 12:05:29 -0000	1.23
+++ nsswitch/winbindd_nss.h	16 Aug 2002 08:16:19 -0000
@@ -36,7 +36,7 @@
 
 /* Update this when you change the interface.  */
 
-#define WINBIND_INTERFACE_VERSION 5
+#define WINBIND_INTERFACE_VERSION 6
 
 /* Socket commands */
 
@@ -153,7 +153,7 @@
 		} name;
 		uint32 num_entries;  /* getpwent, getgrent */
 	} data;
-	fstring domain;      /* {set,get,end}{pw,gr}ent() */
+	char null_term;
 };
 
 /* Response values */
Index: nsswitch/winbindd_user.c
===================================================================
RCS file: /data/cvs/samba/source/nsswitch/winbindd_user.c,v
retrieving revision 1.45
diff -u -r1.45 winbindd_user.c
--- nsswitch/winbindd_user.c	31 Jul 2002 12:05:29 -0000	1.45
+++ nsswitch/winbindd_user.c	16 Aug 2002 08:16:19 -0000
@@ -284,16 +284,6 @@
 	for(domain = domain_list(); domain != NULL; domain = domain->next) {
 		struct getent_state *domain_state;
                 
-		/*
-		 * Skip domains other than WINBINDD_DOMAIN environment
-		 * variable.
-		 */
-                
-		if ((strcmp(state->request.domain, "") != 0) &&
-				!check_domain_env(state->request.domain, 
-						  domain->name))
-			continue;
-
 		/* Create a state record for this domain */
                 
 		if ((domain_state = (struct getent_state *)
@@ -550,13 +540,6 @@
 		NTSTATUS status;
 		struct winbindd_methods *methods;
 		int i;
-
-		/* Skip domains other than WINBINDD_DOMAIN environment
-		   variable */ 
-
-		if ((strcmp(state->request.domain, "") != 0) &&
-		    !check_domain_env(state->request.domain, domain->name))
-			continue;
 
 		methods = domain->methods;
 


More information about the samba-technical mailing list