diff options
author | Andrew Bartlett <abartlet@samba.org> | 2009-07-27 22:04:26 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2009-07-27 22:41:42 +1000 |
commit | a40ce5d0d9d06f592a8885162bbaf644006b9f0f (patch) | |
tree | 27a367040a91d1cd6605db042acda7e45c1ca2cb /source4/libnet/libnet_export_keytab.c | |
parent | 56f4516399431cc508ca0c3e0dd7f179cc7ab62c (diff) | |
download | samba-a40ce5d0d9d06f592a8885162bbaf644006b9f0f.tar.gz samba-a40ce5d0d9d06f592a8885162bbaf644006b9f0f.tar.bz2 samba-a40ce5d0d9d06f592a8885162bbaf644006b9f0f.zip |
s4:kerberos Add 'net export keytab' command for wireshark decryption
It is much easier to do decryption with wireshark when the keytab is
available for every host in the domain. Running 'net export keytab
<keytab name>' will export the current (as pointed to by the supplied
smb.conf) local Samba4 doamin.
(This uses Heimdal's 'hdb' keytab and then the existing hdb-samba4,
and so has a good chance of keeping working in the long term).
Andrew Bartlett
Diffstat (limited to 'source4/libnet/libnet_export_keytab.c')
-rw-r--r-- | source4/libnet/libnet_export_keytab.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/source4/libnet/libnet_export_keytab.c b/source4/libnet/libnet_export_keytab.c new file mode 100644 index 0000000000..43fd0aa30e --- /dev/null +++ b/source4/libnet/libnet_export_keytab.c @@ -0,0 +1,54 @@ +#include "includes.h" +#include "system/kerberos.h" +#include "auth/kerberos/kerberos.h" +#include <hdb.h> +#include "kdc/hdb-samba4.h" +#include "auth/kerberos/keytab_copy.h" +#include "libnet/libnet.h" + +NTSTATUS libnet_export_keytab(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct libnet_export_keytab *r) +{ + krb5_error_code ret; + struct smb_krb5_context *smb_krb5_context; + const char *from_keytab; + + /* Register hdb-samba4 hooks for use as a keytab */ + + struct hdb_samba4_context *hdb_samba4_context = talloc(mem_ctx, struct hdb_samba4_context); + if (!hdb_samba4_context) { + return NT_STATUS_NO_MEMORY; + } + + hdb_samba4_context->ev_ctx = ctx->event_ctx; + hdb_samba4_context->lp_ctx = ctx->lp_ctx; + + from_keytab = talloc_asprintf(hdb_samba4_context, "HDB:samba4&%p", hdb_samba4_context); + if (!from_keytab) { + return NT_STATUS_NO_MEMORY; + } + + ret = smb_krb5_init_context(ctx, ctx->event_ctx, ctx->lp_ctx, &smb_krb5_context); + if (ret) { + return NT_STATUS_NO_MEMORY; + } + + ret = krb5_plugin_register(smb_krb5_context->krb5_context, + PLUGIN_TYPE_DATA, "hdb", + &hdb_samba4); + if(ret) { + return NT_STATUS_NO_MEMORY; + } + + ret = krb5_kt_register(smb_krb5_context->krb5_context, &hdb_kt_ops); + if(ret) { + return NT_STATUS_NO_MEMORY; + } + + ret = kt_copy(smb_krb5_context->krb5_context, from_keytab, r->in.keytab_name); + if(ret) { + r->out.error_string = smb_get_krb5_error_message(smb_krb5_context->krb5_context, + ret, mem_ctx); + return NT_STATUS_UNSUCCESSFUL; + } + return NT_STATUS_OK; +} |