Merge commit 'refs/pull/14907/head' of git://github.com/NixOS/nixpkgs into staging

+17 -2
+9 -1
doc/stdenv.xml
··· 1169 echo @foo@ 1170 </programlisting> 1171 1172 - That is, no substitution is performed for undefined variables.</para></listitem> 1173 </varlistentry> 1174 1175
··· 1169 echo @foo@ 1170 </programlisting> 1171 1172 + That is, no substitution is performed for undefined variables.</para> 1173 + 1174 + <para>Environment variables that start with an uppercase letter are filtered out, 1175 + to prevent global variables (like <literal>HOME</literal>) from accidentally 1176 + getting substituted. 1177 + The variables also have to be valid bash “names”, as 1178 + defined in the bash manpage (alphanumeric or <literal>_</literal>, must not 1179 + start with a number).</para> 1180 + </listitem> 1181 </varlistentry> 1182 1183
+1
pkgs/build-support/substitute/substitute-all.nix
··· 2 3 args: 4 5 stdenv.mkDerivation ({ 6 name = if args ? name then args.name else baseNameOf (toString args.src); 7 builder = ./substitute-all.sh;
··· 2 3 args: 4 5 + # see the substituteAll in the nixpkgs documentation for usage and constaints 6 stdenv.mkDerivation ({ 7 name = if args ? name then args.name else baseNameOf (toString args.src); 8 builder = ./substitute-all.sh;
+7 -1
pkgs/stdenv/generic/setup.sh
··· 408 409 if [ "$p" = --subst-var ]; then 410 varName="${params[$((n + 1))]}" 411 pattern="@$varName@" 412 replacement="${!varName}" 413 n=$((n + 1)) ··· 439 local output="$2" 440 441 # Select all environment variables that start with a lowercase character. 442 - for envVar in $(env | sed -e $'s/^\([a-z][^=]*\)=.*/\\1/; t \n d'); do 443 if [ "$NIX_DEBUG" = "1" ]; then 444 echo "$envVar -> ${!envVar}" 445 fi
··· 408 409 if [ "$p" = --subst-var ]; then 410 varName="${params[$((n + 1))]}" 411 + # check if the used nix attribute name is a valid bash name 412 + if ! [[ "$varName" =~ ^[a-zA-Z_]+[a-zA-Z0-9_]*$ ]]; then 413 + echo "substitution variables must be valid bash names, \"$varName\" isn't." 414 + exit 1; 415 + fi 416 pattern="@$varName@" 417 replacement="${!varName}" 418 n=$((n + 1)) ··· 444 local output="$2" 445 446 # Select all environment variables that start with a lowercase character. 447 + # Will not work with nix attribute names (and thus env variables) containing '\n'. 448 + for envVar in $(set | sed -e $'s/^\([a-z][^=]*\)=.*/\\1/; t \n d'); do 449 if [ "$NIX_DEBUG" = "1" ]; then 450 echo "$envVar -> ${!envVar}" 451 fi