From 7842e89bfcd916dfabad6d37150941461660242d Mon Sep 17 00:00:00 2001 From: talyz Date: Tue, 4 May 2021 16:10:23 +0200 Subject: [PATCH] nixos/gitlab: Use replace-secret to avoid leaking secrets Using `replace-literal` to insert secrets leaks the secrets through the `replace-literal` process' `/proc//cmdline` file. `replace-secret` solves this by reading the secret straight from the file instead, which also simplifies the code a bit. --- nixos/modules/services/misc/gitlab.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/misc/gitlab.nix b/nixos/modules/services/misc/gitlab.nix index 8153754af0f..253d87537cf 100644 --- a/nixos/modules/services/misc/gitlab.nix +++ b/nixos/modules/services/misc/gitlab.nix @@ -952,7 +952,7 @@ in { path = with pkgs; [ jq openssl - replace + replace-secret git ]; serviceConfig = { @@ -994,8 +994,7 @@ in { ${optionalString cfg.smtp.enable '' install -m u=rw ${smtpSettings} ${cfg.statePath}/config/initializers/smtp_settings.rb ${optionalString (cfg.smtp.passwordFile != null) '' - smtp_password=$(<'${cfg.smtp.passwordFile}') - replace-literal -e '@smtpPassword@' "$smtp_password" '${cfg.statePath}/config/initializers/smtp_settings.rb' + replace-secret '@smtpPassword@' '${cfg.smtp.passwordFile}' '${cfg.statePath}/config/initializers/smtp_settings.rb' ''} ''}