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
This commit is contained in:
Stan Lagun 2016-03-31 17:09:19 +03:00
parent 14f08ecc85
commit 699aa62378
3 changed files with 15 additions and 26 deletions

View File

@ -14,19 +14,20 @@ 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
verifyExitcode: $verifyExitcode
verifyExitcode: $verifyExitcode

View File

@ -1,14 +0,0 @@
#!/bin/bash
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
eval ${*}

View File

@ -238,11 +238,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: