diff options
author | Simo Sorce <idra@samba.org> | 2008-09-23 14:30:06 -0400 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2008-09-23 18:17:46 -0400 |
commit | 508527890adc7bedd47522a7dae0c96d2b2e4bae (patch) | |
tree | 77e510421ff8eb98c0a9b0836905ca2f67eaf42f /source4/wrepl_server | |
parent | d275cc762dad1985045d381ca211e92234d9d77d (diff) | |
download | samba-508527890adc7bedd47522a7dae0c96d2b2e4bae.tar.gz samba-508527890adc7bedd47522a7dae0c96d2b2e4bae.tar.bz2 samba-508527890adc7bedd47522a7dae0c96d2b2e4bae.zip |
Merge ldb_search() and ldb_search_exp_fmt() into a simgle function.
The previous ldb_search() interface made it way too easy to leak results,
and being able to use a printf-like expression turns to be really useful.
Diffstat (limited to 'source4/wrepl_server')
-rw-r--r-- | source4/wrepl_server/wrepl_in_call.c | 3 | ||||
-rw-r--r-- | source4/wrepl_server/wrepl_scavenging.c | 9 | ||||
-rw-r--r-- | source4/wrepl_server/wrepl_server.c | 15 |
3 files changed, 10 insertions, 17 deletions
diff --git a/source4/wrepl_server/wrepl_in_call.c b/source4/wrepl_server/wrepl_in_call.c index 0508c306e0..ac44b4d75d 100644 --- a/source4/wrepl_server/wrepl_in_call.c +++ b/source4/wrepl_server/wrepl_in_call.c @@ -262,9 +262,8 @@ static NTSTATUS wreplsrv_in_send_request(struct wreplsrv_in_call *call) (long long)owner_in->min_version, (long long)owner_in->max_version); NT_STATUS_HAVE_NO_MEMORY(filter); - ret = ldb_search(service->wins_db->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res); + ret = ldb_search(service->wins_db->ldb, call, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "%s", filter); if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION; - talloc_steal(call, res); DEBUG(10,("WINSREPL: filter '%s' count %d\n", filter, res->count)); if (res->count == 0) { diff --git a/source4/wrepl_server/wrepl_scavenging.c b/source4/wrepl_server/wrepl_scavenging.c index a5cd36797d..a239403e3b 100644 --- a/source4/wrepl_server/wrepl_scavenging.c +++ b/source4/wrepl_server/wrepl_scavenging.c @@ -74,9 +74,8 @@ static NTSTATUS wreplsrv_scavenging_owned_records(struct wreplsrv_service *servi "(expireTime<=%s))", owner_filter, now_timestr); NT_STATUS_HAVE_NO_MEMORY(filter); - ret = ldb_search(service->wins_db->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res); + ret = ldb_search(service->wins_db->ldb, tmp_mem, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "%s", filter); if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION; - talloc_steal(tmp_mem, res); DEBUG(10,("WINS scavenging: filter '%s' count %d\n", filter, res->count)); tombstone_extra_time = timeval_add(&service->startup_time, @@ -188,9 +187,8 @@ static NTSTATUS wreplsrv_scavenging_replica_non_active_records(struct wreplsrv_s "(!(recordState=%u))(expireTime<=%s))", owner_filter, WREPL_STATE_ACTIVE, now_timestr); NT_STATUS_HAVE_NO_MEMORY(filter); - ret = ldb_search(service->wins_db->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res); + ret = ldb_search(service->wins_db->ldb, tmp_mem, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "%s", filter); if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION; - talloc_steal(tmp_mem, res); DEBUG(10,("WINS scavenging: filter '%s' count %d\n", filter, res->count)); tombstone_extra_time = timeval_add(&service->startup_time, @@ -404,9 +402,8 @@ static NTSTATUS wreplsrv_scavenging_replica_active_records(struct wreplsrv_servi "(recordState=%u)(expireTime<=%s))", owner_filter, WREPL_STATE_ACTIVE, now_timestr); NT_STATUS_HAVE_NO_MEMORY(filter); - ret = ldb_search(service->wins_db->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res); + ret = ldb_search(service->wins_db->ldb, tmp_mem, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "%s", filter); if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION; - talloc_steal(tmp_mem, res); DEBUG(10,("WINS scavenging: filter '%s' count %d\n", filter, res->count)); for (i=0; i < res->count; i++) { diff --git a/source4/wrepl_server/wrepl_server.c b/source4/wrepl_server/wrepl_server.c index b703066986..48a68e4432 100644 --- a/source4/wrepl_server/wrepl_server.c +++ b/source4/wrepl_server/wrepl_server.c @@ -55,10 +55,8 @@ static uint64_t wins_config_db_get_seqnumber(struct ldb_context *ldb) if (!dn) goto failed; /* find the record in the WINS database */ - ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, - NULL, NULL, &res); + ret = ldb_search(ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE, NULL, NULL); if (ret != LDB_SUCCESS) goto failed; - talloc_steal(tmp_ctx, res); if (res->count > 1) goto failed; if (res->count == 1) { @@ -157,10 +155,10 @@ NTSTATUS wreplsrv_load_partners(struct wreplsrv_service *service) service->config.seqnumber = new_seqnumber; /* find the record in the WINS database */ - ret = ldb_search(service->config.ldb, ldb_dn_new(tmp_ctx, service->config.ldb, "CN=PARTNERS"), LDB_SCOPE_SUBTREE, - "(objectClass=wreplPartner)", NULL, &res); + ret = ldb_search(service->config.ldb, tmp_ctx, &res, + ldb_dn_new(tmp_ctx, service->config.ldb, "CN=PARTNERS"), + LDB_SCOPE_SUBTREE, NULL, "(objectClass=wreplPartner)"); if (ret != LDB_SUCCESS) goto failed; - talloc_steal(tmp_ctx, res); /* first disable all existing partners */ for (partner=service->partners; partner; partner = partner->next) { @@ -391,11 +389,10 @@ static NTSTATUS wreplsrv_load_table(struct wreplsrv_service *service) } /* find the record in the WINS database */ - ret = ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, - "(objectClass=winsRecord)", attrs, &res); + ret = ldb_search(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + attrs, "(objectClass=winsRecord)"); status = NT_STATUS_INTERNAL_DB_CORRUPTION; if (ret != LDB_SUCCESS) goto failed; - talloc_steal(tmp_ctx, res); for (i=0; i < res->count; i++) { wins_owner = ldb_msg_find_attr_as_string(res->msgs[i], "winsOwner", NULL); |