svn commit: samba r23525 - in branches: SAMBA_3_0/source/nsswitch SAMBA_3_0_25/source/nsswitch SAMBA_3_0_26/source/nsswitch

idra at samba.org idra at samba.org
Sat Jun 16 18:59:05 GMT 2007


Author: idra
Date: 2007-06-16 18:59:02 +0000 (Sat, 16 Jun 2007)
New Revision: 23525

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

Log:

I believe this patch is ok, got no reply of it being not ok.
This closes #4624 for me.


Modified:
   branches/SAMBA_3_0/source/nsswitch/idmap_rid.c
   branches/SAMBA_3_0_25/source/nsswitch/idmap_rid.c
   branches/SAMBA_3_0_26/source/nsswitch/idmap_rid.c


Changeset:
Modified: branches/SAMBA_3_0/source/nsswitch/idmap_rid.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/idmap_rid.c	2007-06-16 18:54:13 UTC (rev 23524)
+++ branches/SAMBA_3_0/source/nsswitch/idmap_rid.c	2007-06-16 18:59:02 UTC (rev 23525)
@@ -43,6 +43,10 @@
 	struct idmap_rid_context *ctx;
 	char *config_option = NULL;
 	const char *range;
+	uid_t low_uid = 0;
+	uid_t high_uid = 0;
+	gid_t low_gid = 0;
+	gid_t high_gid = 0;
 
 	if ( (ctx = TALLOC_ZERO_P(dom, struct idmap_rid_context)) == NULL ) {
 		DEBUG(0, ("Out of memory!\n"));
@@ -65,8 +69,25 @@
 		ctx->high_id = 0;
 	}
 
-	if ( !ctx->low_id || !ctx->high_id ) {
-		DEBUG(1, ("ERROR: Invalid configuration, ID range missing\n"));
+	/* lets see if the range is defined by the old idmap uid/idmap gid */
+	if (!ctx->low_id && !ctx->high_id) {
+		if (lp_idmap_uid(&low_uid, &high_uid)) {
+			ctx->low_id = low_uid;
+			ctx->high_id = high_uid;
+		}
+
+		if (lp_idmap_gid(&low_gid, &high_gid)) {
+			if ((ctx->low_id != low_gid) ||
+			    (ctx->high_id != high_uid)) {
+				DEBUG(1, ("ERROR: idmap uid irange must match idmap gid range\n"));
+				ret = NT_STATUS_UNSUCCESSFUL;
+				goto failed;
+			}
+		}
+	}
+
+	if (!ctx->low_id || !ctx->high_id) {
+		DEBUG(1, ("ERROR: Invalid configuration, ID range missing or invalid\n"));
 		ret = NT_STATUS_UNSUCCESSFUL;
 		goto failed;
 	}
@@ -75,6 +96,7 @@
 	ctx->domain_name = talloc_strdup( ctx, dom->name );
 	
 	dom->private_data = ctx;
+	dom->initialized = True;
 
 	talloc_free(config_option);
 	return NT_STATUS_OK;
@@ -150,6 +172,14 @@
 	NTSTATUS ret;
 	int i;
 
+	/* Initilization my have been deferred because of an error, retry or fail */
+	if ( ! dom->initialized) {
+		ret = idmap_rid_initialize(dom);
+		if ( ! NT_STATUS_IS_OK(ret)) {
+			return ret;
+		}
+	}
+
 	ridctx = talloc_get_type(dom->private_data, struct idmap_rid_context);
 
 	ctx = talloc_new(dom);
@@ -184,6 +214,14 @@
 	NTSTATUS ret;
 	int i;
 
+	/* Initilization my have been deferred because of an error, retry or fail */
+	if ( ! dom->initialized) {
+		ret = idmap_rid_initialize(dom);
+		if ( ! NT_STATUS_IS_OK(ret)) {
+			return ret;
+		}
+	}
+
 	ridctx = talloc_get_type(dom->private_data, struct idmap_rid_context);
 
 	ctx = talloc_new(dom);

Modified: branches/SAMBA_3_0_25/source/nsswitch/idmap_rid.c
===================================================================
--- branches/SAMBA_3_0_25/source/nsswitch/idmap_rid.c	2007-06-16 18:54:13 UTC (rev 23524)
+++ branches/SAMBA_3_0_25/source/nsswitch/idmap_rid.c	2007-06-16 18:59:02 UTC (rev 23525)
@@ -43,6 +43,10 @@
 	struct idmap_rid_context *ctx;
 	char *config_option = NULL;
 	const char *range;
+	uid_t low_uid = 0;
+	uid_t high_uid = 0;
+	gid_t low_gid = 0;
+	gid_t high_gid = 0;
 
 	if ( (ctx = TALLOC_ZERO_P(dom, struct idmap_rid_context)) == NULL ) {
 		DEBUG(0, ("Out of memory!\n"));
@@ -65,8 +69,25 @@
 		ctx->high_id = 0;
 	}
 
-	if ( !ctx->low_id || !ctx->high_id ) {
-		DEBUG(1, ("ERROR: Invalid configuration, ID range missing\n"));
+	/* lets see if the range is defined by the old idmap uid/idmap gid */
+	if (!ctx->low_id && !ctx->high_id) {
+		if (lp_idmap_uid(&low_uid, &high_uid)) {
+			ctx->low_id = low_uid;
+			ctx->high_id = high_uid;
+		}
+
+		if (lp_idmap_gid(&low_gid, &high_gid)) {
+			if ((ctx->low_id != low_gid) ||
+			    (ctx->high_id != high_uid)) {
+				DEBUG(1, ("ERROR: idmap uid irange must match idmap gid range\n"));
+				ret = NT_STATUS_UNSUCCESSFUL;
+				goto failed;
+			}
+		}
+	}
+
+	if (!ctx->low_id || !ctx->high_id) {
+		DEBUG(1, ("ERROR: Invalid configuration, ID range missing or invalid\n"));
 		ret = NT_STATUS_UNSUCCESSFUL;
 		goto failed;
 	}
@@ -75,6 +96,7 @@
 	ctx->domain_name = talloc_strdup( ctx, dom->name );
 	
 	dom->private_data = ctx;
+	dom->initialized = True;
 
 	talloc_free(config_option);
 	return NT_STATUS_OK;
@@ -150,6 +172,14 @@
 	NTSTATUS ret;
 	int i;
 
+	/* Initilization my have been deferred because of an error, retry or fail */
+	if ( ! dom->initialized) {
+		ret = idmap_rid_initialize(dom);
+		if ( ! NT_STATUS_IS_OK(ret)) {
+			return ret;
+		}
+	}
+
 	ridctx = talloc_get_type(dom->private_data, struct idmap_rid_context);
 
 	ctx = talloc_new(dom);
@@ -184,6 +214,14 @@
 	NTSTATUS ret;
 	int i;
 
+	/* Initilization my have been deferred because of an error, retry or fail */
+	if ( ! dom->initialized) {
+		ret = idmap_rid_initialize(dom);
+		if ( ! NT_STATUS_IS_OK(ret)) {
+			return ret;
+		}
+	}
+
 	ridctx = talloc_get_type(dom->private_data, struct idmap_rid_context);
 
 	ctx = talloc_new(dom);

Modified: branches/SAMBA_3_0_26/source/nsswitch/idmap_rid.c
===================================================================
--- branches/SAMBA_3_0_26/source/nsswitch/idmap_rid.c	2007-06-16 18:54:13 UTC (rev 23524)
+++ branches/SAMBA_3_0_26/source/nsswitch/idmap_rid.c	2007-06-16 18:59:02 UTC (rev 23525)
@@ -43,6 +43,10 @@
 	struct idmap_rid_context *ctx;
 	char *config_option = NULL;
 	const char *range;
+	uid_t low_uid = 0;
+	uid_t high_uid = 0;
+	gid_t low_gid = 0;
+	gid_t high_gid = 0;
 
 	if ( (ctx = TALLOC_ZERO_P(dom, struct idmap_rid_context)) == NULL ) {
 		DEBUG(0, ("Out of memory!\n"));
@@ -65,8 +69,25 @@
 		ctx->high_id = 0;
 	}
 
-	if ( !ctx->low_id || !ctx->high_id ) {
-		DEBUG(1, ("ERROR: Invalid configuration, ID range missing\n"));
+	/* lets see if the range is defined by the old idmap uid/idmap gid */
+	if (!ctx->low_id && !ctx->high_id) {
+		if (lp_idmap_uid(&low_uid, &high_uid)) {
+			ctx->low_id = low_uid;
+			ctx->high_id = high_uid;
+		}
+
+		if (lp_idmap_gid(&low_gid, &high_gid)) {
+			if ((ctx->low_id != low_gid) ||
+			    (ctx->high_id != high_uid)) {
+				DEBUG(1, ("ERROR: idmap uid irange must match idmap gid range\n"));
+				ret = NT_STATUS_UNSUCCESSFUL;
+				goto failed;
+			}
+		}
+	}
+
+	if (!ctx->low_id || !ctx->high_id) {
+		DEBUG(1, ("ERROR: Invalid configuration, ID range missing or invalid\n"));
 		ret = NT_STATUS_UNSUCCESSFUL;
 		goto failed;
 	}
@@ -75,6 +96,7 @@
 	ctx->domain_name = talloc_strdup( ctx, dom->name );
 	
 	dom->private_data = ctx;
+	dom->initialized = True;
 
 	talloc_free(config_option);
 	return NT_STATUS_OK;
@@ -150,6 +172,14 @@
 	NTSTATUS ret;
 	int i;
 
+	/* Initilization my have been deferred because of an error, retry or fail */
+	if ( ! dom->initialized) {
+		ret = idmap_rid_initialize(dom);
+		if ( ! NT_STATUS_IS_OK(ret)) {
+			return ret;
+		}
+	}
+
 	ridctx = talloc_get_type(dom->private_data, struct idmap_rid_context);
 
 	ctx = talloc_new(dom);
@@ -184,6 +214,14 @@
 	NTSTATUS ret;
 	int i;
 
+	/* Initilization my have been deferred because of an error, retry or fail */
+	if ( ! dom->initialized) {
+		ret = idmap_rid_initialize(dom);
+		if ( ! NT_STATUS_IS_OK(ret)) {
+			return ret;
+		}
+	}
+
 	ridctx = talloc_get_type(dom->private_data, struct idmap_rid_context);
 
 	ctx = talloc_new(dom);



More information about the samba-cvs mailing list