docker-openldap
docker-openldap copied to clipboard
Bug in /usr/local/bin/slapd-restore
Summary
/usr/local/bin/slapd-restore is wrong.
Steps to reproduce
Try to restore a db archive: slapd-restore-data your_db_archive.gz
What is the expected correct behavior?
Data restoration should work.
Relevant logs and/or screenshots
Sorry, no logs.
Environment
- Image version / tag: tiredofit/openldap version 7.1.16
- Host OS: CentOS 8
Possible fixes
I fixed it like this:
#!/usr/bin/with-contenv bash set -x
This file overwrite the original slapd-restore that comes with the container
and that is buggy
source /assets/functions/00-container source /assets/defaults/10-openldap
Usage: /sbin/slapd-restore dbnum file
dbnum=$1 file=$2
backupPath="/data/backup" file="$backupPath/$file"
stop slapd
s6-svc -d /var/run/s6/services/10-openldap pkill slapd
sleep 5 ps aux
TEMP_FILE=$(mktemp) gunzip -c $file > $TEMP_FILE chown ldap:ldap $TEMP_FILE
if [ "$1" = "0" ]; then rm -rf ${CONFIG_PATH}/slap.d/* fi
if [ "$1" = "1" ]; then rm -rf ${DB_PATH}/* fi
sudo -u ldap slapadd -c -F /etc/openldap/slapd.d -n $dbnum -l $TEMP_FILE
restart slapd
s6-svc -u /var/run/s6/services/10-openldap
rm $TEMP_FILE
exit 0
Thanks for this. Fixed in https://github.com/tiredofit/docker-openldap/commit/ccb0f83f4f28693812e7f7d44ab5eee1d4579024 and tagged as 7.1.17
with credit to you.