diff --git a/libexec-convert-config.sh b/libexec-convert-config.sh deleted file mode 100755 index ca9884f..0000000 --- a/libexec-convert-config.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/sh -# Author: Jan Vcelak - -. /usr/libexec/openldap/functions - -function help() -{ - error "usage: %s [-f config-file] [-F config-dir]\n" "`basename $0`" - exit 2 -} - -load_sysconfig - -while getopts :f:F: opt; do - case "$opt" in - f) - SLAPD_CONFIG_FILE="$OPTARG" - ;; - F) - SLAPD_CONFIG_DIR="$OPTARG" - ;; - *) - help - ;; - esac -done -shift $((OPTIND-1)) -[ -n "$1" ] && help - -# check source, target - -if [ ! -f "$SLAPD_CONFIG_FILE" ]; then - error "Source configuration file '%s' not found." "$SLAPD_CONFIG_FILE" - exit 1 -fi - -if grep -iq '^dn: cn=config$' "$SLAPD_CONFIG_FILE"; then - SLAPD_CONFIG_FILE_FORMAT=ldif -else - SLAPD_CONFIG_FILE_FORMAT=conf -fi - -if [ -d "$SLAPD_CONFIG_DIR" ]; then - if [ `find "$SLAPD_CONFIG_DIR" -maxdepth 0 -empty | wc -l` -eq 0 ]; then - error "Target configuration directory '%s' is not empty." "$SLAPD_CONFIG_DIR" - exit 1 - fi -fi - -# perform the conversion - -tmp_convert=`mktemp --tmpdir=/var/run/openldap` - -if [ `id -u` -eq 0 ]; then - install -d --owner $SLAPD_USER --group `id -g $SLAPD_USER` --mode 0700 "$SLAPD_CONFIG_DIR" &>>$tmp_convert - if [ $SLAPD_CONFIG_FILE_FORMAT = ldif ]; then - run_as_ldap "/usr/sbin/slapadd -F \"$SLAPD_CONFIG_DIR\" -n 0 -l \"$SLAPD_CONFIG_FILE\"" &>>$tmp_convert - else - run_as_ldap "/usr/sbin/slaptest -f \"$SLAPD_CONFIG_FILE\" -F \"$SLAPD_CONFIG_DIR\"" &>>$tmp_convert - fi - retcode=$? -else - error "You are not root! Permission will not be set." - install -d --mode 0700 "$SLAPD_CONFIG_DIR" &>>$tmp_convert - if [ $SLAPD_CONFIG_FILE_FORMAT = ldif ]; then - /usr/sbin/slapadd -F "$SLAPD_CONFIG_DIR" -n 0 -l "$SLAPD_CONFIG_FILE" &>>$tmp_convert - else - /usr/sbin/slaptest -f "$SLAPD_CONFIG_FILE" -F "$SLAPD_CONFIG_DIR" &>>$tmp_convert - fi - retcode=$? -fi - -if [ $retcode -ne 0 ]; then - error "Configuration conversion failed:" - cat $tmp_convert >&2 -fi - -rm $tmp_convert -exit $retcode diff --git a/openldap.spec b/openldap.spec index 500696d..f12a1b4 100644 --- a/openldap.spec +++ b/openldap.spec @@ -16,7 +16,6 @@ Source3: slapd.ldif Source4: ldap.conf Source10: ltb-project-openldap-ppolicy-check-password-%{check_password_version}.tar.gz Source50: libexec-functions -Source51: libexec-convert-config.sh Source52: libexec-check-config.sh Source53: libexec-upgrade-db.sh Source54: libexec-create-certdb.sh @@ -272,7 +271,6 @@ install -m 0644 %SOURCE4 %{buildroot}%{_sysconfdir}/openldap/ldap.conf mkdir -p %{buildroot}%{_libexecdir} install -m 0755 -d %{buildroot}%{_libexecdir}/openldap install -m 0644 %SOURCE50 %{buildroot}%{_libexecdir}/openldap/functions -install -m 0755 %SOURCE51 %{buildroot}%{_libexecdir}/openldap/convert-config.sh install -m 0755 %SOURCE52 %{buildroot}%{_libexecdir}/openldap/check-config.sh install -m 0755 %SOURCE53 %{buildroot}%{_libexecdir}/openldap/upgrade-db.sh install -m 0755 %SOURCE54 %{buildroot}%{_libexecdir}/openldap/create-certdb.sh @@ -376,7 +374,11 @@ exit 0 if [[ ! -f %{_sysconfdir}/openldap/slapd.d/cn=config.ldif && \ ! -f %{_sysconfdir}/openldap/slapd.conf ]]; then - %{_libexecdir}/openldap/convert-config.sh -f %{_datadir}/openldap-servers/slapd.ldif &>/dev/null + # if there is no configuration available, generate one from the defaults + mkdir -p %{_sysconfdir}/openldap/slapd.d/ &>/dev/null || : + /usr/sbin/slapadd -F %{_sysconfdir}/openldap/slapd.d/ -n0 -l %{_datadir}/openldap-servers/slapd.ldif + chown -R ldap:ldap %{_sysconfdir}/openldap/slapd.d/ + %{systemctl_bin} try-restart slapd.service &>/dev/null fi start_slapd=0 @@ -516,7 +518,6 @@ exit 0 %{_libdir}/openldap/valsort* %{_libdir}/openldap/check_password* %{_libexecdir}/openldap/functions -%{_libexecdir}/openldap/convert-config.sh %{_libexecdir}/openldap/check-config.sh %{_libexecdir}/openldap/upgrade-db.sh %{_libexecdir}/openldap/generate-server-cert.sh @@ -542,6 +543,7 @@ exit 0 * Mon Jan 26 2015 Jan Synáček - 2.4.40-7 - remove tmpfiles config since it's no longer needed - fix invalid ldif +- simplify checking for missing server configuration * Fri Jan 16 2015 Jan Synáček - 2.4.40-6 - remove openldap-fedora-systemd.patch