Merge pull request #4591 from bcoca/scriptnonrootsudosafe

now correctly changes script permission in all cases
This commit is contained in:
Michael DeHaan 2013-10-18 15:04:09 -07:00
commit 7b6d64d98c

View file

@ -58,15 +58,18 @@ class ActionModule(object):
conn.put_file(source, tmp_src)
# fix file permissions when the copy is done as a different user
sudoable=True
# set file permissions, more permisive when the copy is done as a different user
if self.runner.sudo and self.runner.sudo_user != 'root':
prepcmd = 'chmod a+rx %s' % tmp_src
cmd_args_chmod = "chmod a+rx %s" % tmp_src
sudoable=False
else:
prepcmd = 'chmod +x %s' % tmp_src
cmd_args_chmod = "chmod +rx %s" % tmp_src
self.runner._low_level_exec_command(conn, cmd_args_chmod, tmp, sudoable=sudoable)
# add preparation steps to one ssh roundtrip executing the script
env_string = self.runner._compute_environment_string(inject)
module_args = prepcmd + '; ' + env_string + tmp_src + ' ' + args
module_args = env_string + tmp_src + ' ' + args
handler = utils.plugins.action_loader.get('raw', self.runner)
result = handler.run(conn, tmp, 'raw', module_args, inject)