s3:idmap_rid: untangle assignment from check in idmap_rid_initialize()
[amitay/samba.git] / source3 / winbindd / idmap_rid.c
index f1cd77853cda0755cd1eadd429fa220f6554c0ab..10cb98e690779973f4a74dc11a93c725d67bb63e 100644 (file)
@@ -36,7 +36,8 @@ struct idmap_rid_context {
   we support multiple domains in the new idmap
  *****************************************************************************/
 
-static NTSTATUS idmap_rid_initialize(struct idmap_domain *dom)
+static NTSTATUS idmap_rid_initialize(struct idmap_domain *dom,
+                                    const char *params)
 {
        NTSTATUS ret;
        struct idmap_rid_context *ctx;
@@ -47,7 +48,8 @@ static NTSTATUS idmap_rid_initialize(struct idmap_domain *dom)
        gid_t low_gid = 0;
        gid_t high_gid = 0;
 
-       if ( (ctx = TALLOC_ZERO_P(dom, struct idmap_rid_context)) == NULL ) {
+       ctx = TALLOC_ZERO_P(dom, struct idmap_rid_context);
+       if (ctx == NULL) {
                DEBUG(0, ("Out of memory!\n"));
                return NT_STATUS_NO_MEMORY;
        }
@@ -95,7 +97,6 @@ static NTSTATUS idmap_rid_initialize(struct idmap_domain *dom)
        ctx->domain_name = talloc_strdup( ctx, dom->name );
        
        dom->private_data = ctx;
-       dom->initialized = True;
 
        talloc_free(config_option);
        return NT_STATUS_OK;
@@ -171,14 +172,11 @@ static NTSTATUS idmap_rid_unixids_to_sids(struct idmap_domain *dom, struct id_ma
        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;
-               }
+       /* initialize the status to avoid suprise */
+       for (i = 0; ids[i]; i++) {
+               ids[i]->status = ID_UNKNOWN;
        }
-
+       
        ridctx = talloc_get_type(dom->private_data, struct idmap_rid_context);
 
        ctx = talloc_new(dom);
@@ -213,14 +211,11 @@ static NTSTATUS idmap_rid_sids_to_unixids(struct idmap_domain *dom, struct id_ma
        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;
-               }
+       /* initialize the status to avoid suprise */
+       for (i = 0; ids[i]; i++) {
+               ids[i]->status = ID_UNKNOWN;
        }
-
+       
        ridctx = talloc_get_type(dom->private_data, struct idmap_rid_context);
 
        ctx = talloc_new(dom);