2 * Copyright (c) 1997 - 2004 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the Institute nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #define KRB5_DEPRECATED
38 #include "krb5_locl.h"
41 #include <CoreFoundation/CoreFoundation.h>
44 /* Gaah! I want a portable funopen */
51 config_fgets(char *str
, size_t len
, struct fileptr
*ptr
)
53 /* XXX this is not correct, in that they don't do the same if the
54 line is longer than len */
56 return fgets(str
, len
, ptr
->f
);
58 /* this is almost strsep_copy */
63 p
= ptr
->s
+ strcspn(ptr
->s
, "\n");
66 l
= min(len
, p
- ptr
->s
);
68 memcpy(str
, ptr
->s
, l
);
76 static krb5_error_code
parse_section(char *p
, krb5_config_section
**s
,
77 krb5_config_section
**res
,
78 const char **error_message
);
79 static krb5_error_code
parse_binding(struct fileptr
*f
, unsigned *lineno
, char *p
,
80 krb5_config_binding
**b
,
81 krb5_config_binding
**parent
,
82 const char **error_message
);
83 static krb5_error_code
parse_list(struct fileptr
*f
, unsigned *lineno
,
84 krb5_config_binding
**parent
,
85 const char **error_message
);
87 static krb5_config_section
*
88 get_entry(krb5_config_section
**parent
, const char *name
, int type
)
90 krb5_config_section
**q
;
92 for(q
= parent
; *q
!= NULL
; q
= &(*q
)->next
)
93 if(type
== krb5_config_list
&&
95 strcmp(name
, (*q
)->name
) == 0)
97 *q
= calloc(1, sizeof(**q
));
100 (*q
)->name
= strdup(name
);
102 if((*q
)->name
== NULL
) {
120 * starting at the line in `p', storing the resulting structure in
121 * `s' and hooking it into `parent'.
122 * Store the error message in `error_message'.
125 static krb5_error_code
126 parse_section(char *p
, krb5_config_section
**s
, krb5_config_section
**parent
,
127 const char **error_message
)
130 krb5_config_section
*tmp
;
132 p1
= strchr (p
+ 1, ']');
134 *error_message
= "missing ]";
135 return KRB5_CONFIG_BADFORMAT
;
138 tmp
= get_entry(parent
, p
+ 1, krb5_config_list
);
140 *error_message
= "out of memory";
141 return KRB5_CONFIG_BADFORMAT
;
148 * Parse a brace-enclosed list from `f', hooking in the structure at
150 * Store the error message in `error_message'.
153 static krb5_error_code
154 parse_list(struct fileptr
*f
, unsigned *lineno
, krb5_config_binding
**parent
,
155 const char **error_message
)
159 krb5_config_binding
*b
= NULL
;
160 unsigned beg_lineno
= *lineno
;
162 while(config_fgets(buf
, sizeof(buf
), f
) != NULL
) {
166 buf
[strcspn(buf
, "\r\n")] = '\0';
168 while(isspace((unsigned char)*p
))
170 if (*p
== '#' || *p
== ';' || *p
== '\0')
172 while(isspace((unsigned char)*p
))
178 ret
= parse_binding (f
, lineno
, p
, &b
, parent
, error_message
);
182 *lineno
= beg_lineno
;
183 *error_message
= "unclosed {";
184 return KRB5_CONFIG_BADFORMAT
;
191 static krb5_error_code
192 parse_binding(struct fileptr
*f
, unsigned *lineno
, char *p
,
193 krb5_config_binding
**b
, krb5_config_binding
**parent
,
194 const char **error_message
)
196 krb5_config_binding
*tmp
;
198 krb5_error_code ret
= 0;
201 while (*p
&& *p
!= '=' && !isspace((unsigned char)*p
))
204 *error_message
= "missing =";
205 return KRB5_CONFIG_BADFORMAT
;
208 while (isspace((unsigned char)*p
))
211 *error_message
= "missing =";
212 return KRB5_CONFIG_BADFORMAT
;
215 while(isspace((unsigned char)*p
))
219 tmp
= get_entry(parent
, p1
, krb5_config_list
);
221 *error_message
= "out of memory";
222 return KRB5_CONFIG_BADFORMAT
;
224 ret
= parse_list (f
, lineno
, &tmp
->u
.list
, error_message
);
226 tmp
= get_entry(parent
, p1
, krb5_config_string
);
228 *error_message
= "out of memory";
229 return KRB5_CONFIG_BADFORMAT
;
233 while(p
> p1
&& isspace((unsigned char)*(p
-1)))
236 tmp
->u
.string
= strdup(p1
);
244 cfstring2cstring(CFStringRef string
)
249 str
= (char *) CFStringGetCStringPtr(string
, kCFStringEncodingUTF8
);
253 len
= CFStringGetLength(string
);
254 len
= 1 + CFStringGetMaximumSizeForEncoding(len
, kCFStringEncodingUTF8
);
259 if (!CFStringGetCString (string
, str
, len
, kCFStringEncodingUTF8
)) {
267 convert_content(const void *key
, const void *value
, void *context
)
269 krb5_config_section
*tmp
, **parent
= context
;
272 if (CFGetTypeID(key
) != CFStringGetTypeID())
275 k
= cfstring2cstring(key
);
279 if (CFGetTypeID(value
) == CFStringGetTypeID()) {
280 tmp
= get_entry(parent
, k
, krb5_config_string
);
281 tmp
->u
.string
= cfstring2cstring(value
);
282 } else if (CFGetTypeID(value
) == CFDictionaryGetTypeID()) {
283 tmp
= get_entry(parent
, k
, krb5_config_list
);
284 CFDictionaryApplyFunction(value
, convert_content
, &tmp
->u
.list
);
291 static krb5_error_code
292 parse_plist_config(krb5_context context
, const char *path
, krb5_config_section
**parent
)
299 url
= CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault
, (UInt8
*)path
, strlen(path
), FALSE
);
301 krb5_clear_error_message(context
);
305 s
= CFReadStreamCreateWithFile(kCFAllocatorDefault
, url
);
308 krb5_clear_error_message(context
);
312 if (!CFReadStreamOpen(s
)) {
314 krb5_clear_error_message(context
);
318 d
= (CFDictionaryRef
)CFPropertyListCreateWithStream (kCFAllocatorDefault
, s
, 0, kCFPropertyListImmutable
, NULL
, &e
);
321 krb5_clear_error_message(context
);
325 CFDictionaryApplyFunction(d
, convert_content
, parent
);
335 * Parse the config file `fname', generating the structures into `res'
336 * returning error messages in `error_message'
339 static krb5_error_code
340 krb5_config_parse_debug (struct fileptr
*f
,
341 krb5_config_section
**res
,
343 const char **error_message
)
345 krb5_config_section
*s
= NULL
;
346 krb5_config_binding
*b
= NULL
;
350 while (config_fgets(buf
, sizeof(buf
), f
) != NULL
) {
354 buf
[strcspn(buf
, "\r\n")] = '\0';
356 while(isspace((unsigned char)*p
))
358 if (*p
== '#' || *p
== ';')
361 ret
= parse_section(p
, &s
, res
, error_message
);
365 } else if (*p
== '}') {
366 *error_message
= "unmatched }";
367 return EINVAL
; /* XXX */
368 } else if(*p
!= '\0') {
370 *error_message
= "binding before section";
373 ret
= parse_binding(f
, lineno
, p
, &b
, &s
->u
.list
, error_message
);
382 is_plist_file(const char *fname
)
384 size_t len
= strlen(fname
);
385 char suffix
[] = ".plist";
386 if (len
< sizeof(suffix
))
388 if (strcasecmp(&fname
[len
- (sizeof(suffix
) - 1)], suffix
) != 0)
394 * Parse a configuration file and add the result into res. This
395 * interface can be used to parse several configuration files into one
396 * resulting krb5_config_section by calling it repeatably.
398 * @param context a Kerberos 5 context.
399 * @param fname a file name to a Kerberos configuration file
400 * @param res the returned result, must be free with krb5_free_config_files().
401 * @return Return an error code or 0, see krb5_get_error_message().
403 * @ingroup krb5_support
406 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
407 krb5_config_parse_file_multi (krb5_context context
,
409 krb5_config_section
**res
)
412 char *newfname
= NULL
;
418 * If the fname starts with "~/" parse configuration file in the
419 * current users home directory. The behavior can be disabled and
420 * enabled by calling krb5_set_home_dir_access().
422 if (fname
[0] == '~' && fname
[1] == '/') {
423 #ifndef KRB5_USE_PATH_TOKENS
424 const char *home
= NULL
;
426 if (!_krb5_homedir_access(context
)) {
427 krb5_set_error_message(context
, EPERM
,
428 "Access to home directory not allowed");
433 home
= getenv("HOME");
436 struct passwd
*pw
= getpwuid(getuid());
441 asprintf(&newfname
, "%s%s", home
, &fname
[1]);
442 if (newfname
== NULL
) {
443 krb5_set_error_message(context
, ENOMEM
,
444 N_("malloc: out of memory", ""));
449 #else /* KRB5_USE_PATH_TOKENS */
450 if (asprintf(&newfname
, "%%{USERCONFIG}%s", &fname
[1]) < 0 ||
453 krb5_set_error_message(context
, ENOMEM
,
454 N_("malloc: out of memory", ""));
461 if (is_plist_file(fname
)) {
463 ret
= parse_plist_config(context
, fname
, res
);
465 krb5_set_error_message(context
, ret
,
466 "Failed to parse plist %s", fname
);
472 krb5_set_error_message(context
, ENOENT
,
473 "no support for plist configuration files");
477 #ifdef KRB5_USE_PATH_TOKENS
478 char * exp_fname
= NULL
;
480 ret
= _krb5_expand_path_tokens(context
, fname
, &exp_fname
);
489 fname
= newfname
= exp_fname
;
492 f
.f
= fopen(fname
, "r");
496 krb5_set_error_message (context
, ret
, "open %s: %s",
497 fname
, strerror(ret
));
503 ret
= krb5_config_parse_debug (&f
, res
, &lineno
, &str
);
506 krb5_set_error_message (context
, ret
, "%s:%u: %s",
516 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
517 krb5_config_parse_file (krb5_context context
,
519 krb5_config_section
**res
)
522 return krb5_config_parse_file_multi(context
, fname
, res
);
526 free_binding (krb5_context context
, krb5_config_binding
*b
)
528 krb5_config_binding
*next_b
;
532 if (b
->type
== krb5_config_string
)
534 else if (b
->type
== krb5_config_list
)
535 free_binding (context
, b
->u
.list
);
537 krb5_abortx(context
, "unknown binding type (%d) in free_binding",
546 * Free configuration file section, the result of
547 * krb5_config_parse_file() and krb5_config_parse_file_multi().
549 * @param context A Kerberos 5 context
550 * @param s the configuration section to free
552 * @return returns 0 on successes, otherwise an error code, see
553 * krb5_get_error_message()
555 * @ingroup krb5_support
558 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
559 krb5_config_file_free (krb5_context context
, krb5_config_section
*s
)
561 free_binding (context
, s
);
565 #ifndef HEIMDAL_SMALLER
567 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
568 _krb5_config_copy(krb5_context context
,
569 krb5_config_section
*c
,
570 krb5_config_section
**head
)
572 krb5_config_binding
*d
, *previous
= NULL
;
577 d
= calloc(1, sizeof(*d
));
582 d
->name
= strdup(c
->name
);
584 if (d
->type
== krb5_config_string
)
585 d
->u
.string
= strdup(c
->u
.string
);
586 else if (d
->type
== krb5_config_list
)
587 _krb5_config_copy (context
, c
->u
.list
, &d
->u
.list
);
590 "unknown binding type (%d) in krb5_config_copy",
601 #endif /* HEIMDAL_SMALLER */
603 KRB5_LIB_FUNCTION
const void * KRB5_LIB_CALL
604 _krb5_config_get_next (krb5_context context
,
605 const krb5_config_section
*c
,
606 const krb5_config_binding
**pointer
,
613 va_start(args
, type
);
614 ret
= _krb5_config_vget_next (context
, c
, pointer
, type
, args
);
620 vget_next(krb5_context context
,
621 const krb5_config_binding
*b
,
622 const krb5_config_binding
**pointer
,
627 const char *p
= va_arg(args
, const char *);
629 if(strcmp(b
->name
, name
) == 0) {
630 if(b
->type
== type
&& p
== NULL
) {
633 } else if(b
->type
== krb5_config_list
&& p
!= NULL
) {
634 return vget_next(context
, b
->u
.list
, pointer
, type
, p
, args
);
642 KRB5_LIB_FUNCTION
const void * KRB5_LIB_CALL
643 _krb5_config_vget_next (krb5_context context
,
644 const krb5_config_section
*c
,
645 const krb5_config_binding
**pointer
,
649 const krb5_config_binding
*b
;
658 if (*pointer
== NULL
) {
659 /* first time here, walk down the tree looking for the right
661 p
= va_arg(args
, const char *);
664 return vget_next(context
, c
, pointer
, type
, p
, args
);
667 /* we were called again, so just look for more entries with the
668 same name and type */
669 for (b
= (*pointer
)->next
; b
!= NULL
; b
= b
->next
) {
670 if(strcmp(b
->name
, (*pointer
)->name
) == 0 && b
->type
== type
) {
678 KRB5_LIB_FUNCTION
const void * KRB5_LIB_CALL
679 _krb5_config_get (krb5_context context
,
680 const krb5_config_section
*c
,
687 va_start(args
, type
);
688 ret
= _krb5_config_vget (context
, c
, type
, args
);
695 _krb5_config_vget (krb5_context context
,
696 const krb5_config_section
*c
,
700 const krb5_config_binding
*foo
= NULL
;
702 return _krb5_config_vget_next (context
, c
, &foo
, type
, args
);
706 * Get a list of configuration binding list for more processing
708 * @param context A Kerberos 5 context.
709 * @param c a configuration section, or NULL to use the section from context
710 * @param ... a list of names, terminated with NULL.
712 * @return NULL if configuration list is not found, a list otherwise
714 * @ingroup krb5_support
717 KRB5_LIB_FUNCTION
const krb5_config_binding
* KRB5_LIB_CALL
718 krb5_config_get_list (krb5_context context
,
719 const krb5_config_section
*c
,
722 const krb5_config_binding
*ret
;
726 ret
= krb5_config_vget_list (context
, c
, args
);
732 * Get a list of configuration binding list for more processing
734 * @param context A Kerberos 5 context.
735 * @param c a configuration section, or NULL to use the section from context
736 * @param args a va_list of arguments
738 * @return NULL if configuration list is not found, a list otherwise
740 * @ingroup krb5_support
743 KRB5_LIB_FUNCTION
const krb5_config_binding
* KRB5_LIB_CALL
744 krb5_config_vget_list (krb5_context context
,
745 const krb5_config_section
*c
,
748 return _krb5_config_vget (context
, c
, krb5_config_list
, args
);
752 * Returns a "const char *" to a string in the configuration database.
753 * The string may not be valid after a reload of the configuration
754 * database so a caller should make a local copy if it needs to keep
757 * @param context A Kerberos 5 context.
758 * @param c a configuration section, or NULL to use the section from context
759 * @param ... a list of names, terminated with NULL.
761 * @return NULL if configuration string not found, a string otherwise
763 * @ingroup krb5_support
766 KRB5_LIB_FUNCTION
const char* KRB5_LIB_CALL
767 krb5_config_get_string (krb5_context context
,
768 const krb5_config_section
*c
,
775 ret
= krb5_config_vget_string (context
, c
, args
);
781 * Like krb5_config_get_string(), but uses a va_list instead of ...
783 * @param context A Kerberos 5 context.
784 * @param c a configuration section, or NULL to use the section from context
785 * @param args a va_list of arguments
787 * @return NULL if configuration string not found, a string otherwise
789 * @ingroup krb5_support
792 KRB5_LIB_FUNCTION
const char* KRB5_LIB_CALL
793 krb5_config_vget_string (krb5_context context
,
794 const krb5_config_section
*c
,
797 return _krb5_config_vget (context
, c
, krb5_config_string
, args
);
801 * Like krb5_config_vget_string(), but instead of returning NULL,
802 * instead return a default value.
804 * @param context A Kerberos 5 context.
805 * @param c a configuration section, or NULL to use the section from context
806 * @param def_value the default value to return if no configuration
807 * found in the database.
808 * @param args a va_list of arguments
810 * @return a configuration string
812 * @ingroup krb5_support
815 KRB5_LIB_FUNCTION
const char* KRB5_LIB_CALL
816 krb5_config_vget_string_default (krb5_context context
,
817 const krb5_config_section
*c
,
818 const char *def_value
,
823 ret
= krb5_config_vget_string (context
, c
, args
);
830 * Like krb5_config_get_string(), but instead of returning NULL,
831 * instead return a default value.
833 * @param context A Kerberos 5 context.
834 * @param c a configuration section, or NULL to use the section from context
835 * @param def_value the default value to return if no configuration
836 * found in the database.
837 * @param ... a list of names, terminated with NULL.
839 * @return a configuration string
841 * @ingroup krb5_support
844 KRB5_LIB_FUNCTION
const char* KRB5_LIB_CALL
845 krb5_config_get_string_default (krb5_context context
,
846 const krb5_config_section
*c
,
847 const char *def_value
,
853 va_start(args
, def_value
);
854 ret
= krb5_config_vget_string_default (context
, c
, def_value
, args
);
860 * Get a list of configuration strings, free the result with
861 * krb5_config_free_strings().
863 * @param context A Kerberos 5 context.
864 * @param c a configuration section, or NULL to use the section from context
865 * @param args a va_list of arguments
867 * @return TRUE or FALSE
869 * @ingroup krb5_support
872 KRB5_LIB_FUNCTION
char ** KRB5_LIB_CALL
873 krb5_config_vget_strings(krb5_context context
,
874 const krb5_config_section
*c
,
877 char **strings
= NULL
;
879 const krb5_config_binding
*b
= NULL
;
882 while((p
= _krb5_config_vget_next(context
, c
, &b
,
883 krb5_config_string
, args
))) {
884 char *tmp
= strdup(p
);
889 s
= strtok_r(tmp
, " \t", &pos
);
891 char **tmp2
= realloc(strings
, (nstr
+ 1) * sizeof(*strings
));
895 strings
[nstr
] = strdup(s
);
897 if(strings
[nstr
-1] == NULL
)
899 s
= strtok_r(NULL
, " \t", &pos
);
904 char **tmp
= realloc(strings
, (nstr
+ 1) * sizeof(*strings
));
908 strings
[nstr
] = NULL
;
920 * Get a list of configuration strings, free the result with
921 * krb5_config_free_strings().
923 * @param context A Kerberos 5 context.
924 * @param c a configuration section, or NULL to use the section from context
925 * @param ... a list of names, terminated with NULL.
927 * @return TRUE or FALSE
929 * @ingroup krb5_support
932 KRB5_LIB_FUNCTION
char** KRB5_LIB_CALL
933 krb5_config_get_strings(krb5_context context
,
934 const krb5_config_section
*c
,
940 ret
= krb5_config_vget_strings(context
, c
, ap
);
946 * Free the resulting strings from krb5_config-get_strings() and
947 * krb5_config_vget_strings().
949 * @param strings strings to free
951 * @ingroup krb5_support
954 KRB5_LIB_FUNCTION
void KRB5_LIB_CALL
955 krb5_config_free_strings(char **strings
)
966 * Like krb5_config_get_bool_default() but with a va_list list of
967 * configuration selection.
969 * Configuration value to a boolean value, where yes/true and any
970 * non-zero number means TRUE and other value is FALSE.
972 * @param context A Kerberos 5 context.
973 * @param c a configuration section, or NULL to use the section from context
974 * @param def_value the default value to return if no configuration
975 * found in the database.
976 * @param args a va_list of arguments
978 * @return TRUE or FALSE
980 * @ingroup krb5_support
983 KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
984 krb5_config_vget_bool_default (krb5_context context
,
985 const krb5_config_section
*c
,
986 krb5_boolean def_value
,
990 str
= krb5_config_vget_string (context
, c
, args
);
993 if(strcasecmp(str
, "yes") == 0 ||
994 strcasecmp(str
, "true") == 0 ||
995 atoi(str
)) return TRUE
;
1000 * krb5_config_get_bool() will convert the configuration
1001 * option value to a boolean value, where yes/true and any non-zero
1002 * number means TRUE and other value is FALSE.
1004 * @param context A Kerberos 5 context.
1005 * @param c a configuration section, or NULL to use the section from context
1006 * @param args a va_list of arguments
1008 * @return TRUE or FALSE
1010 * @ingroup krb5_support
1013 KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
1014 krb5_config_vget_bool (krb5_context context
,
1015 const krb5_config_section
*c
,
1018 return krb5_config_vget_bool_default (context
, c
, FALSE
, args
);
1022 * krb5_config_get_bool_default() will convert the configuration
1023 * option value to a boolean value, where yes/true and any non-zero
1024 * number means TRUE and other value is FALSE.
1026 * @param context A Kerberos 5 context.
1027 * @param c a configuration section, or NULL to use the section from context
1028 * @param def_value the default value to return if no configuration
1029 * found in the database.
1030 * @param ... a list of names, terminated with NULL.
1032 * @return TRUE or FALSE
1034 * @ingroup krb5_support
1037 KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
1038 krb5_config_get_bool_default (krb5_context context
,
1039 const krb5_config_section
*c
,
1040 krb5_boolean def_value
,
1045 va_start(ap
, def_value
);
1046 ret
= krb5_config_vget_bool_default(context
, c
, def_value
, ap
);
1052 * Like krb5_config_get_bool() but with a va_list list of
1053 * configuration selection.
1055 * Configuration value to a boolean value, where yes/true and any
1056 * non-zero number means TRUE and other value is FALSE.
1058 * @param context A Kerberos 5 context.
1059 * @param c a configuration section, or NULL to use the section from context
1060 * @param ... a list of names, terminated with NULL.
1062 * @return TRUE or FALSE
1064 * @ingroup krb5_support
1067 KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
1068 krb5_config_get_bool (krb5_context context
,
1069 const krb5_config_section
*c
,
1075 ret
= krb5_config_vget_bool (context
, c
, ap
);
1081 * Get the time from the configuration file using a relative time.
1083 * Like krb5_config_get_time_default() but with a va_list list of
1084 * configuration selection.
1086 * @param context A Kerberos 5 context.
1087 * @param c a configuration section, or NULL to use the section from context
1088 * @param def_value the default value to return if no configuration
1089 * found in the database.
1090 * @param args a va_list of arguments
1092 * @return parsed the time (or def_value on parse error)
1094 * @ingroup krb5_support
1097 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1098 krb5_config_vget_time_default (krb5_context context
,
1099 const krb5_config_section
*c
,
1106 str
= krb5_config_vget_string (context
, c
, args
);
1109 if (krb5_string_to_deltat(str
, &t
))
1115 * Get the time from the configuration file using a relative time, for example: 1h30s
1117 * @param context A Kerberos 5 context.
1118 * @param c a configuration section, or NULL to use the section from context
1119 * @param args a va_list of arguments
1121 * @return parsed the time or -1 on error
1123 * @ingroup krb5_support
1126 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1127 krb5_config_vget_time (krb5_context context
,
1128 const krb5_config_section
*c
,
1131 return krb5_config_vget_time_default (context
, c
, -1, args
);
1135 * Get the time from the configuration file using a relative time, for example: 1h30s
1137 * @param context A Kerberos 5 context.
1138 * @param c a configuration section, or NULL to use the section from context
1139 * @param def_value the default value to return if no configuration
1140 * found in the database.
1141 * @param ... a list of names, terminated with NULL.
1143 * @return parsed the time (or def_value on parse error)
1145 * @ingroup krb5_support
1148 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1149 krb5_config_get_time_default (krb5_context context
,
1150 const krb5_config_section
*c
,
1156 va_start(ap
, def_value
);
1157 ret
= krb5_config_vget_time_default(context
, c
, def_value
, ap
);
1163 * Get the time from the configuration file using a relative time, for example: 1h30s
1165 * @param context A Kerberos 5 context.
1166 * @param c a configuration section, or NULL to use the section from context
1167 * @param ... a list of names, terminated with NULL.
1169 * @return parsed the time or -1 on error
1171 * @ingroup krb5_support
1174 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1175 krb5_config_get_time (krb5_context context
,
1176 const krb5_config_section
*c
,
1182 ret
= krb5_config_vget_time (context
, c
, ap
);
1188 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1189 krb5_config_vget_int_default (krb5_context context
,
1190 const krb5_config_section
*c
,
1195 str
= krb5_config_vget_string (context
, c
, args
);
1201 l
= strtol(str
, &endptr
, 0);
1209 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1210 krb5_config_vget_int (krb5_context context
,
1211 const krb5_config_section
*c
,
1214 return krb5_config_vget_int_default (context
, c
, -1, args
);
1217 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1218 krb5_config_get_int_default (krb5_context context
,
1219 const krb5_config_section
*c
,
1225 va_start(ap
, def_value
);
1226 ret
= krb5_config_vget_int_default(context
, c
, def_value
, ap
);
1231 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1232 krb5_config_get_int (krb5_context context
,
1233 const krb5_config_section
*c
,
1239 ret
= krb5_config_vget_int (context
, c
, ap
);
1245 #ifndef HEIMDAL_SMALLER
1248 * Deprecated: configuration files are not strings
1250 * @ingroup krb5_deprecated
1254 krb5_error_code KRB5_LIB_FUNCTION
1255 krb5_config_parse_string_multi(krb5_context context
,
1257 krb5_config_section
**res
)
1260 unsigned lineno
= 0;
1261 krb5_error_code ret
;
1266 ret
= krb5_config_parse_debug (&f
, res
, &lineno
, &str
);
1268 krb5_set_error_message (context
, ret
, "%s:%u: %s",
1269 "<constant>", lineno
, str
);