[augeas-devel] [PATCH 2 of 2] Add slapd.aug and test modules

Free Ekanayaka free at 64studio.com
Tue Sep 2 13:18:19 UTC 2008


# HG changeset patch
# User Free Ekanayaka <free at 64studio.com>
# Date 1220361417 -7200
# Node ID c80aa0c86b5d27c1ae7c5fdc11dc021957865590
# Parent  bc15db596f09c3e7317792ba91c924c57679b173
Add slapd.aug and test modules

diff -r bc15db596f09 -r c80aa0c86b5d lenses/slapd.aug
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lenses/slapd.aug	Tue Sep 02 15:16:57 2008 +0200
@@ -0,0 +1,155 @@
+(* Slapd module for Augeas
+   Author: Free Ekanayaka <free at 64studio.com>
+
+   Reference: man slapd.conf(5), man slapd.access (5)
+
+*)
+
+module Slapd =
+  autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol         = Util.eol
+let spc         = Util.del_ws_spc
+let sep         = del /[ \t\n]+/ " "
+
+let sto_to_eol  = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+let sto_to_spc  = store /[^\\# \t\n]+/
+let sto_to_by   = store (/[^\\# \t\n]+/ - "by")
+
+(************************************************************************
+ *                           ACCESS TO
+ *************************************************************************)
+
+let access_re   = "access to"
+let who         = [ spc . label "who"     . sto_to_spc ]
+let what        = [ spc . label "what"    . sto_to_spc ]
+
+(* TODO: parse the control field, see man slapd.access (5) *)
+let control     = [ spc . label "control" . sto_to_by  ]
+let by          = [ sep . key "by". who . what. control? ]
+         
+let access      = [ key access_re . spc. sto_to_spc . by+ . eol ]
+
+(************************************************************************
+ *                             GLOBAL
+ *************************************************************************)
+
+(* TODO: parse special field separately, see man slapd.conf (5) *)
+let global_re   = "allow"
+                | "argsfile"
+                | "attributeoptions"
+                | "attributetype"
+                | "authz-policy"
+                | "ldap"
+                | "dn"
+                | "concurrency"
+                | "cron_max_pending"
+                | "conn_max_pending_auth"
+                | "defaultsearchbase"
+                | "disallow"
+                | "ditcontentrule"
+                | "gentlehup"
+                | "idletimeout"
+                | "include"
+                | "index_substr_if_minlen"
+                | "index_substr_if_maxlen"
+                | "index_substr_any_len"
+                | "index_substr_any_step"
+                | "localSSF"
+                | "loglevel"
+                | "moduleload"
+                | "modulepath"
+                | "objectclass"
+                | "objectidentifier"
+                | "password-hash"
+                | "password-crypt-salt-format"
+                | "pidfile"
+                | "referral"
+                | "replica-argsfile"
+                | "replica-pidfile"
+                | "replicationinterval"
+                | "require"
+                | "reverse-lookup"
+                | "rootDSE"
+                | "sasl-host "
+                | "sasl-realm"
+                | "sasl-secprops"
+                | "schemadn"
+                | "security"
+                | "sizelimit"
+                | "sockbuf_max_incoming "
+                | "sockbuf_max_incoming_auth"
+                | "threads"
+                | "timelimit time"
+                | "tool-threads"
+                | "TLSCipherSuite"
+                | "TLSCACertificateFile"
+                | "TLSCACertificatePath"
+                | "TLSCertificateFile"
+                | "TLSCertificateKeyFile"
+                | "TLSDHParamFile"
+                | "TLSRandFile"
+                | "TLSVerifyClient"
+                | "TLSCRLCheck"
+                | "backend"
+  
+let global     = Spacevars.entry global_re
+
+(************************************************************************
+ *                             DATABASE
+ *************************************************************************)
+
+(* TODO: support all types of database backend *)
+let database_hdb = "cachesize"
+                | "cachefree"
+                | "checkpoint"
+                | "dbconfig"
+                | "dbnosync"
+                | "directory"
+                | "dirtyread"
+                | "idlcachesize"
+                | "index"
+                | "linearindex"
+                | "lockdetect"
+                | "mode"
+                | "searchstack"
+                | "shm_key"
+
+let database_re = "suffix"
+                | "lastmod"
+                | "limits"
+                | "maxderefdepth"
+                | "overlay"
+                | "readonly"
+                | "replica uri"
+                | "replogfile"
+                | "restrict"
+                | "rootdn"
+                | "rootpw"
+                | "suffix"
+                | "subordinate"
+                | "syncrepl rid"
+                | "updatedn"
+                | "updateref"
+                | database_hdb
+
+let database    = [ key "database"
+                  . spc
+                  . sto_to_eol
+                  . eol
+                  . Spacevars.lns (Spacevars.entry database_re|access) ]
+
+(************************************************************************
+ *                              LENS
+ *************************************************************************)
+
+let lns         = Spacevars.lns (global|access) . (database)*
+
+let filter      = Util.stdexcl
+                . incl "/etc/ldap/slapd.conf"
+
+let xfm         = transform lns filter
diff -r bc15db596f09 -r c80aa0c86b5d lenses/tests/test_slapd.aug
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lenses/tests/test_slapd.aug	Tue Sep 02 15:16:57 2008 +0200
@@ -0,0 +1,65 @@
+module Test_slapd =
+
+let conf = "# This is the main slapd configuration file. See slapd.conf(5) for more
+# info on the configuration options.
+
+#######################################################################
+# Global Directives:
+
+# Features to permit
+#allow bind_v2
+
+# Schema and objectClass definitions
+include         /etc/ldap/schema/core.schema
+
+#######################################################################
+# Specific Directives for database #1, of type hdb:
+# Database specific directives apply to this databasse until another
+# 'database' directive occurs
+database        hdb
+
+# The base of your directory in database #1
+suffix          \"dc=nodomain\"
+
+access to attrs=userPassword,shadowLastChange
+        by dn=\"cn=admin,dc=nodomain\" write
+        by anonymous auth
+        by self write
+        by * none
+"
+
+test Slapd.lns get conf =
+  { "#comment" = "This is the main slapd configuration file. See slapd.conf(5) for more" }
+  { "#comment" = "info on the configuration options." }
+  {}
+  { "#comment" = "######################################################################" }
+  { "#comment" = "Global Directives:"}
+  {}
+  { "#comment" = "Features to permit" }
+  { "#comment" = "allow bind_v2" }
+  {}
+  { "#comment" = "Schema and objectClass definitions" }
+  { "include"  = "/etc/ldap/schema/core.schema" }
+  {}
+  { "#comment" = "######################################################################" }
+  { "#comment" = "Specific Directives for database #1, of type hdb:" }
+  { "#comment" = "Database specific directives apply to this databasse until another" }
+  { "#comment" = "'database' directive occurs" }
+  { "database" = "hdb"
+     {}
+     { "#comment" = "The base of your directory in database #1" }
+     { "suffix"   = "\"dc=nodomain\"" }
+     {}
+     { "access to" = "attrs=userPassword,shadowLastChange"
+        { "by"
+           { "who" = "dn=\"cn=admin,dc=nodomain\"" }
+           { "what" = "write" } }
+        { "by"
+           { "who" = "anonymous" }
+           { "what" = "auth" } }
+        { "by"
+           { "who" = "self" }
+           { "what" = "write" } }
+        { "by"
+           { "who" = "*" }
+           { "what" = "none" } } } }




More information about the augeas-devel mailing list