svn commit: samba r22473 - in branches: SAMBA_3_0/source/nsswitch	SAMBA_3_0_25/source/nsswitch SAMBA_3_0_25/source/passdb	SAMBA_3_0_RELEASE/source/nsswitch Author: jerry
Date: 2007-04-23 06:10:22 +0000 (Mon, 23 Apr 2007)
New Revision: 22473

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

Log:
Correct fix for setting a default compat tdb idmap backend.
Previous code would always fill in "idmap backend = tdb"
even if you defined idmap domains.  My fault.  I should
have tested the original patch more before committing.



Modified:
   branches/SAMBA_3_0/source/nsswitch/idmap.c
   branches/SAMBA_3_0_25/source/nsswitch/idmap.c
   branches/SAMBA_3_0_25/source/passdb/pdb_ldap.c
   branches/SAMBA_3_0_RELEASE/source/nsswitch/idmap.c


Changeset:
Modified: branches/SAMBA_3_0/source/nsswitch/idmap.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/idmap.c	2007-04-23 00:43:47 UTC (rev 22472)
+++ branches/SAMBA_3_0/source/nsswitch/idmap.c	2007-04-23 06:10:22 UTC (rev 22473)
@@ -289,40 +289,42 @@
 
 	dom_list = lp_idmap_domains();
 	
-	if ( dom_list && lp_idmap_backend() ) {
-		DEBUG(0, ("WARNING: idmap backend and idmap domains are "
-			  "mutually excusive!\\n"));
-		DEBUGADD(0,("idmap backend option will be IGNORED!\\n"));
-	} else if ( lp_idmap_backend() ) {
-		const char **compat_list = lp_idmap_backend();
+	if ( lp_idmap_backend() ) {
+       		const char **compat_list = lp_idmap_backend();
 		char *p = NULL;
 		const char *q = NULL;		
 
-		compat = 1;
+		if ( dom_list ) {			
+			DEBUG(0, ("WARNING: idmap backend and idmap domains are "
+				  "mutually excusive!\\n"));
+			DEBUGADD(0,("idmap backend option will be IGNORED!\\n"));
+		} else {
+			compat = 1;
 
-		if ( (compat_backend = talloc_strdup( idmap_ctx, *compat_list )) == NULL ) {
-			ret = NT_STATUS_NO_MEMORY;
-			goto done;			
-		}
+			if ( (compat_backend = talloc_strdup( idmap_ctx, *compat_list )) == NULL ) {
+				ret = NT_STATUS_NO_MEMORY;
+				goto done;
+			}
 		
-		/* strip any leading idmap_ prefix of */
-		if (strncmp(*compat_list, "idmap_", 6) == 0 ) {
-			q = *compat_list += 6;
-			DEBUG(0, ("WARNING: idmap backend uses obsolete and "
-				  "deprecated 'idmap_' prefix.\\n"
-				  "Please replace 'idmap_%s' by '%s' in %s\\n", 
-				  q, q, dyn_CONFIGFILE));
-			compat_backend = talloc_strdup( idmap_ctx, q);
-		} else {
-			compat_backend = talloc_strdup( idmap_ctx, *compat_list);
-		}
+			/* strip any leading idmap_ prefix of */
+			if (strncmp(*compat_list, "idmap_", 6) == 0 ) {
+				q = *compat_list += 6;
+				DEBUG(0, ("WARNING: idmap backend uses obsolete and "
+					  "deprecated 'idmap_' prefix.\\n"
+					  "Please replace 'idmap_%s' by '%s' in %s\\n", 
+					  q, q, dyn_CONFIGFILE));
+				compat_backend = talloc_strdup( idmap_ctx, q);
+			} else {
+				compat_backend = talloc_strdup( idmap_ctx, *compat_list);
+			}
 			
-		/* separate the backend and module arguements */
-		if ((p = strchr(compat_backend, ':')) != NULL) {
-			*p = '\\0';			
-			compat_params = p + 1;
-		}
-	} else {
+			/* separate the backend and module arguements */
+			if ((p = strchr(compat_backend, ':')) != NULL) {
+				*p = '\\0';			
+				compat_params = p + 1;
+			}
+		}		
+	} else if ( !dom_list ) {
 		/* Back compatible: without idmap domains and explicit
 		   idmap backend.  Taking default idmap backend: tdb */
 		
@@ -331,7 +333,6 @@
 		compat_params = compat_backend;
 	}
 
-
 	if ( ! dom_list) {
 		dom_list = idmap_default_domain;
 	}

Modified: branches/SAMBA_3_0_25/source/nsswitch/idmap.c
===================================================================
--- branches/SAMBA_3_0_25/source/nsswitch/idmap.c	2007-04-23 00:43:47 UTC (rev 22472)
+++ branches/SAMBA_3_0_25/source/nsswitch/idmap.c	2007-04-23 06:10:22 UTC (rev 22473)
@@ -289,40 +289,42 @@
 
 	dom_list = lp_idmap_domains();
 	
-	if ( dom_list && lp_idmap_backend() ) {
-		DEBUG(0, ("WARNING: idmap backend and idmap domains are "
-			  "mutually excusive!\\n"));
-		DEBUGADD(0,("idmap backend option will be IGNORED!\\n"));
-	} else if ( lp_idmap_backend() ) {
-		const char **compat_list = lp_idmap_backend();
+	if ( lp_idmap_backend() ) {
+       		const char **compat_list = lp_idmap_backend();
 		char *p = NULL;
 		const char *q = NULL;		
 
-		compat = 1;
+		if ( dom_list ) {			
+			DEBUG(0, ("WARNING: idmap backend and idmap domains are "
+				  "mutually excusive!\\n"));
+			DEBUGADD(0,("idmap backend option will be IGNORED!\\n"));
+		} else {
+			compat = 1;
 
-		if ( (compat_backend = talloc_strdup( idmap_ctx, *compat_list )) == NULL ) {
-			ret = NT_STATUS_NO_MEMORY;
-			goto done;			
-		}
+			if ( (compat_backend = talloc_strdup( idmap_ctx, *compat_list )) == NULL ) {
+				ret = NT_STATUS_NO_MEMORY;
+				goto done;
+			}
 		
-		/* strip any leading idmap_ prefix of */
-		if (strncmp(*compat_list, "idmap_", 6) == 0 ) {
-			q = *compat_list += 6;
-			DEBUG(0, ("WARNING: idmap backend uses obsolete and "
-				  "deprecated 'idmap_' prefix.\\n"
-				  "Please replace 'idmap_%s' by '%s' in %s\\n", 
-				  q, q, dyn_CONFIGFILE));
-			compat_backend = talloc_strdup( idmap_ctx, q);
-		} else {
-			compat_backend = talloc_strdup( idmap_ctx, *compat_list);
-		}
+			/* strip any leading idmap_ prefix of */
+			if (strncmp(*compat_list, "idmap_", 6) == 0 ) {
+				q = *compat_list += 6;
+				DEBUG(0, ("WARNING: idmap backend uses obsolete and "
+					  "deprecated 'idmap_' prefix.\\n"
+					  "Please replace 'idmap_%s' by '%s' in %s\\n", 
+					  q, q, dyn_CONFIGFILE));
+				compat_backend = talloc_strdup( idmap_ctx, q);
+			} else {
+				compat_backend = talloc_strdup( idmap_ctx, *compat_list);
+			}
 			
-		/* separate the backend and module arguements */
-		if ((p = strchr(compat_backend, ':')) != NULL) {
-			*p = '\\0';			
-			compat_params = p + 1;
-		}
-	} else {
+			/* separate the backend and module arguements */
+			if ((p = strchr(compat_backend, ':')) != NULL) {
+				*p = '\\0';			
+				compat_params = p + 1;
+			}
+		}		
+	} else if ( !dom_list ) {
 		/* Back compatible: without idmap domains and explicit
 		   idmap backend.  Taking default idmap backend: tdb */
 		
@@ -331,7 +333,6 @@
 		compat_params = compat_backend;
 	}
 
-
 	if ( ! dom_list) {
 		dom_list = idmap_default_domain;
 	}

Modified: branches/SAMBA_3_0_25/source/passdb/pdb_ldap.c
===================================================================
--- branches/SAMBA_3_0_25/source/passdb/pdb_ldap.c	2007-04-23 00:43:47 UTC (rev 22472)
+++ branches/SAMBA_3_0_25/source/passdb/pdb_ldap.c	2007-04-23 06:10:22 UTC (rev 22473)
@@ -455,7 +455,11 @@
 			temp))
 		return (time_t) 0;
 
-	strptime(temp, "%Y%m%d%H%M%SZ", &tm);
+	if ( !strptime(temp, "%Y%m%d%H%M%SZ", &tm)) {
+		DEBUG(2,("ldapsam_get_entry_timestamp: strptime failed on: %s\\n",
+			(char*)temp));
+		return (time_t) 0;
+	}
 	tzset();
 	return timegm(&tm);
 }

Modified: branches/SAMBA_3_0_RELEASE/source/nsswitch/idmap.c
===================================================================
--- branches/SAMBA_3_0_RELEASE/source/nsswitch/idmap.c	2007-04-23 00:43:47 UTC (rev 22472)
+++ branches/SAMBA_3_0_RELEASE/source/nsswitch/idmap.c	2007-04-23 06:10:22 UTC (rev 22473)
@@ -289,40 +289,42 @@
 
 	dom_list = lp_idmap_domains();
 	
-	if ( dom_list && lp_idmap_backend() ) {
-		DEBUG(0, ("WARNING: idmap backend and idmap domains are "
-			  "mutually excusive!\\n"));
-		DEBUGADD(0,("idmap backend option will be IGNORED!\\n"));
-	} else if ( lp_idmap_backend() ) {
-		const char **compat_list = lp_idmap_backend();
+	if ( lp_idmap_backend() ) {
+       		const char **compat_list = lp_idmap_backend();
 		char *p = NULL;
 		const char *q = NULL;		
 
-		compat = 1;
+		if ( dom_list ) {			
+			DEBUG(0, ("WARNING: idmap backend and idmap domains are "
+				  "mutually excusive!\\n"));
+			DEBUGADD(0,("idmap backend option will be IGNORED!\\n"));
+		} else {
+			compat = 1;
 
-		if ( (compat_backend = talloc_strdup( idmap_ctx, *compat_list )) == NULL ) {
-			ret = NT_STATUS_NO_MEMORY;
-			goto done;			
-		}
+			if ( (compat_backend = talloc_strdup( idmap_ctx, *compat_list )) == NULL ) {
+				ret = NT_STATUS_NO_MEMORY;
+				goto done;
+			}
 		
-		/* strip any leading idmap_ prefix of */
-		if (strncmp(*compat_list, "idmap_", 6) == 0 ) {
-			q = *compat_list += 6;
-			DEBUG(0, ("WARNING: idmap backend uses obsolete and "
-				  "deprecated 'idmap_' prefix.\\n"
-				  "Please replace 'idmap_%s' by '%s' in %s\\n", 
-				  q, q, dyn_CONFIGFILE));
-			compat_backend = talloc_strdup( idmap_ctx, q);
-		} else {
-			compat_backend = talloc_strdup( idmap_ctx, *compat_list);
-		}
+			/* strip any leading idmap_ prefix of */
+			if (strncmp(*compat_list, "idmap_", 6) == 0 ) {
+				q = *compat_list += 6;
+				DEBUG(0, ("WARNING: idmap backend uses obsolete and "
+					  "deprecated 'idmap_' prefix.\\n"
+					  "Please replace 'idmap_%s' by '%s' in %s\\n", 
+					  q, q, dyn_CONFIGFILE));
+				compat_backend = talloc_strdup( idmap_ctx, q);
+			} else {
+				compat_backend = talloc_strdup( idmap_ctx, *compat_list);
+			}
 			
-		/* separate the backend and module arguements */
-		if ((p = strchr(compat_backend, ':')) != NULL) {
-			*p = '\\0';			
-			compat_params = p + 1;
-		}
-	} else {
+			/* separate the backend and module arguements */
+			if ((p = strchr(compat_backend, ':')) != NULL) {
+				*p = '\\0';			
+				compat_params = p + 1;
+			}
+		}		
+	} else if ( !dom_list ) {
 		/* Back compatible: without idmap domains and explicit
 		   idmap backend.  Taking default idmap backend: tdb */
 		
@@ -331,7 +333,6 @@
 		compat_params = compat_backend;
 	}
 
-
 	if ( ! dom_list) {
 		dom_list = idmap_default_domain;
 	}

