xref: /titanic_41/usr/src/lib/smbsrv/libsmbns/common/smbns_krb.h (revision dc25fd745d311a1cf9d98d7b7897caa0877adff0)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SMBSRV_SMB_KRB_H
27 #define	_SMBSRV_SMB_KRB_H
28 
29 #include <kerberosv5/krb5.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #define	SMBNS_KRB5_KEYTAB	"/etc/krb5/krb5.keytab"
36 #define	SMBNS_KRB5_KEYTAB_TMP	"/etc/krb5/krb5.keytab.tmp.XXXXXX"
37 
38 /* core set of SPNs */
39 typedef enum smb_krb5_spn_idx {
40 	SMBKRB5_SPN_IDX_HOST = 0,
41 	SMBKRB5_SPN_IDX_NFS,
42 	SMBKRB5_SPN_IDX_HTTP,
43 	SMBKRB5_SPN_IDX_ROOT,
44 	SMBKRB5_SPN_IDX_MAX
45 } smb_krb5_spn_idx_t;
46 
47 int smb_kinit(char *, char *);
48 char *smb_krb5_get_spn(smb_krb5_spn_idx_t idx, char *fqhost);
49 char *smb_krb5_get_upn(char *spn, char *domain);
50 int smb_krb5_ctx_init(krb5_context *ctx);
51 void smb_krb5_ctx_fini(krb5_context ctx);
52 int smb_krb5_get_principals(char *domain, krb5_context ctx,
53     krb5_principal *krb5princs);
54 void smb_krb5_free_principals(krb5_context ctx, krb5_principal *krb5princs,
55     size_t num);
56 int smb_krb5_setpwd(krb5_context ctx, krb5_principal princ, char *passwd);
57 int smb_krb5_add_keytab_entries(krb5_context ctx, krb5_principal *princs,
58     char *fname, krb5_kvno kvno, char *passwd, krb5_enctype *enctypes,
59     int enctype_count);
60 boolean_t smb_krb5_find_keytab_entries(const char *fqhn, char *fname);
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 
66 #endif /* _SMBSRV_SMB_KRB_H */
67