Remove "idmap alloc config : range" parameter
authorVolker Lendecke <vl@samba.org>
Wed, 16 Jul 2008 14:51:46 +0000 (16:51 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 12 Aug 2008 09:28:29 +0000 (11:28 +0200)
This was overwritten by "idmap uid/gid" anyway. These are now the range
parameters for the alloc backend.
(This used to be commit d563a7b80dc3e759069db2cd54d596a1b8c55191)

source3/winbindd/idmap_ldap.c
source3/winbindd/idmap_tdb.c
source3/winbindd/idmap_tdb2.c

index 64b176389e86cbb52490aada6543467177b30776..5657cb591ec1c6a4bfd1c731caba9262f191a7db 100644 (file)
@@ -263,50 +263,27 @@ static NTSTATUS idmap_ldap_alloc_init(const char *params)
 
        /* load ranges */
 
 
        /* load ranges */
 
-       idmap_alloc_ldap->low_uid = 0;
-       idmap_alloc_ldap->high_uid = 0;
-       idmap_alloc_ldap->low_gid = 0;
-       idmap_alloc_ldap->high_gid = 0;
-
-       range = lp_parm_const_string(-1, "idmap alloc config", "range", NULL);
-       if (range && range[0]) {
-               unsigned low_id, high_id;
-
-               if (sscanf(range, "%u - %u", &low_id, &high_id) == 2) {
-                       if (low_id < high_id) {
-                               idmap_alloc_ldap->low_gid = low_id;
-                               idmap_alloc_ldap->low_uid = low_id;
-                               idmap_alloc_ldap->high_gid = high_id;
-                               idmap_alloc_ldap->high_uid = high_id;
-                       } else {
-                               DEBUG(1, ("ERROR: invalid idmap alloc range "
-                                         "[%s]", range));
-                       }
-               } else {
-                       DEBUG(1, ("ERROR: invalid syntax for idmap alloc "
-                                 "config:range [%s]", range));
-               }
-       }
-
-       if (lp_idmap_uid(&low_uid, &high_uid)) {
-               idmap_alloc_ldap->low_uid = low_uid;
-               idmap_alloc_ldap->high_uid = high_uid;
+       if (!lp_idmap_uid(&low_uid, &high_uid)
+           || !lp_idmap_gid(&low_gid, &high_gid)) {
+               DEBUG(1, ("idmap uid or idmap gid missing\n"));
+               ret = NT_STATUS_UNSUCCESSFUL;
+               goto done;
        }
 
        }
 
-       if (lp_idmap_gid(&low_gid, &high_gid)) {
-               idmap_alloc_ldap->low_gid = low_gid;
-               idmap_alloc_ldap->high_gid= high_gid;
-       }
+       idmap_alloc_ldap->low_uid = low_uid;
+       idmap_alloc_ldap->high_uid = high_uid;
+       idmap_alloc_ldap->low_gid = low_gid;
+       idmap_alloc_ldap->high_gid= high_gid;
 
        if (idmap_alloc_ldap->high_uid <= idmap_alloc_ldap->low_uid) {
 
        if (idmap_alloc_ldap->high_uid <= idmap_alloc_ldap->low_uid) {
-               DEBUG(1, ("idmap uid range missing or invalid\n"));
+               DEBUG(1, ("idmap uid range invalid\n"));
                DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n"));
                ret = NT_STATUS_UNSUCCESSFUL;
                goto done;
        }
 
        if (idmap_alloc_ldap->high_gid <= idmap_alloc_ldap->low_gid) {
                DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n"));
                ret = NT_STATUS_UNSUCCESSFUL;
                goto done;
        }
 
        if (idmap_alloc_ldap->high_gid <= idmap_alloc_ldap->low_gid) {
-               DEBUG(1, ("idmap gid range missing or invalid\n"));
+               DEBUG(1, ("idmap gid range invalid\n"));
                DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n"));
                ret = NT_STATUS_UNSUCCESSFUL;
                goto done;
                DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n"));
                ret = NT_STATUS_UNSUCCESSFUL;
                goto done;
index 3f6cccd35adaae6ecb8aff7182275ba135571791..2b9520d54da4d3d29b0558323f039a41de5ac79c 100644 (file)
@@ -318,6 +318,7 @@ static NTSTATUS idmap_tdb_alloc_init( const char *params )
        uid_t high_uid = 0;
        gid_t low_gid = 0;
        gid_t high_gid = 0;
        uid_t high_uid = 0;
        gid_t low_gid = 0;
        gid_t high_gid = 0;
+       uint32_t low_id, high_id;
 
        /* use our own context here */
        ctx = talloc_new(NULL);
 
        /* use our own context here */
        ctx = talloc_new(NULL);
@@ -335,67 +336,47 @@ static NTSTATUS idmap_tdb_alloc_init( const char *params )
        talloc_free(ctx);
 
        /* load ranges */
        talloc_free(ctx);
 
        /* load ranges */
-       idmap_tdb_state.low_uid = 0;
-       idmap_tdb_state.high_uid = 0;
-       idmap_tdb_state.low_gid = 0;
-       idmap_tdb_state.high_gid = 0;
-
-       range = lp_parm_const_string(-1, "idmap alloc config", "range", NULL);
-       if (range && range[0]) {
-               unsigned low_id, high_id;
-
-               if (sscanf(range, "%u - %u", &low_id, &high_id) == 2) {
-                       if (low_id < high_id) {
-                               idmap_tdb_state.low_gid = idmap_tdb_state.low_uid = low_id;
-                               idmap_tdb_state.high_gid = idmap_tdb_state.high_uid = high_id;
-                       } else {
-                               DEBUG(1, ("ERROR: invalid idmap alloc range [%s]", range));
-                       }
-               } else {
-                       DEBUG(1, ("ERROR: invalid syntax for idmap alloc config:range [%s]", range));
-               }
-       }
 
 
-       /* Create high water marks for group and user id */
-       if (lp_idmap_uid(&low_uid, &high_uid)) {
-               idmap_tdb_state.low_uid = low_uid;
-               idmap_tdb_state.high_uid = high_uid;
+       if (!lp_idmap_uid(&low_uid, &high_uid)
+           || !lp_idmap_gid(&low_gid, &high_gid)) {
+               DEBUG(1, ("idmap uid or idmap gid missing\n"));
+               return NT_STATUS_UNSUCCESSFUL;
        }
 
        }
 
-       if (lp_idmap_gid(&low_gid, &high_gid)) {
-               idmap_tdb_state.low_gid = low_gid;
-               idmap_tdb_state.high_gid = high_gid;
-       }
+       idmap_tdb_state.low_uid = low_uid;
+       idmap_tdb_state.high_uid = high_uid;
+       idmap_tdb_state.low_gid = low_gid;
+       idmap_tdb_state.high_gid = high_gid;
 
        if (idmap_tdb_state.high_uid <= idmap_tdb_state.low_uid) {
                DEBUG(1, ("idmap uid range missing or invalid\n"));
                DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n"));
                return NT_STATUS_UNSUCCESSFUL;
 
        if (idmap_tdb_state.high_uid <= idmap_tdb_state.low_uid) {
                DEBUG(1, ("idmap uid range missing or invalid\n"));
                DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n"));
                return NT_STATUS_UNSUCCESSFUL;
-       } else {
-               uint32 low_id;
-
-               if (((low_id = tdb_fetch_int32(idmap_alloc_tdb, HWM_USER)) == -1) ||
-                   (low_id < idmap_tdb_state.low_uid)) {
-                       if (tdb_store_int32(idmap_alloc_tdb, HWM_USER, idmap_tdb_state.low_uid) == -1) {
-                               DEBUG(0, ("Unable to initialise user hwm in idmap database\n"));
-                               return NT_STATUS_INTERNAL_DB_ERROR;
-                       }
-               }
        }
 
        if (idmap_tdb_state.high_gid <= idmap_tdb_state.low_gid) {
                DEBUG(1, ("idmap gid range missing or invalid\n"));
                DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n"));
                return NT_STATUS_UNSUCCESSFUL;
        }
 
        if (idmap_tdb_state.high_gid <= idmap_tdb_state.low_gid) {
                DEBUG(1, ("idmap gid range missing or invalid\n"));
                DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n"));
                return NT_STATUS_UNSUCCESSFUL;
-       } else {
-               uint32 low_id;
-
-               if (((low_id = tdb_fetch_int32(idmap_alloc_tdb, HWM_GROUP)) == -1) ||
-                   (low_id < idmap_tdb_state.low_gid)) {
-                       if (tdb_store_int32(idmap_alloc_tdb, HWM_GROUP, idmap_tdb_state.low_gid) == -1) {
-                               DEBUG(0, ("Unable to initialise group hwm in idmap database\n"));
-                               return NT_STATUS_INTERNAL_DB_ERROR;
-                       }
+       }
+
+       if (((low_id = tdb_fetch_int32(idmap_alloc_tdb, HWM_USER)) == -1) ||
+           (low_id < idmap_tdb_state.low_uid)) {
+               if (tdb_store_int32(idmap_alloc_tdb, HWM_USER,
+                                   idmap_tdb_state.low_uid) == -1) {
+                       DEBUG(0, ("Unable to initialise user hwm in idmap "
+                                 "database\n"));
+                       return NT_STATUS_INTERNAL_DB_ERROR;
+               }
+       }
+
+       if (((low_id = tdb_fetch_int32(idmap_alloc_tdb, HWM_GROUP)) == -1) ||
+           (low_id < idmap_tdb_state.low_gid)) {
+               if (tdb_store_int32(idmap_alloc_tdb, HWM_GROUP,
+                                   idmap_tdb_state.low_gid) == -1) {
+                       DEBUG(0, ("Unable to initialise group hwm in idmap "
+                                 "database\n"));
+                       return NT_STATUS_INTERNAL_DB_ERROR;
                }
        }
 
                }
        }
 
index d30b6459fb621020d9ae00968db3b53eed94554e..cb5e9ec6d408bac846e6cc8e0820a46c94ce8581 100644 (file)
@@ -128,62 +128,46 @@ static NTSTATUS idmap_tdb2_alloc_load(void)
        uid_t high_uid = 0;
        gid_t low_gid = 0;
        gid_t high_gid = 0;
        uid_t high_uid = 0;
        gid_t low_gid = 0;
        gid_t high_gid = 0;
-
-       /* load ranges */
-       idmap_tdb2_state.low_uid = 0;
-       idmap_tdb2_state.high_uid = 0;
-       idmap_tdb2_state.low_gid = 0;
-       idmap_tdb2_state.high_gid = 0;
+       uint32 low_id, high_id;
 
        /* see if a idmap script is configured */
 
        /* see if a idmap script is configured */
-       idmap_tdb2_state.idmap_script = lp_parm_const_string(-1, "idmap", "script", NULL);
+       idmap_tdb2_state.idmap_script = lp_parm_const_string(-1, "idmap",
+                                                            "script", NULL);
 
        if (idmap_tdb2_state.idmap_script) {
 
        if (idmap_tdb2_state.idmap_script) {
-               DEBUG(1, ("using idmap script '%s'\n", idmap_tdb2_state.idmap_script));
-       }
-
-       range = lp_parm_const_string(-1, "idmap alloc config", "range", NULL);
-       if (range && range[0]) {
-               unsigned low_id, high_id;
-               if (sscanf(range, "%u - %u", &low_id, &high_id) == 2) {
-                       if (low_id < high_id) {
-                               idmap_tdb2_state.low_gid = idmap_tdb2_state.low_uid = low_id;
-                               idmap_tdb2_state.high_gid = idmap_tdb2_state.high_uid = high_id;
-                       } else {
-                               DEBUG(1, ("ERROR: invalid idmap alloc range [%s]", range));
-                       }
-               } else {
-                       DEBUG(1, ("ERROR: invalid syntax for idmap alloc config:range [%s]", range));
-               }
+               DEBUG(1, ("using idmap script '%s'\n",
+                         idmap_tdb2_state.idmap_script));
        }
 
        }
 
+       /* load ranges */
+
        /* Create high water marks for group and user id */
        /* Create high water marks for group and user id */
-       if (lp_idmap_uid(&low_uid, &high_uid)) {
-               idmap_tdb2_state.low_uid = low_uid;
-               idmap_tdb2_state.high_uid = high_uid;
+       if (!lp_idmap_uid(&low_uid, &high_uid)
+           || !lp_idmap_gid(&low_gid, &high_gid)) {
+               DEBUG(1, ("idmap uid or idmap gid missing\n"));
+               return NT_STATUS_UNSUCCESSFUL;
        }
 
        }
 
-       if (lp_idmap_gid(&low_gid, &high_gid)) {
-               idmap_tdb2_state.low_gid = low_gid;
-               idmap_tdb2_state.high_gid = high_gid;
-       }
+       idmap_tdb2_state.low_uid = low_uid;
+       idmap_tdb2_state.high_uid = high_uid;
+       idmap_tdb2_state.low_gid = low_gid;
+       idmap_tdb2_state.high_gid = high_gid;
 
        if (idmap_tdb2_state.high_uid <= idmap_tdb2_state.low_uid) {
                DEBUG(1, ("idmap uid range missing or invalid\n"));
                DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n"));
                return NT_STATUS_UNSUCCESSFUL;
 
        if (idmap_tdb2_state.high_uid <= idmap_tdb2_state.low_uid) {
                DEBUG(1, ("idmap uid range missing or invalid\n"));
                DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n"));
                return NT_STATUS_UNSUCCESSFUL;
-       } else {
-               uint32 low_id;
-
-               if (((low_id = dbwrap_fetch_int32(idmap_tdb2_perm,
-                                                 HWM_USER)) == -1) ||
-                   (low_id < idmap_tdb2_state.low_uid)) {
-                       if (dbwrap_store_int32(
-                                   idmap_tdb2_perm, HWM_USER,
-                                   idmap_tdb2_state.low_uid) == -1) {
-                               DEBUG(0, ("Unable to initialise user hwm in idmap database\n"));
-                               return NT_STATUS_INTERNAL_DB_ERROR;
-                       }
+       }
+
+       if (((low_id = dbwrap_fetch_int32(idmap_tdb2_perm,
+                                         HWM_USER)) == -1) ||
+           (low_id < idmap_tdb2_state.low_uid)) {
+               if (dbwrap_store_int32(
+                           idmap_tdb2_perm, HWM_USER,
+                           idmap_tdb2_state.low_uid) == -1) {
+                       DEBUG(0, ("Unable to initialise user hwm in idmap "
+                                 "database\n"));
+                       return NT_STATUS_INTERNAL_DB_ERROR;
                }
        }
 
                }
        }
 
@@ -191,18 +175,17 @@ static NTSTATUS idmap_tdb2_alloc_load(void)
                DEBUG(1, ("idmap gid range missing or invalid\n"));
                DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n"));
                return NT_STATUS_UNSUCCESSFUL;
                DEBUG(1, ("idmap gid range missing or invalid\n"));
                DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n"));
                return NT_STATUS_UNSUCCESSFUL;
-       } else {
-               uint32 low_id;
-
-               if (((low_id = dbwrap_fetch_int32(idmap_tdb2_perm,
-                                                 HWM_GROUP)) == -1) ||
-                   (low_id < idmap_tdb2_state.low_gid)) {
-                       if (dbwrap_store_int32(
-                                   idmap_tdb2_perm, HWM_GROUP,
-                                   idmap_tdb2_state.low_gid) == -1) {
-                               DEBUG(0, ("Unable to initialise group hwm in idmap database\n"));
-                               return NT_STATUS_INTERNAL_DB_ERROR;
-                       }
+       }
+
+       if (((low_id = dbwrap_fetch_int32(idmap_tdb2_perm,
+                                         HWM_GROUP)) == -1) ||
+           (low_id < idmap_tdb2_state.low_gid)) {
+               if (dbwrap_store_int32(
+                           idmap_tdb2_perm, HWM_GROUP,
+                           idmap_tdb2_state.low_gid) == -1) {
+                       DEBUG(0, ("Unable to initialise group hwm in idmap "
+                                 "database\n"));
+                       return NT_STATUS_INTERNAL_DB_ERROR;
                }
        }
 
                }
        }