1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #11764 from lpirl/devel_v2

fixes remote code execution for su/sudo with strict remote umasks
This commit is contained in:
James Cammarata 2015-08-11 22:30:44 -04:00
commit e0b074000e
2 changed files with 8 additions and 3 deletions

View file

@ -164,7 +164,7 @@ class ActionBase:
tmp_mode = None
if self._play_context.remote_user != 'root' or self._play_context.become and self._play_context.become_user != 'root':
tmp_mode = 'a+rx'
tmp_mode = 0755
cmd = self._connection._shell.mkdtemp(basefile, use_system_tmp, tmp_mode)
self._display.debug("executing _low_level_execute_command to create the tmp path")

View file

@ -65,9 +65,14 @@ class ShellModule(object):
if system and (basetmp.startswith('$HOME') or basetmp.startswith('~/')):
basetmp = self.join_path('/tmp', basefile)
cmd = 'mkdir -p "%s"' % basetmp
if mode:
cmd += ' && chmod %s "%s"' % (mode, basetmp)
cmd += ' && echo "%s"' % basetmp
# change the umask in a subshell to achieve the desired mode
# also for directories created with `mkdir -p`
if mode:
tmp_umask = 0777 & ~mode
cmd = '(umask %o && %s)' % (tmp_umask, cmd)
return cmd
def expand_user(self, user_home_path):