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

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