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 **err_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 **err_message);
83 static krb5_error_code parse_list(struct fileptr *f, unsigned *lineno,
84 krb5_config_binding **parent,
85 const char **err_message);
88 _krb5_config_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 `err_message'.
125 static krb5_error_code
126 parse_section(char *p, krb5_config_section **s, krb5_config_section **parent,
127 const char **err_message)
130 krb5_config_section *tmp;
132 p1 = strchr (p + 1, ']');
134 *err_message = "missing ]";
135 return KRB5_CONFIG_BADFORMAT;
138 tmp = _krb5_config_get_entry(parent, p + 1, krb5_config_list);
140 *err_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 `err_message'.
153 static krb5_error_code
154 parse_list(struct fileptr *f, unsigned *lineno, krb5_config_binding **parent,
155 const char **err_message)
157 char buf[KRB5_BUFSIZ];
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, err_message);
182 *lineno = beg_lineno;
183 *err_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 **err_message)
196 krb5_config_binding *tmp;
198 krb5_error_code ret = 0;
201 while (*p && *p != '=' && !isspace((unsigned char)*p))
204 *err_message = "missing =";
205 return KRB5_CONFIG_BADFORMAT;
208 while (isspace((unsigned char)*p))
211 *err_message = "missing =";
212 return KRB5_CONFIG_BADFORMAT;
215 while(isspace((unsigned char)*p))
219 tmp = _krb5_config_get_entry(parent, p1, krb5_config_list);
221 *err_message = "out of memory";
222 return KRB5_CONFIG_BADFORMAT;
224 ret = parse_list (f, lineno, &tmp->u.list, err_message);
226 tmp = _krb5_config_get_entry(parent, p1, krb5_config_string);
228 *err_message = "out of memory";
229 return KRB5_CONFIG_BADFORMAT;
233 while(p > p1 && isspace((unsigned char)*(p-1)))
236 tmp->u.string = strdup(p1);
242 #if defined(__APPLE__)
244 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
245 #define HAVE_CFPROPERTYLISTCREATEWITHSTREAM 1
249 cfstring2cstring(CFStringRef string)
254 str = (char *) CFStringGetCStringPtr(string, kCFStringEncodingUTF8);
258 len = CFStringGetLength(string);
259 len = 1 + CFStringGetMaximumSizeForEncoding(len, kCFStringEncodingUTF8);
264 if (!CFStringGetCString (string, str, len, kCFStringEncodingUTF8)) {
272 convert_content(const void *key, const void *value, void *context)
274 krb5_config_section *tmp, **parent = context;
277 if (CFGetTypeID(key) != CFStringGetTypeID())
280 k = cfstring2cstring(key);
284 if (CFGetTypeID(value) == CFStringGetTypeID()) {
285 tmp = _krb5_config_get_entry(parent, k, krb5_config_string);
286 tmp->u.string = cfstring2cstring(value);
287 } else if (CFGetTypeID(value) == CFDictionaryGetTypeID()) {
288 tmp = _krb5_config_get_entry(parent, k, krb5_config_list);
289 CFDictionaryApplyFunction(value, convert_content, &tmp->u.list);
296 static krb5_error_code
297 parse_plist_config(krb5_context context, const char *path, krb5_config_section **parent)
303 url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (UInt8 *)path, strlen(path), FALSE);
305 krb5_clear_error_message(context);
309 s = CFReadStreamCreateWithFile(kCFAllocatorDefault, url);
312 krb5_clear_error_message(context);
316 if (!CFReadStreamOpen(s)) {
318 krb5_clear_error_message(context);
322 #ifdef HAVE_CFPROPERTYLISTCREATEWITHSTREAM
323 d = (CFDictionaryRef)CFPropertyListCreateWithStream(NULL, s, 0, kCFPropertyListImmutable, NULL, NULL);
325 d = (CFDictionaryRef)CFPropertyListCreateFromStream(NULL, s, 0, kCFPropertyListImmutable, NULL, NULL);
329 krb5_clear_error_message(context);
333 CFDictionaryApplyFunction(d, convert_content, parent);
343 * Parse the config file `fname', generating the structures into `res'
344 * returning error messages in `err_message'
347 static krb5_error_code
348 krb5_config_parse_debug (struct fileptr *f,
349 krb5_config_section **res,
351 const char **err_message)
353 krb5_config_section *s = NULL;
354 krb5_config_binding *b = NULL;
355 char buf[KRB5_BUFSIZ];
358 while (config_fgets(buf, sizeof(buf), f) != NULL) {
362 buf[strcspn(buf, "\r\n")] = '\0';
364 while(isspace((unsigned char)*p))
366 if (*p == '#' || *p == ';')
369 ret = parse_section(p, &s, res, err_message);
373 } else if (*p == '}') {
374 *err_message = "unmatched }";
375 return EINVAL; /* XXX */
376 } else if(*p != '\0') {
378 *err_message = "binding before section";
381 ret = parse_binding(f, lineno, p, &b, &s->u.list, err_message);
390 is_plist_file(const char *fname)
392 size_t len = strlen(fname);
393 char suffix[] = ".plist";
394 if (len < sizeof(suffix))
396 if (strcasecmp(&fname[len - (sizeof(suffix) - 1)], suffix) != 0)
402 * Parse a configuration file and add the result into res. This
403 * interface can be used to parse several configuration files into one
404 * resulting krb5_config_section by calling it repeatably.
406 * @param context a Kerberos 5 context.
407 * @param fname a file name to a Kerberos configuration file
408 * @param res the returned result, must be free with krb5_free_config_files().
409 * @return Return an error code or 0, see krb5_get_error_message().
411 * @ingroup krb5_support
414 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
415 krb5_config_parse_file_multi (krb5_context context,
417 krb5_config_section **res)
420 char *newfname = NULL;
426 * If the fname starts with "~/" parse configuration file in the
427 * current users home directory. The behavior can be disabled and
428 * enabled by calling krb5_set_home_dir_access().
430 if (fname[0] == '~' && fname[1] == '/') {
431 #ifndef KRB5_USE_PATH_TOKENS
432 const char *home = NULL;
434 if (!_krb5_homedir_access(context)) {
435 krb5_set_error_message(context, EPERM,
436 "Access to home directory not allowed");
441 home = getenv("HOME");
444 struct passwd *pw = getpwuid(getuid());
449 asprintf(&newfname, "%s%s", home, &fname[1]);
450 if (newfname == NULL) {
451 krb5_set_error_message(context, ENOMEM,
452 N_("malloc: out of memory", ""));
457 #else /* KRB5_USE_PATH_TOKENS */
458 if (asprintf(&newfname, "%%{USERCONFIG}%s", &fname[1]) < 0 ||
461 krb5_set_error_message(context, ENOMEM,
462 N_("malloc: out of memory", ""));
469 if (is_plist_file(fname)) {
471 ret = parse_plist_config(context, fname, res);
473 krb5_set_error_message(context, ret,
474 "Failed to parse plist %s", fname);
480 krb5_set_error_message(context, ENOENT,
481 "no support for plist configuration files");
485 #ifdef KRB5_USE_PATH_TOKENS
486 char * exp_fname = NULL;
488 ret = _krb5_expand_path_tokens(context, fname, &exp_fname);
497 fname = newfname = exp_fname;
500 f.f = fopen(fname, "r");
504 krb5_set_error_message (context, ret, "open %s: %s",
505 fname, strerror(ret));
511 ret = krb5_config_parse_debug (&f, res, &lineno, &str);
514 krb5_set_error_message (context, ret, "%s:%u: %s",
524 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
525 krb5_config_parse_file (krb5_context context,
527 krb5_config_section **res)
530 return krb5_config_parse_file_multi(context, fname, res);
534 free_binding (krb5_context context, krb5_config_binding *b)
536 krb5_config_binding *next_b;
540 if (b->type == krb5_config_string)
542 else if (b->type == krb5_config_list)
543 free_binding (context, b->u.list);
545 krb5_abortx(context, "unknown binding type (%d) in free_binding",
554 * Free configuration file section, the result of
555 * krb5_config_parse_file() and krb5_config_parse_file_multi().
557 * @param context A Kerberos 5 context
558 * @param s the configuration section to free
560 * @return returns 0 on successes, otherwise an error code, see
561 * krb5_get_error_message()
563 * @ingroup krb5_support
566 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
567 krb5_config_file_free (krb5_context context, krb5_config_section *s)
569 free_binding (context, s);
573 #ifndef HEIMDAL_SMALLER
575 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
576 _krb5_config_copy(krb5_context context,
577 krb5_config_section *c,
578 krb5_config_section **head)
580 krb5_config_binding *d, *previous = NULL;
585 d = calloc(1, sizeof(*d));
590 d->name = strdup(c->name);
592 if (d->type == krb5_config_string)
593 d->u.string = strdup(c->u.string);
594 else if (d->type == krb5_config_list)
595 _krb5_config_copy (context, c->u.list, &d->u.list);
598 "unknown binding type (%d) in krb5_config_copy",
609 #endif /* HEIMDAL_SMALLER */
611 KRB5_LIB_FUNCTION const void * KRB5_LIB_CALL
612 _krb5_config_get_next (krb5_context context,
613 const krb5_config_section *c,
614 const krb5_config_binding **pointer,
621 va_start(args, type);
622 ret = _krb5_config_vget_next (context, c, pointer, type, args);
628 vget_next(krb5_context context,
629 const krb5_config_binding *b,
630 const krb5_config_binding **pointer,
635 const char *p = va_arg(args, const char *);
637 if(strcmp(b->name, name) == 0) {
638 if(b->type == type && p == NULL) {
641 } else if(b->type == krb5_config_list && p != NULL) {
642 return vget_next(context, b->u.list, pointer, type, p, args);
650 KRB5_LIB_FUNCTION const void * KRB5_LIB_CALL
651 _krb5_config_vget_next (krb5_context context,
652 const krb5_config_section *c,
653 const krb5_config_binding **pointer,
657 const krb5_config_binding *b;
666 if (*pointer == NULL) {
667 /* first time here, walk down the tree looking for the right
669 p = va_arg(args, const char *);
672 return vget_next(context, c, pointer, type, p, args);
675 /* we were called again, so just look for more entries with the
676 same name and type */
677 for (b = (*pointer)->next; b != NULL; b = b->next) {
678 if(strcmp(b->name, (*pointer)->name) == 0 && b->type == type) {
686 KRB5_LIB_FUNCTION const void * KRB5_LIB_CALL
687 _krb5_config_get (krb5_context context,
688 const krb5_config_section *c,
695 va_start(args, type);
696 ret = _krb5_config_vget (context, c, type, args);
703 _krb5_config_vget (krb5_context context,
704 const krb5_config_section *c,
708 const krb5_config_binding *foo = NULL;
710 return _krb5_config_vget_next (context, c, &foo, type, args);
714 * Get a list of configuration binding list for more processing
716 * @param context A Kerberos 5 context.
717 * @param c a configuration section, or NULL to use the section from context
718 * @param ... a list of names, terminated with NULL.
720 * @return NULL if configuration list is not found, a list otherwise
722 * @ingroup krb5_support
725 KRB5_LIB_FUNCTION const krb5_config_binding * KRB5_LIB_CALL
726 krb5_config_get_list (krb5_context context,
727 const krb5_config_section *c,
730 const krb5_config_binding *ret;
734 ret = krb5_config_vget_list (context, c, args);
740 * Get a list of configuration binding list for more processing
742 * @param context A Kerberos 5 context.
743 * @param c a configuration section, or NULL to use the section from context
744 * @param args a va_list of arguments
746 * @return NULL if configuration list is not found, a list otherwise
748 * @ingroup krb5_support
751 KRB5_LIB_FUNCTION const krb5_config_binding * KRB5_LIB_CALL
752 krb5_config_vget_list (krb5_context context,
753 const krb5_config_section *c,
756 return _krb5_config_vget (context, c, krb5_config_list, args);
760 * Returns a "const char *" to a string in the configuration database.
761 * The string may not be valid after a reload of the configuration
762 * database so a caller should make a local copy if it needs to keep
765 * @param context A Kerberos 5 context.
766 * @param c a configuration section, or NULL to use the section from context
767 * @param ... a list of names, terminated with NULL.
769 * @return NULL if configuration string not found, a string otherwise
771 * @ingroup krb5_support
774 KRB5_LIB_FUNCTION const char* KRB5_LIB_CALL
775 krb5_config_get_string (krb5_context context,
776 const krb5_config_section *c,
783 ret = krb5_config_vget_string (context, c, args);
789 * Like krb5_config_get_string(), but uses a va_list instead of ...
791 * @param context A Kerberos 5 context.
792 * @param c a configuration section, or NULL to use the section from context
793 * @param args a va_list of arguments
795 * @return NULL if configuration string not found, a string otherwise
797 * @ingroup krb5_support
800 KRB5_LIB_FUNCTION const char* KRB5_LIB_CALL
801 krb5_config_vget_string (krb5_context context,
802 const krb5_config_section *c,
805 return _krb5_config_vget (context, c, krb5_config_string, args);
809 * Like krb5_config_vget_string(), but instead of returning NULL,
810 * instead return a default value.
812 * @param context A Kerberos 5 context.
813 * @param c a configuration section, or NULL to use the section from context
814 * @param def_value the default value to return if no configuration
815 * found in the database.
816 * @param args a va_list of arguments
818 * @return a configuration string
820 * @ingroup krb5_support
823 KRB5_LIB_FUNCTION const char* KRB5_LIB_CALL
824 krb5_config_vget_string_default (krb5_context context,
825 const krb5_config_section *c,
826 const char *def_value,
831 ret = krb5_config_vget_string (context, c, args);
838 * Like krb5_config_get_string(), but instead of returning NULL,
839 * instead return a default value.
841 * @param context A Kerberos 5 context.
842 * @param c a configuration section, or NULL to use the section from context
843 * @param def_value the default value to return if no configuration
844 * found in the database.
845 * @param ... a list of names, terminated with NULL.
847 * @return a configuration string
849 * @ingroup krb5_support
852 KRB5_LIB_FUNCTION const char* KRB5_LIB_CALL
853 krb5_config_get_string_default (krb5_context context,
854 const krb5_config_section *c,
855 const char *def_value,
861 va_start(args, def_value);
862 ret = krb5_config_vget_string_default (context, c, def_value, args);
868 next_component_string(char * begin, char * delims, char **state)
879 while (*end == '"') {
880 char * t = strchr(end + 1, '"');
891 pos = strcspn(end, delims);
898 if (*begin == '"' && *(end - 1) == '"' && begin + 1 < end) {
899 begin++; *(end - 1) = '\0';
905 if (*begin == '"' && *(end - 1) == '"' && begin + 1 < end) {
906 begin++; *(end - 1) = '\0';
912 * Get a list of configuration strings, free the result with
913 * krb5_config_free_strings().
915 * @param context A Kerberos 5 context.
916 * @param c a configuration section, or NULL to use the section from context
917 * @param args a va_list of arguments
919 * @return TRUE or FALSE
921 * @ingroup krb5_support
924 KRB5_LIB_FUNCTION char ** KRB5_LIB_CALL
925 krb5_config_vget_strings(krb5_context context,
926 const krb5_config_section *c,
929 char **strings = NULL;
931 const krb5_config_binding *b = NULL;
934 while((p = _krb5_config_vget_next(context, c, &b,
935 krb5_config_string, args))) {
936 char *tmp = strdup(p);
941 s = next_component_string(tmp, " \t", &pos);
943 char **tmp2 = realloc(strings, (nstr + 1) * sizeof(*strings));
947 strings[nstr] = strdup(s);
949 if(strings[nstr-1] == NULL)
951 s = next_component_string(NULL, " \t", &pos);
956 char **tmp = realloc(strings, (nstr + 1) * sizeof(*strings));
960 strings[nstr] = NULL;
972 * Get a list of configuration strings, free the result with
973 * krb5_config_free_strings().
975 * @param context A Kerberos 5 context.
976 * @param c a configuration section, or NULL to use the section from context
977 * @param ... a list of names, terminated with NULL.
979 * @return TRUE or FALSE
981 * @ingroup krb5_support
984 KRB5_LIB_FUNCTION char** KRB5_LIB_CALL
985 krb5_config_get_strings(krb5_context context,
986 const krb5_config_section *c,
992 ret = krb5_config_vget_strings(context, c, ap);
998 * Free the resulting strings from krb5_config-get_strings() and
999 * krb5_config_vget_strings().
1001 * @param strings strings to free
1003 * @ingroup krb5_support
1006 KRB5_LIB_FUNCTION void KRB5_LIB_CALL
1007 krb5_config_free_strings(char **strings)
1018 * Like krb5_config_get_bool_default() but with a va_list list of
1019 * configuration selection.
1021 * Configuration value to a boolean value, where yes/true and any
1022 * non-zero number means TRUE and other value is FALSE.
1024 * @param context A Kerberos 5 context.
1025 * @param c a configuration section, or NULL to use the section from context
1026 * @param def_value the default value to return if no configuration
1027 * found in the database.
1028 * @param args a va_list of arguments
1030 * @return TRUE or FALSE
1032 * @ingroup krb5_support
1035 KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
1036 krb5_config_vget_bool_default (krb5_context context,
1037 const krb5_config_section *c,
1038 krb5_boolean def_value,
1042 str = krb5_config_vget_string (context, c, args);
1045 if(strcasecmp(str, "yes") == 0 ||
1046 strcasecmp(str, "true") == 0 ||
1047 atoi(str)) return TRUE;
1052 * krb5_config_get_bool() will convert the configuration
1053 * option value to a boolean value, where yes/true and any non-zero
1054 * number means TRUE and other value is FALSE.
1056 * @param context A Kerberos 5 context.
1057 * @param c a configuration section, or NULL to use the section from context
1058 * @param args a va_list of arguments
1060 * @return TRUE or FALSE
1062 * @ingroup krb5_support
1065 KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
1066 krb5_config_vget_bool (krb5_context context,
1067 const krb5_config_section *c,
1070 return krb5_config_vget_bool_default (context, c, FALSE, args);
1074 * krb5_config_get_bool_default() will convert the configuration
1075 * option value to a boolean value, where yes/true and any non-zero
1076 * number means TRUE and other value is FALSE.
1078 * @param context A Kerberos 5 context.
1079 * @param c a configuration section, or NULL to use the section from context
1080 * @param def_value the default value to return if no configuration
1081 * found in the database.
1082 * @param ... a list of names, terminated with NULL.
1084 * @return TRUE or FALSE
1086 * @ingroup krb5_support
1089 KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
1090 krb5_config_get_bool_default (krb5_context context,
1091 const krb5_config_section *c,
1092 krb5_boolean def_value,
1097 va_start(ap, def_value);
1098 ret = krb5_config_vget_bool_default(context, c, def_value, ap);
1104 * Like krb5_config_get_bool() but with a va_list list of
1105 * configuration selection.
1107 * Configuration value to a boolean value, where yes/true and any
1108 * non-zero number means TRUE and other value is FALSE.
1110 * @param context A Kerberos 5 context.
1111 * @param c a configuration section, or NULL to use the section from context
1112 * @param ... a list of names, terminated with NULL.
1114 * @return TRUE or FALSE
1116 * @ingroup krb5_support
1119 KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
1120 krb5_config_get_bool (krb5_context context,
1121 const krb5_config_section *c,
1127 ret = krb5_config_vget_bool (context, c, ap);
1133 * Get the time from the configuration file using a relative time.
1135 * Like krb5_config_get_time_default() but with a va_list list of
1136 * configuration selection.
1138 * @param context A Kerberos 5 context.
1139 * @param c a configuration section, or NULL to use the section from context
1140 * @param def_value the default value to return if no configuration
1141 * found in the database.
1142 * @param args a va_list of arguments
1144 * @return parsed the time (or def_value on parse error)
1146 * @ingroup krb5_support
1149 KRB5_LIB_FUNCTION int KRB5_LIB_CALL
1150 krb5_config_vget_time_default (krb5_context context,
1151 const krb5_config_section *c,
1158 str = krb5_config_vget_string (context, c, args);
1161 if (krb5_string_to_deltat(str, &t))
1167 * Get the time from the configuration file using a relative time, for example: 1h30s
1169 * @param context A Kerberos 5 context.
1170 * @param c a configuration section, or NULL to use the section from context
1171 * @param args a va_list of arguments
1173 * @return parsed the time or -1 on error
1175 * @ingroup krb5_support
1178 KRB5_LIB_FUNCTION int KRB5_LIB_CALL
1179 krb5_config_vget_time (krb5_context context,
1180 const krb5_config_section *c,
1183 return krb5_config_vget_time_default (context, c, -1, args);
1187 * Get the time from the configuration file using a relative time, for example: 1h30s
1189 * @param context A Kerberos 5 context.
1190 * @param c a configuration section, or NULL to use the section from context
1191 * @param def_value the default value to return if no configuration
1192 * found in the database.
1193 * @param ... a list of names, terminated with NULL.
1195 * @return parsed the time (or def_value on parse error)
1197 * @ingroup krb5_support
1200 KRB5_LIB_FUNCTION int KRB5_LIB_CALL
1201 krb5_config_get_time_default (krb5_context context,
1202 const krb5_config_section *c,
1208 va_start(ap, def_value);
1209 ret = krb5_config_vget_time_default(context, c, def_value, ap);
1215 * Get the time from the configuration file using a relative time, for example: 1h30s
1217 * @param context A Kerberos 5 context.
1218 * @param c a configuration section, or NULL to use the section from context
1219 * @param ... a list of names, terminated with NULL.
1221 * @return parsed the time or -1 on error
1223 * @ingroup krb5_support
1226 KRB5_LIB_FUNCTION int KRB5_LIB_CALL
1227 krb5_config_get_time (krb5_context context,
1228 const krb5_config_section *c,
1234 ret = krb5_config_vget_time (context, c, ap);
1240 KRB5_LIB_FUNCTION int KRB5_LIB_CALL
1241 krb5_config_vget_int_default (krb5_context context,
1242 const krb5_config_section *c,
1247 str = krb5_config_vget_string (context, c, args);
1253 l = strtol(str, &endptr, 0);
1261 KRB5_LIB_FUNCTION int KRB5_LIB_CALL
1262 krb5_config_vget_int (krb5_context context,
1263 const krb5_config_section *c,
1266 return krb5_config_vget_int_default (context, c, -1, args);
1269 KRB5_LIB_FUNCTION int KRB5_LIB_CALL
1270 krb5_config_get_int_default (krb5_context context,
1271 const krb5_config_section *c,
1277 va_start(ap, def_value);
1278 ret = krb5_config_vget_int_default(context, c, def_value, ap);
1283 KRB5_LIB_FUNCTION int KRB5_LIB_CALL
1284 krb5_config_get_int (krb5_context context,
1285 const krb5_config_section *c,
1291 ret = krb5_config_vget_int (context, c, ap);
1297 #ifndef HEIMDAL_SMALLER
1300 * Deprecated: configuration files are not strings
1302 * @ingroup krb5_deprecated
1306 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
1307 krb5_config_parse_string_multi(krb5_context context,
1309 krb5_config_section **res)
1312 unsigned lineno = 0;
1313 krb5_error_code ret;
1318 ret = krb5_config_parse_debug (&f, res, &lineno, &str);
1320 krb5_set_error_message (context, ret, "%s:%u: %s",
1321 "<constant>", lineno, str);