svn rev #24256: trunk/ doc/ src/config-files/ src/util/profile/

ghudson@MIT.EDU ghudson at MIT.EDU
Wed Aug 25 14:22:53 EDT 2010


http://src.mit.edu/fisheye/changelog/krb5/?cs=24256
Commit By: ghudson
Log Message:
ticket: 6761

Revise the profile include design so that included files are
syntactically independent of parent files.



Changed Files:
U   trunk/doc/krb5conf.texinfo
U   trunk/src/config-files/krb5.conf.M
U   trunk/src/util/profile/prof_parse.c
U   trunk/src/util/profile/prof_test1
Modified: trunk/doc/krb5conf.texinfo
===================================================================
--- trunk/doc/krb5conf.texinfo	2010-08-24 22:57:40 UTC (rev 24255)
+++ trunk/doc/krb5conf.texinfo	2010-08-25 18:22:53 UTC (rev 24256)
@@ -51,8 +51,9 @@
 @var{FILENAME} or @var{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 configuration
-fragments should begin with a section header.
+alphanumeric characters, dashes, or underscores.  Included profile files
+are syntactically independent of their parents, so each included file
+must begin with a section header.
 
 The @code{krb5.conf} file may contain any or all of the following 
 sections:

Modified: trunk/src/config-files/krb5.conf.M
===================================================================
--- trunk/src/config-files/krb5.conf.M	2010-08-24 22:57:40 UTC (rev 24255)
+++ trunk/src/config-files/krb5.conf.M	2010-08-25 18:22:53 UTC (rev 24256)
@@ -67,7 +67,8 @@
 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
-fragments should begin with a section header.
+files are syntactically independent of their parents, so each included
+file must begin with a section header.
 
 .PP
 The following sections are currently used in the 

Modified: trunk/src/util/profile/prof_parse.c
===================================================================
--- trunk/src/util/profile/prof_parse.c	2010-08-24 22:57:40 UTC (rev 24255)
+++ trunk/src/util/profile/prof_parse.c	2010-08-25 18:22:53 UTC (rev 24256)
@@ -70,14 +70,6 @@
 }
 
 
-static errcode_t parse_init_state(struct parse_state *state)
-{
-    state->state = STATE_INIT_COMMENT;
-    state->group_level = 0;
-
-    return profile_create_node("(root)", 0, &state->root_section);
-}
-
 static errcode_t parse_std_line(char *line, struct parse_state *state)
 {
     char    *cp, ch, *tag, *value;
@@ -205,16 +197,24 @@
     return 0;
 }
 
-/* Parse lines from filename as if they were part of the profile file. */
+/* Open and parse an included profile file. */
 static errcode_t parse_include_file(char *filename, struct parse_state *state)
 {
     FILE    *fp;
     errcode_t retval = 0;
+    struct parse_state incstate;
 
+    /* Create a new state so that fragments are syntactically independent,
+     * sharing the root section with the existing state. */
+    incstate.state = STATE_INIT_COMMENT;
+    incstate.group_level = 0;
+    incstate.root_section = state->root_section;
+    incstate.current_section = NULL;
+
     fp = fopen(filename, "r");
     if (fp == NULL)
         return PROF_FAIL_INCLUDE_FILE;
-    retval = parse_file(fp, state);
+    retval = parse_file(fp, &incstate);
     fclose(fp);
     return retval;
 }
@@ -233,10 +233,9 @@
 }
 
 /*
- * Parse lines from files in dirname as if they were part of the profile file.
- * Only files with names consisting entirely of alphanumeric chracters and
- * underscores are parsed, in order to avoid parsing editor backup files,
- * .rpmsave files, and the like.
+ * 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.
  */
 static errcode_t parse_include_dir(char *dirname, struct parse_state *state)
 {
@@ -371,9 +370,15 @@
     errcode_t retval;
 
     *root = NULL;
-    retval = parse_init_state(&state);
+
+    /* Initialize parsing state with a new root node. */
+    state.state = STATE_INIT_COMMENT;
+    state.group_level = 0;
+    state.current_section = NULL;
+    retval = profile_create_node("(root)", 0, &state.root_section);
     if (retval)
         return retval;
+
     retval = parse_file(f, &state);
     if (retval) {
         profile_free_node(state.root_section);

Modified: trunk/src/util/profile/prof_test1
===================================================================
--- trunk/src/util/profile/prof_test1	2010-08-24 22:57:40 UTC (rev 24255)
+++ trunk/src/util/profile/prof_test1	2010-08-25 18:22:53 UTC (rev 24256)
@@ -203,9 +203,41 @@
     puts "OK: test4: include and includedir directives"
 }
 
+proc test5 {} {
+    global wd verbose
+
+    # Test syntactic independence of included profile files.
+    catch [file delete $wd/testinc.ini]
+    set f [open "$wd/testinc.ini" w]
+    puts $f {[sec1]}
+    puts $f "var = {"
+    puts $f "a = 1"
+    puts $f "include testinc2.ini"
+    puts $f "c = 3"
+    puts $f "}"
+    close $f
+    catch [file delete $wd/testinc2.ini]
+    set f [open "$wd/testinc2.ini" w]
+    puts $f {[sec2]}
+    puts $f "b = 2"
+    close $f
+    set p [profile_init_path $wd/testinc.ini]
+    set a [profile_get_values $p {sec1 var a}]
+    set b [profile_get_values $p {sec2 b}]
+    set c [profile_get_values $p {sec1 var c}]
+    if $verbose { puts "Read values [concat $a $b $c] from profile" }
+    if { $a != 1 || $b != 2 || $c != 3 } {
+	puts stderr, "Error: test5: Wrong results from profile"
+	exit 1
+    }
+
+    puts "OK: test5: syntax independence of included files"
+}
+
 test1
 test2
 test3
 test4
+test5
 
 exit 0




More information about the cvs-krb5 mailing list