2 #include "system/kerberos.h"
3 #include "auth/kerberos/kerberos.h"
5 #include "kdc/samba_kdc.h"
6 #include "libnet/libnet.h"
8 extern struct hdb_method hdb_samba4
;
10 NTSTATUS
libnet_export_keytab(struct libnet_context
*ctx
, TALLOC_CTX
*mem_ctx
, struct libnet_export_keytab
*r
)
13 struct smb_krb5_context
*smb_krb5_context
;
14 const char *from_keytab
;
16 /* Register hdb-samba4 hooks for use as a keytab */
18 struct samba_kdc_base_context
*base_ctx
= talloc_zero(mem_ctx
, struct samba_kdc_base_context
);
20 return NT_STATUS_NO_MEMORY
;
23 base_ctx
->ev_ctx
= ctx
->event_ctx
;
24 base_ctx
->lp_ctx
= ctx
->lp_ctx
;
26 from_keytab
= talloc_asprintf(base_ctx
, "HDB:samba4&%p", base_ctx
);
28 return NT_STATUS_NO_MEMORY
;
31 ret
= smb_krb5_init_context(ctx
, ctx
->event_ctx
, ctx
->lp_ctx
, &smb_krb5_context
);
33 return NT_STATUS_NO_MEMORY
;
36 ret
= krb5_plugin_register(smb_krb5_context
->krb5_context
,
37 PLUGIN_TYPE_DATA
, "hdb",
40 return NT_STATUS_NO_MEMORY
;
43 ret
= krb5_kt_register(smb_krb5_context
->krb5_context
, &hdb_kt_ops
);
45 return NT_STATUS_NO_MEMORY
;
48 unlink(r
->in
.keytab_name
);
50 ret
= kt_copy(smb_krb5_context
->krb5_context
, from_keytab
, r
->in
.keytab_name
);
52 r
->out
.error_string
= smb_get_krb5_error_message(smb_krb5_context
->krb5_context
,
54 return NT_STATUS_UNSUCCESSFUL
;