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 /source3/utils | |
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
Diffstat (limited to 'source3/utils')
-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 |
3 files changed, 25 insertions, 20 deletions
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; } |