Commit 7b6d64d9 by Michael DeHaan

Merge pull request #4591 from bcoca/scriptnonrootsudosafe

now correctly changes script permission in all cases
parents 3c4dd618 c476ed93
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment