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

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