Blame SOURCES/0008-Slapd-revert-Slapd-module-to-1.1.0-compatible-add-Sl.patch

3b98a7
From faf60bc7b1cb727482a17de9a2483998763978c0 Mon Sep 17 00:00:00 2001
3b98a7
From: Dominic Cleal <dcleal@redhat.com>
3b98a7
Date: Fri, 12 Jun 2015 11:14:32 +0100
3b98a7
Subject: [PATCH] Slapd: revert Slapd module to 1.1.0-compatible, add Slapd_140
3b98a7
3b98a7
In order to keep the default sshd config lens compatible with 1.1.0,
3b98a7
the lens from 1.4.0 has been kept in the Slapd_140 module and is not
3b98a7
loaded by default.  Use aug_transform, augtool --transform etc. to use
3b98a7
it instead of Slapd.
3b98a7
---
3b98a7
 lenses/slapd.aug                |  18 ++--
3b98a7
 lenses/slapd_140.aug            | 158 ++++++++++++++++++++++++++++++++
3b98a7
 lenses/tests/test_slapd.aug     |  55 +++--------
3b98a7
 lenses/tests/test_slapd_140.aug |  94 +++++++++++++++++++
3b98a7
 tests/Makefile.am               |   1 +
3b98a7
 5 files changed, 273 insertions(+), 53 deletions(-)
3b98a7
 create mode 100644 lenses/slapd_140.aug
3b98a7
 create mode 100644 lenses/tests/test_slapd_140.aug
3b98a7
3b98a7
diff --git a/lenses/slapd.aug b/lenses/slapd.aug
3b98a7
index e1195655..afe074b1 100644
3b98a7
--- a/lenses/slapd.aug
3b98a7
+++ b/lenses/slapd.aug
3b98a7
@@ -18,6 +18,7 @@ let sep         = del /[ \t\n]+/ " "
3b98a7
 
3b98a7
 let sto_to_eol  = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
3b98a7
 let sto_to_spc  = store /[^\\# \t\n]+/
3b98a7
+let sto_to_by   = store (/[^\\# \t\n]+/ - "by")
3b98a7
 
3b98a7
 let comment     = Util.comment
3b98a7
 let empty       = Util.empty
3b98a7
@@ -27,14 +28,12 @@ let empty       = Util.empty
3b98a7
  *************************************************************************)
3b98a7
 
3b98a7
 let access_re   = "access to"
3b98a7
-let control_re  = "stop" | "continue" | "break"
3b98a7
-let what        = [ spc . label "access"
3b98a7
-                  . store (/[^\\# \t\n]+/ - ("by" | control_re)) ]
3b98a7
+let who         = [ spc . label "who"     . sto_to_spc ]
3b98a7
+let what        = [ spc . label "what"    . sto_to_spc ]
3b98a7
 
3b98a7
 (* TODO: parse the control field, see man slapd.access (5) *)
3b98a7
-let control     = [ spc . label "control" . store control_re ]
3b98a7
-let by          = [ sep . key "by" . spc . sto_to_spc
3b98a7
-                  . what? . control? ]
3b98a7
+let control     = [ spc . label "control" . sto_to_by  ]
3b98a7
+let by          = [ sep . key "by". who . what. control? ]
3b98a7
 
3b98a7
 let access      = [ key access_re . spc. sto_to_spc . by+ . eol ]
3b98a7
 
3b98a7
@@ -134,21 +133,18 @@ let database_re = "suffix"
3b98a7
                 | "restrict"
3b98a7
                 | "rootdn"
3b98a7
                 | "rootpw"
3b98a7
+                | "suffix"
3b98a7
                 | "subordinate"
3b98a7
                 | "syncrepl rid"
3b98a7
                 | "updatedn"
3b98a7
                 | "updateref"
3b98a7
                 | database_hdb
3b98a7
 
3b98a7
-let database_entry =
3b98a7
-     let val = Quote.double_opt
3b98a7
-  in Build.key_value_line database_re Sep.space val
3b98a7
-
3b98a7
 let database    = [ key "database"
3b98a7
                   . spc
3b98a7
                   . sto_to_eol
3b98a7
                   . eol
3b98a7
-                  . (comment|empty|database_entry|access)* ]
3b98a7
+                  . (comment|empty|Build.key_ws_value database_re|access)* ]
3b98a7
 
3b98a7
 (************************************************************************
3b98a7
  *                              LENS
3b98a7
diff --git a/lenses/slapd_140.aug b/lenses/slapd_140.aug
3b98a7
new file mode 100644
3b98a7
index 00000000..8d1cd074
3b98a7
--- /dev/null
3b98a7
+++ b/lenses/slapd_140.aug
3b98a7
@@ -0,0 +1,158 @@
3b98a7
+(* Slapd module for Augeas
3b98a7
+   This module is compatible with Augeas 1.4.0, but is not loaded by default.
3b98a7
+
3b98a7
+   Author: Free Ekanayaka <free@64studio.com>
3b98a7
+
3b98a7
+   Reference: man slapd.conf(5), man slapd.access (5)
3b98a7
+
3b98a7
+*)
3b98a7
+
3b98a7
+module Slapd_140 =
3b98a7
+
3b98a7
+(************************************************************************
3b98a7
+ *                           USEFUL PRIMITIVES
3b98a7
+ *************************************************************************)
3b98a7
+
3b98a7
+let eol         = Util.eol
3b98a7
+let spc         = Util.del_ws_spc
3b98a7
+let sep         = del /[ \t\n]+/ " "
3b98a7
+
3b98a7
+let sto_to_eol  = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
3b98a7
+let sto_to_spc  = store /[^\\# \t\n]+/
3b98a7
+
3b98a7
+let comment     = Util.comment
3b98a7
+let empty       = Util.empty
3b98a7
+
3b98a7
+(************************************************************************
3b98a7
+ *                           ACCESS TO
3b98a7
+ *************************************************************************)
3b98a7
+
3b98a7
+let access_re   = "access to"
3b98a7
+let control_re  = "stop" | "continue" | "break"
3b98a7
+let what        = [ spc . label "access"
3b98a7
+                  . store (/[^\\# \t\n]+/ - ("by" | control_re)) ]
3b98a7
+
3b98a7
+(* TODO: parse the control field, see man slapd.access (5) *)
3b98a7
+let control     = [ spc . label "control" . store control_re ]
3b98a7
+let by          = [ sep . key "by" . spc . sto_to_spc
3b98a7
+                  . what? . control? ]
3b98a7
+
3b98a7
+let access      = [ key access_re . spc. sto_to_spc . by+ . eol ]
3b98a7
+
3b98a7
+(************************************************************************
3b98a7
+ *                             GLOBAL
3b98a7
+ *************************************************************************)
3b98a7
+
3b98a7
+(* TODO: parse special field separately, see man slapd.conf (5) *)
3b98a7
+let global_re   = "allow"
3b98a7
+                | "argsfile"
3b98a7
+                | "attributeoptions"
3b98a7
+                | "attributetype"
3b98a7
+                | "authz-policy"
3b98a7
+                | "ldap"
3b98a7
+                | "dn"
3b98a7
+                | "concurrency"
3b98a7
+                | "cron_max_pending"
3b98a7
+                | "conn_max_pending_auth"
3b98a7
+                | "defaultsearchbase"
3b98a7
+                | "disallow"
3b98a7
+                | "ditcontentrule"
3b98a7
+                | "gentlehup"
3b98a7
+                | "idletimeout"
3b98a7
+                | "include"
3b98a7
+                | "index_substr_if_minlen"
3b98a7
+                | "index_substr_if_maxlen"
3b98a7
+                | "index_substr_any_len"
3b98a7
+                | "index_substr_any_step"
3b98a7
+                | "localSSF"
3b98a7
+                | "loglevel"
3b98a7
+                | "moduleload"
3b98a7
+                | "modulepath"
3b98a7
+                | "objectclass"
3b98a7
+                | "objectidentifier"
3b98a7
+                | "password-hash"
3b98a7
+                | "password-crypt-salt-format"
3b98a7
+                | "pidfile"
3b98a7
+                | "referral"
3b98a7
+                | "replica-argsfile"
3b98a7
+                | "replica-pidfile"
3b98a7
+                | "replicationinterval"
3b98a7
+                | "require"
3b98a7
+                | "reverse-lookup"
3b98a7
+                | "rootDSE"
3b98a7
+                | "sasl-host "
3b98a7
+                | "sasl-realm"
3b98a7
+                | "sasl-secprops"
3b98a7
+                | "schemadn"
3b98a7
+                | "security"
3b98a7
+                | "sizelimit"
3b98a7
+                | "sockbuf_max_incoming "
3b98a7
+                | "sockbuf_max_incoming_auth"
3b98a7
+                | "threads"
3b98a7
+                | "timelimit time"
3b98a7
+                | "tool-threads"
3b98a7
+                | "TLSCipherSuite"
3b98a7
+                | "TLSCACertificateFile"
3b98a7
+                | "TLSCACertificatePath"
3b98a7
+                | "TLSCertificateFile"
3b98a7
+                | "TLSCertificateKeyFile"
3b98a7
+                | "TLSDHParamFile"
3b98a7
+                | "TLSRandFile"
3b98a7
+                | "TLSVerifyClient"
3b98a7
+                | "TLSCRLCheck"
3b98a7
+                | "backend"
3b98a7
+
3b98a7
+let global     = Build.key_ws_value global_re
3b98a7
+
3b98a7
+(************************************************************************
3b98a7
+ *                             DATABASE
3b98a7
+ *************************************************************************)
3b98a7
+
3b98a7
+(* TODO: support all types of database backend *)
3b98a7
+let database_hdb = "cachesize"
3b98a7
+                | "cachefree"
3b98a7
+                | "checkpoint"
3b98a7
+                | "dbconfig"
3b98a7
+                | "dbnosync"
3b98a7
+                | "directory"
3b98a7
+                | "dirtyread"
3b98a7
+                | "idlcachesize"
3b98a7
+                | "index"
3b98a7
+                | "linearindex"
3b98a7
+                | "lockdetect"
3b98a7
+                | "mode"
3b98a7
+                | "searchstack"
3b98a7
+                | "shm_key"
3b98a7
+
3b98a7
+let database_re = "suffix"
3b98a7
+                | "lastmod"
3b98a7
+                | "limits"
3b98a7
+                | "maxderefdepth"
3b98a7
+                | "overlay"
3b98a7
+                | "readonly"
3b98a7
+                | "replica uri"
3b98a7
+                | "replogfile"
3b98a7
+                | "restrict"
3b98a7
+                | "rootdn"
3b98a7
+                | "rootpw"
3b98a7
+                | "subordinate"
3b98a7
+                | "syncrepl rid"
3b98a7
+                | "updatedn"
3b98a7
+                | "updateref"
3b98a7
+                | database_hdb
3b98a7
+
3b98a7
+let database_entry =
3b98a7
+     let val = Quote.double_opt
3b98a7
+  in Build.key_value_line database_re Sep.space val
3b98a7
+
3b98a7
+let database    = [ key "database"
3b98a7
+                  . spc
3b98a7
+                  . sto_to_eol
3b98a7
+                  . eol
3b98a7
+                  . (comment|empty|database_entry|access)* ]
3b98a7
+
3b98a7
+(************************************************************************
3b98a7
+ *                              LENS
3b98a7
+ *************************************************************************)
3b98a7
+
3b98a7
+let lns         = (comment|empty|global|access)* . (database)*
3b98a7
diff --git a/lenses/tests/test_slapd.aug b/lenses/tests/test_slapd.aug
3b98a7
index a4bbb4e9..e477342a 100644
3b98a7
--- a/lenses/tests/test_slapd.aug
3b98a7
+++ b/lenses/tests/test_slapd.aug
3b98a7
@@ -48,47 +48,18 @@ test Slapd.lns get conf =
3b98a7
   { "database" = "hdb"
3b98a7
      {}
3b98a7
      { "#comment" = "The base of your directory in database #1" }
3b98a7
-     { "suffix"   = "dc=nodomain" }
3b98a7
+     { "suffix"   = "\"dc=nodomain\"" }
3b98a7
      {}
3b98a7
      { "access to" = "attrs=userPassword,shadowLastChange"
3b98a7
-        { "by" = "dn=\"cn=admin,dc=nodomain\""
3b98a7
-           { "access" = "write" } }
3b98a7
-        { "by" = "anonymous"
3b98a7
-           { "access" = "auth" } }
3b98a7
-        { "by" = "self"
3b98a7
-           { "access" = "write" } }
3b98a7
-        { "by" = "*"
3b98a7
-           { "access" = "none" } } } }
3b98a7
-
3b98a7
-(* Test: Slapd.lns
3b98a7
-     Full access test with who/access/control *)
3b98a7
-test Slapd.lns get "access to dn.subtree=\"dc=example,dc=com\"
3b98a7
-  by self write stop\n" =
3b98a7
-  { "access to" = "dn.subtree=\"dc=example,dc=com\""
3b98a7
-    { "by" = "self"
3b98a7
-      { "access" = "write" }
3b98a7
-      { "control" = "stop" } } }
3b98a7
-
3b98a7
-(* Test: Slapd.lns
3b98a7
-     access test with who *)
3b98a7
-test Slapd.lns get "access to dn.subtree=\"dc=example,dc=com\"
3b98a7
-  by self\n" =
3b98a7
-  { "access to" = "dn.subtree=\"dc=example,dc=com\""
3b98a7
-    { "by" = "self" } }
3b98a7
-
3b98a7
-(* Test: Slapd.lns
3b98a7
-     access test with who/access *)
3b98a7
-test Slapd.lns get "access to dn.subtree=\"dc=example,dc=com\"
3b98a7
-  by self write\n" =
3b98a7
-  { "access to" = "dn.subtree=\"dc=example,dc=com\""
3b98a7
-    { "by" = "self"
3b98a7
-      { "access" = "write" } } }
3b98a7
-
3b98a7
-(* Test: Slapd.lns
3b98a7
-     access test with who/control *)
3b98a7
-test Slapd.lns get "access to dn.subtree=\"dc=example,dc=com\"
3b98a7
-  by self stop\n" =
3b98a7
-  { "access to" = "dn.subtree=\"dc=example,dc=com\""
3b98a7
-    { "by" = "self"
3b98a7
-      { "control" = "stop" } } }
3b98a7
-
3b98a7
+        { "by"
3b98a7
+           { "who" = "dn=\"cn=admin,dc=nodomain\"" }
3b98a7
+           { "what" = "write" } }
3b98a7
+        { "by"
3b98a7
+           { "who" = "anonymous" }
3b98a7
+           { "what" = "auth" } }
3b98a7
+        { "by"
3b98a7
+           { "who" = "self" }
3b98a7
+           { "what" = "write" } }
3b98a7
+        { "by"
3b98a7
+           { "who" = "*" }
3b98a7
+           { "what" = "none" } } } }
3b98a7
diff --git a/lenses/tests/test_slapd_140.aug b/lenses/tests/test_slapd_140.aug
3b98a7
new file mode 100644
3b98a7
index 00000000..0118f030
3b98a7
--- /dev/null
3b98a7
+++ b/lenses/tests/test_slapd_140.aug
3b98a7
@@ -0,0 +1,94 @@
3b98a7
+module Test_slapd_140 =
3b98a7
+
3b98a7
+let conf = "# This is the main slapd configuration file. See slapd.conf(5) for more
3b98a7
+# info on the configuration options.
3b98a7
+
3b98a7
+#######################################################################
3b98a7
+# Global Directives:
3b98a7
+
3b98a7
+# Features to permit
3b98a7
+#allow bind_v2
3b98a7
+
3b98a7
+# Schema and objectClass definitions
3b98a7
+include         /etc/ldap/schema/core.schema
3b98a7
+
3b98a7
+#######################################################################
3b98a7
+# Specific Directives for database #1, of type hdb:
3b98a7
+# Database specific directives apply to this databasse until another
3b98a7
+# 'database' directive occurs
3b98a7
+database        hdb
3b98a7
+
3b98a7
+# The base of your directory in database #1
3b98a7
+suffix          \"dc=nodomain\"
3b98a7
+
3b98a7
+access to attrs=userPassword,shadowLastChange
3b98a7
+        by dn=\"cn=admin,dc=nodomain\" write
3b98a7
+        by anonymous auth
3b98a7
+        by self write
3b98a7
+        by * none
3b98a7
+"
3b98a7
+
3b98a7
+test Slapd_140.lns get conf =
3b98a7
+  { "#comment" = "This is the main slapd configuration file. See slapd.conf(5) for more" }
3b98a7
+  { "#comment" = "info on the configuration options." }
3b98a7
+  {}
3b98a7
+  { "#comment" = "######################################################################" }
3b98a7
+  { "#comment" = "Global Directives:"}
3b98a7
+  {}
3b98a7
+  { "#comment" = "Features to permit" }
3b98a7
+  { "#comment" = "allow bind_v2" }
3b98a7
+  {}
3b98a7
+  { "#comment" = "Schema and objectClass definitions" }
3b98a7
+  { "include"  = "/etc/ldap/schema/core.schema" }
3b98a7
+  {}
3b98a7
+  { "#comment" = "######################################################################" }
3b98a7
+  { "#comment" = "Specific Directives for database #1, of type hdb:" }
3b98a7
+  { "#comment" = "Database specific directives apply to this databasse until another" }
3b98a7
+  { "#comment" = "'database' directive occurs" }
3b98a7
+  { "database" = "hdb"
3b98a7
+     {}
3b98a7
+     { "#comment" = "The base of your directory in database #1" }
3b98a7
+     { "suffix"   = "dc=nodomain" }
3b98a7
+     {}
3b98a7
+     { "access to" = "attrs=userPassword,shadowLastChange"
3b98a7
+        { "by" = "dn=\"cn=admin,dc=nodomain\""
3b98a7
+           { "access" = "write" } }
3b98a7
+        { "by" = "anonymous"
3b98a7
+           { "access" = "auth" } }
3b98a7
+        { "by" = "self"
3b98a7
+           { "access" = "write" } }
3b98a7
+        { "by" = "*"
3b98a7
+           { "access" = "none" } } } }
3b98a7
+
3b98a7
+(* Test: Slapd_140.lns
3b98a7
+     Full access test with who/access/control *)
3b98a7
+test Slapd_140.lns get "access to dn.subtree=\"dc=example,dc=com\"
3b98a7
+  by self write stop\n" =
3b98a7
+  { "access to" = "dn.subtree=\"dc=example,dc=com\""
3b98a7
+    { "by" = "self"
3b98a7
+      { "access" = "write" }
3b98a7
+      { "control" = "stop" } } }
3b98a7
+
3b98a7
+(* Test: Slapd_140.lns
3b98a7
+     access test with who *)
3b98a7
+test Slapd_140.lns get "access to dn.subtree=\"dc=example,dc=com\"
3b98a7
+  by self\n" =
3b98a7
+  { "access to" = "dn.subtree=\"dc=example,dc=com\""
3b98a7
+    { "by" = "self" } }
3b98a7
+
3b98a7
+(* Test: Slapd_140.lns
3b98a7
+     access test with who/access *)
3b98a7
+test Slapd_140.lns get "access to dn.subtree=\"dc=example,dc=com\"
3b98a7
+  by self write\n" =
3b98a7
+  { "access to" = "dn.subtree=\"dc=example,dc=com\""
3b98a7
+    { "by" = "self"
3b98a7
+      { "access" = "write" } } }
3b98a7
+
3b98a7
+(* Test: Slapd_140.lns
3b98a7
+     access test with who/control *)
3b98a7
+test Slapd_140.lns get "access to dn.subtree=\"dc=example,dc=com\"
3b98a7
+  by self stop\n" =
3b98a7
+  { "access to" = "dn.subtree=\"dc=example,dc=com\""
3b98a7
+    { "by" = "self"
3b98a7
+      { "control" = "stop" } } }
3b98a7
+
3b98a7
diff --git a/tests/Makefile.am b/tests/Makefile.am
3b98a7
index 315cac9c..65d8993e 100644
3b98a7
--- a/tests/Makefile.am
3b98a7
+++ b/tests/Makefile.am
3b98a7
@@ -182,6 +182,7 @@ lens_tests =			\
3b98a7
   lens-simplevars.sh	\
3b98a7
   lens-sip_conf.sh	    \
3b98a7
   lens-slapd.sh			\
3b98a7
+  lens-slapd_140.sh			\
3b98a7
   lens-smbusers.sh			\
3b98a7
   lens-solaris_system.sh		\
3b98a7
   lens-soma.sh			\
3b98a7
-- 
c941cc
2.24.1
3b98a7