summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaïm Favier <n@monade.li>2023-06-23 21:09:03 +0200
committerGitHub <noreply@github.com>2023-06-23 21:09:03 +0200
commit1c69fce73a92cb686e007927b28b7095885948aa (patch)
tree6147d2c2f926e0007f00f0df1d326006c080201e
parentMerge pull request #239344 from NixOS/backport-239313-to-release-23.05 (diff)
parentnixos/syncthing: fix escaping (diff)
downloadnixpkgs-1c69fce73a92cb686e007927b28b7095885948aa.tar.gz
Merge pull request #239428 from NixOS/backport-239427-to-release-23.05
[Backport release-23.05] nixos/syncthing: fix escaping
-rw-r--r--nixos/modules/services/networking/syncthing.nix6
-rw-r--r--nixos/tests/syncthing-init.nix5
2 files changed, 6 insertions, 5 deletions
diff --git a/nixos/modules/services/networking/syncthing.nix b/nixos/modules/services/networking/syncthing.nix
index 3d41fe4013ea..69b45eb02d1d 100644
--- a/nixos/modules/services/networking/syncthing.nix
+++ b/nixos/modules/services/networking/syncthing.nix
@@ -55,9 +55,9 @@ let
# generate the new config by merging with the NixOS config options
new_cfg=$(printf '%s\n' "$old_cfg" | ${pkgs.jq}/bin/jq -c '. * {
- "devices": (${builtins.toJSON devices}${optionalString (cfg.devices == {} || ! cfg.overrideDevices) " + .devices"}),
- "folders": (${builtins.toJSON folders}${optionalString (cfg.folders == {} || ! cfg.overrideFolders) " + .folders"})
- } * ${builtins.toJSON cfg.extraOptions}')
+ "devices": ('${escapeShellArg (builtins.toJSON devices)}'${optionalString (cfg.devices == {} || ! cfg.overrideDevices) " + .devices"}),
+ "folders": ('${escapeShellArg (builtins.toJSON folders)}'${optionalString (cfg.folders == {} || ! cfg.overrideFolders) " + .folders"})
+ } * '${escapeShellArg (builtins.toJSON cfg.extraOptions)})
# send the new config
curl -X PUT -d "$new_cfg" ${cfg.guiAddress}/rest/config
diff --git a/nixos/tests/syncthing-init.nix b/nixos/tests/syncthing-init.nix
index fcd90739e6a5..5102c0127832 100644
--- a/nixos/tests/syncthing-init.nix
+++ b/nixos/tests/syncthing-init.nix
@@ -1,6 +1,7 @@
import ./make-test-python.nix ({ lib, pkgs, ... }: let
testId = "7CFNTQM-IMTJBHJ-3UWRDIU-ZGQJFR6-VCXZ3NB-XUH3KZO-N52ITXR-LAIYUAU";
+ testName = "testDevice foo'bar";
in {
name = "syncthing-init";
@@ -9,12 +10,12 @@ in {
nodes.machine = {
services.syncthing = {
enable = true;
- devices.testDevice = {
+ devices.${testName} = {
id = testId;
};
folders.testFolder = {
path = "/tmp/test";
- devices = [ "testDevice" ];
+ devices = [ testName ];
};
extraOptions.gui.user = "guiUser";
};