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

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