summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorzimbatm <zimbatm@zimbatm.com>2016-06-19 23:27:52 +0100
committerGitHub <noreply@github.com>2016-06-19 23:27:52 +0100
commitb0f8416c5c0e5345897832ae0cce139ed85c7fdb (patch)
treec34d9ef7febb4c1a6df6f179130506219e5e2d81 /pkgs
parent53f421c0c4b4916426c369bfb996422209e6ebf7 (diff)
parent28fa4a2f03e2232d95dec9dc2b8ef40857d725db (diff)
downloadnixpkgs-b0f8416c5c0e5345897832ae0cce139ed85c7fdb.tar
nixpkgs-b0f8416c5c0e5345897832ae0cce139ed85c7fdb.tar.gz
nixpkgs-b0f8416c5c0e5345897832ae0cce139ed85c7fdb.tar.bz2
nixpkgs-b0f8416c5c0e5345897832ae0cce139ed85c7fdb.tar.lz
nixpkgs-b0f8416c5c0e5345897832ae0cce139ed85c7fdb.tar.xz
nixpkgs-b0f8416c5c0e5345897832ae0cce139ed85c7fdb.tar.zst
nixpkgs-b0f8416c5c0e5345897832ae0cce139ed85c7fdb.zip
Merge pull request #16180 from zimbatm/shell-escaping
Escape all shell arguments uniformly
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/build-support/vm/windows/controller/default.nix4
-rw-r--r--pkgs/development/ruby-modules/bundler-env/default.nix6
-rw-r--r--pkgs/development/ruby-modules/gem/default.nix7
-rw-r--r--pkgs/servers/x11/xquartz/default.nix3
4 files changed, 7 insertions, 13 deletions
diff --git a/pkgs/build-support/vm/windows/controller/default.nix b/pkgs/build-support/vm/windows/controller/default.nix
index 1c8e6af83b8..06a0a229306 100644
--- a/pkgs/build-support/vm/windows/controller/default.nix
+++ b/pkgs/build-support/vm/windows/controller/default.nix
@@ -71,8 +71,6 @@ let
     };
   };
 
-  shellEscape = x: "'${replaceChars ["'"] [("'\\'" + "'")] x}'";
-
   loopForever = "while :; do ${coreutils}/bin/sleep 1; done";
 
   initScript = writeScript "init.sh" (''
@@ -132,7 +130,7 @@ let
       -o StrictHostKeyChecking=no \
       -i /ssh.key \
       -l Administrator \
-      192.168.0.1 -- ${shellEscape command}
+      192.168.0.1 -- ${lib.escapeShellArg command}
   '') + optionalString (suspendTo != null) ''
     ${coreutils}/bin/touch /xchg/suspend_now
     ${loopForever}
diff --git a/pkgs/development/ruby-modules/bundler-env/default.nix b/pkgs/development/ruby-modules/bundler-env/default.nix
index 4ebba0d5b65..56a3b371d1d 100644
--- a/pkgs/development/ruby-modules/bundler-env/default.nix
+++ b/pkgs/development/ruby-modules/bundler-env/default.nix
@@ -16,8 +16,6 @@
 }@args:
 
 let
-
-  shellEscape = x: "'${lib.replaceChars ["'"] [("'\\'" + "'")] x}'";
   importedGemset = import gemset;
   filteredGemset = (lib.filterAttrs (name: attrs:
     if (builtins.hasAttr "groups" attrs)
@@ -58,8 +56,8 @@ let
         "${confFiles}/Gemfile" \
         "$out/${ruby.gemPath}" \
         "${bundler}/${ruby.gemPath}" \
-        ${shellEscape (toString envPaths)} \
-        ${shellEscape (toString groups)}
+        ${lib.escapeShellArg envPaths} \
+        ${lib.escapeShellArg groups}
     '' + lib.optionalString (postBuild != null) postBuild;
     passthru = rec {
       inherit ruby bundler meta gems;
diff --git a/pkgs/development/ruby-modules/gem/default.nix b/pkgs/development/ruby-modules/gem/default.nix
index 6e1b0c00bd0..74dc64000c0 100644
--- a/pkgs/development/ruby-modules/gem/default.nix
+++ b/pkgs/development/ruby-modules/gem/default.nix
@@ -18,8 +18,8 @@
 # Normal gem packages can be used outside of bundler; a binstub is created in
 # $out/bin.
 
-{ lib, ruby, bundler, fetchurl, fetchgit, makeWrapper, git,
-  buildRubyGem, darwin
+{ lib, fetchurl, fetchgit, makeWrapper, git, darwin
+, ruby, bundler
 } @ defs:
 
 lib.makeOverridable (
@@ -53,7 +53,6 @@ lib.makeOverridable (
 , ...} @ attrs:
 
 let
-  shellEscape = x: "'${lib.replaceChars ["'"] [("'\\'" + "'")] x}'";
   src = attrs.src or (
     if type == "gem" then
       fetchurl {
@@ -165,7 +164,7 @@ stdenv.mkDerivation (attrs // {
       ${src} \
       ${attrs.rev} \
       ${version} \
-      ${shellEscape (toString buildFlags)}
+      ${lib.escapeShellArgs buildFlags}
     ''}
 
     ${lib.optionalString (type == "gem") ''
diff --git a/pkgs/servers/x11/xquartz/default.nix b/pkgs/servers/x11/xquartz/default.nix
index 16a4aeb1ce5..79b99faea9b 100644
--- a/pkgs/servers/x11/xquartz/default.nix
+++ b/pkgs/servers/x11/xquartz/default.nix
@@ -37,7 +37,6 @@
 # that point into the user's profile.
 
 let
-  shellEscape = x: "'${lib.replaceChars ["'"] [("'\\'" + "'")] x}'";
   installer = writeScript "xquartz-install" ''
     NIX_LINK=$HOME/.nix-profile
 
@@ -138,7 +137,7 @@ in stdenv.mkDerivation {
     defaultStartX="$out/bin/startx -- $out/bin/Xquartz"
 
     ruby ${./patch_plist.rb} \
-      ${shellEscape (builtins.toXML {
+      ${lib.escapeShellArg (builtins.toXML {
         XQUARTZ_DEFAULT_CLIENT = "${xterm}/bin/xterm";
         XQUARTZ_DEFAULT_SHELL  = "${shell}";
         XQUARTZ_DEFAULT_STARTX = "@STARTX@";