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

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