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 asprintf(&newfname
, "%%{USERCONFIG}%s", &fname
[1]);
451 if (newfname
== NULL
) {
452 krb5_set_error_message(context
, ENOMEM
,
453 N_("malloc: out of memory", ""));
460 if (is_plist_file(fname
)) {
462 ret
= parse_plist_config(context
, fname
, res
);
464 krb5_set_error_message(context
, ret
,
465 "Failed to parse plist %s", fname
);
471 krb5_set_error_message(context
, ENOENT
,
472 "no support for plist configuration files");
476 #ifdef KRB5_USE_PATH_TOKENS
477 char * exp_fname
= NULL
;
479 ret
= _krb5_expand_path_tokens(context
, fname
, &exp_fname
);
488 fname
= newfname
= exp_fname
;
491 f
.f
= fopen(fname
, "r");
495 krb5_set_error_message (context
, ret
, "open %s: %s",
496 fname
, strerror(ret
));
502 ret
= krb5_config_parse_debug (&f
, res
, &lineno
, &str
);
505 krb5_set_error_message (context
, ret
, "%s:%u: %s",
515 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
516 krb5_config_parse_file (krb5_context context
,
518 krb5_config_section
**res
)
521 return krb5_config_parse_file_multi(context
, fname
, res
);
525 free_binding (krb5_context context
, krb5_config_binding
*b
)
527 krb5_config_binding
*next_b
;
531 if (b
->type
== krb5_config_string
)
533 else if (b
->type
== krb5_config_list
)
534 free_binding (context
, b
->u
.list
);
536 krb5_abortx(context
, "unknown binding type (%d) in free_binding",
545 * Free configuration file section, the result of
546 * krb5_config_parse_file() and krb5_config_parse_file_multi().
548 * @param context A Kerberos 5 context
549 * @param s the configuration section to free
551 * @return returns 0 on successes, otherwise an error code, see
552 * krb5_get_error_message()
554 * @ingroup krb5_support
557 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
558 krb5_config_file_free (krb5_context context
, krb5_config_section
*s
)
560 free_binding (context
, s
);
564 #ifndef HEIMDAL_SMALLER
566 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
567 _krb5_config_copy(krb5_context context
,
568 krb5_config_section
*c
,
569 krb5_config_section
**head
)
571 krb5_config_binding
*d
, *previous
= NULL
;
576 d
= calloc(1, sizeof(*d
));
581 d
->name
= strdup(c
->name
);
583 if (d
->type
== krb5_config_string
)
584 d
->u
.string
= strdup(c
->u
.string
);
585 else if (d
->type
== krb5_config_list
)
586 _krb5_config_copy (context
, c
->u
.list
, &d
->u
.list
);
589 "unknown binding type (%d) in krb5_config_copy",
600 #endif /* HEIMDAL_SMALLER */
602 KRB5_LIB_FUNCTION
const void * KRB5_LIB_CALL
603 _krb5_config_get_next (krb5_context context
,
604 const krb5_config_section
*c
,
605 const krb5_config_binding
**pointer
,
612 va_start(args
, type
);
613 ret
= _krb5_config_vget_next (context
, c
, pointer
, type
, args
);
619 vget_next(krb5_context context
,
620 const krb5_config_binding
*b
,
621 const krb5_config_binding
**pointer
,
626 const char *p
= va_arg(args
, const char *);
628 if(strcmp(b
->name
, name
) == 0) {
629 if(b
->type
== type
&& p
== NULL
) {
632 } else if(b
->type
== krb5_config_list
&& p
!= NULL
) {
633 return vget_next(context
, b
->u
.list
, pointer
, type
, p
, args
);
641 KRB5_LIB_FUNCTION
const void * KRB5_LIB_CALL
642 _krb5_config_vget_next (krb5_context context
,
643 const krb5_config_section
*c
,
644 const krb5_config_binding
**pointer
,
648 const krb5_config_binding
*b
;
657 if (*pointer
== NULL
) {
658 /* first time here, walk down the tree looking for the right
660 p
= va_arg(args
, const char *);
663 return vget_next(context
, c
, pointer
, type
, p
, args
);
666 /* we were called again, so just look for more entries with the
667 same name and type */
668 for (b
= (*pointer
)->next
; b
!= NULL
; b
= b
->next
) {
669 if(strcmp(b
->name
, (*pointer
)->name
) == 0 && b
->type
== type
) {
677 KRB5_LIB_FUNCTION
const void * KRB5_LIB_CALL
678 _krb5_config_get (krb5_context context
,
679 const krb5_config_section
*c
,
686 va_start(args
, type
);
687 ret
= _krb5_config_vget (context
, c
, type
, args
);
694 _krb5_config_vget (krb5_context context
,
695 const krb5_config_section
*c
,
699 const krb5_config_binding
*foo
= NULL
;
701 return _krb5_config_vget_next (context
, c
, &foo
, type
, args
);
705 * Get a list of configuration binding list for more processing
707 * @param context A Kerberos 5 context.
708 * @param c a configuration section, or NULL to use the section from context
709 * @param ... a list of names, terminated with NULL.
711 * @return NULL if configuration list is not found, a list otherwise
713 * @ingroup krb5_support
716 KRB5_LIB_FUNCTION
const krb5_config_binding
* KRB5_LIB_CALL
717 krb5_config_get_list (krb5_context context
,
718 const krb5_config_section
*c
,
721 const krb5_config_binding
*ret
;
725 ret
= krb5_config_vget_list (context
, c
, args
);
731 * Get a list of configuration binding list for more processing
733 * @param context A Kerberos 5 context.
734 * @param c a configuration section, or NULL to use the section from context
735 * @param args a va_list of arguments
737 * @return NULL if configuration list is not found, a list otherwise
739 * @ingroup krb5_support
742 KRB5_LIB_FUNCTION
const krb5_config_binding
* KRB5_LIB_CALL
743 krb5_config_vget_list (krb5_context context
,
744 const krb5_config_section
*c
,
747 return _krb5_config_vget (context
, c
, krb5_config_list
, args
);
751 * Returns a "const char *" to a string in the configuration database.
752 * The string may not be valid after a reload of the configuration
753 * database so a caller should make a local copy if it needs to keep
756 * @param context A Kerberos 5 context.
757 * @param c a configuration section, or NULL to use the section from context
758 * @param ... a list of names, terminated with NULL.
760 * @return NULL if configuration string not found, a string otherwise
762 * @ingroup krb5_support
765 KRB5_LIB_FUNCTION
const char* KRB5_LIB_CALL
766 krb5_config_get_string (krb5_context context
,
767 const krb5_config_section
*c
,
774 ret
= krb5_config_vget_string (context
, c
, args
);
780 * Like krb5_config_get_string(), but uses a va_list instead of ...
782 * @param context A Kerberos 5 context.
783 * @param c a configuration section, or NULL to use the section from context
784 * @param args a va_list of arguments
786 * @return NULL if configuration string not found, a string otherwise
788 * @ingroup krb5_support
791 KRB5_LIB_FUNCTION
const char* KRB5_LIB_CALL
792 krb5_config_vget_string (krb5_context context
,
793 const krb5_config_section
*c
,
796 return _krb5_config_vget (context
, c
, krb5_config_string
, args
);
800 * Like krb5_config_vget_string(), but instead of returning NULL,
801 * instead return a default value.
803 * @param context A Kerberos 5 context.
804 * @param c a configuration section, or NULL to use the section from context
805 * @param def_value the default value to return if no configuration
806 * found in the database.
807 * @param args a va_list of arguments
809 * @return a configuration string
811 * @ingroup krb5_support
814 KRB5_LIB_FUNCTION
const char* KRB5_LIB_CALL
815 krb5_config_vget_string_default (krb5_context context
,
816 const krb5_config_section
*c
,
817 const char *def_value
,
822 ret
= krb5_config_vget_string (context
, c
, args
);
829 * Like krb5_config_get_string(), but instead of returning NULL,
830 * instead return a default value.
832 * @param context A Kerberos 5 context.
833 * @param c a configuration section, or NULL to use the section from context
834 * @param def_value the default value to return if no configuration
835 * found in the database.
836 * @param ... a list of names, terminated with NULL.
838 * @return a configuration string
840 * @ingroup krb5_support
843 KRB5_LIB_FUNCTION
const char* KRB5_LIB_CALL
844 krb5_config_get_string_default (krb5_context context
,
845 const krb5_config_section
*c
,
846 const char *def_value
,
852 va_start(args
, def_value
);
853 ret
= krb5_config_vget_string_default (context
, c
, def_value
, args
);
859 * Get a list of configuration strings, free the result with
860 * krb5_config_free_strings().
862 * @param context A Kerberos 5 context.
863 * @param c a configuration section, or NULL to use the section from context
864 * @param args a va_list of arguments
866 * @return TRUE or FALSE
868 * @ingroup krb5_support
871 KRB5_LIB_FUNCTION
char ** KRB5_LIB_CALL
872 krb5_config_vget_strings(krb5_context context
,
873 const krb5_config_section
*c
,
876 char **strings
= NULL
;
878 const krb5_config_binding
*b
= NULL
;
881 while((p
= _krb5_config_vget_next(context
, c
, &b
,
882 krb5_config_string
, args
))) {
883 char *tmp
= strdup(p
);
888 s
= strtok_r(tmp
, " \t", &pos
);
890 char **tmp2
= realloc(strings
, (nstr
+ 1) * sizeof(*strings
));
894 strings
[nstr
] = strdup(s
);
896 if(strings
[nstr
-1] == NULL
)
898 s
= strtok_r(NULL
, " \t", &pos
);
903 char **tmp
= realloc(strings
, (nstr
+ 1) * sizeof(*strings
));
907 strings
[nstr
] = NULL
;
919 * Get a list of configuration strings, free the result with
920 * krb5_config_free_strings().
922 * @param context A Kerberos 5 context.
923 * @param c a configuration section, or NULL to use the section from context
924 * @param ... a list of names, terminated with NULL.
926 * @return TRUE or FALSE
928 * @ingroup krb5_support
931 KRB5_LIB_FUNCTION
char** KRB5_LIB_CALL
932 krb5_config_get_strings(krb5_context context
,
933 const krb5_config_section
*c
,
939 ret
= krb5_config_vget_strings(context
, c
, ap
);
945 * Free the resulting strings from krb5_config-get_strings() and
946 * krb5_config_vget_strings().
948 * @param strings strings to free
950 * @ingroup krb5_support
953 KRB5_LIB_FUNCTION
void KRB5_LIB_CALL
954 krb5_config_free_strings(char **strings
)
965 * Like krb5_config_get_bool_default() but with a va_list list of
966 * configuration selection.
968 * Configuration value to a boolean value, where yes/true and any
969 * non-zero number means TRUE and other value is FALSE.
971 * @param context A Kerberos 5 context.
972 * @param c a configuration section, or NULL to use the section from context
973 * @param def_value the default value to return if no configuration
974 * found in the database.
975 * @param args a va_list of arguments
977 * @return TRUE or FALSE
979 * @ingroup krb5_support
982 KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
983 krb5_config_vget_bool_default (krb5_context context
,
984 const krb5_config_section
*c
,
985 krb5_boolean def_value
,
989 str
= krb5_config_vget_string (context
, c
, args
);
992 if(strcasecmp(str
, "yes") == 0 ||
993 strcasecmp(str
, "true") == 0 ||
994 atoi(str
)) return TRUE
;
999 * krb5_config_get_bool() will convert the configuration
1000 * option value to a boolean value, where yes/true and any non-zero
1001 * number means TRUE and other value is FALSE.
1003 * @param context A Kerberos 5 context.
1004 * @param c a configuration section, or NULL to use the section from context
1005 * @param args a va_list of arguments
1007 * @return TRUE or FALSE
1009 * @ingroup krb5_support
1012 KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
1013 krb5_config_vget_bool (krb5_context context
,
1014 const krb5_config_section
*c
,
1017 return krb5_config_vget_bool_default (context
, c
, FALSE
, args
);
1021 * krb5_config_get_bool_default() will convert the configuration
1022 * option value to a boolean value, where yes/true and any non-zero
1023 * number means TRUE and other value is FALSE.
1025 * @param context A Kerberos 5 context.
1026 * @param c a configuration section, or NULL to use the section from context
1027 * @param def_value the default value to return if no configuration
1028 * found in the database.
1029 * @param ... a list of names, terminated with NULL.
1031 * @return TRUE or FALSE
1033 * @ingroup krb5_support
1036 KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
1037 krb5_config_get_bool_default (krb5_context context
,
1038 const krb5_config_section
*c
,
1039 krb5_boolean def_value
,
1044 va_start(ap
, def_value
);
1045 ret
= krb5_config_vget_bool_default(context
, c
, def_value
, ap
);
1051 * Like krb5_config_get_bool() but with a va_list list of
1052 * configuration selection.
1054 * Configuration value to a boolean value, where yes/true and any
1055 * non-zero number means TRUE and other value is FALSE.
1057 * @param context A Kerberos 5 context.
1058 * @param c a configuration section, or NULL to use the section from context
1059 * @param ... a list of names, terminated with NULL.
1061 * @return TRUE or FALSE
1063 * @ingroup krb5_support
1066 KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
1067 krb5_config_get_bool (krb5_context context
,
1068 const krb5_config_section
*c
,
1074 ret
= krb5_config_vget_bool (context
, c
, ap
);
1080 * Get the time from the configuration file using a relative time.
1082 * Like krb5_config_get_time_default() but with a va_list list of
1083 * configuration selection.
1085 * @param context A Kerberos 5 context.
1086 * @param c a configuration section, or NULL to use the section from context
1087 * @param def_value the default value to return if no configuration
1088 * found in the database.
1089 * @param args a va_list of arguments
1091 * @return parsed the time (or def_value on parse error)
1093 * @ingroup krb5_support
1096 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1097 krb5_config_vget_time_default (krb5_context context
,
1098 const krb5_config_section
*c
,
1105 str
= krb5_config_vget_string (context
, c
, args
);
1108 if (krb5_string_to_deltat(str
, &t
))
1114 * Get the time from the configuration file using a relative time, for example: 1h30s
1116 * @param context A Kerberos 5 context.
1117 * @param c a configuration section, or NULL to use the section from context
1118 * @param args a va_list of arguments
1120 * @return parsed the time or -1 on error
1122 * @ingroup krb5_support
1125 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1126 krb5_config_vget_time (krb5_context context
,
1127 const krb5_config_section
*c
,
1130 return krb5_config_vget_time_default (context
, c
, -1, args
);
1134 * Get the time from the configuration file using a relative time, for example: 1h30s
1136 * @param context A Kerberos 5 context.
1137 * @param c a configuration section, or NULL to use the section from context
1138 * @param def_value the default value to return if no configuration
1139 * found in the database.
1140 * @param ... a list of names, terminated with NULL.
1142 * @return parsed the time (or def_value on parse error)
1144 * @ingroup krb5_support
1147 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1148 krb5_config_get_time_default (krb5_context context
,
1149 const krb5_config_section
*c
,
1155 va_start(ap
, def_value
);
1156 ret
= krb5_config_vget_time_default(context
, c
, def_value
, ap
);
1162 * Get the time from the configuration file using a relative time, for example: 1h30s
1164 * @param context A Kerberos 5 context.
1165 * @param c a configuration section, or NULL to use the section from context
1166 * @param ... a list of names, terminated with NULL.
1168 * @return parsed the time or -1 on error
1170 * @ingroup krb5_support
1173 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1174 krb5_config_get_time (krb5_context context
,
1175 const krb5_config_section
*c
,
1181 ret
= krb5_config_vget_time (context
, c
, ap
);
1187 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1188 krb5_config_vget_int_default (krb5_context context
,
1189 const krb5_config_section
*c
,
1194 str
= krb5_config_vget_string (context
, c
, args
);
1200 l
= strtol(str
, &endptr
, 0);
1208 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1209 krb5_config_vget_int (krb5_context context
,
1210 const krb5_config_section
*c
,
1213 return krb5_config_vget_int_default (context
, c
, -1, args
);
1216 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1217 krb5_config_get_int_default (krb5_context context
,
1218 const krb5_config_section
*c
,
1224 va_start(ap
, def_value
);
1225 ret
= krb5_config_vget_int_default(context
, c
, def_value
, ap
);
1230 KRB5_LIB_FUNCTION
int KRB5_LIB_CALL
1231 krb5_config_get_int (krb5_context context
,
1232 const krb5_config_section
*c
,
1238 ret
= krb5_config_vget_int (context
, c
, ap
);
1244 #ifndef HEIMDAL_SMALLER
1247 * Deprecated: configuration files are not strings
1249 * @ingroup krb5_deprecated
1253 krb5_error_code KRB5_LIB_FUNCTION
1254 krb5_config_parse_string_multi(krb5_context context
,
1256 krb5_config_section
**res
)
1259 unsigned lineno
= 0;
1260 krb5_error_code ret
;
1265 ret
= krb5_config_parse_debug (&f
, res
, &lineno
, &str
);
1267 krb5_set_error_message (context
, ret
, "%s:%u: %s",
1268 "<constant>", lineno
, str
);