2 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
8 * lib/krb5/os/ktdefname.c
10 * Copyright 1990 by the Massachusetts Institute of Technology.
11 * All Rights Reserved.
13 * Export of this software from the United States of America may
14 * require a specific license from the United States Government.
15 * It is the responsibility of any person or organization contemplating
16 * export to obtain such a license before exporting.
18 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
19 * distribute this software and its documentation for any purpose and
20 * without fee is hereby granted, provided that the above copyright
21 * notice appear in all copies and that both that copyright notice and
22 * this permission notice appear in supporting documentation, and that
23 * the name of M.I.T. not be used in advertising or publicity pertaining
24 * to distribution of the software without specific, written prior
25 * permission. Furthermore if you modify this software you must label
26 * your software as modified software and not distribute it in such a
27 * fashion that it might be confused with the original M.I.T. software.
28 * M.I.T. makes no representations about the suitability of
29 * this software for any purpose. It is provided "as is" without express
30 * or implied warranty.
33 * Return default keytab file name.
40 extern char *krb5_defkeyname
;
42 /* this is a an exceedinly gross thing. */
43 char *krb5_overridekeyname
= NULL
;
45 krb5_error_code KRB5_CALLCONV
46 krb5_kt_default_name(krb5_context context
, char *name
, int namesize
)
51 if (krb5_overridekeyname
) {
52 if ((size_t) namesize
< (strlen(krb5_overridekeyname
)+1))
53 return KRB5_CONFIG_NOTENUFSPACE
;
54 /* Solaris Kerberos */
55 strncpy(name
, krb5_overridekeyname
, namesize
);
56 } else if ((context
->profile_secure
== FALSE
) &&
57 (cp
= getenv("KRB5_KTNAME"))) {
58 if ((size_t) namesize
< (strlen(cp
)+1))
59 return KRB5_CONFIG_NOTENUFSPACE
;
60 /* Solaris Kerberos */
61 strncpy(name
, cp
, namesize
);
62 } else if ((profile_get_string(context
->profile
,
64 "default_keytab_name", NULL
,
65 NULL
, &retval
) == 0) &&
67 if ((size_t) namesize
< (strlen(retval
)+1))
68 return KRB5_CONFIG_NOTENUFSPACE
;
69 /* Solaris Kerberos */
70 strncpy(name
, retval
, namesize
);
71 profile_release_string(retval
);
78 len
= GetWindowsDirectory( defname
, sizeof(defname
)-2 );
80 if ( (len
+ strlen(krb5_defkeyname
) + 1) > namesize
)
81 return KRB5_CONFIG_NOTENUFSPACE
;
82 sprintf(name
, krb5_defkeyname
, defname
);
85 if ((size_t) namesize
< (strlen(krb5_defkeyname
)+1))
86 return KRB5_CONFIG_NOTENUFSPACE
;
87 /* Solaris Kerberos */
88 strncpy(name
, krb5_defkeyname
, namesize
);