]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Make profile includedir accept all *.conf files
authorPeter Jones <pjones@redhat.com>
Fri, 26 Feb 2016 14:49:58 +0000 (09:49 -0500)
committerGreg Hudson <ghudson@mit.edu>
Thu, 24 Mar 2016 20:35:42 +0000 (16:35 -0400)
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)

doc/admin/conf_files/krb5_conf.rst
src/man/krb5.conf.man
src/util/profile/prof_parse.c
src/util/profile/prof_test1

index bf7d2407bd13e9590a916b0c39892986c161df3d..b31ddff6fce0ff4671b5bb7969bb7fbf334bda8f 100644 (file)
@@ -54,9 +54,10 @@ following directives at the beginning of a line::
 *FILENAME* or *DIRNAME* should be an absolute path. The named file or
 directory must exist and be readable.  Including a directory includes
 all files within the directory whose names consist solely of
-alphanumeric characters, dashes, or underscores.  Included profile
-files are syntactically independent of their parents, so each included
-file must begin with a section header.
+alphanumeric characters, dashes, or underscores.  Starting in release
+1.15, files with names ending in ".conf" are also included.  Included
+profile files are syntactically independent of their parents, so each
+included file must begin with a section header.
 
 The krb5.conf file can specify that configuration should be obtained
 from a loadable module, rather than the file itself, using the
index a4b30e941465c839840067397d66da360e923092..e035072cd97c1f641311b7ee8e9e27e332acc92c 100644 (file)
@@ -111,9 +111,10 @@ includedir DIRNAME
 \fIFILENAME\fP or \fIDIRNAME\fP should be an absolute path. The named file or
 directory must exist and be readable.  Including a directory includes
 all files within the directory whose names consist solely of
-alphanumeric characters, dashes, or underscores.  Included profile
-files are syntactically independent of their parents, so each included
-file must begin with a section header.
+alphanumeric characters, dashes, or underscores, or any filename
+ending in ".conf".  Included profile files are syntactically
+independent of their parents, so each included file must begin with a
+section header.
 .sp
 The krb5.conf file can specify that configuration should be obtained
 from a loadable module, rather than the file itself, using the
index 1c2a270cbeee2172cf15320e0f7c8128d14608eb..e7c1f65aa09f3506ba66f266d9be725d1f7ef0cc 100644 (file)
@@ -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)
index 87368d83d0480ea0441ab56b497a1eeefd592d6f..d0bb1877fc6d0d4c0302394fdebaa434a42ec402 100644 (file)
@@ -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]