mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
fixes remote code execution for su/sudo and strict remote umasks
* temporarily changes umask for creating temporary directories * otherwise parent directories may not get chmod'ed and end up unreadable refs #9902
This commit is contained in:
parent
e505a1b7c4
commit
d9aa14feea
2 changed files with 8 additions and 3 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue