allow parsing of more than one file
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11098 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -39,10 +39,13 @@ RCSID("$Id$");
|
|||||||
|
|
||||||
/* verify krb5.conf */
|
/* verify krb5.conf */
|
||||||
|
|
||||||
|
static int dumpconfig_flag = 0;
|
||||||
static int version_flag = 0;
|
static int version_flag = 0;
|
||||||
static int help_flag = 0;
|
static int help_flag = 0;
|
||||||
|
|
||||||
static struct getargs args[] = {
|
static struct getargs args[] = {
|
||||||
|
{"dumpconfig", 0, arg_flag, &dumpconfig_flag,
|
||||||
|
"show the parsed config files", NULL },
|
||||||
{"version", 0, arg_flag, &version_flag,
|
{"version", 0, arg_flag, &version_flag,
|
||||||
"print version", NULL },
|
"print version", NULL },
|
||||||
{"help", 0, arg_flag, &help_flag,
|
{"help", 0, arg_flag, &help_flag,
|
||||||
@@ -447,7 +450,7 @@ check_section(krb5_context context, const char *path, krb5_config_section *cf,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dump_config(int level, krb5_config_section *top)
|
dumpconfig(int level, krb5_config_section *top)
|
||||||
{
|
{
|
||||||
krb5_config_section *x;
|
krb5_config_section *x;
|
||||||
for(x = top; x; x = x->next) {
|
for(x = top; x; x = x->next) {
|
||||||
@@ -458,9 +461,9 @@ dump_config(int level, krb5_config_section *top)
|
|||||||
} else {
|
} else {
|
||||||
printf("%*s%s = {\n", 4 * level, " ", x->name);
|
printf("%*s%s = {\n", 4 * level, " ", x->name);
|
||||||
}
|
}
|
||||||
dump_config(level + 1, x->u.list);
|
dumpconfig(level + 1, x->u.list);
|
||||||
if(level > 0)
|
if(level > 0)
|
||||||
printf("%*s}\n", 4 * level);
|
printf("%*s}\n", 4 * level, " ");
|
||||||
break;
|
break;
|
||||||
case krb5_config_string:
|
case krb5_config_string:
|
||||||
printf("%*s%s = %s\n", 4 * level, " ", x->name, x->u.string);
|
printf("%*s%s = %s\n", 4 * level, " ", x->name, x->u.string);
|
||||||
@@ -473,11 +476,10 @@ int
|
|||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
krb5_context context;
|
krb5_context context;
|
||||||
const char *config_file = NULL;
|
|
||||||
krb5_error_code ret;
|
krb5_error_code ret;
|
||||||
krb5_config_section *tmp_cf;
|
krb5_config_section *tmp_cf;
|
||||||
int optind = 0;
|
int optind = 0;
|
||||||
int dump_config_file = 1;
|
int i;
|
||||||
|
|
||||||
setprogname (argv[0]);
|
setprogname (argv[0]);
|
||||||
|
|
||||||
@@ -499,24 +501,21 @@ main(int argc, char **argv)
|
|||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
if (argc == 0) {
|
tmp_cf = NULL;
|
||||||
config_file = getenv("KRB5_CONFIG");
|
if(argc == 0)
|
||||||
if (config_file == NULL)
|
krb5_get_default_config_files(&argv);
|
||||||
config_file = krb5_config_file;
|
|
||||||
} else if (argc == 1) {
|
while(*argv) {
|
||||||
config_file = argv[0];
|
ret = krb5_config_parse_file_multi(context, *argv, &tmp_cf);
|
||||||
} else {
|
if (ret != 0) {
|
||||||
usage (1);
|
krb5_warn (context, ret, "krb5_config_parse_file");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
argv++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(dumpconfig_flag)
|
||||||
|
dumpconfig(0, tmp_cf);
|
||||||
|
|
||||||
ret = krb5_config_parse_file (context, config_file, &tmp_cf);
|
|
||||||
if (ret != 0) {
|
|
||||||
krb5_warn (context, ret, "krb5_config_parse_file");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dump_config_file)
|
|
||||||
dump_config(0, tmp_cf);
|
|
||||||
|
|
||||||
return check_section(context, "", tmp_cf, toplevel_sections);
|
return check_section(context, "", tmp_cf, toplevel_sections);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user