chmod needs more specific arguments to work with sudo_user
Basically if umask is set to something like 0007 then chmod +r and chmod +x are not the same as chmod a+r and chmod a+x Using os.path.basename rather than source.split should make ansible more portable (and even if never ported, more readable)pull/4420/head
parent
fc330cafce
commit
414eceb138
|
@ -210,10 +210,10 @@ class Runner(object):
|
||||||
args = utils.jsonify(args,format=True)
|
args = utils.jsonify(args,format=True)
|
||||||
|
|
||||||
(remote_module_path, is_new_style) = self._copy_module(conn, tmp, module_name, inject)
|
(remote_module_path, is_new_style) = self._copy_module(conn, tmp, module_name, inject)
|
||||||
cmd = "chmod +x %s" % remote_module_path
|
cmd = "chmod u+x %s" % remote_module_path
|
||||||
if self.sudo and self.sudo_user != 'root':
|
if self.sudo and self.sudo_user != 'root':
|
||||||
# deal with possible umask issues once sudo'ed to other user
|
# deal with possible umask issues once sudo'ed to other user
|
||||||
cmd = "chmod 555 %s" % remote_module_path
|
cmd = "chmod a+rx %s" % remote_module_path
|
||||||
self._low_level_exec_command(conn, cmd, tmp)
|
self._low_level_exec_command(conn, cmd, tmp)
|
||||||
|
|
||||||
cmd = ""
|
cmd = ""
|
||||||
|
@ -266,7 +266,7 @@ class Runner(object):
|
||||||
module_args += " #USE_SHELL"
|
module_args += " #USE_SHELL"
|
||||||
|
|
||||||
(module_path, is_new_style) = self._copy_module(conn, tmp, module_name, inject)
|
(module_path, is_new_style) = self._copy_module(conn, tmp, module_name, inject)
|
||||||
self._low_level_exec_command(conn, "chmod +x %s" % module_path, tmp)
|
self._low_level_exec_command(conn, "chmod a+rx %s" % module_path, tmp)
|
||||||
|
|
||||||
return self._execute_module(conn, tmp, 'async_wrapper', module_args,
|
return self._execute_module(conn, tmp, 'async_wrapper', module_args,
|
||||||
async_module=module_path,
|
async_module=module_path,
|
||||||
|
@ -315,8 +315,11 @@ class Runner(object):
|
||||||
exec_rc = None
|
exec_rc = None
|
||||||
if local_md5 != remote_md5:
|
if local_md5 != remote_md5:
|
||||||
# transfer the file to a remote tmp location
|
# transfer the file to a remote tmp location
|
||||||
tmp_src = tmp + source.split('/')[-1]
|
tmp_src = tmp + os.path.basename(source)
|
||||||
conn.put_file(source, tmp_src)
|
conn.put_file(source, tmp_src)
|
||||||
|
# fix file permissions when the copy is done as a different user
|
||||||
|
if self.sudo and self.sudo_user:
|
||||||
|
self._low_level_exec_command(conn, "chmod a+r %s" % tmp_src, tmp)
|
||||||
|
|
||||||
# run the copy module
|
# run the copy module
|
||||||
self.module_args = "%s src=%s" % (self.module_args, tmp_src)
|
self.module_args = "%s src=%s" % (self.module_args, tmp_src)
|
||||||
|
@ -669,7 +672,7 @@ class Runner(object):
|
||||||
|
|
||||||
cmd = 'mkdir -p %s' % basetmp
|
cmd = 'mkdir -p %s' % basetmp
|
||||||
if self.remote_user != 'root':
|
if self.remote_user != 'root':
|
||||||
cmd += ' && chmod a+x %s' % basetmp
|
cmd += ' && chmod a+rx %s' % basetmp
|
||||||
cmd += ' && echo %s' % basetmp
|
cmd += ' && echo %s' % basetmp
|
||||||
|
|
||||||
result = self._low_level_exec_command(conn, cmd, None, sudoable=False)
|
result = self._low_level_exec_command(conn, cmd, None, sudoable=False)
|
||||||
|
|
Loading…
Reference in New Issue