4b2da6bb90f3d2d5e45d2602f16f7af616013fe9
[nfs-utils.git] / utils / gssd / krb5_util.h
1 #ifndef KRB5_UTIL_H
2 #define KRB5_UTIL_H
3
4 #include <krb5.h>
5
6 /*
7  * List of principals from our keytab that we
8  * will try to use to obtain credentials
9  * (known as a principal list entry (ple))
10  */
11 struct gssd_k5_kt_princ {
12         struct gssd_k5_kt_princ *next;
13         krb5_principal princ;
14         char *ccname;
15         char *realm;
16         krb5_timestamp endtime;
17 };
18
19
20 int gssd_setup_krb5_user_gss_ccache(uid_t uid, char *servername,
21                                      char *dirname);
22 int  gssd_get_krb5_machine_cred_list(char ***list);
23 void gssd_free_krb5_machine_cred_list(char **list);
24 void gssd_setup_krb5_machine_gss_ccache(char *servername);
25 void gssd_destroy_krb5_machine_creds(void);
26 int  gssd_refresh_krb5_machine_credential(char *hostname,
27                                           struct gssd_k5_kt_princ *ple);
28 const char *
29 gssd_k5_err_msg(krb5_context context, krb5_error_code code);
30 void gssd_k5_get_default_realm(char **def_realm);
31
32 #ifdef HAVE_SET_ALLOWABLE_ENCTYPES
33 int limit_krb5_enctypes(struct rpc_gss_sec *sec, uid_t uid);
34 #endif
35
36 /*
37  * Hide away some of the MIT vs. Heimdal differences
38  * here with macros...
39  */
40
41 #ifdef HAVE_KRB5
42 #define k5_free_unparsed_name(ctx, name)        krb5_free_unparsed_name((ctx), (name))
43 #define k5_free_default_realm(ctx, realm)       krb5_free_default_realm((ctx), (realm))
44 #define k5_free_kt_entry(ctx, kte)              krb5_free_keytab_entry_contents((ctx),(kte))
45 #else   /* Heimdal */
46 #define k5_free_unparsed_name(ctx, name)        free(name)
47 #define k5_free_default_realm(ctx, realm)       free(realm)
48 #define k5_free_kt_entry(ctx, kte)              krb5_kt_free_entry((ctx),(kte))
49 #undef USE_GSS_KRB5_CCACHE_NAME
50 #define USE_GSS_KRB5_CCACHE_NAME 1
51 #endif
52
53 #endif /* KRB5_UTIL_H */