Patchwork [1/2] Fix remote command execution

login
register
mail settings
Submitter Chase Douglas
Date Feb. 15, 2010, 4:20 p.m.
Message ID <1266250823-12394-2-git-send-email-chase.douglas@canonical.com>
Download mbox | patch
Permalink /patch/45400/
State Accepted
Delegated to: Stefan Bader
Headers show

Comments

Chase Douglas - Feb. 15, 2010, 4:20 p.m.
The remote command execution through ssh was broken due to HEREDOC
usage within a subshell. This change breaks the command synthesis
into a separate variable that is then fed to ssh in a second step.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
---
 buildscripts/build-create-host |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

Patch

diff --git a/buildscripts/build-create-host b/buildscripts/build-create-host
index 50590d5..5bf163e 100755
--- a/buildscripts/build-create-host
+++ b/buildscripts/build-create-host
@@ -14,28 +14,28 @@  if [ "${HOST}" = "" ]; then
 	exit 1
 fi
 
-HOSTINFO="$(cat <<EOD | ssh ${HOST} -oConnectTimeout=60
-if [ "\`type -p dpkg-architecture\`" != "" ]; then
-	echo HOSTARCH="\`dpkg-architecture -qDEB_BUILD_ARCH\`"
+CMD='if [ "\`type -p dpkg-architecture\`" != "" ]; then
+	echo HOSTARCH="\`dpkg-architecture -qDEB_BUILD_ARCH\`";
 else
-	echo HOSTARCH="\`dpkg --print-architecture\`"
-fi
+	echo HOSTARCH="\`dpkg --print-architecture\`";
+fi;
 if [ "\`type -p schroot\`" != "" ]; then
-	CHROOTCMD="schroot"
+	CHROOTCMD="schroot";
 elif [ "\`type -p dchroot\`" != "" ]; then
-	CHROOTCMD="dchroot"
+	CHROOTCMD="dchroot";
 else
-	exit 1
-fi
-echo "CHROOTCMD=\$CHROOTCMD"
+	exit 1;
+fi;
+echo "CHROOTCMD=$CHROOTCMD";
 
-if [ \`id -u\` -ne 0 ]; then
-	echo "FAKEROOT=fakeroot"
+if [ `id -u` -ne 0 ]; then
+	echo "FAKEROOT=fakeroot";
 else
-	echo "FAKEROOT=''"
-fi
-echo "BASE=\$HOME"
-EOD)"
+	echo "FAKEROOT=\"\"";
+fi;
+echo "BASE=$HOME"'
+
+HOSTINFO=$(echo $CMD | ssh ${HOST} -oConnectTimeout=60)
 
 case $? in
 	255)