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

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