xref: /titanic_41/usr/src/lib/smbsrv/libsmbns/common/smbns_krb.h (revision 0f1702c5201310f0529cd5abb77652e5e9b241b6)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SMBSRV_SMB_KRB5_H
27 #define	_SMBSRV_SMB_KRB5_H
28 
29 #include <gssapi/gssapi.h>
30 #include <kerberosv5/krb5.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #define	SMBNS_KRB5_KEYTAB	"/etc/krb5/krb5.keytab"
37 #define	SMBNS_KRB5_KEYTAB_TMP	"/etc/krb5/krb5.keytab.tmp.XXXXXX"
38 
39 /* core set of SPNs */
40 typedef enum smb_krb5_spn_idx {
41 	SMBKRB5_SPN_IDX_HOST = 0,
42 	SMBKRB5_SPN_IDX_NFS,
43 	SMBKRB5_SPN_IDX_HTTP,
44 	SMBKRB5_SPN_IDX_ROOT,
45 	SMBKRB5_SPN_IDX_MAX
46 } smb_krb5_spn_idx_t;
47 
48 extern gss_OID gss_nt_user_name;
49 extern gss_OID gss_nt_machine_uid_name;
50 extern gss_OID gss_nt_string_uid_name;
51 extern gss_OID gss_nt_service_name;
52 extern gss_OID gss_nt_exported_name;
53 extern gss_OID gss_nt_service_name_v2;
54 
55 int krb5_acquire_cred_kinit(char *, char *, gss_cred_id_t *,
56     gss_OID *, int *, char *);
57 int krb5_establish_sec_ctx_kinit(char *, char *, gss_cred_id_t,
58     gss_ctx_id_t *, gss_name_t, gss_OID, int, gss_buffer_desc *,
59     gss_buffer_desc *, OM_uint32 *, OM_uint32 *, int *,
60     int *, OM_uint32 *, char *);
61 char *smb_krb5_get_spn(smb_krb5_spn_idx_t idx, char *fqhost);
62 char *smb_krb5_get_upn(char *spn, char *domain);
63 int smb_krb5_ctx_init(krb5_context *ctx);
64 void smb_krb5_ctx_fini(krb5_context ctx);
65 int smb_krb5_get_principals(char *domain, krb5_context ctx,
66     krb5_principal *krb5princs);
67 void smb_krb5_free_principals(krb5_context ctx, krb5_principal *krb5princs,
68     size_t num);
69 int smb_krb5_setpwd(krb5_context ctx, krb5_principal princ, char *passwd);
70 int smb_krb5_add_keytab_entries(krb5_context ctx, krb5_principal *princs,
71     char *fname, krb5_kvno kvno, char *passwd, krb5_enctype *enctypes,
72     int enctype_count);
73 boolean_t smb_krb5_find_keytab_entries(const char *fqhn, char *fname);
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif /* _SMBSRV_SMB_KRB5_H */
80