tiredofit / docker-openldap

Dockerized LDAP server with many customizable options
MIT License
110 stars 48 forks source link

6.9.0 seem not to load defaults/10-openldap and fails when TLS_ENFORCE="true" #23

Closed cristichiru closed 4 years ago

cristichiru commented 4 years ago

Trying to deploy with TLS_ENFORCE: "true" will fail to launch ldap.

It seems that the defaults/10-openldap that is supposed to set some vars is not actually loaded, because WAS_STARTED_WITH_REPLICATION seems empty, since touch complains.

Also, I have noticed that dhparam.pem file is created in the root of the container, as I did not specify the path, just the name, assuming the defaults. This is another clue.

Maybe this is not yet working.

Log

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] 00-functions: applying...
[fix-attrs.d] 00-functions: exited 0.
[fix-attrs.d] 01-s6: applying...
[fix-attrs.d] 01-s6: exited 0.
[fix-attrs.d] 02-zabbix: applying...
[fix-attrs.d] 02-zabbix: exited 0.
[fix-attrs.d] 03-logrotate: applying...
[fix-attrs.d] 03-logrotate: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-startup: executing...
[cont-init.d] 00-startup: exited 0.
[cont-init.d] 01-timezone: executing...
[NOTICE] ** [timezone] Setting timezone to 'Etc/GMT'
[cont-init.d] 01-timezone: exited 0.
[cont-init.d] 02-permissions: executing...
[cont-init.d] 02-permissions: exited 0.
[cont-init.d] 03-zabbix: executing...
[cont-init.d] 03-zabbix: exited 0.
[cont-init.d] 04-cron: executing...
[cont-init.d] 04-cron: exited 0.
[cont-init.d] 05-smtp: executing...
[NOTICE] ** [smtp] Disabling SMTP Features
[cont-init.d] 05-smtp: exited 0.
[cont-init.d] 09-nginx: executing...
/var/run/s6/etc/cont-init.d/09-nginx: line 4: prepare_service: command not found
[cont-init.d] 09-nginx: exited 0.
[cont-init.d] 10-openldap: executing...
[INFO] ** [openldap] Starting OpenLDAP Initialization Sequence
[INFO] ** [openldap] Waiting for OpenLDAP to be ready
[INFO] ** [openldap] Starting TLS configuration. Please wait...
/var/run/s6/etc/cont-init.d/10-openldap: line 344: $WAS_STARTED_WITH_TLS: ambiguous redirect
/var/run/s6/etc/cont-init.d/10-openldap: line 345: $WAS_STARTED_WITH_TLS: ambiguous redirect
/var/run/s6/etc/cont-init.d/10-openldap: line 346: $WAS_STARTED_WITH_TLS: ambiguous redirect
/var/run/s6/etc/cont-init.d/10-openldap: line 347: $WAS_STARTED_WITH_TLS: ambiguous redirect
[NOTICE] ** [openldap] Adding TLS enforcement
[INFO] ** [openldap] Configuring replication
/var/run/s6/etc/cont-init.d/10-openldap: line 394: $WAS_STARTED_WITH_REPLICATION: ambiguous redirect
[INFO] ** [openldap] Finished OpenLDAP Initialization
[INFO] ** [openldap] Configuring ldap client
[NOTICE] ** [openldap] Ready to start OpenLDAP
touch: missing file operand
Try 'touch --help' for more information.
[cont-init.d] 10-openldap: exited 0.
[cont-init.d] 99-container: executing...
[cont-init.d] 99-container: exited 0.
[cont-init.d] done.
[services.d] starting services
[INFO] ** [zabbix] Starting Zabbix Agent
[services.d] done.

In my opinion, if ldap is failing to start, the whole container should fail.

tiredofit commented 4 years ago

Hi there, the clue is up at the top - where its looking for a function called prepare_service. Something has happened with Docker Hub and it's built a whole bunch of images out of sequence before the underlying base image was built.

You could try an earlier tagged version or try latest - I don't know when Docker Hub will finish off what its doing, it has been going on now for near 5 days.

tiredofit commented 4 years ago

Deleting the tag from Docker Hub

tiredofit commented 4 years ago

New build up 6.9.1 which should resolve all these issues. My apologies.

cristichiru commented 4 years ago

Thank you for looking into this.

I have tried again with 6.9.1 and seems to be kind of the same problem.

Container still fails:

[INFO] /etc/cont-init.d/10-openldap ** [openldap] Starting TLS configuration. Please wait...
+ silent ssl-helper /server.crt /server.key /ca.crt
+ '[' true = TRUE ']'
+ '[' true = true ']'
+ ssl-helper /server.crt /server.key /ca.crt
+ PREFIX=/server.crt
+ CERT_FILE=/server.key
+ KEY_FILE=/ca.crt
+ CA_FILE=
+ PREFIX=/SERVER.CRT
+ PREFIX_SSL_HELPER_TOOL=/SERVER.CRT_SSL_HELPER_TOOL
+ PREFIX_SSL_HELPER_AUTO_RENEW=/SERVER.CRT_SSL_HELPER_AUTO_RENEW
+ PREFIX_SSL_HELPER_AUTO_RENEW_CRON_EXP=/SERVER.CRT_SSL_HELPER_AUTO_RENEW_CRON_EXP
+ PREFIX_SSL_HELPER_AUTO_RENEW_SERVICES_IMPACTED=/SERVER.CRT_SSL_HELPER_AUTO_RENEW_SERVICES_IMPACTED
+ PREFIX_SSL_HELPER_AUTO_RENEW_FROM_FILES=/SERVER.CRT_SSL_HELPER_AUTO_RENEW_FROM_FILES
+ PREFIX_SSL_HELPER_AUTO_RENEW_CERT_FROM_FILE=/SERVER.CRT_SSL_HELPER_AUTO_RENEW_CERT_FROM_FILE
+ PREFIX_SSL_HELPER_AUTO_RENEW_KEY_FROM_FILE=/SERVER.CRT_SSL_HELPER_AUTO_RENEW_KEY_FROM_FILE
+ PREFIX_SSL_HELPER_AUTO_RENEW_CA_CERT_FROM_FILE=/SERVER.CRT_SSL_HELPER_AUTO_RENEW_CA_CERT_FROM_FILE
/usr/sbin/ssl-helper: line 27: /SERVER.CRT_SSL_HELPER_TOOL: invalid variable name
[cont-init.d] 10-openldap: exited 1.
[cont-init.d] 99-container: executing...
+ PROCESS_NAME=container
+ var_false FALSE
+ '[' FALSE = FALSE ']'
+ output_off
+ '[' true = TRUE ']'
+ '[' true = true ']'
+ set +x
**********************************************************************************************************************
**********************************************************************************************************************
****                                                                                                              ****
****       ERROR - Some initialization scripts haven't completed - All services are now halted                    ****
****             - The following scripts in '/etc/cont-init.d' did not pass their completion check                ****
****                                                                                                              ****
**********************************************************************************************************************
**********************************************************************************************************************

10-openldap

Notice how, among other things, CA and Key files are mapped incorrectly.

Other investigation

Running inside the container:

for e in `grep -oE '^\w+' /assets/defaults/10-openldap`; do eval "echo $e=\$$e"; done

produces:

BACKUP_TTL=15
CONFIG_PASS=thisisnotanactualpass
DOMAIN=mydomain.com
ENABLE_NGINX=
ENABLE_READONLY_USER=false
ENABLE_REPLICATION=true
ENABLE_TLS=true
FIRST_START_DONE=
LOG_LEVEL=256
ORGANIZATION=MyOrg
READONLY_USER_PASS=readonlychangeme
READONLY_USER_USER=
REMOVE_CONFIG_AFTER_SETUP=
SCHEMA_TYPE=rfc2307bis
SLAPD_ARGS=
SLAPD_HOSTS=ldap://server1.lan ldaps://server1.lan ldapi:///
SSL_HELPER_PREFIX=
TLS_CA_CRT_FILENAME=ca.crt
TLS_CA_CRT_PATH=
TLS_CIPHER_SUITE=ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:-DHE-DSS:-RSA:!aNULL:!MD5:!DSS:!SHA
TLS_CRT_FILENAME=server.crt
TLS_CRT_PATH=
TLS_DH_PARAM_FILENAME=dhparam.pem
TLS_DH_PARAM_KEYSIZE=2048
TLS_DH_PARAM_PATH=
TLS_ENFORCE=false
TLS_KEY_FILENAME=server.key
TLS_KEY_PATH=
TLS_RESET_PERMISSIONS=
TLS_VERIFY_CLIENT=
ULIMIT_N=2048
WAS_STARTED_WITH_REPLICATION=
WAS_STARTED_WITH_TLS=
WAS_STARTED_WITH_TLS_ENFORCE=

As you can see, some vars are not set. The ones that have values, are set by me.

tiredofit commented 4 years ago

Yes definitely not right. I will go back and look at this in the next 24 hours. Can you switch to using something before the 6.9.0 series for now?

cristichiru commented 4 years ago

Thanks. No worries, 6.8.9 does the job just right at the moment. I switch easily using an ansible playbook/role.

tiredofit commented 4 years ago

Found the problem. When upgrading my base images there was a one line missed out on upgrading this image to support it where it simply pulled the functions, but not the defaults. You should have success going forward.

cristichiru commented 4 years ago

6.9.2 seems to be working fine. Enabled debug and all variables seem to be right.

Thank you for the effort put into this. Your release is simpler and it just works (with multimaster replication) compared to oxisia release. Daily dumps of data and config is a really nice touch.

For anyone interested, I am using this ansible playbook and role to deploy tiredofit/docker-openldap release.