summaryrefslogtreecommitdiff
path: root/source3/libnet
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-06-27 15:54:01 +0200
committerGünther Deschner <gd@samba.org>2008-07-01 10:00:57 +0200
commitfc836440a5c4ad1a3a5f0de0e64b4cd83e28e3c9 (patch)
treed58647e2ad9a464413f7c00b86d1492d4d00f906 /source3/libnet
parent4aaa3a0fac09044498a6f725242f12e534e21d18 (diff)
downloadsamba-fc836440a5c4ad1a3a5f0de0e64b4cd83e28e3c9.tar.gz
samba-fc836440a5c4ad1a3a5f0de0e64b4cd83e28e3c9.tar.bz2
samba-fc836440a5c4ad1a3a5f0de0e64b4cd83e28e3c9.zip
net_vampire: keep keytab context and flush keytab only after the last query.
Guenther (This used to be commit 48efe7dbce1cde6689f94fafe2d7756f673bc050)
Diffstat (limited to 'source3/libnet')
-rw-r--r--source3/libnet/libnet_samsync_keytab.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/source3/libnet/libnet_samsync_keytab.c b/source3/libnet/libnet_samsync_keytab.c
index bfb3a58ce2..f284f08ad9 100644
--- a/source3/libnet/libnet_samsync_keytab.c
+++ b/source3/libnet/libnet_samsync_keytab.c
@@ -116,13 +116,16 @@ NTSTATUS fetch_sam_entries_keytab(TALLOC_CTX *mem_ctx,
{
NTSTATUS status = NT_STATUS_OK;
krb5_error_code ret = 0;
- struct libnet_keytab_context *keytab_ctx = NULL;
+ static struct libnet_keytab_context *keytab_ctx = NULL;
int i;
- ret = libnet_keytab_init(mem_ctx, ctx->output_filename, &keytab_ctx);
- if (ret) {
- status = krb5_to_nt_status(ret);
- goto out;
+ if (!keytab_ctx) {
+ ret = libnet_keytab_init(mem_ctx, ctx->output_filename,
+ &keytab_ctx);
+ if (ret) {
+ status = krb5_to_nt_status(ret);
+ goto out;
+ }
}
status = keytab_ad_connect(mem_ctx,
@@ -150,20 +153,22 @@ NTSTATUS fetch_sam_entries_keytab(TALLOC_CTX *mem_ctx,
}
}
- ret = libnet_keytab_add(keytab_ctx);
- if (ret) {
- status = krb5_to_nt_status(ret);
- ctx->error_message = talloc_asprintf(mem_ctx,
- "Failed to add entries to keytab %s: %s",
- keytab_ctx->keytab_name, error_message(ret));
- goto out;
- }
-
if (last_query) {
+
+ ret = libnet_keytab_add(keytab_ctx);
+ if (ret) {
+ status = krb5_to_nt_status(ret);
+ ctx->error_message = talloc_asprintf(mem_ctx,
+ "Failed to add entries to keytab %s: %s",
+ keytab_ctx->keytab_name, error_message(ret));
+ goto out;
+ }
+
ctx->result_message = talloc_asprintf(mem_ctx,
"Vampired %d accounts to keytab %s",
keytab_ctx->count,
keytab_ctx->keytab_name);
+
TALLOC_FREE(keytab_ctx);
}