2 * Copyright (c) 1997 - 2005 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include "krb5_locl.h"
37 __RCSID("$Heimdal: context.c 22293 2007-12-14 05:25:59Z lha $"
38 "$NetBSD: context.c,v 1.13 2008/03/22 08:37:13 mlelstv Exp $");
40 #define INIT_FIELD(C, T, E, D, F) \
41 (C)->E = krb5_config_get_ ## T ## _default ((C), NULL, (D), \
42 "libdefaults", F, NULL)
44 #define INIT_FLAG(C, O, V, D, F) \
46 if (krb5_config_get_bool_default((C), NULL, (D),"libdefaults", F, NULL)) { \
52 * Set the list of etypes `ret_etypes' from the configuration variable
56 static krb5_error_code
57 set_etypes (krb5_context context
,
59 krb5_enctype
**ret_enctypes
)
62 krb5_enctype
*etypes
= NULL
;
64 etypes_str
= krb5_config_get_strings(context
, NULL
, "libdefaults",
68 for(i
= 0; etypes_str
[i
]; i
++);
69 etypes
= malloc((i
+1) * sizeof(*etypes
));
71 krb5_config_free_strings (etypes_str
);
72 krb5_set_error_string (context
, "malloc: out of memory");
75 for(j
= 0, k
= 0; j
< i
; j
++) {
77 if(krb5_string_to_enctype(context
, etypes_str
[j
], &e
) != 0)
79 if (krb5_enctype_valid(context
, e
) != 0)
83 etypes
[k
] = ETYPE_NULL
;
84 krb5_config_free_strings(etypes_str
);
86 *ret_enctypes
= etypes
;
91 * read variables from the configuration file and set in `context'
94 static krb5_error_code
95 init_context_from_config_file(krb5_context context
)
99 krb5_enctype
*tmptypes
;
101 INIT_FIELD(context
, time
, max_skew
, 5 * 60, "clockskew");
102 INIT_FIELD(context
, time
, kdc_timeout
, 3, "kdc_timeout");
103 INIT_FIELD(context
, int, max_retries
, 3, "max_retries");
105 INIT_FIELD(context
, string
, http_proxy
, NULL
, "http_proxy");
107 ret
= set_etypes (context
, "default_etypes", &tmptypes
);
110 free(context
->etypes
);
111 context
->etypes
= tmptypes
;
113 ret
= set_etypes (context
, "default_etypes_des", &tmptypes
);
116 free(context
->etypes_des
);
117 context
->etypes_des
= tmptypes
;
119 /* default keytab name */
122 tmp
= getenv("KRB5_KTNAME");
124 context
->default_keytab
= tmp
;
126 INIT_FIELD(context
, string
, default_keytab
,
127 KEYTAB_DEFAULT
, "default_keytab_name");
129 INIT_FIELD(context
, string
, default_keytab_modify
,
130 NULL
, "default_keytab_modify_name");
132 INIT_FIELD(context
, string
, time_fmt
,
133 "%Y-%m-%dT%H:%M:%S", "time_format");
135 INIT_FIELD(context
, string
, date_fmt
,
136 "%Y-%m-%d", "date_format");
138 INIT_FIELD(context
, bool, log_utc
,
143 /* init dns-proxy slime */
144 tmp
= krb5_config_get_string(context
, NULL
, "libdefaults",
147 roken_gethostby_setup(context
->http_proxy
, tmp
);
148 krb5_free_host_realm (context
, context
->default_realms
);
149 context
->default_realms
= NULL
;
152 krb5_addresses addresses
;
155 krb5_set_extra_addresses(context
, NULL
);
156 adr
= krb5_config_get_strings(context
, NULL
,
160 memset(&addresses
, 0, sizeof(addresses
));
161 for(a
= adr
; a
&& *a
; a
++) {
162 ret
= krb5_parse_address(context
, *a
, &addresses
);
164 krb5_add_extra_addresses(context
, &addresses
);
165 krb5_free_addresses(context
, &addresses
);
168 krb5_config_free_strings(adr
);
170 krb5_set_ignore_addresses(context
, NULL
);
171 adr
= krb5_config_get_strings(context
, NULL
,
175 memset(&addresses
, 0, sizeof(addresses
));
176 for(a
= adr
; a
&& *a
; a
++) {
177 ret
= krb5_parse_address(context
, *a
, &addresses
);
179 krb5_add_ignore_addresses(context
, &addresses
);
180 krb5_free_addresses(context
, &addresses
);
183 krb5_config_free_strings(adr
);
186 INIT_FIELD(context
, bool, scan_interfaces
, TRUE
, "scan_interfaces");
187 INIT_FIELD(context
, int, fcache_vno
, 0, "fcache_version");
188 /* prefer dns_lookup_kdc over srv_lookup. */
189 INIT_FIELD(context
, bool, srv_lookup
, TRUE
, "srv_lookup");
190 INIT_FIELD(context
, bool, srv_lookup
, context
->srv_lookup
, "dns_lookup_kdc");
191 INIT_FIELD(context
, int, large_msg_size
, 1400, "large_message_size");
192 INIT_FLAG(context
, flags
, KRB5_CTX_F_DNS_CANONICALIZE_HOSTNAME
, TRUE
, "dns_canonicalize_hostname");
193 INIT_FLAG(context
, flags
, KRB5_CTX_F_CHECK_PAC
, TRUE
, "check_pac");
194 context
->default_cc_name
= NULL
;
195 context
->default_cc_name_set
= 0;
200 * Initializes the context structure and reads the configuration file
201 * /etc/krb5.conf. The structure should be freed by calling
202 * krb5_free_context() when it is no longer being used.
204 * @param context pointer to returned context
206 * @return Returns 0 to indicate success. Otherwise an errno code is
207 * returned. Failure means either that something bad happened during
208 * initialization (typically ENOMEM) or that Kerberos should not be
214 krb5_error_code KRB5_LIB_FUNCTION
215 krb5_init_context(krb5_context
*context
)
223 p
= calloc(1, sizeof(*p
));
227 p
->mutex
= malloc(sizeof(HEIMDAL_MUTEX
));
228 if (p
->mutex
== NULL
) {
232 HEIMDAL_MUTEX_init(p
->mutex
);
234 ret
= krb5_get_default_config_files(&files
);
237 ret
= krb5_set_config_files(p
, files
);
238 krb5_free_config_files(files
);
242 /* init error tables */
247 krb5_cc_register(p
, &krb5_acc_ops
, TRUE
);
248 krb5_cc_register(p
, &krb5_fcc_ops
, TRUE
);
249 krb5_cc_register(p
, &krb5_mcc_ops
, TRUE
);
251 krb5_cc_register(p
, &krb5_kcm_ops
, TRUE
);
256 krb5_kt_register (p
, &krb5_fkt_ops
);
257 krb5_kt_register (p
, &krb5_wrfkt_ops
);
258 krb5_kt_register (p
, &krb5_javakt_ops
);
259 krb5_kt_register (p
, &krb5_mkt_ops
);
260 krb5_kt_register (p
, &krb5_akf_ops
);
261 krb5_kt_register (p
, &krb4_fkt_ops
);
262 krb5_kt_register (p
, &krb5_srvtab_fkt_ops
);
263 krb5_kt_register (p
, &krb5_any_ops
);
267 krb5_free_context(p
);
275 * Frees the krb5_context allocated by krb5_init_context().
277 * @param context context to be freed.
282 void KRB5_LIB_FUNCTION
283 krb5_free_context(krb5_context context
)
285 if (context
->default_cc_name
)
286 free(context
->default_cc_name
);
287 if (context
->default_cc_name_env
)
288 free(context
->default_cc_name_env
);
289 free(context
->etypes
);
290 free(context
->etypes_des
);
291 krb5_free_host_realm (context
, context
->default_realms
);
292 krb5_config_file_free (context
, context
->cf
);
293 free_error_table (context
->et_list
);
294 free(context
->cc_ops
);
295 free(context
->kt_types
);
296 krb5_clear_error_string(context
);
297 if(context
->warn_dest
!= NULL
)
298 krb5_closelog(context
, context
->warn_dest
);
299 krb5_set_extra_addresses(context
, NULL
);
300 krb5_set_ignore_addresses(context
, NULL
);
301 krb5_set_send_to_kdc_func(context
, NULL
, NULL
);
302 if (context
->mutex
!= NULL
) {
303 HEIMDAL_MUTEX_destroy(context
->mutex
);
304 free(context
->mutex
);
306 memset(context
, 0, sizeof(*context
));
311 * Reinit the context from a new set of filenames.
313 * @param context context to add configuration too.
314 * @param filenames array of filenames, end of list is indicated with a NULL filename.
316 * @return Returns 0 to indicate success. Otherwise an kerberos et
317 * error code is returned, see krb5_get_error_message().
322 krb5_error_code KRB5_LIB_FUNCTION
323 krb5_set_config_files(krb5_context context
, char **filenames
)
326 krb5_config_binding
*tmp
= NULL
;
327 while(filenames
!= NULL
&& *filenames
!= NULL
&& **filenames
!= '\0') {
328 ret
= krb5_config_parse_file_multi(context
, *filenames
, &tmp
);
329 if(ret
!= 0 && ret
!= ENOENT
&& ret
!= EACCES
) {
330 krb5_config_file_free(context
, tmp
);
336 /* with this enabled and if there are no config files, Kerberos is
337 considererd disabled */
341 krb5_config_file_free(context
, context
->cf
);
343 ret
= init_context_from_config_file(context
);
347 static krb5_error_code
348 add_file(char ***pfilenames
, int *len
, char *file
)
350 char **pp
= *pfilenames
;
353 for(i
= 0; i
< *len
; i
++) {
354 if(strcmp(pp
[i
], file
) == 0) {
360 pp
= realloc(*pfilenames
, (*len
+ 2) * sizeof(*pp
));
374 * `pq' isn't free, it's up the the caller
377 krb5_error_code KRB5_LIB_FUNCTION
378 krb5_prepend_config_files(const char *filelist
, char **pq
, char ***ret_pp
)
393 l
= strsep_copy(&q
, ":", NULL
, 0);
398 krb5_free_config_files(pp
);
401 l
= strsep_copy(&p
, ":", fn
, l
+ 1);
402 ret
= add_file(&pp
, &len
, fn
);
404 krb5_free_config_files(pp
);
412 for (i
= 0; pq
[i
] != NULL
; i
++) {
415 krb5_free_config_files(pp
);
418 ret
= add_file(&pp
, &len
, fn
);
420 krb5_free_config_files(pp
);
431 * Prepend the filename to the global configuration list.
433 * @param filelist a filename to add to the default list of filename
434 * @param pfilenames return array of filenames, should be freed with krb5_free_config_files().
436 * @return Returns 0 to indicate success. Otherwise an kerberos et
437 * error code is returned, see krb5_get_error_message().
442 krb5_error_code KRB5_LIB_FUNCTION
443 krb5_prepend_config_files_default(const char *filelist
, char ***pfilenames
)
446 char **defpp
, **pp
= NULL
;
448 ret
= krb5_get_default_config_files(&defpp
);
452 ret
= krb5_prepend_config_files(filelist
, defpp
, &pp
);
453 krb5_free_config_files(defpp
);
462 * Get the global configuration list.
464 * @param pfilenames return array of filenames, should be freed with krb5_free_config_files().
466 * @return Returns 0 to indicate success. Otherwise an kerberos et
467 * error code is returned, see krb5_get_error_message().
472 krb5_error_code KRB5_LIB_FUNCTION
473 krb5_get_default_config_files(char ***pfilenames
)
475 const char *files
= NULL
;
477 if (pfilenames
== NULL
)
480 files
= getenv("KRB5_CONFIG");
482 files
= krb5_config_file
;
484 return krb5_prepend_config_files(files
, NULL
, pfilenames
);
488 * Free a list of configuration files.
490 * @param filenames list to be freed.
492 * @return Returns 0 to indicate success. Otherwise an kerberos et
493 * error code is returned, see krb5_get_error_message().
498 void KRB5_LIB_FUNCTION
499 krb5_free_config_files(char **filenames
)
502 for(p
= filenames
; *p
!= NULL
; p
++)
508 * Returns the list of Kerberos encryption types sorted in order of
509 * most preferred to least preferred encryption type. Note that some
510 * encryption types might be disabled, so you need to check with
511 * krb5_enctype_valid() before using the encryption type.
513 * @return list of enctypes, terminated with ETYPE_NULL. Its a static
514 * array completed into the Kerberos library so the content doesn't
520 const krb5_enctype
* KRB5_LIB_FUNCTION
521 krb5_kerberos_enctypes(krb5_context context
)
523 static const krb5_enctype p
[] = {
524 ETYPE_AES256_CTS_HMAC_SHA1_96
,
525 ETYPE_AES128_CTS_HMAC_SHA1_96
,
528 ETYPE_ARCFOUR_HMAC_MD5
,
538 * set `etype' to a malloced list of the default enctypes
541 static krb5_error_code
542 default_etypes(krb5_context context
, krb5_enctype
**etype
)
544 const krb5_enctype
*p
;
545 krb5_enctype
*e
= NULL
, *ep
;
548 p
= krb5_kerberos_enctypes(context
);
550 for (i
= 0; p
[i
] != ETYPE_NULL
; i
++) {
551 if (krb5_enctype_valid(context
, p
[i
]) != 0)
553 ep
= realloc(e
, (n
+ 2) * sizeof(*e
));
556 krb5_set_error_string (context
, "malloc: out of memory");
561 e
[n
+ 1] = ETYPE_NULL
;
569 * Set the default encryption types that will be use in communcation
570 * with the KDC, clients and servers.
572 * @param context Kerberos 5 context.
573 * @param etypes Encryption types, array terminated with ETYPE_NULL (0).
575 * @return Returns 0 to indicate success. Otherwise an kerberos et
576 * error code is returned, see krb5_get_error_message().
581 krb5_error_code KRB5_LIB_FUNCTION
582 krb5_set_default_in_tkt_etypes(krb5_context context
,
583 const krb5_enctype
*etypes
)
585 krb5_enctype
*p
= NULL
;
589 for (i
= 0; etypes
[i
]; ++i
) {
591 ret
= krb5_enctype_valid(context
, etypes
[i
]);
598 krb5_set_error_string (context
, "malloc: out of memory");
601 memmove(p
, etypes
, i
* sizeof(krb5_enctype
));
604 free(context
->etypes
);
610 * Get the default encryption types that will be use in communcation
611 * with the KDC, clients and servers.
613 * @param context Kerberos 5 context.
614 * @param etypes Encryption types, array terminated with
615 * ETYPE_NULL(0), caller should free array with krb5_xfree():
617 * @return Returns 0 to indicate success. Otherwise an kerberos et
618 * error code is returned, see krb5_get_error_message().
623 krb5_error_code KRB5_LIB_FUNCTION
624 krb5_get_default_in_tkt_etypes(krb5_context context
,
625 krb5_enctype
**etypes
)
631 if(context
->etypes
) {
632 for(i
= 0; context
->etypes
[i
]; i
++);
636 krb5_set_error_string (context
, "malloc: out of memory");
639 memmove(p
, context
->etypes
, i
* sizeof(krb5_enctype
));
641 ret
= default_etypes(context
, &p
);
650 * Return the error string for the error code. The caller must not
653 * @param context Kerberos 5 context.
654 * @param code Kerberos error code.
656 * @return the error message matching code
661 const char* KRB5_LIB_FUNCTION
662 krb5_get_err_text(krb5_context context
, krb5_error_code code
)
664 const char *p
= NULL
;
666 p
= com_right(context
->et_list
, code
);
675 * Init the built-in ets in the Kerberos library.
677 * @param context kerberos context to add the ets too
682 void KRB5_LIB_FUNCTION
683 krb5_init_ets(krb5_context context
)
685 if(context
->et_list
== NULL
){
686 krb5_add_et_list(context
, initialize_krb5_error_table_r
);
687 krb5_add_et_list(context
, initialize_asn1_error_table_r
);
688 krb5_add_et_list(context
, initialize_heim_error_table_r
);
689 krb5_add_et_list(context
, initialize_k524_error_table_r
);
691 krb5_add_et_list(context
, initialize_hx_error_table_r
);
697 * Make the kerberos library default to the admin KDC.
699 * @param context Kerberos 5 context.
700 * @param flag boolean flag to select if the use the admin KDC or not.
705 void KRB5_LIB_FUNCTION
706 krb5_set_use_admin_kdc (krb5_context context
, krb5_boolean flag
)
708 context
->use_admin_kdc
= flag
;
712 * Make the kerberos library default to the admin KDC.
714 * @param context Kerberos 5 context.
716 * @return boolean flag to telling the context will use admin KDC as the default KDC.
721 krb5_boolean KRB5_LIB_FUNCTION
722 krb5_get_use_admin_kdc (krb5_context context
)
724 return context
->use_admin_kdc
;
728 * Add extra address to the address list that the library will add to
729 * the client's address list when communicating with the KDC.
731 * @param context Kerberos 5 context.
732 * @param addresses addreses to add
734 * @return Returns 0 to indicate success. Otherwise an kerberos et
735 * error code is returned, see krb5_get_error_message().
740 krb5_error_code KRB5_LIB_FUNCTION
741 krb5_add_extra_addresses(krb5_context context
, krb5_addresses
*addresses
)
744 if(context
->extra_addresses
)
745 return krb5_append_addresses(context
,
746 context
->extra_addresses
, addresses
);
748 return krb5_set_extra_addresses(context
, addresses
);
752 * Set extra address to the address list that the library will add to
753 * the client's address list when communicating with the KDC.
755 * @param context Kerberos 5 context.
756 * @param addresses addreses to set
758 * @return Returns 0 to indicate success. Otherwise an kerberos et
759 * error code is returned, see krb5_get_error_message().
764 krb5_error_code KRB5_LIB_FUNCTION
765 krb5_set_extra_addresses(krb5_context context
, const krb5_addresses
*addresses
)
767 if(context
->extra_addresses
)
768 krb5_free_addresses(context
, context
->extra_addresses
);
770 if(addresses
== NULL
) {
771 if(context
->extra_addresses
!= NULL
) {
772 free(context
->extra_addresses
);
773 context
->extra_addresses
= NULL
;
777 if(context
->extra_addresses
== NULL
) {
778 context
->extra_addresses
= malloc(sizeof(*context
->extra_addresses
));
779 if(context
->extra_addresses
== NULL
) {
780 krb5_set_error_string (context
, "malloc: out of memory");
784 return krb5_copy_addresses(context
, addresses
, context
->extra_addresses
);
788 * Get extra address to the address list that the library will add to
789 * the client's address list when communicating with the KDC.
791 * @param context Kerberos 5 context.
792 * @param addresses addreses to set
794 * @return Returns 0 to indicate success. Otherwise an kerberos et
795 * error code is returned, see krb5_get_error_message().
800 krb5_error_code KRB5_LIB_FUNCTION
801 krb5_get_extra_addresses(krb5_context context
, krb5_addresses
*addresses
)
803 if(context
->extra_addresses
== NULL
) {
804 memset(addresses
, 0, sizeof(*addresses
));
807 return krb5_copy_addresses(context
,context
->extra_addresses
, addresses
);
811 * Add extra addresses to ignore when fetching addresses from the
812 * underlaying operating system.
814 * @param context Kerberos 5 context.
815 * @param addresses addreses to ignore
817 * @return Returns 0 to indicate success. Otherwise an kerberos et
818 * error code is returned, see krb5_get_error_message().
823 krb5_error_code KRB5_LIB_FUNCTION
824 krb5_add_ignore_addresses(krb5_context context
, krb5_addresses
*addresses
)
827 if(context
->ignore_addresses
)
828 return krb5_append_addresses(context
,
829 context
->ignore_addresses
, addresses
);
831 return krb5_set_ignore_addresses(context
, addresses
);
835 * Set extra addresses to ignore when fetching addresses from the
836 * underlaying operating system.
838 * @param context Kerberos 5 context.
839 * @param addresses addreses to ignore
841 * @return Returns 0 to indicate success. Otherwise an kerberos et
842 * error code is returned, see krb5_get_error_message().
847 krb5_error_code KRB5_LIB_FUNCTION
848 krb5_set_ignore_addresses(krb5_context context
, const krb5_addresses
*addresses
)
850 if(context
->ignore_addresses
)
851 krb5_free_addresses(context
, context
->ignore_addresses
);
852 if(addresses
== NULL
) {
853 if(context
->ignore_addresses
!= NULL
) {
854 free(context
->ignore_addresses
);
855 context
->ignore_addresses
= NULL
;
859 if(context
->ignore_addresses
== NULL
) {
860 context
->ignore_addresses
= malloc(sizeof(*context
->ignore_addresses
));
861 if(context
->ignore_addresses
== NULL
) {
862 krb5_set_error_string (context
, "malloc: out of memory");
866 return krb5_copy_addresses(context
, addresses
, context
->ignore_addresses
);
870 * Get extra addresses to ignore when fetching addresses from the
871 * underlaying operating system.
873 * @param context Kerberos 5 context.
874 * @param addresses list addreses ignored
876 * @return Returns 0 to indicate success. Otherwise an kerberos et
877 * error code is returned, see krb5_get_error_message().
882 krb5_error_code KRB5_LIB_FUNCTION
883 krb5_get_ignore_addresses(krb5_context context
, krb5_addresses
*addresses
)
885 if(context
->ignore_addresses
== NULL
) {
886 memset(addresses
, 0, sizeof(*addresses
));
889 return krb5_copy_addresses(context
, context
->ignore_addresses
, addresses
);
893 * Set version of fcache that the library should use.
895 * @param context Kerberos 5 context.
896 * @param version version number.
898 * @return Returns 0 to indicate success. Otherwise an kerberos et
899 * error code is returned, see krb5_get_error_message().
904 krb5_error_code KRB5_LIB_FUNCTION
905 krb5_set_fcache_version(krb5_context context
, int version
)
907 context
->fcache_vno
= version
;
912 * Get version of fcache that the library should use.
914 * @param context Kerberos 5 context.
915 * @param version version number.
917 * @return Returns 0 to indicate success. Otherwise an kerberos et
918 * error code is returned, see krb5_get_error_message().
923 krb5_error_code KRB5_LIB_FUNCTION
924 krb5_get_fcache_version(krb5_context context
, int *version
)
926 *version
= context
->fcache_vno
;
931 * Runtime check if the Kerberos library was complied with thread support.
933 * @return TRUE if the library was compiled with thread support, FALSE if not.
939 krb5_boolean KRB5_LIB_FUNCTION
940 krb5_is_thread_safe(void)
942 #ifdef ENABLE_PTHREAD_SUPPORT
950 * Set if the library should use DNS to canonicalize hostnames.
952 * @param context Kerberos 5 context.
953 * @param flag if its dns canonicalizion is used or not.
958 void KRB5_LIB_FUNCTION
959 krb5_set_dns_canonicalize_hostname (krb5_context context
, krb5_boolean flag
)
962 context
->flags
|= KRB5_CTX_F_DNS_CANONICALIZE_HOSTNAME
;
964 context
->flags
&= ~KRB5_CTX_F_DNS_CANONICALIZE_HOSTNAME
;
968 * Get if the library uses DNS to canonicalize hostnames.
970 * @param context Kerberos 5 context.
972 * @return return non zero if the library uses DNS to canonicalize hostnames.
977 krb5_boolean KRB5_LIB_FUNCTION
978 krb5_get_dns_canonicalize_hostname (krb5_context context
)
980 return (context
->flags
& KRB5_CTX_F_DNS_CANONICALIZE_HOSTNAME
) ? 1 : 0;
984 * Get current offset in time to the KDC.
986 * @param context Kerberos 5 context.
987 * @param sec seconds part of offset.
988 * @param usec micro seconds part of offset.
990 * @return return non zero if the library uses DNS to canonicalize hostnames.
995 krb5_error_code KRB5_LIB_FUNCTION
996 krb5_get_kdc_sec_offset (krb5_context context
, int32_t *sec
, int32_t *usec
)
999 *sec
= context
->kdc_sec_offset
;
1001 *usec
= context
->kdc_usec_offset
;
1006 * Get max time skew allowed.
1008 * @param context Kerberos 5 context.
1010 * @return timeskew in seconds.
1015 time_t KRB5_LIB_FUNCTION
1016 krb5_get_max_time_skew (krb5_context context
)
1018 return context
->max_skew
;
1022 * Set max time skew allowed.
1024 * @param context Kerberos 5 context.
1025 * @param t timeskew in seconds.
1030 void KRB5_LIB_FUNCTION
1031 krb5_set_max_time_skew (krb5_context context
, time_t t
)
1033 context
->max_skew
= t
;