]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix creation/rename of top-level profile sections
authorGreg Hudson <ghudson@mit.edu>
Wed, 16 Jul 2014 20:30:26 +0000 (16:30 -0400)
committerTom Yu <tlyu@mit.edu>
Thu, 7 Aug 2014 22:09:07 +0000 (18:09 -0400)
profile_rename_section should demand only one name.

profile_add_relation should demand only one name if it is creating a
new section.  It aso needs to reset state before calling
profile_find_node for the section, in case it didn't look up any
parent sections previously.

(cherry picked from commit 590df2f41f84e0f9492e08f7dbd26fbcd3118ea0)

ticket: 7972
version_fixed: 1.12.2
status: resolved

src/util/profile/prof_set.c

index b21023681bba05a188466cbb80c6e15af1d4efd2..af4b2f853fbf259627fc7e03e4d803cfb9cd265b 100644 (file)
@@ -207,7 +207,7 @@ profile_rename_section(profile_t profile, const char **names,
     if (retval)
         return retval;
 
-    if (names == 0 || names[0] == 0 || names[1] == 0)
+    if (names == 0 || names[0] == 0)
         return PROF_BAD_NAMESET;
 
     k5_mutex_lock(&profile->first_file->data->lock);
@@ -264,7 +264,8 @@ profile_add_relation(profile_t profile, const char **names,
     if (retval)
         return retval;
 
-    if (names == 0 || names[0] == 0 || names[1] == 0)
+    /* Require at least two names for a new relation, one for a new section. */
+    if (names == 0 || names[0] == 0 || (names[1] == 0 && new_value))
         return PROF_BAD_NAMESET;
 
     k5_mutex_lock(&profile->first_file->data->lock);
@@ -282,6 +283,7 @@ profile_add_relation(profile_t profile, const char **names,
     }
 
     if (new_value == 0) {
+        state = 0;
         retval = profile_find_node(section, *cpp, 0, 1, &state, 0);
         if (retval == 0) {
             k5_mutex_unlock(&profile->first_file->data->lock);