xref: /titanic_41/usr/src/lib/smbsrv/libsmbns/common/smbns_krb.h (revision a18dc42fc967d11feba9b8be61c6727dc6c56b48)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <gssapi/gssapi.h>
32 #include <kerberosv5/krb5.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #define	SMBNS_KRB5_KEYTAB "/etc/krb5/krb5.keytab"
39 
40 /* core set of SPNs */
41 typedef enum smb_krb5_spn_idx {
42 	SMBKRB5_SPN_IDX_HOST = 0,
43 	SMBKRB5_SPN_IDX_NFS,
44 	SMBKRB5_SPN_IDX_HTTP,
45 	SMBKRB5_SPN_IDX_ROOT,
46 	SMBKRB5_SPN_IDX_MAX
47 } smb_krb5_spn_idx_t;
48 
49 extern gss_OID gss_nt_user_name;
50 extern gss_OID gss_nt_machine_uid_name;
51 extern gss_OID gss_nt_string_uid_name;
52 extern gss_OID gss_nt_service_name;
53 extern gss_OID gss_nt_exported_name;
54 extern gss_OID gss_nt_service_name_v2;
55 
56 int krb5_acquire_cred_kinit(char *, char *, gss_cred_id_t *,
57     gss_OID *, int *, char *);
58 int krb5_establish_sec_ctx_kinit(char *, char *, gss_cred_id_t,
59     gss_ctx_id_t *, gss_name_t, gss_OID, int, gss_buffer_desc *,
60     gss_buffer_desc *, OM_uint32 *, OM_uint32 *, int *,
61     int *, OM_uint32 *, char *);
62 char *smb_krb5_get_spn(smb_krb5_spn_idx_t idx, char *fqhost);
63 char *smb_krb5_get_upn(char *spn, char *domain);
64 int smb_krb5_ctx_init(krb5_context *ctx);
65 void smb_krb5_ctx_fini(krb5_context ctx);
66 int smb_krb5_get_principals(char *domain, krb5_context ctx,
67     krb5_principal *krb5princs);
68 void smb_krb5_free_principals(krb5_context ctx, krb5_principal *krb5princs,
69     size_t num);
70 int smb_krb5_setpwd(krb5_context ctx, krb5_principal princ, char *passwd);
71 int smb_krb5_remove_keytab_entries(krb5_context ctx, krb5_principal *princs,
72     char *fname);
73 int smb_krb5_update_keytab_entries(krb5_context ctx, krb5_principal *princs,
74     char *fname, krb5_kvno kvno, char *passwd, krb5_enctype *enctypes,
75     int enctype_count);
76 boolean_t smb_krb5_find_keytab_entries(const char *fqhn, char *fname);
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif /* _SMBSRV_SMB_KRB5_H */
83