make sure tmpdir resolvs user dirs (#20486)

* make sure tmpdir resolvs user dirs

fixes #20332
supercedes #20484

* typo fix
pull/20657/head
Brian Coca 8 years ago committed by GitHub
parent 619e97d67e
commit 10fa2cd0ef

@ -218,7 +218,12 @@ class ActionBase(with_metaclass(ABCMeta, object)):
tmp_mode = 0o700
cmd = self._connection._shell.mkdtemp(basefile, use_system_tmp, tmp_mode)
if use_system_tmp:
tmpdir = None
else:
tmpdir = self._remote_expand_user(C.DEFAULT_REMOTE_TMP)
cmd = self._connection._shell.mkdtemp(basefile, use_system_tmp, tmp_mode, tmpdir)
result = self._low_level_execute_command(cmd, sudoable=False)
# error handling on this seems a little aggressive?

@ -91,7 +91,7 @@ class ShellBase(object):
cmd = ['test', '-e', shlex_quote(path)]
return ' '.join(cmd)
def mkdtemp(self, basefile=None, system=False, mode=None):
def mkdtemp(self, basefile=None, system=False, mode=None, tmpdir=None):
if not basefile:
basefile = 'ansible-tmp-%s-%s' % (time.time(), random.randint(0, 2**48))
@ -107,13 +107,17 @@ class ShellBase(object):
# to somewhere in or below /var/tmp and if so use /var/tmp. If
# anything else we use /tmp (because /tmp is specified by POSIX nad
# /var/tmp is not).
if system:
if C.DEFAULT_REMOTE_TMP.startswith('/var/tmp'):
basetmpdir = '/var/tmp'
else:
basetmpdir = '/tmp'
else:
elif tmpdir is None:
basetmpdir = C.DEFAULT_REMOTE_TMP
else:
basetmpdir = tmpdir
basetmp = self.join_path(basetmpdir, basefile)
cmd = 'mkdir -p %s echo %s %s' % (self._SHELL_SUB_LEFT, basetmp, self._SHELL_SUB_RIGHT)

Loading…
Cancel
Save