diff options
author | Peter Jones <pjones@redhat.com> | 2016-02-26 09:49:58 -0500 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2016-03-24 16:35:42 -0400 |
commit | 0744026f06e8cbf477aa49cfe16b5fd28a9ddc9e (patch) | |
tree | 059bffc829af9fc24d847c42019daef9d0e38c40 /src/util | |
parent | 624476e0350cde6c37078a808c7b6bceb6046c53 (diff) | |
download | krb5-0744026f06e8cbf477aa49cfe16b5fd28a9ddc9e.zip krb5-0744026f06e8cbf477aa49cfe16b5fd28a9ddc9e.tar.gz krb5-0744026f06e8cbf477aa49cfe16b5fd28a9ddc9e.tar.bz2 |
Make profile includedir accept all *.conf files
Since the main config file is krb5.conf, it is intuitive to name
included files with a ".conf" extension; currently such files are
silently ignored. Accept filenames ending in ".conf" as well as files
with no special characters.
[ghudson@mit.edu: shorten commit message and comment; accept the
filename ".conf" itself for simplicity; add a test; adjust
documentation change to note that allowing .conf is new in 1.15]
ticket: 8389 (new)
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/profile/prof_parse.c | 13 | ||||
-rw-r--r-- | src/util/profile/prof_test1 | 9 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/util/profile/prof_parse.c b/src/util/profile/prof_parse.c index 1c2a270..e7c1f65 100644 --- a/src/util/profile/prof_parse.c +++ b/src/util/profile/prof_parse.c @@ -222,10 +222,14 @@ static errcode_t parse_include_file(const char *filename, } /* Return non-zero if filename contains only alphanumeric characters, dashes, - * and underscores. */ + * and underscores, or if the filename ends in ".conf". */ static int valid_name(const char *filename) { const char *p; + size_t len = strlen(filename); + + if (len >= 5 && !strcmp(filename + len - 5, ".conf")) + return 1; for (p = filename; *p != '\0'; p++) { if (!isalnum((unsigned char)*p) && *p != '-' && *p != '_') @@ -235,9 +239,10 @@ static int valid_name(const char *filename) } /* - * Include files within dirname. Only files with names consisting entirely of - * alphanumeric chracters, dashes, and underscores are included, in order to - * avoid including editor backup files, .rpmsave files, and the like. + * Include files within dirname. Only files with names ending in ".conf", or + * consisting entirely of alphanumeric characters, dashes, and underscores are + * included. This restriction avoids including editor backup files, .rpmsave + * files, and the like. */ static errcode_t parse_include_dir(const char *dirname, struct profile_node *root_section) diff --git a/src/util/profile/prof_test1 b/src/util/profile/prof_test1 index 87368d8..d0bb187 100644 --- a/src/util/profile/prof_test1 +++ b/src/util/profile/prof_test1 @@ -183,12 +183,15 @@ proc test4 {} { } profile_release $p - # Test including a directory. (Put two copies of test2.ini inside - # it and check that we get two values for one of the variables.) + # Test including a directory. Put four copies of test2.ini inside + # the directory, two with invalid names. Check that we get two + # values for one of the variables. catch [file delete -force $wd/test_include_dir] exec mkdir $wd/test_include_dir exec cp $wd/test2.ini $wd/test_include_dir/a - exec cp $wd/test2.ini $wd/test_include_dir/b + exec cp $wd/test2.ini $wd/test_include_dir/a~ + exec cp $wd/test2.ini $wd/test_include_dir/b.conf + exec cp $wd/test2.ini $wd/test_include_dir/b.conf.rpmsave catch [file delete $wd/testinc.ini] exec echo "includedir $wd/test_include_dir" >$wd/testinc.ini set p [profile_init_path $wd/testinc.ini] |