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"
39 #define INIT_FIELD(C, T, E, D, F) \
40 (C)->E = krb5_config_get_ ## T ## _default ((C), NULL, (D), \
41 "libdefaults", F, NULL)
42 #define INIT_FLAG(C, O, V, D, F) \
44 if (krb5_config_get_bool_default((C), NULL, (D),"libdefaults", F, NULL)) { \
50 * Set the list of etypes `ret_etypes' from the configuration variable
54 static krb5_error_code
55 set_etypes (krb5_context context
,
57 krb5_enctype
**ret_enctypes
)
60 krb5_enctype
*etypes
= NULL
;
62 etypes_str
= krb5_config_get_strings(context
, NULL
, "libdefaults",
66 for(i
= 0; etypes_str
[i
]; i
++);
67 etypes
= malloc((i
+1) * sizeof(*etypes
));
69 krb5_config_free_strings (etypes_str
);
70 krb5_set_error_string (context
, "malloc: out of memory");
73 for(j
= 0, k
= 0; j
< i
; j
++) {
75 if(krb5_string_to_enctype(context
, etypes_str
[j
], &e
) != 0)
77 if (krb5_enctype_valid(context
, e
) != 0)
81 etypes
[k
] = ETYPE_NULL
;
82 krb5_config_free_strings(etypes_str
);
84 *ret_enctypes
= etypes
;
89 * read variables from the configuration file and set in `context'
92 static krb5_error_code
93 init_context_from_config_file(krb5_context context
)
97 krb5_enctype
*tmptypes
;
99 INIT_FIELD(context
, time
, max_skew
, 5 * 60, "clockskew");
100 INIT_FIELD(context
, time
, kdc_timeout
, 3, "kdc_timeout");
101 INIT_FIELD(context
, int, max_retries
, 3, "max_retries");
103 INIT_FIELD(context
, string
, http_proxy
, NULL
, "http_proxy");
105 ret
= set_etypes (context
, "default_etypes", &tmptypes
);
108 free(context
->etypes
);
109 context
->etypes
= tmptypes
;
111 ret
= set_etypes (context
, "default_etypes_des", &tmptypes
);
114 free(context
->etypes_des
);
115 context
->etypes_des
= tmptypes
;
117 /* default keytab name */
120 tmp
= getenv("KRB5_KTNAME");
122 context
->default_keytab
= tmp
;
124 INIT_FIELD(context
, string
, default_keytab
,
125 KEYTAB_DEFAULT
, "default_keytab_name");
127 INIT_FIELD(context
, string
, default_keytab_modify
,
128 NULL
, "default_keytab_modify_name");
130 INIT_FIELD(context
, string
, time_fmt
,
131 "%Y-%m-%dT%H:%M:%S", "time_format");
133 INIT_FIELD(context
, string
, date_fmt
,
134 "%Y-%m-%d", "date_format");
136 INIT_FIELD(context
, bool, log_utc
,
141 /* init dns-proxy slime */
142 tmp
= krb5_config_get_string(context
, NULL
, "libdefaults",
145 roken_gethostby_setup(context
->http_proxy
, tmp
);
146 krb5_free_host_realm (context
, context
->default_realms
);
147 context
->default_realms
= NULL
;
150 krb5_addresses addresses
;
153 krb5_set_extra_addresses(context
, NULL
);
154 adr
= krb5_config_get_strings(context
, NULL
,
158 memset(&addresses
, 0, sizeof(addresses
));
159 for(a
= adr
; a
&& *a
; a
++) {
160 ret
= krb5_parse_address(context
, *a
, &addresses
);
162 krb5_add_extra_addresses(context
, &addresses
);
163 krb5_free_addresses(context
, &addresses
);
166 krb5_config_free_strings(adr
);
168 krb5_set_ignore_addresses(context
, NULL
);
169 adr
= krb5_config_get_strings(context
, NULL
,
173 memset(&addresses
, 0, sizeof(addresses
));
174 for(a
= adr
; a
&& *a
; a
++) {
175 ret
= krb5_parse_address(context
, *a
, &addresses
);
177 krb5_add_ignore_addresses(context
, &addresses
);
178 krb5_free_addresses(context
, &addresses
);
181 krb5_config_free_strings(adr
);
184 INIT_FIELD(context
, bool, scan_interfaces
, TRUE
, "scan_interfaces");
185 INIT_FIELD(context
, int, fcache_vno
, 0, "fcache_version");
186 /* prefer dns_lookup_kdc over srv_lookup. */
187 INIT_FIELD(context
, bool, srv_lookup
, TRUE
, "srv_lookup");
188 INIT_FIELD(context
, bool, srv_lookup
, context
->srv_lookup
, "dns_lookup_kdc");
189 INIT_FIELD(context
, int, large_msg_size
, 1400, "large_message_size");
190 INIT_FLAG(context
, flags
, KRB5_CTX_F_DNS_CANONICALIZE_HOSTNAME
, TRUE
, "dns_canonicalize_hostname");
191 INIT_FLAG(context
, flags
, KRB5_CTX_F_CHECK_PAC
, TRUE
, "check_pac");
192 context
->default_cc_name
= NULL
;
193 context
->default_cc_name_set
= 0;
198 * Initializes the context structure and reads the configuration file
199 * /etc/krb5.conf. The structure should be freed by calling
200 * krb5_free_context() when it is no longer being used.
202 * @param context pointer to returned context
204 * @return Returns 0 to indicate success. Otherwise an errno code is
205 * returned. Failure means either that something bad happened during
206 * initialization (typically ENOMEM) or that Kerberos should not be
212 krb5_error_code KRB5_LIB_FUNCTION
213 krb5_init_context(krb5_context
*context
)
221 p
= calloc(1, sizeof(*p
));
225 p
->mutex
= malloc(sizeof(HEIMDAL_MUTEX
));
226 if (p
->mutex
== NULL
) {
230 HEIMDAL_MUTEX_init(p
->mutex
);
232 ret
= krb5_get_default_config_files(&files
);
235 ret
= krb5_set_config_files(p
, files
);
236 krb5_free_config_files(files
);
240 /* init error tables */
245 krb5_cc_register(p
, &krb5_acc_ops
, TRUE
);
246 krb5_cc_register(p
, &krb5_fcc_ops
, TRUE
);
247 krb5_cc_register(p
, &krb5_mcc_ops
, TRUE
);
249 krb5_cc_register(p
, &krb5_kcm_ops
, TRUE
);
254 krb5_kt_register (p
, &krb5_fkt_ops
);
255 krb5_kt_register (p
, &krb5_wrfkt_ops
);
256 krb5_kt_register (p
, &krb5_javakt_ops
);
257 krb5_kt_register (p
, &krb5_mkt_ops
);
258 krb5_kt_register (p
, &krb5_akf_ops
);
259 krb5_kt_register (p
, &krb4_fkt_ops
);
260 krb5_kt_register (p
, &krb5_srvtab_fkt_ops
);
261 krb5_kt_register (p
, &krb5_any_ops
);
265 krb5_free_context(p
);
273 * Frees the krb5_context allocated by krb5_init_context().
275 * @param context context to be freed.
280 void KRB5_LIB_FUNCTION
281 krb5_free_context(krb5_context context
)
283 if (context
->default_cc_name
)
284 free(context
->default_cc_name
);
285 if (context
->default_cc_name_env
)
286 free(context
->default_cc_name_env
);
287 free(context
->etypes
);
288 free(context
->etypes_des
);
289 krb5_free_host_realm (context
, context
->default_realms
);
290 krb5_config_file_free (context
, context
->cf
);
291 free_error_table (context
->et_list
);
292 free(context
->cc_ops
);
293 free(context
->kt_types
);
294 krb5_clear_error_string(context
);
295 if(context
->warn_dest
!= NULL
)
296 krb5_closelog(context
, context
->warn_dest
);
297 krb5_set_extra_addresses(context
, NULL
);
298 krb5_set_ignore_addresses(context
, NULL
);
299 krb5_set_send_to_kdc_func(context
, NULL
, NULL
);
300 if (context
->mutex
!= NULL
) {
301 HEIMDAL_MUTEX_destroy(context
->mutex
);
302 free(context
->mutex
);
304 memset(context
, 0, sizeof(*context
));
309 * Reinit the context from a new set of filenames.
311 * @param context context to add configuration too.
312 * @param filenames array of filenames, end of list is indicated with a NULL filename.
314 * @return Returns 0 to indicate success. Otherwise an kerberos et
315 * error code is returned, see krb5_get_error_message().
320 krb5_error_code KRB5_LIB_FUNCTION
321 krb5_set_config_files(krb5_context context
, char **filenames
)
324 krb5_config_binding
*tmp
= NULL
;
325 while(filenames
!= NULL
&& *filenames
!= NULL
&& **filenames
!= '\0') {
326 ret
= krb5_config_parse_file_multi(context
, *filenames
, &tmp
);
327 if(ret
!= 0 && ret
!= ENOENT
&& ret
!= EACCES
) {
328 krb5_config_file_free(context
, tmp
);
334 /* with this enabled and if there are no config files, Kerberos is
335 considererd disabled */
339 krb5_config_file_free(context
, context
->cf
);
341 ret
= init_context_from_config_file(context
);
345 static krb5_error_code
346 add_file(char ***pfilenames
, int *len
, char *file
)
348 char **pp
= *pfilenames
;
351 for(i
= 0; i
< *len
; i
++) {
352 if(strcmp(pp
[i
], file
) == 0) {
358 pp
= realloc(*pfilenames
, (*len
+ 2) * sizeof(*pp
));
372 * `pq' isn't free, it's up the the caller
375 krb5_error_code KRB5_LIB_FUNCTION
376 krb5_prepend_config_files(const char *filelist
, char **pq
, char ***ret_pp
)
391 l
= strsep_copy(&q
, ":", NULL
, 0);
396 krb5_free_config_files(pp
);
399 l
= strsep_copy(&p
, ":", fn
, l
+ 1);
400 ret
= add_file(&pp
, &len
, fn
);
402 krb5_free_config_files(pp
);
410 for (i
= 0; pq
[i
] != NULL
; i
++) {
413 krb5_free_config_files(pp
);
416 ret
= add_file(&pp
, &len
, fn
);
418 krb5_free_config_files(pp
);
429 * Prepend the filename to the global configuration list.
431 * @param filelist a filename to add to the default list of filename
432 * @param pfilenames return array of filenames, should be freed with krb5_free_config_files().
434 * @return Returns 0 to indicate success. Otherwise an kerberos et
435 * error code is returned, see krb5_get_error_message().
440 krb5_error_code KRB5_LIB_FUNCTION
441 krb5_prepend_config_files_default(const char *filelist
, char ***pfilenames
)
444 char **defpp
, **pp
= NULL
;
446 ret
= krb5_get_default_config_files(&defpp
);
450 ret
= krb5_prepend_config_files(filelist
, defpp
, &pp
);
451 krb5_free_config_files(defpp
);
460 * Get the global configuration list.
462 * @param pfilenames return array of filenames, should be freed with krb5_free_config_files().
464 * @return Returns 0 to indicate success. Otherwise an kerberos et
465 * error code is returned, see krb5_get_error_message().
470 krb5_error_code KRB5_LIB_FUNCTION
471 krb5_get_default_config_files(char ***pfilenames
)
473 const char *files
= NULL
;
475 if (pfilenames
== NULL
)
478 files
= getenv("KRB5_CONFIG");
480 files
= krb5_config_file
;
482 return krb5_prepend_config_files(files
, NULL
, pfilenames
);
486 * Free a list of configuration files.
488 * @param filenames list to be freed.
490 * @return Returns 0 to indicate success. Otherwise an kerberos et
491 * error code is returned, see krb5_get_error_message().
496 void KRB5_LIB_FUNCTION
497 krb5_free_config_files(char **filenames
)
500 for(p
= filenames
; *p
!= NULL
; p
++)
506 * Returns the list of Kerberos encryption types sorted in order of
507 * most preferred to least preferred encryption type. Note that some
508 * encryption types might be disabled, so you need to check with
509 * krb5_enctype_valid() before using the encryption type.
511 * @return list of enctypes, terminated with ETYPE_NULL. Its a static
512 * array completed into the Kerberos library so the content doesn't
518 const krb5_enctype
* KRB5_LIB_FUNCTION
519 krb5_kerberos_enctypes(krb5_context context
)
521 static const krb5_enctype p
[] = {
522 ETYPE_AES256_CTS_HMAC_SHA1_96
,
523 ETYPE_AES128_CTS_HMAC_SHA1_96
,
526 ETYPE_ARCFOUR_HMAC_MD5
,
536 * set `etype' to a malloced list of the default enctypes
539 static krb5_error_code
540 default_etypes(krb5_context context
, krb5_enctype
**etype
)
542 const krb5_enctype
*p
;
543 krb5_enctype
*e
= NULL
, *ep
;
546 p
= krb5_kerberos_enctypes(context
);
548 for (i
= 0; p
[i
] != ETYPE_NULL
; i
++) {
549 if (krb5_enctype_valid(context
, p
[i
]) != 0)
551 ep
= realloc(e
, (n
+ 2) * sizeof(*e
));
554 krb5_set_error_string (context
, "malloc: out of memory");
559 e
[n
+ 1] = ETYPE_NULL
;
567 * Set the default encryption types that will be use in communcation
568 * with the KDC, clients and servers.
570 * @param context Kerberos 5 context.
571 * @param etypes Encryption types, array terminated with ETYPE_NULL (0).
573 * @return Returns 0 to indicate success. Otherwise an kerberos et
574 * error code is returned, see krb5_get_error_message().
579 krb5_error_code KRB5_LIB_FUNCTION
580 krb5_set_default_in_tkt_etypes(krb5_context context
,
581 const krb5_enctype
*etypes
)
583 krb5_enctype
*p
= NULL
;
587 for (i
= 0; etypes
[i
]; ++i
) {
589 ret
= krb5_enctype_valid(context
, etypes
[i
]);
596 krb5_set_error_string (context
, "malloc: out of memory");
599 memmove(p
, etypes
, i
* sizeof(krb5_enctype
));
602 free(context
->etypes
);
608 * Get the default encryption types that will be use in communcation
609 * with the KDC, clients and servers.
611 * @param context Kerberos 5 context.
612 * @param etypes Encryption types, array terminated with
613 * ETYPE_NULL(0), caller should free array with krb5_xfree():
615 * @return Returns 0 to indicate success. Otherwise an kerberos et
616 * error code is returned, see krb5_get_error_message().
621 krb5_error_code KRB5_LIB_FUNCTION
622 krb5_get_default_in_tkt_etypes(krb5_context context
,
623 krb5_enctype
**etypes
)
629 if(context
->etypes
) {
630 for(i
= 0; context
->etypes
[i
]; i
++);
634 krb5_set_error_string (context
, "malloc: out of memory");
637 memmove(p
, context
->etypes
, i
* sizeof(krb5_enctype
));
639 ret
= default_etypes(context
, &p
);
648 * Return the error string for the error code. The caller must not
651 * @param context Kerberos 5 context.
652 * @param code Kerberos error code.
654 * @return the error message matching code
659 const char* KRB5_LIB_FUNCTION
660 krb5_get_err_text(krb5_context context
, krb5_error_code code
)
662 const char *p
= NULL
;
664 p
= com_right(context
->et_list
, code
);
673 * Init the built-in ets in the Kerberos library.
675 * @param context kerberos context to add the ets too
680 void KRB5_LIB_FUNCTION
681 krb5_init_ets(krb5_context context
)
683 if(context
->et_list
== NULL
){
684 krb5_add_et_list(context
, initialize_krb5_error_table_r
);
685 krb5_add_et_list(context
, initialize_asn1_error_table_r
);
686 krb5_add_et_list(context
, initialize_heim_error_table_r
);
687 krb5_add_et_list(context
, initialize_k524_error_table_r
);
689 krb5_add_et_list(context
, initialize_hx_error_table_r
);
695 * Make the kerberos library default to the admin KDC.
697 * @param context Kerberos 5 context.
698 * @param flag boolean flag to select if the use the admin KDC or not.
703 void KRB5_LIB_FUNCTION
704 krb5_set_use_admin_kdc (krb5_context context
, krb5_boolean flag
)
706 context
->use_admin_kdc
= flag
;
710 * Make the kerberos library default to the admin KDC.
712 * @param context Kerberos 5 context.
714 * @return boolean flag to telling the context will use admin KDC as the default KDC.
719 krb5_boolean KRB5_LIB_FUNCTION
720 krb5_get_use_admin_kdc (krb5_context context
)
722 return context
->use_admin_kdc
;
726 * Add extra address to the address list that the library will add to
727 * the client's address list when communicating with the KDC.
729 * @param context Kerberos 5 context.
730 * @param addresses addreses to add
732 * @return Returns 0 to indicate success. Otherwise an kerberos et
733 * error code is returned, see krb5_get_error_message().
738 krb5_error_code KRB5_LIB_FUNCTION
739 krb5_add_extra_addresses(krb5_context context
, krb5_addresses
*addresses
)
742 if(context
->extra_addresses
)
743 return krb5_append_addresses(context
,
744 context
->extra_addresses
, addresses
);
746 return krb5_set_extra_addresses(context
, addresses
);
750 * Set extra address to the address list that the library will add to
751 * the client's address list when communicating with the KDC.
753 * @param context Kerberos 5 context.
754 * @param addresses addreses to set
756 * @return Returns 0 to indicate success. Otherwise an kerberos et
757 * error code is returned, see krb5_get_error_message().
762 krb5_error_code KRB5_LIB_FUNCTION
763 krb5_set_extra_addresses(krb5_context context
, const krb5_addresses
*addresses
)
765 if(context
->extra_addresses
)
766 krb5_free_addresses(context
, context
->extra_addresses
);
768 if(addresses
== NULL
) {
769 if(context
->extra_addresses
!= NULL
) {
770 free(context
->extra_addresses
);
771 context
->extra_addresses
= NULL
;
775 if(context
->extra_addresses
== NULL
) {
776 context
->extra_addresses
= malloc(sizeof(*context
->extra_addresses
));
777 if(context
->extra_addresses
== NULL
) {
778 krb5_set_error_string (context
, "malloc: out of memory");
782 return krb5_copy_addresses(context
, addresses
, context
->extra_addresses
);
786 * Get extra address to the address list that the library will add to
787 * the client's address list when communicating with the KDC.
789 * @param context Kerberos 5 context.
790 * @param addresses addreses to set
792 * @return Returns 0 to indicate success. Otherwise an kerberos et
793 * error code is returned, see krb5_get_error_message().
798 krb5_error_code KRB5_LIB_FUNCTION
799 krb5_get_extra_addresses(krb5_context context
, krb5_addresses
*addresses
)
801 if(context
->extra_addresses
== NULL
) {
802 memset(addresses
, 0, sizeof(*addresses
));
805 return krb5_copy_addresses(context
,context
->extra_addresses
, addresses
);
809 * Add extra addresses to ignore when fetching addresses from the
810 * underlaying operating system.
812 * @param context Kerberos 5 context.
813 * @param addresses addreses to ignore
815 * @return Returns 0 to indicate success. Otherwise an kerberos et
816 * error code is returned, see krb5_get_error_message().
821 krb5_error_code KRB5_LIB_FUNCTION
822 krb5_add_ignore_addresses(krb5_context context
, krb5_addresses
*addresses
)
825 if(context
->ignore_addresses
)
826 return krb5_append_addresses(context
,
827 context
->ignore_addresses
, addresses
);
829 return krb5_set_ignore_addresses(context
, addresses
);
833 * Set extra addresses to ignore when fetching addresses from the
834 * underlaying operating system.
836 * @param context Kerberos 5 context.
837 * @param addresses addreses to ignore
839 * @return Returns 0 to indicate success. Otherwise an kerberos et
840 * error code is returned, see krb5_get_error_message().
845 krb5_error_code KRB5_LIB_FUNCTION
846 krb5_set_ignore_addresses(krb5_context context
, const krb5_addresses
*addresses
)
848 if(context
->ignore_addresses
)
849 krb5_free_addresses(context
, context
->ignore_addresses
);
850 if(addresses
== NULL
) {
851 if(context
->ignore_addresses
!= NULL
) {
852 free(context
->ignore_addresses
);
853 context
->ignore_addresses
= NULL
;
857 if(context
->ignore_addresses
== NULL
) {
858 context
->ignore_addresses
= malloc(sizeof(*context
->ignore_addresses
));
859 if(context
->ignore_addresses
== NULL
) {
860 krb5_set_error_string (context
, "malloc: out of memory");
864 return krb5_copy_addresses(context
, addresses
, context
->ignore_addresses
);
868 * Get extra addresses to ignore when fetching addresses from the
869 * underlaying operating system.
871 * @param context Kerberos 5 context.
872 * @param addresses list addreses ignored
874 * @return Returns 0 to indicate success. Otherwise an kerberos et
875 * error code is returned, see krb5_get_error_message().
880 krb5_error_code KRB5_LIB_FUNCTION
881 krb5_get_ignore_addresses(krb5_context context
, krb5_addresses
*addresses
)
883 if(context
->ignore_addresses
== NULL
) {
884 memset(addresses
, 0, sizeof(*addresses
));
887 return krb5_copy_addresses(context
, context
->ignore_addresses
, addresses
);
891 * Set version of fcache that the library should use.
893 * @param context Kerberos 5 context.
894 * @param version version number.
896 * @return Returns 0 to indicate success. Otherwise an kerberos et
897 * error code is returned, see krb5_get_error_message().
902 krb5_error_code KRB5_LIB_FUNCTION
903 krb5_set_fcache_version(krb5_context context
, int version
)
905 context
->fcache_vno
= version
;
910 * Get version of fcache that the library should use.
912 * @param context Kerberos 5 context.
913 * @param version version number.
915 * @return Returns 0 to indicate success. Otherwise an kerberos et
916 * error code is returned, see krb5_get_error_message().
921 krb5_error_code KRB5_LIB_FUNCTION
922 krb5_get_fcache_version(krb5_context context
, int *version
)
924 *version
= context
->fcache_vno
;
929 * Runtime check if the Kerberos library was complied with thread support.
931 * @return TRUE if the library was compiled with thread support, FALSE if not.
937 krb5_boolean KRB5_LIB_FUNCTION
938 krb5_is_thread_safe(void)
940 #ifdef ENABLE_PTHREAD_SUPPORT
948 * Set if the library should use DNS to canonicalize hostnames.
950 * @param context Kerberos 5 context.
951 * @param flag if its dns canonicalizion is used or not.
956 void KRB5_LIB_FUNCTION
957 krb5_set_dns_canonicalize_hostname (krb5_context context
, krb5_boolean flag
)
960 context
->flags
|= KRB5_CTX_F_DNS_CANONICALIZE_HOSTNAME
;
962 context
->flags
&= ~KRB5_CTX_F_DNS_CANONICALIZE_HOSTNAME
;
966 * Get if the library uses DNS to canonicalize hostnames.
968 * @param context Kerberos 5 context.
970 * @return return non zero if the library uses DNS to canonicalize hostnames.
975 krb5_boolean KRB5_LIB_FUNCTION
976 krb5_get_dns_canonicalize_hostname (krb5_context context
)
978 return (context
->flags
& KRB5_CTX_F_DNS_CANONICALIZE_HOSTNAME
) ? 1 : 0;
982 * Get current offset in time to the KDC.
984 * @param context Kerberos 5 context.
985 * @param sec seconds part of offset.
986 * @param usec micro seconds part of offset.
988 * @return return non zero if the library uses DNS to canonicalize hostnames.
993 krb5_error_code KRB5_LIB_FUNCTION
994 krb5_get_kdc_sec_offset (krb5_context context
, int32_t *sec
, int32_t *usec
)
997 *sec
= context
->kdc_sec_offset
;
999 *usec
= context
->kdc_usec_offset
;
1004 * Get max time skew allowed.
1006 * @param context Kerberos 5 context.
1008 * @return timeskew in seconds.
1013 time_t KRB5_LIB_FUNCTION
1014 krb5_get_max_time_skew (krb5_context context
)
1016 return context
->max_skew
;
1020 * Set max time skew allowed.
1022 * @param context Kerberos 5 context.
1023 * @param t timeskew in seconds.
1028 void KRB5_LIB_FUNCTION
1029 krb5_set_max_time_skew (krb5_context context
, time_t t
)
1031 context
->max_skew
= t
;