Skip to content

Commit 9fb2d30

Browse files
committed
Merge branch 'pcolmer-stable' into release-1.4.0
2 parents d2b6711 + 16eaeae commit 9fb2d30

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed

example/docker-compose.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ services:
2424
LDAP_TLS_CIPHER_SUITE: "SECURE256:-VERS-SSL3.0"
2525
LDAP_TLS_VERIFY_CLIENT: "demand"
2626
LDAP_REPLICATION: "false"
27-
#LDAP_REPLICATION_CONFIG_SYNCPROV: "binddn="cn=admin,cn=config" bindmethod=simple credentials=$LDAP_CONFIG_PASSWORD searchbase="cn=config" type=refreshAndPersist retry="60 +" timeout=1 starttls=critical"
28-
#LDAP_REPLICATION_DB_SYNCPROV: "binddn="cn=admin,$LDAP_BASE_DN" bindmethod=simple credentials=$LDAP_ADMIN_PASSWORD searchbase="$LDAP_BASE_DN" type=refreshAndPersist interval=00:00:00:10 retry="60 +" timeout=1 starttls=critical"
27+
#LDAP_REPLICATION_CONFIG_SYNCPROV: "binddn="cn=admin,cn=config" bindmethod=simple credentials=$$LDAP_CONFIG_PASSWORD searchbase="cn=config" type=refreshAndPersist retry="60 +" timeout=1 starttls=critical"
28+
#LDAP_REPLICATION_DB_SYNCPROV: "binddn="cn=admin,$$LDAP_BASE_DN" bindmethod=simple credentials=$$LDAP_ADMIN_PASSWORD searchbase="$$LDAP_BASE_DN" type=refreshAndPersist interval=00:00:00:10 retry="60 +" timeout=1 starttls=critical"
2929
#LDAP_REPLICATION_HOSTS: "#PYTHON2BASH:['ldap://ldap.example.org','ldap://ldap2.example.org']"
3030
KEEP_EXISTING_CONFIG: "false"
3131
LDAP_REMOVE_CONFIG_AFTER_SETUP: "true"
@@ -39,8 +39,11 @@ services:
3939
ports:
4040
- "389:389"
4141
- "636:636"
42-
domainname: "example.org" # important: same as hostname
43-
hostname: "example.org"
42+
# For replication to work correctly, domainname and hostname must be
43+
# set correctly so that "hostname"."domainname" equates to the
44+
# fully-qualified domain name for the host.
45+
domainname: "example.org"
46+
hostname: "ldap-server"
4447
phpldapadmin:
4548
image: osixia/phpldapadmin:latest
4649
container_name: phpldapadmin

image/service/slapd/process.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ log-helper level eq trace && set -x
99
# see https://github.com/docker/docker/issues/8231
1010
ulimit -n $LDAP_NOFILE
1111

12-
exec /usr/sbin/slapd -h "ldap://$HOSTNAME:$LDAP_PORT ldaps://$HOSTNAME:$LDAPS_PORT ldapi:///" -u openldap -g openldap -d $LDAP_LOG_LEVEL
12+
# Call hostname to determine the fully qualified domain name. We want OpenLDAP to listen
13+
# to the named host for the ldap:// and ldaps:// protocols.
14+
FQDN="$(/bin/hostname --fqdn)"
15+
HOST_PARAM="ldap://$FQDN:$LDAP_PORT ldaps://$FQDN:$LDAP_PORT"
16+
exec /usr/sbin/slapd -h "$HOST_PARAM ldapi:///" -u openldap -g openldap -d "$LDAP_LOG_LEVEL"

image/service/slapd/startup.sh

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ ulimit -n $LDAP_NOFILE
1212

1313

1414
# usage: file_env VAR
15-
# ie: file_env 'XYZ_DB_PASSWORD'
15+
# ie: file_env 'XYZ_DB_PASSWORD'
1616
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
1717
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
1818
file_env() {
19-
local var="$1"
20-
local fileVar="${var}_FILE"
19+
local var="$1"
20+
local fileVar="${var}_FILE"
2121

2222
# The variables are already defined from the docker-light-baseimage
2323
# So if the _FILE variable is available we ovewrite them
24-
if [ "${!fileVar:-}" ]; then
24+
if [ "${!fileVar:-}" ]; then
2525
log-helper trace "${fileVar} was defined"
2626

27-
val="$(< "${!fileVar}")"
27+
val="$(< "${!fileVar}")"
2828
log-helper debug "${var} was repalced with the contents of ${fileVar} (the value was: ${val})"
2929

3030
export "$var"="$val"
31-
fi
32-
33-
unset "$fileVar"
31+
fi
32+
33+
unset "$fileVar"
3434
}
3535

3636

@@ -267,11 +267,11 @@ EOF
267267

268268
# start OpenLDAP
269269
log-helper info "Start OpenLDAP..."
270-
270+
# At this stage, we can just listen to ldap:// and ldap:// without naming any names
271271
if log-helper level ge debug; then
272-
slapd -h "ldap://$HOSTNAME $PREVIOUS_HOSTNAME_PARAM ldap://localhost ldapi:///" -u openldap -g openldap -d $LDAP_LOG_LEVEL 2>&1 &
272+
slapd -h "ldap:/// ldapi:///" -u openldap -g openldap -d "$LDAP_LOG_LEVEL" 2>&1 &
273273
else
274-
slapd -h "ldap://$HOSTNAME $PREVIOUS_HOSTNAME_PARAM ldap://localhost ldapi:///" -u openldap -g openldap
274+
slapd -h "ldap:/// ldapi:///" -u openldap -g openldap
275275
fi
276276

277277

@@ -365,7 +365,7 @@ EOF
365365

366366
# create DHParamFile if not found
367367
[ -f ${LDAP_TLS_DH_PARAM_PATH} ] || openssl dhparam -out ${LDAP_TLS_DH_PARAM_PATH} 2048
368-
368+
369369
# fix file permissions
370370
if [ "${DISABLE_CHOWN,,}" == "false" ]; then
371371
chmod 600 ${LDAP_TLS_DH_PARAM_PATH}
@@ -520,8 +520,17 @@ ln -sf ${CONTAINER_SERVICE_DIR}/slapd/assets/.ldaprc $HOME/.ldaprc
520520
ln -sf ${CONTAINER_SERVICE_DIR}/slapd/assets/ldap.conf /etc/ldap/ldap.conf
521521

522522
# force OpenLDAP to listen on all interfaces
523+
# We need to make sure that /etc/hosts continues to include the
524+
# fully-qualified domain name and not just the specified hostname.
525+
# Without the FQDN, /bin/hostname --fqdn stops working.
526+
FQDN="$(/bin/hostname --fqdn)"
527+
if [ "$FQDN" != "$HOSTNAME" ]; then
528+
FQDN_PARAM="$FQDN"
529+
else
530+
FQDN_PARAM=""
531+
fi
523532
ETC_HOSTS=$(cat /etc/hosts | sed "/$HOSTNAME/d")
524-
echo "0.0.0.0 $HOSTNAME" > /etc/hosts
533+
echo "0.0.0.0 $FQDN_PARAM $HOSTNAME" > /etc/hosts
525534
echo "$ETC_HOSTS" >> /etc/hosts
526535

527536
exit 0

0 commit comments

Comments
 (0)