Blame SOURCES/0023-Krb5-improve-dbmodules-and-includes-630.patch

084415
From 88cde0890c817bb66a64e32f970a7e6aa0cf53cf Mon Sep 17 00:00:00 2001
9f41aa
From: Pino Toscano <ptoscano@redhat.com>
9f41aa
Date: Tue, 4 Feb 2020 17:54:22 +0100
9f41aa
Subject: [PATCH] Krb5: improve [dbmodules] and includes (#630)
9f41aa
9f41aa
* Krb5: fix/revamp parsing of [dbmodules] subsection
9f41aa
9f41aa
The [dbmodules] subsection so far was parsed much like the [dbdefaults]
9f41aa
one, and thus it did not handle realms.
9f41aa
9f41aa
Revamp it a bit to handle realms, and specify the only keyword not in
9f41aa
realm subsections.
9f41aa
9f41aa
* Krb5: allow include/includedir directives everywhere
9f41aa
9f41aa
MIT Kerberos allows this, so do not restrict them only before any other
9f41aa
section.
9f41aa
---
9f41aa
 lenses/krb5.aug            | 27 +++++++++++++++++++--------
9f41aa
 lenses/tests/test_krb5.aug | 36 +++++++++++++++++++++++++++++++++++-
9f41aa
 2 files changed, 54 insertions(+), 9 deletions(-)
9f41aa
9f41aa
diff --git a/lenses/krb5.aug b/lenses/krb5.aug
9f41aa
index 46c22656..6b509c42 100644
9f41aa
--- a/lenses/krb5.aug
9f41aa
+++ b/lenses/krb5.aug
9f41aa
@@ -21,10 +21,11 @@ let closebr = del /[ \t]*\}/ "}"
9f41aa
    and realms in the [appdefaults] section.
9f41aa
 *)
9f41aa
 
9f41aa
+let include_re = /include(dir)?/
9f41aa
 let realm_re = /[A-Z0-9][.a-zA-Z0-9-]*/
9f41aa
 let realm_anycase_re = /[A-Za-z0-9][.a-zA-Z0-9-]*/
9f41aa
 let app_re = /[a-z][a-zA-Z0-9_]*/
9f41aa
-let name_re = /[.a-zA-Z0-9_-]+/
9f41aa
+let name_re = /[.a-zA-Z0-9_-]+/ - include_re
9f41aa
 
9f41aa
 let value_br = store /[^;# \t\r\n{}]+/
9f41aa
 let value = store /[^;# \t\r\n]+/
9f41aa
@@ -130,10 +131,19 @@ let dbdefaults =
9f41aa
     simple_section "dbdefaults" keys
9f41aa
 
9f41aa
 let dbmodules =
9f41aa
-  let keys = /db_library|ldap_kerberos_container_dn|ldap_kdc_dn/
9f41aa
-    |/ldap_kadmind_dn|ldap_service_password_file|ldap_servers/
9f41aa
-    |/ldap_conns_per_server/ in
9f41aa
-    simple_section "dbmodules" keys
9f41aa
+  let subsec_key = /database_name|db_library|disable_last_success/
9f41aa
+    |/disable_lockout|ldap_conns_per_server|ldap_(kdc|kadmind)_dn/
9f41aa
+    |/ldap_(kdc|kadmind)_sasl_mech|ldap_(kdc|kadmind)_sasl_authcid/
9f41aa
+    |/ldap_(kdc|kadmind)_sasl_authzid|ldap_(kdc|kadmind)_sasl_realm/
9f41aa
+    |/ldap_kerberos_container_dn|ldap_servers/
9f41aa
+    |/ldap_service_password_file|mapsize|max_readers|nosync/
9f41aa
+    |/unlockiter/ in
9f41aa
+  let subsec_option = subsec_entry subsec_key eq comment in
9f41aa
+  let key = /db_module_dir/ in
9f41aa
+  let option = entry key eq value comment in
9f41aa
+  let realm = [ indent . label "realm" . store realm_re .
9f41aa
+                  eq_openbr . (subsec_option)* . closebr . eol ] in
9f41aa
+    record "dbmodules" (option|realm)
9f41aa
 
9f41aa
 (* This section is not documented in the krb5.conf manpage,
9f41aa
    but the Fermi example uses it. *)
9f41aa
@@ -152,11 +162,12 @@ let kdc =
9f41aa
 let pam =
9f41aa
   simple_section "pam" name_re
9f41aa
 
9f41aa
-let includes = Build.key_value_line /include(dir)?/ Sep.space (store Rx.fspath)
9f41aa
+let includes = Build.key_value_line include_re Sep.space (store Rx.fspath)
9f41aa
+let include_lines = includes . (comment|empty)*
9f41aa
 
9f41aa
-let lns = (comment|empty|includes)* .
9f41aa
+let lns = (comment|empty)* .
9f41aa
   (libdefaults|login|appdefaults|realms|domain_realm
9f41aa
-  |logging|capaths|dbdefaults|dbmodules|instance_mapping|kdc|pam)*
9f41aa
+  |logging|capaths|dbdefaults|dbmodules|instance_mapping|kdc|pam|include_lines)*
9f41aa
 
9f41aa
 let filter = (incl "/etc/krb5.conf.d/*.conf")
9f41aa
            . (incl "/etc/krb5.conf")
9f41aa
diff --git a/lenses/tests/test_krb5.aug b/lenses/tests/test_krb5.aug
9f41aa
index f746543b..10b87605 100644
9f41aa
--- a/lenses/tests/test_krb5.aug
9f41aa
+++ b/lenses/tests/test_krb5.aug
9f41aa
@@ -1029,7 +1029,7 @@ default_ccache_name = KEYRING:persistent:%{uid}\n" =
9f41aa
     {  }
9f41aa
     { "default_ccache_name" = "KEYRING:persistent:%{uid}" } }
9f41aa
 
9f41aa
-(* Include(dir) test *)
9f41aa
+(* Include(dir) tests *)
9f41aa
 let include_test = "include /etc/krb5.other_conf.d/other.conf
9f41aa
 includedir /etc/krb5.conf.d/
9f41aa
 "
9f41aa
@@ -1037,3 +1037,37 @@ includedir /etc/krb5.conf.d/
9f41aa
 test Krb5.lns get include_test =
9f41aa
   { "include" = "/etc/krb5.other_conf.d/other.conf" }
9f41aa
   { "includedir" = "/etc/krb5.conf.d/" }
9f41aa
+
9f41aa
+let include2_test = "[logging]
9f41aa
+ default = FILE:/var/log/krb5libs.log
9f41aa
+
9f41aa
+include /etc/krb5.other_conf.d/other.conf
9f41aa
+
9f41aa
+includedir /etc/krb5.conf.d/
9f41aa
+"
9f41aa
+
9f41aa
+test Krb5.lns get include2_test =
9f41aa
+  { "logging"
9f41aa
+    { "default"
9f41aa
+      { "file" = "/var/log/krb5libs.log" } }
9f41aa
+    {  }
9f41aa
+  }
9f41aa
+  { "include" = "/etc/krb5.other_conf.d/other.conf" }
9f41aa
+  {  }
9f41aa
+  { "includedir" = "/etc/krb5.conf.d/" }
9f41aa
+
9f41aa
+(* [dbmodules] test *)
9f41aa
+let dbmodules_test = "[dbmodules]
9f41aa
+    ATHENA.MIT.EDU = {
9f41aa
+        disable_last_success = true
9f41aa
+    }
9f41aa
+    db_module_dir = /some/path
9f41aa
+"
9f41aa
+
9f41aa
+test Krb5.lns get dbmodules_test =
9f41aa
+  { "dbmodules"
9f41aa
+    { "realm" = "ATHENA.MIT.EDU"
9f41aa
+      { "disable_last_success" = "true" }
9f41aa
+    }
9f41aa
+    { "db_module_dir" = "/some/path" }
9f41aa
+  }
9f41aa
-- 
9f41aa
2.24.1
9f41aa