2 #include "system/kerberos.h"
3 #include "auth/kerberos/kerberos.h"
5 #include "kdc/hdb-samba4.h"
6 #include "libnet/libnet.h"
8 NTSTATUS
libnet_export_keytab(struct libnet_context
*ctx
, TALLOC_CTX
*mem_ctx
, struct libnet_export_keytab
*r
)
11 struct smb_krb5_context
*smb_krb5_context
;
12 const char *from_keytab
;
14 /* Register hdb-samba4 hooks for use as a keytab */
16 struct hdb_samba4_context
*hdb_samba4_context
= talloc(mem_ctx
, struct hdb_samba4_context
);
17 if (!hdb_samba4_context
) {
18 return NT_STATUS_NO_MEMORY
;
21 hdb_samba4_context
->ev_ctx
= ctx
->event_ctx
;
22 hdb_samba4_context
->lp_ctx
= ctx
->lp_ctx
;
24 from_keytab
= talloc_asprintf(hdb_samba4_context
, "HDB:samba4&%p", hdb_samba4_context
);
26 return NT_STATUS_NO_MEMORY
;
29 ret
= smb_krb5_init_context(ctx
, ctx
->event_ctx
, ctx
->lp_ctx
, &smb_krb5_context
);
31 return NT_STATUS_NO_MEMORY
;
34 ret
= krb5_plugin_register(smb_krb5_context
->krb5_context
,
35 PLUGIN_TYPE_DATA
, "hdb",
38 return NT_STATUS_NO_MEMORY
;
41 ret
= krb5_kt_register(smb_krb5_context
->krb5_context
, &hdb_kt_ops
);
43 return NT_STATUS_NO_MEMORY
;
46 ret
= kt_copy(smb_krb5_context
->krb5_context
, from_keytab
, r
->in
.keytab_name
);
48 r
->out
.error_string
= smb_get_krb5_error_message(smb_krb5_context
->krb5_context
,
50 return NT_STATUS_UNSUCCESSFUL
;