nixos/roundcube: read only first line of password file

Only read the first line of the password file, if has multiple lines.
Mention that behaviour in options documentation.
This commit is contained in:
Andreas Brinner 2023-04-23 20:28:00 +02:00
parent 78fb35ce39
commit 9d5dba7170

View file

@ -73,7 +73,8 @@ in
description = lib.mdDoc ''
Password file for the postgresql connection.
Must be formated according to PostgreSQL .pgpass standard (see https://www.postgresql.org/docs/current/libpq-pgpass.html)
and readable by user `nginx`. Ignored if `database.host` is set to `localhost`, as peer authentication will be used.
but only one line, no comments and readable by user `nginx`.
Ignored if `database.host` is set to `localhost`, as peer authentication will be used.
'';
};
dbname = mkOption {
@ -128,7 +129,7 @@ in
<?php
${lib.optionalString (!localDB) ''
$password = file_get_contents('${cfg.database.passwordFile}');
$password = file('${cfg.database.passwordFile}')[0];
$password = preg_split('~\\\\.(*SKIP)(*FAIL)|\:~s', $password);
$password = end($password);
$password = str_replace("\\:", ":", $password);