OpenLDAP init Script
Joshua Gimer
jgimer at gmail.com
Wed May 23 18:58:27 UTC 2007
I just wanted to point out what I would consider an implementation flaw in
RH Version of OpenLDAP. It is both the same on RHEL4 and 5. In the LDAP init
script provided by Red Hat (/etc/init.d/ldap) there is a problem with how
the stop function shuts down running LDAP Directories. I have actually
already have had database corruption on two systems because of this.
Killproc is called without a signal, it defaults to -TERM and then -KILL.
You can see this here:
Taken from killproc() in /etc/init.d/functions:
if [ -n "${pid:-}" ] ; then
[ "$BOOTUP" = "verbose" -a -z "$LSB" ] && echo -n "$base "
if [ "$notset" -eq "1" ] ; then
if checkpid $pid 2>&1; then
# TERM first, then KILL if not dead
kill -TERM $pid >/dev/null 2>&1
usleep 100000
if checkpid $pid && sleep 1 &&
checkpid $pid && sleep $delay &&
checkpid $pid ; then
kill -KILL $pid >/dev/null 2>&1
usleep 100000
fi
fi
checkpid $pid
RC=$?
[ "$RC" -eq 0 ] && failure $"$base shutdown" ||
success $"$base shutdown"
RC=$((! $RC))
# use specified level only
else
if checkpid $pid; then
kill $killlevel $pid >/dev/null 2>&1
RC=$?
[ "$RC" -eq 0 ] && success $"$base
$killlevel" || failure $"$base $killlevel"
fi
fi
else
failure $"$base shutdown"
RC=1
fi
/etc/init.d/ldap stop function
function stop() {
# Stop daemons.
prog=`basename ${slapd}`
echo -n $"Stopping $prog: "
killproc ${slapd}
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]; then
if grep -q "^replogfile" /etc/openldap/slapd.conf; then
prog=`basename ${slurpd}`
echo -n $"Stopping $prog: "
killproc ${slurpd}
RETVAL=$?
echo
fi
fi
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ldap /var/run/slapd.args
return $RETVAL
}
I am making the suggestion that Red hat change the default init script that
is distributes with OpenLDAP to stop the directories with -INT. Like below:
function stop() {
# Stop daemons.
prog=`basename ${slapd}`
echo -n $"Stopping $prog: "
killproc ${slapd}
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]; then
if grep -q "^replogfile" /etc/openldap/slapd.conf; then
prog=`basename ${slurpd}`
echo -n $"Stopping $prog: "
killproc ${slurpd} -INT
RETVAL=$?
echo
fi
fi
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ldap /var/run/slapd.args
return $RETVAL
}
This will get rid of the issue of database corruption, when using
/etc/init.d/ldap.
If there is anyone else out there that has had similar problems, please
speak up. You can fix this by changing to your database directory and
running slapd_db_recover.
--
Thx
Joshua Gimer
More information about the redhat-list
mailing list