Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in /usr/local/bin/slapd-restore #43

Open
janpolito opened this issue Jun 1, 2021 · 1 comment
Open

Bug in /usr/local/bin/slapd-restore #43

janpolito opened this issue Jun 1, 2021 · 1 comment
Labels

Comments

@janpolito
Copy link

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

@janpolito janpolito added the bug label Jun 1, 2021
@tiredofit
Copy link
Owner

Thanks for this. Fixed in ccb0f83 and tagged as 7.1.17 with credit to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants