diff options
author | Andrew Bartlett <abartlet@samba.org> | 2008-04-11 19:15:24 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2008-04-11 19:15:24 +1000 |
commit | a1a3089199d9ad523e63148a5a2afcca8db39bdf (patch) | |
tree | 1aef2b967bff0df2db08308e4decc382e58aeb24 /source4 | |
parent | 393007315d56d72cd4ebccc204da703b27eb968b (diff) | |
download | samba-a1a3089199d9ad523e63148a5a2afcca8db39bdf.tar.gz samba-a1a3089199d9ad523e63148a5a2afcca8db39bdf.tar.bz2 samba-a1a3089199d9ad523e63148a5a2afcca8db39bdf.zip |
Use the python-provided ldb and lp_ctx pointers in libnet_vampire.c
By using the already open smb.conf and sam.ldb, we not only avoid
overhead, but also remove the risk we could touch a different
database.
Andrew Bartlett
(This used to be commit 38634183a074556c8dfdcb6affc60f4bcc15a3f0)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/libnet/libnet_vampire.c | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/source4/libnet/libnet_vampire.c b/source4/libnet/libnet_vampire.c index 476b97954f..9d32088fe6 100644 --- a/source4/libnet/libnet_vampire.c +++ b/source4/libnet/libnet_vampire.c @@ -77,14 +77,8 @@ static NTSTATUS vampire_prepare_db(void *private_data, { struct vampire_state *s = talloc_get_type(private_data, struct vampire_state); struct provision_settings settings; + struct provision_result result; NTSTATUS status; - bool ok; - struct loadparm_context *lp_ctx = loadparm_init(s); - char *smbconf; - - if (!lp_ctx) { - return NT_STATUS_NO_MEMORY; - } settings.site_name = p->dest_dsa->site_name; settings.root_dn_str = p->forest->root_dn_str; @@ -98,31 +92,14 @@ static NTSTATUS vampire_prepare_db(void *private_data, settings.machine_password = generate_random_str(s, 16); settings.targetdir = s->targetdir; - status = provision_bare(s, s->lp_ctx, &settings); - - smbconf = talloc_asprintf(lp_ctx, "%s/%s", s->targetdir, "/etc/smb.conf"); + status = provision_bare(s, s->lp_ctx, &settings, &result); - ok = lp_load(lp_ctx, smbconf); - if (!ok) { - DEBUG(0,("Failed load freshly generated smb.conf '%s'\n", smbconf)); - return NT_STATUS_INVALID_PARAMETER; + if (!NT_STATUS_IS_OK(status)) { + return status; } - s->ldb = samdb_connect(s, lp_ctx, - system_session(s, lp_ctx)); - if (!s->ldb) { - DEBUG(0,("Failed to open '%s'\n", lp_sam_url(lp_ctx))); - return NT_STATUS_INTERNAL_DB_ERROR; - } - - /* We must set these up to ensure the replMetaData is written correctly, - before our NTDS Settings entry is replicated */ - ok = samdb_set_ntds_invocation_id(s->ldb, &p->dest_dsa->invocation_id); - if (!ok) { - DEBUG(0,("Failed to set cached ntds invocationId\n")); - return NT_STATUS_FOOBAR; - } - s->lp_ctx = lp_ctx; + s->ldb = result.samdb; + s->lp_ctx = result.lp_ctx; return NT_STATUS_OK; |