1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

programs.rclone: fix injecting secret when value begins with "-"

This commit is contained in:
Kylie McClain 2025-08-28 16:18:39 -04:00 committed by Austin Horstman
parent 4896177e2c
commit e44549074a
3 changed files with 12 additions and 8 deletions

View file

@ -259,7 +259,7 @@ in
if ! ${lib.getExe cfg.package} config update \
${remote.name} config_refresh_token=false \
${secret} "$(cat "${secretFile}")" \
${secret}="$(cat "${secretFile}")" \
--non-interactive; then
echo "Failed to inject secret \"${secretFile}\""
cleanup

View file

@ -21,7 +21,7 @@ in
imports = [
./no-secrets.nix
./with-secrets-in-store.nix
./secrets-with-whitespace.nix
./secrets-arbitrary-characters.nix
./no-type.nix
./mount.nix
./shell.nix

View file

@ -1,6 +1,6 @@
{ pkgs, ... }:
let
module = pkgs.writeText "secrets-with-whitespace-module" ''
module = pkgs.writeText "secrets-arbitrary-characters-module" ''
{
programs.rclone.remotes = {
alices-cool-remote-v3 = {
@ -8,25 +8,29 @@ let
type = "memory";
description = "alices speeedy remote";
};
secrets.spaces-secret = "${pkgs.writeText "secret" ''
secrets = {
spaces-secret = "${pkgs.writeText "secret" ''
This is a secret with spaces, it has single spaces, and lots of spaces :3
''}";
symbols-secret = "${pkgs.writeText "secret" "-x'$$*>\"+:&#{!@'"}";
};
};
};
}
'';
expected = pkgs.writeText "secrets-with-whitespace-expected" ''
expected = pkgs.writeText "secrets-arbitrary-characters-expected" ''
[alices-cool-remote-v3]
description = alices speeedy remote
type = memory
spaces-secret = This is a secret with spaces, it has single spaces, and lots of spaces :3
symbols-secret = -x'$$*>"+:&#{!@'
'';
in
{
script = ''
with subtest("Secrets with spaces"):
with subtest("Secrets with arbitrary characters"):
succeed_as_alice("install -m644 ${module} /home/alice/.config/home-manager/test-remote.nix")
actual = succeed_as_alice("home-manager switch")