mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00: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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user