[Pkg-openldap-devel] Bug#411413: Patch to /etc/init.d/slapd allowing "/etc/ldap/slapd.d"-style configuration.

Mike Burr meburr at gmail.com
Mon Feb 26 14:23:06 UTC 2007


I also have an interest in experimenting with this new slapd feature.
Since /etc/init.d/slapd is a configuration file, I took the liberty of
making some changes on my system. Below is a patch to the init script
that changes it's behavior such that, in /etc/defaults/slapd:

1) If SLAPD_CONF is a path to a file, slapd is started with the '-f'
switch (same as old behavior)

2) If SLAPD_CONF is a null string or undefined, the '-f' switch is
used with the default config file, "/etc/ldap/slapd.conf". (same as
old behavior)

3) If SLAPD_CONF is a path to a directory, the '-F', rather than the
'-f' option will be used. (new behavior)

4) If SLAPD_CONF is a path to a directory and SLURPD_START=yes, slurpd
will not be started. start_slurpd() will print a message (stdout) and
return with 0. (new behavior)

5) If SLAPD_CONF is a path which points to something other than a file
or directory, the /etc/init.d/slapd will complain and exit with an
error, before starting or stopping any daemons.

It works for me, but probably needs tweaking. I think that its
possible to run slapd and slurpd simultaneously with slapd using "-F
/path/to/slapd.d/", but it appears that slurpd still requires the
old-style slapd.conf to be present. So, rather than introducing a new
SLURPD_CONF variable (etc, etc), I just punted and made slurpd in-op
if using "slapd -F".

Take it or leave it, just thought it might be useful:



--- /etc/init.d/slapd   (revision 1445)
+++ /etc/init.d/slapd   (working copy)
@@ -25,9 +25,6 @@
 # Load the default location of the slapd config file
 if [ -z "$SLAPD_CONF" ]; then
        SLAPD_CONF="/etc/ldap/slapd.conf"
-else
-       SLAPD_OPTIONS="-f $SLAPD_CONF $SLAPD_OPTIONS"
-       SLURPD_OPTIONS="-f $SLAPD_CONF $SLURPD_OPTIONS"
 fi

 # Stop processing if the config file is not there
@@ -55,8 +52,23 @@

 # Find out the name of slapd's pid file
 if [ -z "$SLAPD_PIDFILE" ]; then
-       SLAPD_PIDFILE=`sed -ne 's/^pidfile[[:space:]]\+\(.\+\)/\1/p' \
-               "$SLAPD_CONF"`
+    # If using old one-file configuration scheme
+    if [ -f "$SLAPD_CONF" ] ; then
+        SLAPD_PIDFILE=`sed -ne 's/^pidfile[[:space:]]\+\(.\+\)/\1/p' \
+            "$SLAPD_CONF"`
+        SLAPD_OPTIONS="-f $SLAPD_CONF $SLAPD_OPTIONS"
+        SLURPD_OPTIONS="-f $SLAPD_CONF $SLURPD_OPTIONS"
+    # Else, if using new directory configuration scheme
+    elif [ -d "$SLAPD_CONF" ] ; then
+        SLAPD_PIDFILE=`sed -ne \
+           's/^olcPidFile:[[:space:]]\+\(.\+\)[[:space:]]*/\1/p' \
+           "$SLAPD_CONF"/'cn=config.ldif'`
+        SLAPD_OPTIONS="-F $SLAPD_CONF $SLAPD_OPTIONS"
+        SLURPD_OPTIONS="-F $SLAPD_CONF $SLURPD_OPTIONS"
+    else
+        echo "Cannot continue: $SLAPD_CONF is neither a file nor a directory."
+        exit 1
+    fi
 fi

 # XXX: Breaks upgrading if there is no pidfile (invoke-rc.d stop will fail)
@@ -146,6 +158,12 @@
        if [ "$SLURPD_START" != yes ]; then
                return 0
        fi
+    if [ ! -f "$SLAPD_CONF" ] ; then
+        echo -n " (Running slurpd is not supported when running slapd
with the "
+        echo -n "new-style \"slapd.d\" directory-based configuration,
i.e. '-F'. "
+        echo -n "slurpd will NOT be started.)"
+        return 0
+    fi
        echo -n " slurpd"
        reason="`start-stop-daemon --start --quiet --oknodo \
                --exec /usr/sbin/slurpd -- $SLURPD_OPTIONS 2>&1`"



FYI, please feel free to let me know if I've gone about any of this
wrong. I scanned http://www.debian.org/Bugs/Reporting but didn't find
anything that seemed relevant to replying to existing bugs via email
(e.g., whether to use the "pseudo-header", what subject: to use, etc.)

Also, it looks like when pasting into a web form (??), the tabs in my
patch get converted into spaces. Just so you know...

-Mike Burr




More information about the Pkg-openldap-devel mailing list