r17451: Change pdb_getgrsid not to take a DOM_SID but a const DOM_SID * as an
authorVolker Lendecke <vlendec@samba.org>
Tue, 8 Aug 2006 08:26:40 +0000 (08:26 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:38:34 +0000 (11:38 -0500)
argument.

Volker

source/groupdb/mapping.c
source/include/passdb.h
source/passdb/lookup_sid.c
source/passdb/pdb_interface.c
source/passdb/pdb_ldap.c
source/rpc_server/srv_lsa_nt.c
source/rpc_server/srv_samr_nt.c
source/utils/net_groupmap.c
source/utils/net_rpc_samsync.c
source/utils/net_sam.c

index c701ef165dd4e0c856e388ebdf44eb9cce8e7400..20bc63e56e320a529aa2e69e21b36961885a6737 100644 (file)
@@ -220,7 +220,7 @@ NTSTATUS map_unix_group(const struct group *grp, GROUP_MAP *pmap)
  Return the sid and the type of the unix group.
 ****************************************************************************/
 
-static BOOL get_group_map_from_sid(DOM_SID sid, GROUP_MAP *map)
+static BOOL get_group_map_from_sid(const DOM_SID *sid, GROUP_MAP *map)
 {
        TDB_DATA kbuf, dbuf;
        pstring key;
@@ -234,7 +234,7 @@ static BOOL get_group_map_from_sid(DOM_SID sid, GROUP_MAP *map)
 
        /* the key is the SID, retrieving is direct */
 
-       sid_to_string(string_sid, &sid);
+       sid_to_string(string_sid, sid);
        slprintf(key, sizeof(key), "%s%s", GROUP_PREFIX, string_sid);
 
        kbuf.dptr = key;
@@ -254,7 +254,7 @@ static BOOL get_group_map_from_sid(DOM_SID sid, GROUP_MAP *map)
                return False;
        }
        
-       sid_copy(&map->sid, &sid);
+       sid_copy(&map->sid, sid);
        
        return True;
 }
@@ -588,7 +588,7 @@ static NTSTATUS add_aliasmem(const DOM_SID *alias, const DOM_SID *member)
                return NT_STATUS_ACCESS_DENIED;
        }
 
-       if (!get_group_map_from_sid(*alias, &map))
+       if (!get_group_map_from_sid(alias, &map))
                return NT_STATUS_NO_SUCH_ALIAS;
 
        if ( (map.sid_name_use != SID_NAME_ALIAS) &&
@@ -691,7 +691,7 @@ static NTSTATUS enum_aliasmem(const DOM_SID *alias, DOM_SID **sids, size_t *num)
                return NT_STATUS_ACCESS_DENIED;
        }
 
-       if (!get_group_map_from_sid(*alias, &map))
+       if (!get_group_map_from_sid(alias, &map))
                return NT_STATUS_NO_SUCH_ALIAS;
 
        if ( (map.sid_name_use != SID_NAME_ALIAS) &&
@@ -796,7 +796,7 @@ static NTSTATUS del_aliasmem(const DOM_SID *alias, const DOM_SID *member)
 
 /* get a domain group from it's SID */
 
-BOOL get_domain_group_from_sid(DOM_SID sid, GROUP_MAP *map)
+BOOL get_domain_group_from_sid(const DOM_SID *sid, GROUP_MAP *map)
 {
        struct group *grp;
        BOOL ret;
@@ -819,12 +819,12 @@ BOOL get_domain_group_from_sid(DOM_SID sid, GROUP_MAP *map)
        if ( !ret ) {
                uint32 rid;
                
-               sid_peek_rid( &sid, &rid );
+               sid_peek_rid( sid, &rid );
                
                if ( rid == DOMAIN_GROUP_RID_USERS ) {
                        fstrcpy( map->nt_name, "None" );
                        fstrcpy( map->comment, "Ordinary Users" );
-                       sid_copy( &map->sid, &sid );
+                       sid_copy( &map->sid, sid );
                        map->sid_name_use = SID_NAME_DOM_GRP;
                        
                        return True;
@@ -998,7 +998,7 @@ int smb_delete_user_group(const char *unix_group, const char *unix_user)
 
 
 NTSTATUS pdb_default_getgrsid(struct pdb_methods *methods, GROUP_MAP *map,
-                                DOM_SID sid)
+                             const DOM_SID *sid)
 {
        return get_group_map_from_sid(sid, map) ?
                NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
@@ -1138,7 +1138,7 @@ NTSTATUS pdb_default_get_aliasinfo(struct pdb_methods *methods,
 {
        GROUP_MAP map;
 
-       if (!pdb_getgrsid(&map, *sid))
+       if (!pdb_getgrsid(&map, sid))
                return NT_STATUS_NO_SUCH_ALIAS;
 
        if ((map.sid_name_use != SID_NAME_ALIAS) &&
@@ -1161,7 +1161,7 @@ NTSTATUS pdb_default_set_aliasinfo(struct pdb_methods *methods,
 {
        GROUP_MAP map;
 
-       if (!pdb_getgrsid(&map, *sid))
+       if (!pdb_getgrsid(&map, sid))
                return NT_STATUS_NO_SUCH_ALIAS;
 
        fstrcpy(map.nt_name, info->acct_name);
@@ -1285,7 +1285,7 @@ BOOL pdb_get_dom_grp_info(const DOM_SID *sid, struct acct_info *info)
        BOOL res;
 
        become_root();
-       res = get_domain_group_from_sid(*sid, &map);
+       res = get_domain_group_from_sid(sid, &map);
        unbecome_root();
 
        if (!res)
@@ -1301,7 +1301,7 @@ BOOL pdb_set_dom_grp_info(const DOM_SID *sid, const struct acct_info *info)
 {
        GROUP_MAP map;
 
-       if (!get_domain_group_from_sid(*sid, &map))
+       if (!get_domain_group_from_sid(sid, &map))
                return False;
 
        fstrcpy(map.nt_name, info->acct_name);
index 35bb93aa31cc63b0e70fa7087b4003959e121e3d..fa3a3bdb3ddac0c5694fce4194347ec3cbda3e15 100644 (file)
@@ -244,7 +244,7 @@ struct pdb_search {
  * enum SID_NAME_USE rather than uint32.
  */
 
-#define PASSDB_INTERFACE_VERSION 14
+#define PASSDB_INTERFACE_VERSION 15
 
 struct pdb_methods 
 {
@@ -277,7 +277,8 @@ struct pdb_methods
        
        NTSTATUS (*update_login_attempts)(struct pdb_methods *methods, struct samu *sam_acct, BOOL success);
 
-       NTSTATUS (*getgrsid)(struct pdb_methods *methods, GROUP_MAP *map, DOM_SID sid);
+       NTSTATUS (*getgrsid)(struct pdb_methods *methods, GROUP_MAP *map,
+                            const DOM_SID *sid);
 
        NTSTATUS (*getgrgid)(struct pdb_methods *methods, GROUP_MAP *map, gid_t gid);
 
index f612cff092ae82485bcf0ab7b22b3e498188c30c..f6c15168a93810af60f442b006dfb92fbee9adbd 100644 (file)
@@ -1352,7 +1352,7 @@ BOOL sid_to_gid(const DOM_SID *psid, gid_t *pgid)
 
        if ((sid_check_is_in_builtin(psid) ||
             sid_check_is_in_wellknown_domain(psid))) {
-               if (pdb_getgrsid(&map, *psid)) {
+               if (pdb_getgrsid(&map, psid)) {
                        *pgid = map.gid;
                        goto done;
                }
index 7f2a8f25b3d08b22120bd103ffdf8f5f0ce28d53..4e30f92acf59a32417cfba3a1014cc3b876341f5 100644 (file)
@@ -561,7 +561,7 @@ NTSTATUS pdb_update_login_attempts(struct samu *sam_acct, BOOL success)
        return pdb->update_login_attempts(pdb, sam_acct, success);
 }
 
-BOOL pdb_getgrsid(GROUP_MAP *map, DOM_SID sid)
+BOOL pdb_getgrsid(GROUP_MAP *map, const DOM_SID *sid)
 {
        struct pdb_methods *pdb = pdb_get_methods();
        return NT_STATUS_IS_OK(pdb->getgrsid(pdb, map, sid));
@@ -636,7 +636,7 @@ static NTSTATUS pdb_default_delete_dom_group(struct pdb_methods *methods,
 
        sid_compose(&group_sid, get_global_sam_sid(), rid);
 
-       if (!get_domain_group_from_sid(group_sid, &map)) {
+       if (!get_domain_group_from_sid(&group_sid, &map)) {
                DEBUG(10, ("Could not find group for rid %d\n", rid));
                return NT_STATUS_NO_SUCH_GROUP;
        }
@@ -812,7 +812,7 @@ static NTSTATUS pdb_default_add_groupmem(struct pdb_methods *methods,
        sid_compose(&group_sid, get_global_sam_sid(), group_rid);
        sid_compose(&member_sid, get_global_sam_sid(), member_rid);
 
-       if (!get_domain_group_from_sid(group_sid, &map) ||
+       if (!get_domain_group_from_sid(&group_sid, &map) ||
            (map.gid == (gid_t)-1) ||
            ((grp = getgrgid(map.gid)) == NULL)) {
                return NT_STATUS_NO_SUCH_GROUP;
@@ -874,7 +874,7 @@ static NTSTATUS pdb_default_del_groupmem(struct pdb_methods *methods,
        sid_compose(&group_sid, get_global_sam_sid(), group_rid);
        sid_compose(&member_sid, get_global_sam_sid(), member_rid);
 
-       if (!get_domain_group_from_sid(group_sid, &map) ||
+       if (!get_domain_group_from_sid(&group_sid, &map) ||
            (map.gid == (gid_t)-1) ||
            ((grp = getgrgid(map.gid)) == NULL)) {
                return NT_STATUS_NO_SUCH_GROUP;
@@ -1276,7 +1276,7 @@ static BOOL pdb_default_sid_to_id(struct pdb_methods *methods,
        if (sid_peek_check_rid(&global_sid_Builtin, sid, &rid)) {
                /* Here we only have aliases */
                GROUP_MAP map;
-               if (!NT_STATUS_IS_OK(methods->getgrsid(methods, &map, *sid))) {
+               if (!NT_STATUS_IS_OK(methods->getgrsid(methods, &map, sid))) {
                        DEBUG(10, ("Could not find map for sid %s\n",
                                   sid_string_static(sid)));
                        goto done;
@@ -1522,7 +1522,7 @@ static BOOL lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32 rid,
        }
        TALLOC_FREE(sam_account);
        
-       ret = pdb_getgrsid(&map, sid);
+       ret = pdb_getgrsid(&map, &sid);
        unbecome_root();
        /* END BECOME_ROOT BLOCK */
   
index afc95fe90f1cb3e65e84d1cfa6e841caae105591..3e9f321ce227bbc30ac79484b21990c5d7bf20e2 100644 (file)
@@ -2245,14 +2245,14 @@ static NTSTATUS ldapsam_getgroup(struct pdb_methods *methods,
  *********************************************************************/
 
 static NTSTATUS ldapsam_getgrsid(struct pdb_methods *methods, GROUP_MAP *map,
-                                DOM_SID sid)
+                                const DOM_SID *sid)
 {
        pstring filter;
 
        pstr_sprintf(filter, "(&(objectClass=%s)(%s=%s))",
                LDAP_OBJ_GROUPMAP, 
                get_attr_key2string(groupmap_attr_list, LDAP_ATTR_GROUP_SID),
-               sid_string_static(&sid));
+               sid_string_static(sid));
 
        return ldapsam_getgroup(methods, filter, map);
 }
index 41df87041433f8fc4e7261a0210ab223bd65534a..33cbba933f386bd69640f2d58697fe4c3b4efd8b 100644 (file)
@@ -1730,7 +1730,7 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA
        if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
                return NT_STATUS_ACCESS_DENIED;
 
-       if (!pdb_getgrsid(&map, info->sid))
+       if (!pdb_getgrsid(&map, &info->sid))
                return NT_STATUS_NO_SUCH_GROUP;
 
        return pdb_update_group_mapping_entry(&map);
index 31e434cbfb1cf7b48f7ad505e7083c51d5f55043..0835da4908acef256f731ab47f3d8d6dd95812cb 100644 (file)
@@ -4438,7 +4438,7 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM
        }
                
        become_root();
-       ret = get_domain_group_from_sid(group_sid, &map);
+       ret = get_domain_group_from_sid(&group_sid, &map);
        unbecome_root();
        if (!ret)
                return NT_STATUS_INVALID_HANDLE;
@@ -4535,7 +4535,7 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_
        }
 
        become_root();
-       result = get_domain_group_from_sid(group_sid, &map);
+       result = get_domain_group_from_sid(&group_sid, &map);
        unbecome_root();
        if (!result)
                return NT_STATUS_NO_SUCH_GROUP;
@@ -4754,7 +4754,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G
 
        /* check if that group really exists */
        become_root();
-       ret = get_domain_group_from_sid(info->sid, &map);
+       ret = get_domain_group_from_sid(&info->sid, &map);
        unbecome_root();
        if (!ret)
                return NT_STATUS_NO_SUCH_GROUP;
index a96ac526bfcd571b46a1517f9a2e8329abaf10bb..3865382c920a611f47b58a9e43583c6a0c97579a 100644 (file)
@@ -153,7 +153,7 @@ static int net_groupmap_list(int argc, const char **argv)
                }
 
                /* Get the current mapping from the database */
-               if(!pdb_getgrsid(&map, sid)) {
+               if(!pdb_getgrsid(&map, &sid)) {
                        d_fprintf(stderr, "Failure to local group SID in the database\n");
                        return -1;
                }
@@ -404,7 +404,7 @@ static int net_groupmap_modify(int argc, const char **argv)
        }       
 
        /* Get the current mapping from the database */
-       if(!pdb_getgrsid(&map, sid)) {
+       if(!pdb_getgrsid(&map, &sid)) {
                d_fprintf(stderr, "Failure to local group SID in the database\n");
                return -1;
        }
@@ -539,7 +539,7 @@ static int net_groupmap_set(int argc, const char **argv)
                DOM_SID sid;
                have_map = ( (strncmp(ntgroup, "S-", 2) == 0) &&
                             string_to_sid(&sid, ntgroup) &&
-                            pdb_getgrsid(&map, sid) );
+                            pdb_getgrsid(&map, &sid) );
        }
 
        if (!have_map) {
index bbe09a3b350721748a3c473239fb06d8f63eb75c..fe3c919d9a5a5765c0e5bb01e1dd01c0e54dea87 100644 (file)
@@ -588,7 +588,7 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta)
 
        group_sid = *pdb_get_group_sid(sam_account);
 
-       if (!pdb_getgrsid(&map, group_sid)) {
+       if (!pdb_getgrsid(&map, &group_sid)) {
                DEBUG(0, ("Primary group of %s has no mapping!\n",
                          pdb_get_username(sam_account)));
        } else {
@@ -630,7 +630,7 @@ static NTSTATUS fetch_group_info(uint32 rid, SAM_GROUP_INFO *delta)
        sid_append_rid(&group_sid, rid);
        sid_to_string(sid_string, &group_sid);
 
-       if (pdb_getgrsid(&map, group_sid)) {
+       if (pdb_getgrsid(&map, &group_sid)) {
                if ( map.gid != -1 )
                        grp = getgrgid(map.gid);
                insert = False;
@@ -689,7 +689,7 @@ static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta)
        sid_copy(&group_sid, get_global_sam_sid());
        sid_append_rid(&group_sid, rid);
 
-       if (!get_domain_group_from_sid(group_sid, &map)) {
+       if (!get_domain_group_from_sid(&group_sid, &map)) {
                DEBUG(0, ("Could not find global group %d\n", rid));
                return NT_STATUS_NO_SUCH_GROUP;
        }
@@ -805,7 +805,6 @@ static NTSTATUS fetch_alias_info(uint32 rid, SAM_ALIAS_INFO *delta,
        fstring comment;
        struct group *grp = NULL;
        DOM_SID alias_sid;
-       fstring sid_string;
        GROUP_MAP map;
        BOOL insert = True;
 
@@ -815,9 +814,8 @@ static NTSTATUS fetch_alias_info(uint32 rid, SAM_ALIAS_INFO *delta,
        /* Find out whether the group is already mapped */
        sid_copy(&alias_sid, &dom_sid);
        sid_append_rid(&alias_sid, rid);
-       sid_to_string(sid_string, &alias_sid);
 
-       if (pdb_getgrsid(&map, alias_sid)) {
+       if (pdb_getgrsid(&map, &alias_sid)) {
                grp = getgrgid(map.gid);
                insert = False;
        }
index 654c9ec5b2a3c4fee8c0f9ef18958f8dd0ec5a18..aed07553b6c4e6fe4db8ead5681b2296d6736540 100644 (file)
@@ -330,7 +330,7 @@ static int net_sam_set_comment(int argc, const char **argv)
                return -1;
        }
 
-       if (!pdb_getgrsid(&map, sid)) {
+       if (!pdb_getgrsid(&map, &sid)) {
                d_fprintf(stderr, "Could not load group %s\n", argv[0]);
                return -1;
        }
@@ -882,7 +882,7 @@ static int net_sam_provision(int argc, const char **argv)
 
        sid_compose(&gsid, get_global_sam_sid(), DOMAIN_GROUP_RID_USERS);
 
-       if (!pdb_getgrsid(&gmap, gsid)) {
+       if (!pdb_getgrsid(&gmap, &gsid)) {
                LDAPMod **mods = NULL;
                char *dn;
                char *uname;
@@ -935,7 +935,7 @@ domu_done:
 
        sid_compose(&gsid, get_global_sam_sid(), DOMAIN_GROUP_RID_ADMINS);
 
-       if (!pdb_getgrsid(&gmap, gsid)) {
+       if (!pdb_getgrsid(&gmap, &gsid)) {
                LDAPMod **mods = NULL;
                char *dn;
                char *uname;