s3:auth small optimization in create_token_from_sid
authorChristian Ambach <ambi@samba.org>
Tue, 29 Jan 2013 16:19:17 +0000 (17:19 +0100)
committerMichael Adam <obnox@samba.org>
Tue, 5 Feb 2013 18:14:25 +0000 (19:14 +0100)
save some calls to lp_idmap_default_range(), calling it
once is enough

Signed-off-by: Christian Ambach <ambi@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Tue Feb  5 19:14:25 CET 2013 on sn-devel-104

source3/auth/token_util.c

index 33b5507744fefce9f429eca8da332f259162f78c..d86d589cc3d6ff14d6c6491fb33d79fa63bca84c 100644 (file)
@@ -565,6 +565,8 @@ static NTSTATUS create_token_from_sid(TALLOC_CTX *mem_ctx,
        uint32_t num_group_sids;
        uint32_t num_gids;
        uint32_t i;
+       uint32_t high, low;
+       bool range_ok;
 
        if (sid_check_is_in_our_sam(user_sid)) {
                bool ret;
@@ -757,13 +759,13 @@ static NTSTATUS create_token_from_sid(TALLOC_CTX *mem_ctx,
           to 'valid user = "Domain Admins"'.  --jerry */
 
        num_gids = num_group_sids;
+       range_ok = lp_idmap_default_range(&low, &high);
        for ( i=0; i<num_gids; i++ ) {
-               uint32_t high, low;
 
                /* don't pickup anything managed by Winbind */
-
-               if ( lp_idmap_default_range(&low, &high) && (gids[i] >= low) && (gids[i] <= high) )
+               if (range_ok && (gids[i] >= low) && (gids[i] <= high)) {
                        continue;
+               }
 
                gid_to_unix_groups_sid(gids[i], &unix_group_sid);