Escaped characters in password hash, so sed doesn't crash anymore

This commit is contained in:
Christian Luginbühl 2015-02-18 21:28:26 +01:00
parent 9d1708513e
commit ddc5204228
3 changed files with 5 additions and 5 deletions

View file

@ -14,7 +14,7 @@ RUN apt-get update && \
EXPOSE 389
VOLUME ["/var/lib/ldap"]
VOLUME ["/var/lib/ldap", "/etc/ldap"]
COPY entrypoint.sh /entrypoint.sh

View file

@ -2,7 +2,7 @@ docker-openldap
===============
A Docker image running OpenLDAP on Debian stable ("wheezy" at the moment). The
Dockerfile is inspired by the well written one from
Dockerfile is inspired by
[cnry/openldap](https://registry.hub.docker.com/u/cnry/openldap/), but as said
before, running a stable Debian and be a little less verbose, but more complete
in the configuration.

View file

@ -22,8 +22,6 @@ if [[ ! -f /etc/ldap/docker-configured ]]; then
slapd slapd/no_configuration boolean false
slapd slapd/password1 password $SLAPD_PASSWORD
slapd slapd/password2 password $SLAPD_PASSWORD
slapd slapd/internal/adminpw string $SLAPD_PASSWORD
slapd slapd/internal/generated_adminpw password $SLAPD_PASSWORD
slapd shared/organization string $SLAPD_ORGANIZATION
slapd slapd/domain string $SLAPD_DOMAIN
slapd slapd/backend select hdb
@ -49,8 +47,10 @@ EOF
if [[ -n "$SLAPD_CONFIG_PASSWORD" ]]; then
password_hash=`slappasswd -s "${SLAPD_CONFIG_PASSWORD}"`
sed_safe_password_hash=${password_hash/\//\\\/}
slapcat -n0 -F /etc/ldap/slapd.d -l /tmp/config.ldif
sed -i "s/\(olcRootDN: cn=admin,cn=config\)/\1\nolcRootPW: ${password_hash}/g" /tmp/config.ldif
sed -i "s/\(olcRootDN: cn=admin,cn=config\)/\1\nolcRootPW: ${sed_safe_password_hash}/g" /tmp/config.ldif
rm -rf /etc/ldap/slapd.d/*
slapadd -n0 -F /etc/ldap/slapd.d -l /tmp/config.ldif >/dev/null 2>&1
fi