From 4547d2efa1fd735b4c36be0c06df54c1794972d0 Mon Sep 17 00:00:00 2001
From: Steven Armstrong <steven@icarus.ethz.ch>
Date: Wed, 25 May 2016 12:39:11 +0200
Subject: [PATCH] properly escape single quotes

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
---
 cdist/conf/type/__install_config/files/remote/exec | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cdist/conf/type/__install_config/files/remote/exec b/cdist/conf/type/__install_config/files/remote/exec
index 58e6b162..fc217e3e 100755
--- a/cdist/conf/type/__install_config/files/remote/exec
+++ b/cdist/conf/type/__install_config/files/remote/exec
@@ -35,7 +35,10 @@ target_host="$__target_host"
 shift
 
 ssh="ssh -o User=root -q $target_host"
-code="$ssh chroot $chroot sh -c '$@'"
+
+# escape ' with '"'"'
+code="$(echo "$@" | sed -e "s/'/'\"'\"'/g")"
+code="$ssh chroot $chroot sh -c '$code'"
 
 log "target_host: $target_host"
 log "chroot: $chroot"