From 1bdeca9e7d23078d3c0544fe37495478b511180c Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Thu, 3 Dec 2020 16:33:48 +0100 Subject: [PATCH] unit: Remove dangerous slash from index names --- garlic/stages/unit.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/garlic/stages/unit.nix b/garlic/stages/unit.nix index 23ed75e..72ee52e 100644 --- a/garlic/stages/unit.nix +++ b/garlic/stages/unit.nix @@ -10,6 +10,7 @@ }: with stdenv.lib; +with builtins; let @@ -38,6 +39,9 @@ let firstStage = (x: x.programPath) (elemAt linkStages 0); jsonConf = writeText "garlic_config.json" (builtins.toJSON conf); + + safeUnitName = replaceStrings ["/" "$"] ["_" "_"] conf.unitName; + safeExpName = replaceStrings ["/" "$"] ["_" "_"] conf.expName; in builtins.trace "evaluating unit ${conf.unitName}" stdenv.mkDerivation { @@ -72,14 +76,14 @@ stdenv.mkDerivation { export GARLIC_UNIT=$(basename $out) # Create an index entry - rm -f "\$GARLIC_INDEX/${conf.unitName}" \ - "\$GARLIC_INDEX/${conf.expName}" + rm -f "\$GARLIC_INDEX/${safeUnitName}" \ + "\$GARLIC_INDEX/${safeExpName}" ln -Tfs "../out/\$GARLIC_UNIT" \ - "\$GARLIC_INDEX/${conf.unitName}" + "\$GARLIC_INDEX/${safeUnitName}" ln -Tfs "../out/\$GARLIC_EXPERIMENT" \ - "\$GARLIC_INDEX/${conf.expName}" + "\$GARLIC_INDEX/${safeExpName}" if [ -e "\$GARLIC_UNIT" ]; then >&2 echo "skipping, unit path already exists: \$GARLIC_UNIT"