diff options
author | Michael Adam <obnox@samba.org> | 2008-07-16 23:08:40 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2008-08-01 16:04:39 +0200 |
commit | 2473888daa3a732fdb7ae69729ab7e3490ffac64 (patch) | |
tree | d67c9e6451d59b150a21685b8b276d050b3f3903 | |
parent | 16c2190b149a2232aa49a16a41e570410edd2eaf (diff) | |
download | samba-2473888daa3a732fdb7ae69729ab7e3490ffac64.tar.gz samba-2473888daa3a732fdb7ae69729ab7e3490ffac64.tar.bz2 samba-2473888daa3a732fdb7ae69729ab7e3490ffac64.zip |
dssync keytab: refactor adding entry to keytab_context out into new function
add_to_keytab_entries()
Michael
(This used to be commit 79151db6eae234a1f9e5131b7776689a4f03a0ef)
-rw-r--r-- | source3/libnet/libnet_dssync_keytab.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/source3/libnet/libnet_dssync_keytab.c b/source3/libnet/libnet_dssync_keytab.c index d59efe74fb..c502211b45 100644 --- a/source3/libnet/libnet_dssync_keytab.c +++ b/source3/libnet/libnet_dssync_keytab.c @@ -22,6 +22,29 @@ #if defined(HAVE_ADS) && defined(ENCTYPE_ARCFOUR_HMAC) +static NTSTATUS add_to_keytab_entries(TALLOC_CTX *mem_ctx, + struct libnet_keytab_context *ctx, + uint32_t kvno, + const char *name, + DATA_BLOB blob) +{ + struct libnet_keytab_entry entry; + + entry.kvno = kvno; + entry.name = talloc_strdup(mem_ctx, name); + entry.principal = talloc_asprintf(mem_ctx, "%s@%s", + name, ctx->dns_domain_name); + entry.password = blob; + NT_STATUS_HAVE_NO_MEMORY(entry.name); + NT_STATUS_HAVE_NO_MEMORY(entry.principal); + NT_STATUS_HAVE_NO_MEMORY(entry.password.data); + + ADD_TO_ARRAY(mem_ctx, struct libnet_keytab_entry, entry, + &ctx->entries, &ctx->count); + + return NT_STATUS_OK; +} + static NTSTATUS keytab_startup(struct dssync_context *ctx, TALLOC_CTX *mem_ctx) { krb5_error_code ret = 0; @@ -166,17 +189,12 @@ static NTSTATUS parse_object(TALLOC_CTX *mem_ctx, } DEBUGADD(1,("\n")); - entry.kvno = kvno; - entry.name = talloc_strdup(mem_ctx, name); - entry.principal = talloc_asprintf(mem_ctx, "%s@%s", - name, ctx->dns_domain_name); - entry.password = data_blob_talloc(mem_ctx, nt_passwd, 16); - NT_STATUS_HAVE_NO_MEMORY(entry.name); - NT_STATUS_HAVE_NO_MEMORY(entry.principal); - NT_STATUS_HAVE_NO_MEMORY(entry.password.data); + status = add_to_keytab_entries(mem_ctx, ctx, kvno, name, + data_blob_talloc(mem_ctx, nt_passwd, 16)); - ADD_TO_ARRAY(mem_ctx, struct libnet_keytab_entry, entry, - &ctx->entries, &ctx->count); + if (!NT_STATUS_IS_OK(status)) { + return status; + } if ((kvno < 0) && (kvno < pwd_history_len)) { return status; |