From f1956eb624e539b091139c75b00881dcfd13b301 Mon Sep 17 00:00:00 2001 From: Stan Lagun Date: Thu, 31 Mar 2016 17:09:19 +0300 Subject: [PATCH] Don't use bash eval for Linux.runCommand Linux.runCommand method used to pass script in a command line argument and evaluated it using "eval". This approach failed when the script contained input redirection. With this fix script is passed as a file which is specified as an entry point in execution plan. Also we supported explicit files in execution plan but not for the script entry point. This was fixed as well. Change-Id: Ifd15fc57b08e33ed61cd2765613cd705ce12a5f2 Closes-Bug: #1562954 --- meta/io.murano/Resources/RunCommand.template | 13 +++++++------ meta/io.murano/Resources/scripts/runCommand.sh | 3 --- murano/engine/system/agent.py | 12 +++++++----- 3 files changed, 14 insertions(+), 14 deletions(-) delete mode 100644 meta/io.murano/Resources/scripts/runCommand.sh diff --git a/meta/io.murano/Resources/RunCommand.template b/meta/io.murano/Resources/RunCommand.template index 88f01e64f..3722ece56 100644 --- a/meta/io.murano/Resources/RunCommand.template +++ b/meta/io.murano/Resources/RunCommand.template @@ -2,18 +2,19 @@ FormatVersion: 2.0.0 Version: 1.0.0 Name: $planName -Parameters: - command: $command +Body: return runCommand() -Body: | - return runCommand("{0}".format(args.command)) +Files: + scriptFile: + BodyType: Text + Name: scriptFile.sh + Body: $command Scripts: runCommand: Type: Application Version: 1.0.0 - EntryPoint: runCommand.sh - Files: [] + EntryPoint: scriptFile.sh Options: captureStdout: $captureStdout captureStderr: $captureStderr diff --git a/meta/io.murano/Resources/scripts/runCommand.sh b/meta/io.murano/Resources/scripts/runCommand.sh deleted file mode 100644 index 64811cd09..000000000 --- a/meta/io.murano/Resources/scripts/runCommand.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -eval ${*} diff --git a/murano/engine/system/agent.py b/murano/engine/system/agent.py index 35266b443..2183dcd03 100644 --- a/murano/engine/system/agent.py +++ b/murano/engine/system/agent.py @@ -243,11 +243,13 @@ class Agent(object): if 'EntryPoint' not in script: raise ValueError('No entry point in script ' + name) - if 'Application' in script['Type']: - script['EntryPoint'] = self._place_file(scripts_folder, - script['EntryPoint'], - template, resources, - files) + if 'Application' == script['Type']: + if script['EntryPoint'] not in files: + script['EntryPoint'] = self._place_file( + scripts_folder, script['EntryPoint'], + template, resources, files) + else: + script['EntryPoint'] = files[script['EntryPoint']] if 'Files' in script: for i, file in enumerate(script['Files']): if self._get_name(file) not in files: