Quote ldap password

Otherwise special characters like # do not work
This commit is contained in:
Sandro Jäckel 2024-04-13 16:08:58 +02:00 committed by lewo
parent 9f6635a035
commit ef4756bcfc
2 changed files with 5 additions and 3 deletions

View File

@ -49,7 +49,7 @@ in
# Appends the LDAP bind password to files to avoid writing this
# password into the Nix store.
appendLdapBindPwd = {
name, file, prefix, passwordFile, destination
name, file, prefix, suffix ? "", passwordFile, destination
}: pkgs.writeScript "append-ldap-bind-pwd-in-${name}" ''
#!${pkgs.stdenv.shell}
set -euo pipefail
@ -61,8 +61,9 @@ in
fi
cat ${file} > ${destination}
echo -n "${prefix}" >> ${destination}
echo -n '${prefix}' >> ${destination}
cat ${passwordFile} >> ${destination}
echo -n '${suffix}' >> ${destination}
chmod 600 ${destination}
'';

View File

@ -90,7 +90,8 @@ let
setPwdInLdapConfFile = appendLdapBindPwd {
name = "ldap-conf-file";
file = ldapConfig;
prefix = "dnpass = ";
prefix = ''dnpass = "'';
suffix = ''"'';
passwordFile = cfg.ldap.bind.passwordFile;
destination = ldapConfFile;
};