1 /*
2  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 
8 /*
9  * lib/krb5/ccache/ccdefault.c
10  *
11  * Copyright 1990 by the Massachusetts Institute of Technology.
12  * All Rights Reserved.
13  *
14  * Export of this software from the United States of America may
15  *   require a specific license from the United States Government.
16  *   It is the responsibility of any person or organization contemplating
17  *   export to obtain such a license before exporting.
18  *
19  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
20  * distribute this software and its documentation for any purpose and
21  * without fee is hereby granted, provided that the above copyright
22  * notice appear in all copies and that both that copyright notice and
23  * this permission notice appear in supporting documentation, and that
24  * the name of M.I.T. not be used in advertising or publicity pertaining
25  * to distribution of the software without specific, written prior
26  * permission.  Furthermore if you modify this software you must label
27  * your software as modified software and not distribute it in such a
28  * fashion that it might be confused with the original M.I.T. software.
29  * M.I.T. makes no representations about the suitability of
30  * this software for any purpose.  It is provided "as is" without express
31  * or implied warranty.
32  *
33  *
34  * Find default credential cache
35  */
36 
37 #include <k5-int.h>
38 
39 /*
40  * Solaris Kerberos:  the following is specific to the Macintosh
41  */
42 #if defined(USE_LOGIN_LIBRARY) && defined(macintosh)
43 #include <KerberosLoginInternal.h>
44 #endif
45 
46 krb5_error_code KRB5_CALLCONV
47 krb5_cc_default(krb5_context context, krb5_ccache *ccache)
48 {
49 	krb5_error_code retval;
50 	krb5_os_context	os_ctx;
51 
52 	if (!context || context->magic != KV5M_CONTEXT)
53 		return KV5M_CONTEXT;
54 
55 	os_ctx = context->os_context;
56 
57 	return krb5_cc_resolve(context, krb5_cc_default_name(context), ccache);
58 }
59 
60 /* This is the internal function which opens the default ccache.  On platforms supporting
61    the login library's automatic popup dialog to get tickets, this function also updated the
62    library's internal view of the current principal associated with this cache.
63 
64    All krb5 and GSS functions which need to open a cache to get a tgt to obtain service tickets
65    should call this function, not krb5_cc_default() */
66 
67 krb5_error_code KRB5_CALLCONV
68 krb5int_cc_default(krb5_context context, krb5_ccache *ccache)
69 {
70 
71 	if (!context || context->magic != KV5M_CONTEXT) {
72 		return KV5M_CONTEXT;
73 	}
74 
75 /*
76  * Solaris Kerberos:  the following is specific to the Macintosh
77  */
78 #ifdef USE_LOGIN_LIBRARY
79 
80 	/* MIT14resync; not needed for Solaris Kerberos */
81 #endif
82 
83 
84     return krb5_cc_default (context, ccache);
85 }
86