3
0
Fork 0
forked from mirrors/nixpkgs

systemd service: fix issues with escaping when unit name contains '-'

systemd escaping rules translate this into a string containing '\'
which is treated by some code paths as quoted, and by others as unquoted
causing the affected units to fail.
This commit is contained in:
Evgeny Egorochkin 2014-06-09 22:41:07 +03:00
parent 03d9bbcfa9
commit b415876bdb

View file

@ -15,13 +15,13 @@ let
pkgs.runCommand "unit" { preferLocalBuild = true; inherit (unit) text; } pkgs.runCommand "unit" { preferLocalBuild = true; inherit (unit) text; }
'' ''
mkdir -p $out mkdir -p $out
echo -n "$text" > $out/${name} echo -n "$text" > $out/${shellEscape name}
'' ''
else else
pkgs.runCommand "unit" { preferLocalBuild = true; } pkgs.runCommand "unit" { preferLocalBuild = true; }
'' ''
mkdir -p $out mkdir -p $out
ln -s /dev/null $out/${name} ln -s /dev/null $out/${shellEscape name}
''; '';
upstreamSystemUnits = upstreamSystemUnits =
@ -187,9 +187,11 @@ let
"timers.target" "timers.target"
]; ];
shellEscape = s: (replaceChars [ "\\" ] [ "\\\\" ] s);
makeJobScript = name: text: makeJobScript = name: text:
let x = pkgs.writeTextFile { name = "unit-script"; executable = true; destination = "/bin/${name}"; inherit text; }; let x = pkgs.writeTextFile { name = "unit-script"; executable = true; destination = "/bin/${shellEscape name}"; inherit text; };
in "${x}/bin/${name}"; in "${x}/bin/${shellEscape name}";
unitConfig = { name, config, ... }: { unitConfig = { name, config, ... }: {
config = { config = {