Use sid_string_talloc where we have a tmp talloc ctx
authorVolker Lendecke <vl@samba.org>
Sat, 15 Dec 2007 20:10:58 +0000 (21:10 +0100)
committerVolker Lendecke <vl@samba.org>
Sat, 15 Dec 2007 21:09:35 +0000 (22:09 +0100)
(This used to be commit f00ab810d2540679bec109498ac89e1eafe18f03)

source3/auth/auth_util.c
source3/passdb/pdb_ldap.c
source3/winbindd/idmap_ldap.c

index c0a9e9bc846305c8ec1947409d5afcd89cd78dc2..0d4caecb2df3a85636e399e0db6130288b59cf9f 100644 (file)
@@ -586,12 +586,12 @@ static NTSTATUS log_nt_token(TALLOC_CTX *tmp_ctx, NT_USER_TOKEN *token)
        for (i=1; i<token->num_sids; i++) {
                group_sidstr = talloc_asprintf(
                        tmp_ctx, "%s %s", group_sidstr,
-                       sid_string_static(&token->user_sids[i]));
+                       sid_string_talloc(tmp_ctx, &token->user_sids[i]));
        }
 
        command = talloc_string_sub(
                tmp_ctx, lp_log_nt_token_command(),
-               "%s", sid_string_static(&token->user_sids[0]));
+               "%s", sid_string_talloc(tmp_ctx, &token->user_sids[0]));
        command = talloc_string_sub(tmp_ctx, command, "%t", group_sidstr);
 
        if (command == NULL) {
index 205ca68fe3e5651a324bab18c68b8085046166d4..750b71fb1c8ac79a2d88c4b62eb587a51cc84267 100644 (file)
@@ -2248,7 +2248,7 @@ static NTSTATUS ldapsam_add_sam_account(struct pdb_methods *my_methods, struct s
                                "(&(%s=%s)(|(objectClass=%s)(objectClass=%s)))",
                                 get_userattr_key2string(ldap_state->schema_ver,
                                         LDAP_ATTR_USER_SID),
-                                sid_to_string(sid_string, sid),
+                                sid_string_talloc(ctx, sid),
                                 LDAP_OBJ_IDMAP_ENTRY,
                                 LDAP_OBJ_SID_ENTRY);
                if (!filter) {
@@ -2700,7 +2700,7 @@ static NTSTATUS ldapsam_enum_group_members(struct pdb_methods *methods,
                                 "(sambaSID=%s))",
                                 LDAP_OBJ_POSIXGROUP,
                                 LDAP_OBJ_GROUPMAP,
-                                sid_string_static(group));
+                                sid_string_talloc(mem_ctx, group));
        if (filter == NULL) {
                ret = NT_STATUS_NO_MEMORY;
                goto done;
@@ -3124,7 +3124,7 @@ static NTSTATUS ldapsam_add_group_mapping_entry(struct pdb_methods *methods,
        }
 
        filter = talloc_asprintf(mem_ctx, "(sambaSid=%s)",
-                                sid_string_static(&map->sid));
+                                sid_string_talloc(mem_ctx, &map->sid));
        if (filter == NULL) {
                result = NT_STATUS_NO_MEMORY;
                goto done;
@@ -3191,7 +3191,7 @@ static NTSTATUS ldapsam_add_group_mapping_entry(struct pdb_methods *methods,
         * the best we can get out of LDAP. */
 
        dn = talloc_asprintf(mem_ctx, "sambaSid=%s,%s",
-                            sid_string_static(&map->sid),
+                            sid_string_talloc(mem_ctx, &map->sid),
                             lp_ldap_group_suffix());
        if (dn == NULL) {
                result = NT_STATUS_NO_MEMORY;
@@ -3206,7 +3206,7 @@ static NTSTATUS ldapsam_add_group_mapping_entry(struct pdb_methods *methods,
                         "sambaGroupMapping");
 
        smbldap_make_mod(ldap_state->smbldap_state->ldap_struct, NULL, &mods, "sambaSid",
-                        sid_string_static(&map->sid));
+                        sid_string_talloc(mem_ctx, &map->sid));
        smbldap_make_mod(ldap_state->smbldap_state->ldap_struct, NULL, &mods, "sambaGroupType",
                         talloc_asprintf(mem_ctx, "%d", map->sid_name_use));
        smbldap_make_mod(ldap_state->smbldap_state->ldap_struct, NULL, &mods, "displayName",
@@ -3259,8 +3259,8 @@ static NTSTATUS ldapsam_update_group_mapping_entry(struct pdb_methods *methods,
                                 "(sambaSid=%s)(gidNumber=%u)"
                                 "(sambaGroupType=%d))",
                                 LDAP_OBJ_GROUPMAP,
-                                sid_string_static(&map->sid), map->gid,
-                                map->sid_name_use);
+                                sid_string_talloc(mem_ctx, &map->sid),
+                                map->gid, map->sid_name_use);
        if (filter == NULL) {
                result = NT_STATUS_NO_MEMORY;
                goto done;
@@ -3338,7 +3338,7 @@ static NTSTATUS ldapsam_delete_group_mapping_entry(struct pdb_methods *methods,
 
        filter = talloc_asprintf(mem_ctx, "(&(objectClass=%s)(%s=%s))",
                                 LDAP_OBJ_GROUPMAP, LDAP_ATTRIBUTE_SID,
-                                sid_string_static(&sid));
+                                sid_string_talloc(mem_ctx, &sid));
        if (filter == NULL) {
                result = NT_STATUS_NO_MEMORY;
                goto done;
@@ -3797,7 +3797,8 @@ static NTSTATUS ldapsam_alias_memberships(struct pdb_methods *methods,
        for (i=0; i<num_members; i++)
                filter = talloc_asprintf(mem_ctx, "%s(sambaSIDList=%s)",
                                         filter,
-                                        sid_string_static(&members[i]));
+                                        sid_string_talloc(mem_ctx,
+                                                          &members[i]));
 
        filter = talloc_asprintf(mem_ctx, "%s))", filter);
 
@@ -4927,7 +4928,7 @@ static bool ldapsam_sid_to_id(struct pdb_methods *methods,
        filter = talloc_asprintf(mem_ctx,
                                 "(&(sambaSid=%s)"
                                 "(|(objectClass=%s)(objectClass=%s)))",
-                                sid_string_static(sid),
+                                sid_string_talloc(mem_ctx, sid),
                                 LDAP_OBJ_GROUPMAP, LDAP_OBJ_SAMBASAMACCOUNT);
        if (filter == NULL) {
                DEBUG(5, ("talloc_asprintf failed\n"));
@@ -5407,7 +5408,8 @@ static NTSTATUS ldapsam_create_dom_group(struct pdb_methods *my_methods,
 
        sid_compose(&group_sid, get_global_sam_sid(), *rid);
 
-       groupsidstr = talloc_strdup(tmp_ctx, sid_string_static(&group_sid));
+       groupsidstr = talloc_strdup(tmp_ctx, sid_string_talloc(tmp_ctx,
+                                                              &group_sid));
        grouptype = talloc_asprintf(tmp_ctx, "%d", SID_NAME_DOM_GRP);
 
        if (!groupsidstr || !grouptype) {
@@ -5464,7 +5466,7 @@ static NTSTATUS ldapsam_delete_dom_group(struct pdb_methods *my_methods, TALLOC_
                                 "(&(sambaSID=%s)"
                                 "(objectClass=%s)"
                                 "(objectClass=%s))",
-                                sid_string_static(&group_sid),
+                                sid_string_talloc(tmp_ctx, &group_sid),
                                 LDAP_OBJ_POSIXGROUP,
                                 LDAP_OBJ_GROUPMAP);
        if (filter == NULL) {
@@ -5578,7 +5580,7 @@ static NTSTATUS ldapsam_change_groupmem(struct pdb_methods *my_methods,
                                 "(&(sambaSID=%s)"
                                 "(objectClass=%s)"
                                 "(objectClass=%s))",
-                                sid_string_static(&member_sid),
+                                sid_string_talloc(tmp_ctx, &member_sid),
                                 LDAP_OBJ_POSIXACCOUNT,
                                 LDAP_OBJ_SAMBASAMACCOUNT);
        if (filter == NULL) {
@@ -5645,7 +5647,7 @@ static NTSTATUS ldapsam_change_groupmem(struct pdb_methods *my_methods,
                                 "(&(sambaSID=%s)"
                                 "(objectClass=%s)"
                                 "(objectClass=%s))",
-                                sid_string_static(&group_sid),
+                                sid_string_talloc(tmp_ctx, &group_sid),
                                 LDAP_OBJ_POSIXGROUP,
                                 LDAP_OBJ_GROUPMAP);
 
index a980d54bbe9ec6de30302cd51c6732b2250fc974..17e9eefe436edcc33a2da241f6bd6ec9a64eacf1 100644 (file)
@@ -1166,7 +1166,7 @@ static NTSTATUS idmap_ldap_sids_to_unixids(struct idmap_domain *dom,
                filter = talloc_asprintf(memctx, "(&(objectClass=%s)(%s=%s))",
                                LDAP_OBJ_IDMAP_ENTRY,
                                LDAP_ATTRIBUTE_SID,
-                               sid_string_static(ids[0]->sid));
+                               sid_string_talloc(memctx, ids[0]->sid));
                CHECK_ALLOC_DONE(filter);
                DEBUG(10, ("Filter: [%s]\n", filter));
        } else {
@@ -1187,7 +1187,8 @@ again:
                for (i = 0; (i < IDMAP_LDAP_MAX_IDS) && ids[idx]; i++, idx++) {
                        filter = talloc_asprintf_append_buffer(filter, "(%s=%s)",
                                        LDAP_ATTRIBUTE_SID,
-                                       sid_string_static(ids[idx]->sid));
+                                       sid_string_talloc(memctx,
+                                                         ids[idx]->sid));
                        CHECK_ALLOC_DONE(filter);
                }
                filter = talloc_asprintf_append_buffer(filter, "))");
@@ -1385,7 +1386,7 @@ static NTSTATUS idmap_ldap_set_mapping(struct idmap_domain *dom,
        id_str = talloc_asprintf(memctx, "%lu", (unsigned long)map->xid.id);
        CHECK_ALLOC_DONE(id_str);
 
-       sid = talloc_strdup(memctx, sid_string_static(map->sid));
+       sid = talloc_strdup(memctx, sid_string_talloc(memctx, map->sid));
        CHECK_ALLOC_DONE(sid);
 
        dn = talloc_asprintf(memctx, "%s=%s,%s",