diff options
author | Volker Lendecke <vl@samba.org> | 2009-02-12 17:48:52 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2009-03-07 17:51:21 +0100 |
commit | 46bcb10b5abb21758cf234764b64220ede1b7ab5 (patch) | |
tree | c99007849f0599477797d3186c563f52d419513e | |
parent | e58ade4136b40d82c24f3556845e7412a3330992 (diff) | |
download | samba-46bcb10b5abb21758cf234764b64220ede1b7ab5.tar.gz samba-46bcb10b5abb21758cf234764b64220ede1b7ab5.tar.bz2 samba-46bcb10b5abb21758cf234764b64220ede1b7ab5.zip |
Shape up pdb_search a bit by making it a talloc ctx with a destructor
-rw-r--r-- | source3/include/passdb.h | 1 | ||||
-rw-r--r-- | source3/include/proto.h | 10 | ||||
-rw-r--r-- | source3/passdb/pdb_interface.c | 63 | ||||
-rw-r--r-- | source3/passdb/pdb_ldap.c | 20 | ||||
-rw-r--r-- | source3/passdb/pdb_smbpasswd.c | 9 | ||||
-rw-r--r-- | source3/passdb/pdb_tdb.c | 11 | ||||
-rw-r--r-- | source3/rpc_server/srv_samr_nt.c | 94 | ||||
-rw-r--r-- | source3/utils/net.c | 9 | ||||
-rw-r--r-- | source3/utils/net_sam.c | 16 | ||||
-rw-r--r-- | source3/utils/pdbedit.c | 20 | ||||
-rw-r--r-- | source3/winbindd/winbindd_passdb.c | 12 |
11 files changed, 128 insertions, 137 deletions
diff --git a/source3/include/passdb.h b/source3/include/passdb.h index 93c1e3f0ab..9cbc6bd340 100644 --- a/source3/include/passdb.h +++ b/source3/include/passdb.h @@ -186,7 +186,6 @@ enum pdb_search_type { }; struct pdb_search { - TALLOC_CTX *mem_ctx; enum pdb_search_type type; struct samr_displayentry *cache; uint32 num_entries; diff --git a/source3/include/proto.h b/source3/include/proto.h index 5cd4e459ae..b6ddacca75 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -4617,14 +4617,14 @@ bool pdb_sid_to_id(const DOM_SID *sid, union unid_t *id, bool pdb_rid_algorithm(void); bool pdb_new_rid(uint32 *rid); bool initialize_password_db(bool reload, struct event_context *event_ctx); -struct pdb_search *pdb_search_init(enum pdb_search_type type); -struct pdb_search *pdb_search_users(uint32 acct_flags); -struct pdb_search *pdb_search_groups(void); -struct pdb_search *pdb_search_aliases(const DOM_SID *sid); +struct pdb_search *pdb_search_init(TALLOC_CTX *mem_ctx, + enum pdb_search_type type); +struct pdb_search *pdb_search_users(TALLOC_CTX *mem_ctx, uint32 acct_flags); +struct pdb_search *pdb_search_groups(TALLOC_CTX *mem_ctx); +struct pdb_search *pdb_search_aliases(TALLOC_CTX *mem_ctx, const DOM_SID *sid); uint32 pdb_search_entries(struct pdb_search *search, uint32 start_idx, uint32 max_entries, struct samr_displayentry **result); -void pdb_search_destroy(struct pdb_search *search); bool pdb_get_trusteddom_pw(const char *domain, char** pwd, DOM_SID *sid, time_t *pass_last_set_time); bool pdb_set_trusteddom_pw(const char* domain, const char* pwd, diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c index e618b425e0..1909bd0da4 100644 --- a/source3/passdb/pdb_interface.c +++ b/source3/passdb/pdb_interface.c @@ -1709,24 +1709,25 @@ static NTSTATUS pdb_default_lookup_names(struct pdb_methods *methods, } #endif -struct pdb_search *pdb_search_init(enum pdb_search_type type) +static int pdb_search_destructor(struct pdb_search *search) { - TALLOC_CTX *mem_ctx; - struct pdb_search *result; - - mem_ctx = talloc_init("pdb_search"); - if (mem_ctx == NULL) { - DEBUG(0, ("talloc_init failed\n")); - return NULL; + if (!search->search_ended) { + search->search_end(search); } + return 0; +} - result = TALLOC_P(mem_ctx, struct pdb_search); +struct pdb_search *pdb_search_init(TALLOC_CTX *mem_ctx, + enum pdb_search_type type) +{ + struct pdb_search *result; + + result = talloc(mem_ctx, struct pdb_search); if (result == NULL) { DEBUG(0, ("talloc failed\n")); return NULL; } - result->mem_ctx = mem_ctx; result->type = type; result->cache = NULL; result->num_entries = 0; @@ -1737,6 +1738,8 @@ struct pdb_search *pdb_search_init(enum pdb_search_type type) result->next_entry = NULL; result->search_end = NULL; + talloc_set_destructor(result, pdb_search_destructor); + return result; } @@ -1783,8 +1786,7 @@ static bool next_entry_groups(struct pdb_search *s, sid_peek_rid(&map->sid, &rid); - fill_displayentry(s->mem_ctx, rid, 0, map->nt_name, NULL, map->comment, - entry); + fill_displayentry(s, rid, 0, map->nt_name, NULL, map->comment, entry); state->current_group += 1; return True; @@ -1802,7 +1804,7 @@ static bool pdb_search_grouptype(struct pdb_search *search, { struct group_search *state; - state = TALLOC_P(search->mem_ctx, struct group_search); + state = talloc(search, struct group_search); if (state == NULL) { DEBUG(0, ("talloc failed\n")); return False; @@ -1853,7 +1855,7 @@ static struct samr_displayentry *pdb_search_getentry(struct pdb_search *search, break; } - ADD_TO_LARGE_ARRAY(search->mem_ctx, struct samr_displayentry, + ADD_TO_LARGE_ARRAY(search, struct samr_displayentry, entry, &search->cache, &search->num_entries, &search->cache_size); } @@ -1861,52 +1863,54 @@ static struct samr_displayentry *pdb_search_getentry(struct pdb_search *search, return (search->num_entries > idx) ? &search->cache[idx] : NULL; } -struct pdb_search *pdb_search_users(uint32 acct_flags) +struct pdb_search *pdb_search_users(TALLOC_CTX *mem_ctx, uint32 acct_flags) { struct pdb_methods *pdb = pdb_get_methods(); struct pdb_search *result; - result = pdb_search_init(PDB_USER_SEARCH); + result = pdb_search_init(mem_ctx, PDB_USER_SEARCH); if (result == NULL) { return NULL; } if (!pdb->search_users(pdb, result, acct_flags)) { - talloc_destroy(result->mem_ctx); + TALLOC_FREE(result); return NULL; } return result; } -struct pdb_search *pdb_search_groups(void) +struct pdb_search *pdb_search_groups(TALLOC_CTX *mem_ctx) { struct pdb_methods *pdb = pdb_get_methods(); struct pdb_search *result; - result = pdb_search_init(PDB_GROUP_SEARCH); + result = pdb_search_init(mem_ctx, PDB_GROUP_SEARCH); if (result == NULL) { return NULL; } if (!pdb->search_groups(pdb, result)) { - talloc_destroy(result->mem_ctx); + TALLOC_FREE(result); return NULL; } return result; } -struct pdb_search *pdb_search_aliases(const DOM_SID *sid) +struct pdb_search *pdb_search_aliases(TALLOC_CTX *mem_ctx, const DOM_SID *sid) { struct pdb_methods *pdb = pdb_get_methods(); struct pdb_search *result; if (pdb == NULL) return NULL; - result = pdb_search_init(PDB_ALIAS_SEARCH); - if (result == NULL) return NULL; + result = pdb_search_init(mem_ctx, PDB_ALIAS_SEARCH); + if (result == NULL) { + return NULL; + } if (!pdb->search_aliases(pdb, result, sid)) { - talloc_destroy(result->mem_ctx); + TALLOC_FREE(result); return NULL; } return result; @@ -1935,17 +1939,6 @@ uint32 pdb_search_entries(struct pdb_search *search, return search->num_entries - start_idx; } -void pdb_search_destroy(struct pdb_search *search) -{ - if (search == NULL) - return; - - if (!search->search_ended) - search->search_end(search); - - talloc_destroy(search->mem_ctx); -} - /******************************************************************* trustdom methods *******************************************************************/ diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index 70a1c62bef..77b19e3de9 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -4349,7 +4349,8 @@ static bool ldapsam_search_next_entry(struct pdb_search *search, !ldapsam_search_nextpage(search)) return False; - result = state->ldap2displayentry(state, search->mem_ctx, state->connection->ldap_struct, + result = state->ldap2displayentry(state, search, + state->connection->ldap_struct, state->current_entry, entry); if (!result) { @@ -4508,7 +4509,7 @@ static bool ldapsam_search_users(struct pdb_methods *methods, (struct ldapsam_privates *)methods->private_data; struct ldap_search_state *state; - state = TALLOC_P(search->mem_ctx, struct ldap_search_state); + state = talloc(search, struct ldap_search_state); if (state == NULL) { DEBUG(0, ("talloc failed\n")); return False; @@ -4525,10 +4526,10 @@ static bool ldapsam_search_users(struct pdb_methods *methods, state->base = lp_ldap_suffix(); state->acct_flags = acct_flags; - state->base = talloc_strdup(search->mem_ctx, state->base); + state->base = talloc_strdup(search, state->base); state->scope = LDAP_SCOPE_SUBTREE; - state->filter = get_ldap_filter(search->mem_ctx, "*"); - state->attrs = talloc_attrs(search->mem_ctx, "uid", "sambaSid", + state->filter = get_ldap_filter(search, "*"); + state->attrs = talloc_attrs(search, "uid", "sambaSid", "displayName", "description", "sambaAcctFlags", NULL); state->attrsonly = 0; @@ -4682,7 +4683,7 @@ static bool ldapsam_search_grouptype(struct pdb_methods *methods, struct ldap_search_state *state; fstring tmp; - state = TALLOC_P(search->mem_ctx, struct ldap_search_state); + state = talloc(search, struct ldap_search_state); if (state == NULL) { DEBUG(0, ("talloc failed\n")); return False; @@ -4690,15 +4691,14 @@ static bool ldapsam_search_grouptype(struct pdb_methods *methods, state->connection = ldap_state->smbldap_state; - state->base = talloc_strdup(search->mem_ctx, lp_ldap_group_suffix()); + state->base = talloc_strdup(search, lp_ldap_group_suffix()); state->connection = ldap_state->smbldap_state; state->scope = LDAP_SCOPE_SUBTREE; - state->filter = talloc_asprintf(search->mem_ctx, - "(&(objectclass=%s)" + state->filter = talloc_asprintf(search, "(&(objectclass=%s)" "(sambaGroupType=%d)(sambaSID=%s*))", LDAP_OBJ_GROUPMAP, type, sid_to_fstring(tmp, sid)); - state->attrs = talloc_attrs(search->mem_ctx, "cn", "sambaSid", + state->attrs = talloc_attrs(search, "cn", "sambaSid", "displayName", "description", "sambaGroupType", NULL); state->attrsonly = 0; diff --git a/source3/passdb/pdb_smbpasswd.c b/source3/passdb/pdb_smbpasswd.c index b72e0f2cba..d663c7f0b2 100644 --- a/source3/passdb/pdb_smbpasswd.c +++ b/source3/passdb/pdb_smbpasswd.c @@ -1566,11 +1566,11 @@ static bool smbpasswd_search_next_entry(struct pdb_search *search, entry->acct_flags = state->entries[state->current].acct_flags; entry->account_name = talloc_strdup( - search->mem_ctx, state->entries[state->current].account_name); + search, state->entries[state->current].account_name); entry->fullname = talloc_strdup( - search->mem_ctx, state->entries[state->current].fullname); + search, state->entries[state->current].fullname); entry->description = talloc_strdup( - search->mem_ctx, state->entries[state->current].description); + search, state->entries[state->current].description); if ((entry->account_name == NULL) || (entry->fullname == NULL) || (entry->description == NULL)) { @@ -1593,8 +1593,7 @@ static bool smbpasswd_search_users(struct pdb_methods *methods, struct smb_passwd *pwd; FILE *fp; - search_state = TALLOC_ZERO_P(search->mem_ctx, - struct smbpasswd_search_state); + search_state = talloc_zero(search, struct smbpasswd_search_state); if (search_state == NULL) { DEBUG(0, ("talloc failed\n")); return false; diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c index 143a2e2390..3442561030 100644 --- a/source3/passdb/pdb_tdb.c +++ b/source3/passdb/pdb_tdb.c @@ -882,12 +882,9 @@ static bool tdbsam_search_next_entry(struct pdb_search *search, entry->acct_flags = pdb_get_acct_ctrl(user); entry->rid = rid; - entry->account_name = talloc_strdup( - search->mem_ctx, pdb_get_username(user)); - entry->fullname = talloc_strdup( - search->mem_ctx, pdb_get_fullname(user)); - entry->description = talloc_strdup( - search->mem_ctx, pdb_get_acct_desc(user)); + entry->account_name = talloc_strdup(search, pdb_get_username(user)); + entry->fullname = talloc_strdup(search, pdb_get_fullname(user)); + entry->description = talloc_strdup(search, pdb_get_acct_desc(user)); TALLOC_FREE(user); @@ -912,7 +909,7 @@ static bool tdbsam_search_users(struct pdb_methods *methods, return false; } - state = TALLOC_ZERO_P(search->mem_ctx, struct tdbsam_search_state); + state = talloc_zero(search, struct tdbsam_search_state); if (state == NULL) { DEBUG(0, ("talloc failed\n")); return false; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 0b8cb35a84..1128a856cd 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -319,8 +319,8 @@ static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid) * enumerate stuff, so just cache 2 entries. */ - static struct disp_info builtin_dispinfo; - static struct disp_info domain_dispinfo; + static struct disp_info *builtin_dispinfo; + static struct disp_info *domain_dispinfo; /* There are two cases to consider here: 1) The SID is a domain SID and we look for an equality match, or @@ -335,18 +335,32 @@ static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid) /* * Necessary only once, but it does not really hurt. */ - sid_copy(&builtin_dispinfo.sid, &global_sid_Builtin); + if (builtin_dispinfo == NULL) { + builtin_dispinfo = talloc_zero( + talloc_autofree_context(), struct disp_info); + if (builtin_dispinfo == NULL) { + return NULL; + } + } + sid_copy(&builtin_dispinfo->sid, &global_sid_Builtin); - return &builtin_dispinfo; + return builtin_dispinfo; } if (sid_check_is_domain(psid) || sid_check_is_in_our_domain(psid)) { /* * Necessary only once, but it does not really hurt. */ - sid_copy(&domain_dispinfo.sid, get_global_sam_sid()); + if (domain_dispinfo == NULL) { + domain_dispinfo = talloc_zero( + talloc_autofree_context(), struct disp_info); + if (domain_dispinfo == NULL) { + return NULL; + } + } + sid_copy(&domain_dispinfo->sid, get_global_sam_sid()); - return &domain_dispinfo; + return domain_dispinfo; } return NULL; @@ -403,32 +417,11 @@ static void free_samr_cache(DISP_INFO *disp_info) become_root(); - if (disp_info->users) { - DEBUG(10,("free_samr_cache: deleting users cache\n")); - pdb_search_destroy(disp_info->users); - disp_info->users = NULL; - } - if (disp_info->machines) { - DEBUG(10,("free_samr_cache: deleting machines cache\n")); - pdb_search_destroy(disp_info->machines); - disp_info->machines = NULL; - } - if (disp_info->groups) { - DEBUG(10,("free_samr_cache: deleting groups cache\n")); - pdb_search_destroy(disp_info->groups); - disp_info->groups = NULL; - } - if (disp_info->aliases) { - DEBUG(10,("free_samr_cache: deleting aliases cache\n")); - pdb_search_destroy(disp_info->aliases); - disp_info->aliases = NULL; - } - if (disp_info->enum_users) { - DEBUG(10,("free_samr_cache: deleting enum_users cache\n")); - pdb_search_destroy(disp_info->enum_users); - disp_info->enum_users = NULL; - } - disp_info->enum_acb_mask = 0; + TALLOC_FREE(disp_info->users); + TALLOC_FREE(disp_info->machines); + TALLOC_FREE(disp_info->groups); + TALLOC_FREE(disp_info->aliases); + TALLOC_FREE(disp_info->enum_users); unbecome_root(); } @@ -524,7 +517,7 @@ static uint32 count_sam_users(struct disp_info *info, uint32 acct_flags) } if (info->users == NULL) { - info->users = pdb_search_users(acct_flags); + info->users = pdb_search_users(info, acct_flags); if (info->users == NULL) { return 0; } @@ -548,7 +541,7 @@ static uint32 count_sam_groups(struct disp_info *info) } if (info->groups == NULL) { - info->groups = pdb_search_groups(); + info->groups = pdb_search_groups(info); if (info->groups == NULL) { return 0; } @@ -567,7 +560,7 @@ static uint32 count_sam_aliases(struct disp_info *info) struct samr_displayentry *entry; if (info->aliases == NULL) { - info->aliases = pdb_search_aliases(&info->sid); + info->aliases = pdb_search_aliases(info, &info->sid); if (info->aliases == NULL) { return 0; } @@ -1012,12 +1005,12 @@ NTSTATUS _samr_EnumDomainUsers(pipes_struct *p, if ((info->disp_info->enum_users != NULL) && (info->disp_info->enum_acb_mask != r->in.acct_flags)) { - pdb_search_destroy(info->disp_info->enum_users); - info->disp_info->enum_users = NULL; + TALLOC_FREE(info->disp_info->enum_users); } if (info->disp_info->enum_users == NULL) { - info->disp_info->enum_users = pdb_search_users(r->in.acct_flags); + info->disp_info->enum_users = pdb_search_users( + info->disp_info, r->in.acct_flags); info->disp_info->enum_acb_mask = r->in.acct_flags; } @@ -1149,7 +1142,7 @@ NTSTATUS _samr_EnumDomainGroups(pipes_struct *p, become_root(); if (info->disp_info->groups == NULL) { - info->disp_info->groups = pdb_search_groups(); + info->disp_info->groups = pdb_search_groups(info->disp_info); if (info->disp_info->groups == NULL) { unbecome_root(); @@ -1216,7 +1209,8 @@ NTSTATUS _samr_EnumDomainAliases(pipes_struct *p, become_root(); if (info->disp_info->aliases == NULL) { - info->disp_info->aliases = pdb_search_aliases(&info->sid); + info->disp_info->aliases = pdb_search_aliases( + info->disp_info, &info->sid); if (info->disp_info->aliases == NULL) { unbecome_root(); return NT_STATUS_ACCESS_DENIED; @@ -1547,7 +1541,8 @@ NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p, case 0x1: case 0x4: if (info->disp_info->users == NULL) { - info->disp_info->users = pdb_search_users(ACB_NORMAL); + info->disp_info->users = pdb_search_users( + info->disp_info, ACB_NORMAL); if (info->disp_info->users == NULL) { unbecome_root(); return NT_STATUS_ACCESS_DENIED; @@ -1565,8 +1560,8 @@ NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p, break; case 0x2: if (info->disp_info->machines == NULL) { - info->disp_info->machines = - pdb_search_users(ACB_WSTRUST|ACB_SVRTRUST); + info->disp_info->machines = pdb_search_users( + info->disp_info, ACB_WSTRUST|ACB_SVRTRUST); if (info->disp_info->machines == NULL) { unbecome_root(); return NT_STATUS_ACCESS_DENIED; @@ -1585,7 +1580,8 @@ NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p, case 0x3: case 0x5: if (info->disp_info->groups == NULL) { - info->disp_info->groups = pdb_search_groups(); + info->disp_info->groups = pdb_search_groups( + info->disp_info); if (info->disp_info->groups == NULL) { unbecome_root(); return NT_STATUS_ACCESS_DENIED; @@ -5632,7 +5628,8 @@ NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p, switch (r->in.level) { case 1: if (info->disp_info->users == NULL) { - info->disp_info->users = pdb_search_users(ACB_NORMAL); + info->disp_info->users = pdb_search_users( + info->disp_info, ACB_NORMAL); if (info->disp_info->users == NULL) { unbecome_root(); return NT_STATUS_ACCESS_DENIED; @@ -5651,8 +5648,8 @@ NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p, break; case 2: if (info->disp_info->machines == NULL) { - info->disp_info->machines = - pdb_search_users(ACB_WSTRUST|ACB_SVRTRUST); + info->disp_info->machines = pdb_search_users( + info->disp_info, ACB_WSTRUST|ACB_SVRTRUST); if (info->disp_info->machines == NULL) { unbecome_root(); return NT_STATUS_ACCESS_DENIED; @@ -5671,7 +5668,8 @@ NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p, break; case 3: if (info->disp_info->groups == NULL) { - info->disp_info->groups = pdb_search_groups(); + info->disp_info->groups = pdb_search_groups( + info->disp_info); if (info->disp_info->groups == NULL) { unbecome_root(); return NT_STATUS_ACCESS_DENIED; diff --git a/source3/utils/net.c b/source3/utils/net.c index d483198a9e..7823a98219 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -272,7 +272,7 @@ static bool search_maxrid(struct pdb_search *search, const char *type, num_entries = pdb_search_entries(search, 0, 0xffffffff, &entries); for (i=0; i<num_entries; i++) *max_rid = MAX(*max_rid, entries[i].rid); - pdb_search_destroy(search); + TALLOC_FREE(search); return true; } @@ -280,13 +280,14 @@ static uint32 get_maxrid(void) { uint32 max_rid = 0; - if (!search_maxrid(pdb_search_users(0), "users", &max_rid)) + if (!search_maxrid(pdb_search_users(talloc_tos(), 0), "users", &max_rid)) return 0; - if (!search_maxrid(pdb_search_groups(), "groups", &max_rid)) + if (!search_maxrid(pdb_search_groups(talloc_tos()), "groups", &max_rid)) return 0; - if (!search_maxrid(pdb_search_aliases(get_global_sam_sid()), + if (!search_maxrid(pdb_search_aliases(talloc_tos(), + get_global_sam_sid()), "aliases", &max_rid)) return 0; diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c index e8ebb60205..eea22c0dc2 100644 --- a/source3/utils/net_sam.c +++ b/source3/utils/net_sam.c @@ -1269,28 +1269,31 @@ static int net_sam_do_list(struct net_context *c, int argc, const char **argv, } } - pdb_search_destroy(search); + TALLOC_FREE(search); return 0; } static int net_sam_list_users(struct net_context *c, int argc, const char **argv) { - return net_sam_do_list(c, argc, argv, pdb_search_users(ACB_NORMAL), + return net_sam_do_list(c, argc, argv, + pdb_search_users(talloc_tos(), ACB_NORMAL), "users"); } static int net_sam_list_groups(struct net_context *c, int argc, const char **argv) { - return net_sam_do_list(c, argc, argv, pdb_search_groups(), "groups"); + return net_sam_do_list(c, argc, argv, pdb_search_groups(talloc_tos()), + "groups"); } static int net_sam_list_localgroups(struct net_context *c, int argc, const char **argv) { return net_sam_do_list(c, argc, argv, - pdb_search_aliases(get_global_sam_sid()), + pdb_search_aliases(talloc_tos(), + get_global_sam_sid()), "localgroups"); } @@ -1298,7 +1301,8 @@ static int net_sam_list_builtin(struct net_context *c, int argc, const char **argv) { return net_sam_do_list(c, argc, argv, - pdb_search_aliases(&global_sid_Builtin), + pdb_search_aliases(talloc_tos(), + &global_sid_Builtin), "builtin"); } @@ -1306,7 +1310,7 @@ static int net_sam_list_workstations(struct net_context *c, int argc, const char **argv) { return net_sam_do_list(c, argc, argv, - pdb_search_users(ACB_WSTRUST), + pdb_search_users(talloc_tos(), ACB_WSTRUST), "workstations"); } diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index 50cbc43d6d..a5bc0c9bd4 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -67,7 +67,7 @@ static int export_database (struct pdb_methods *in, DEBUG(3, ("export_database: username=\"%s\"\n", username ? username : "(NULL)")); - u_search = pdb_search_init(PDB_USER_SEARCH); + u_search = pdb_search_init(talloc_tos(), PDB_USER_SEARCH); if (u_search == NULL) { DEBUG(0, ("pdb_search_init failed\n")); return 1; @@ -75,7 +75,7 @@ static int export_database (struct pdb_methods *in, if (!in->search_users(in, u_search, 0)) { DEBUG(0, ("Could not start searching users\n")); - pdb_search_destroy(u_search); + TALLOC_FREE(u_search); return 1; } @@ -116,7 +116,7 @@ static int export_database (struct pdb_methods *in, fprintf(stderr, "export_database: Memory allocation " "failure!\n"); TALLOC_FREE( user ); - pdb_search_destroy(u_search); + TALLOC_FREE(u_search); return 1; } @@ -139,7 +139,7 @@ static int export_database (struct pdb_methods *in, TALLOC_FREE( user ); } - pdb_search_destroy(u_search); + TALLOC_FREE(u_search); return 0; } @@ -352,7 +352,7 @@ static int print_users_list (struct pdb_methods *in, bool verbosity, bool smbpwd struct pdb_search *u_search; struct samr_displayentry userentry; - u_search = pdb_search_init(PDB_USER_SEARCH); + u_search = pdb_search_init(talloc_tos(), PDB_USER_SEARCH); if (u_search == NULL) { DEBUG(0, ("pdb_search_init failed\n")); return 1; @@ -360,7 +360,7 @@ static int print_users_list (struct pdb_methods *in, bool verbosity, bool smbpwd if (!in->search_users(in, u_search, 0)) { DEBUG(0, ("Could not start searching users\n")); - pdb_search_destroy(u_search); + TALLOC_FREE(u_search); return 1; } @@ -391,7 +391,7 @@ static int print_users_list (struct pdb_methods *in, bool verbosity, bool smbpwd print_sam_info (sam_pwent, verbosity, smbpwdstyle); TALLOC_FREE(sam_pwent); } - pdb_search_destroy(u_search); + TALLOC_FREE(u_search); return 0; } @@ -404,7 +404,7 @@ static int fix_users_list (struct pdb_methods *in) struct pdb_search *u_search; struct samr_displayentry userentry; - u_search = pdb_search_init(PDB_USER_SEARCH); + u_search = pdb_search_init(talloc_tos(), PDB_USER_SEARCH); if (u_search == NULL) { DEBUG(0, ("pdb_search_init failed\n")); return 1; @@ -412,7 +412,7 @@ static int fix_users_list (struct pdb_methods *in) if (!in->search_users(in, u_search, 0)) { DEBUG(0, ("Could not start searching users\n")); - pdb_search_destroy(u_search); + TALLOC_FREE(u_search); return 1; } @@ -444,7 +444,7 @@ static int fix_users_list (struct pdb_methods *in) } TALLOC_FREE(sam_pwent); } - pdb_search_destroy(u_search); + TALLOC_FREE(u_search); return 0; } diff --git a/source3/winbindd/winbindd_passdb.c b/source3/winbindd/winbindd_passdb.c index d704ca0fd3..1a358b2b44 100644 --- a/source3/winbindd/winbindd_passdb.c +++ b/source3/winbindd/winbindd_passdb.c @@ -40,9 +40,9 @@ static NTSTATUS enum_groups_internal(struct winbindd_domain *domain, NTSTATUS result = NT_STATUS_UNSUCCESSFUL; if (sidtype == SID_NAME_ALIAS) { - search = pdb_search_aliases(&domain->sid); + search = pdb_search_aliases(talloc_tos(), &domain->sid); } else { - search = pdb_search_groups(); + search = pdb_search_groups(talloc_tos()); } if (search == NULL) goto done; @@ -68,7 +68,7 @@ static NTSTATUS enum_groups_internal(struct winbindd_domain *domain, result = NT_STATUS_OK; done: - pdb_search_destroy(search); + TALLOC_FREE(search); return result; } @@ -456,7 +456,7 @@ static NTSTATUS sam_query_user_list(struct winbindd_domain *domain, uint32 *num_entries, WINBIND_USERINFO **info) { - struct pdb_search *ps = pdb_search_users(ACB_NORMAL); + struct pdb_search *ps = pdb_search_users(talloc_tos(), ACB_NORMAL); struct samr_displayentry *entries = NULL; uint32 i; @@ -473,7 +473,7 @@ static NTSTATUS sam_query_user_list(struct winbindd_domain *domain, *info = TALLOC_ZERO_ARRAY(mem_ctx, WINBIND_USERINFO, *num_entries); if (!(*info)) { - pdb_search_destroy(ps); + TALLOC_FREE(ps); return NT_STATUS_NO_MEMORY; } @@ -498,7 +498,7 @@ static NTSTATUS sam_query_user_list(struct winbindd_domain *domain, DOMAIN_GROUP_RID_USERS); } - pdb_search_destroy(ps); + TALLOC_FREE(ps); return NT_STATUS_OK; } |