[PR #8925/7c913b23 backport][stable-7] Pass absolute paths to atomic_move() (#8957)
Pass absolute paths to atomic_move() (#8925)
Pass absolute paths to atmoic_move().
(cherry picked from commit 7c913b239a
)
Co-authored-by: Felix Fontein <felix@fontein.de>
pull/9037/head
parent
45dd6a59f8
commit
88b1d1e0c1
|
@ -0,0 +1,6 @@
|
||||||
|
bugfixes:
|
||||||
|
- "ini_file - pass absolute paths to ``module.atomic_move()`` (https://github.com/ansible/ansible/issues/83950, https://github.com/ansible-collections/community.general/pull/8925)."
|
||||||
|
- "java_keystore - pass absolute paths to ``module.atomic_move()`` (https://github.com/ansible/ansible/issues/83950, https://github.com/ansible-collections/community.general/pull/8925)."
|
||||||
|
- "jenkins_plugin - pass absolute paths to ``module.atomic_move()`` (https://github.com/ansible/ansible/issues/83950, https://github.com/ansible-collections/community.general/pull/8925)."
|
||||||
|
- "kdeconfig - pass absolute paths to ``module.atomic_move()`` (https://github.com/ansible/ansible/issues/83950, https://github.com/ansible-collections/community.general/pull/8925)."
|
||||||
|
- "pam_limits - pass absolute paths to ``module.atomic_move()`` (https://github.com/ansible/ansible/issues/83950, https://github.com/ansible-collections/community.general/pull/8925)."
|
|
@ -450,7 +450,7 @@ def do_ini(module, filename, section=None, option=None, values=None,
|
||||||
module.fail_json(msg="Unable to create temporary file %s", traceback=traceback.format_exc())
|
module.fail_json(msg="Unable to create temporary file %s", traceback=traceback.format_exc())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
module.atomic_move(tmpfile, target_filename)
|
module.atomic_move(tmpfile, os.path.abspath(target_filename))
|
||||||
except IOError:
|
except IOError:
|
||||||
module.ansible.fail_json(msg='Unable to move temporary \
|
module.ansible.fail_json(msg='Unable to move temporary \
|
||||||
file %s to %s, IOError' % (tmpfile, target_filename), traceback=traceback.format_exc())
|
file %s to %s, IOError' % (tmpfile, target_filename), traceback=traceback.format_exc())
|
||||||
|
|
|
@ -470,7 +470,7 @@ class JavaKeystore:
|
||||||
|
|
||||||
if self.keystore_type == 'pkcs12':
|
if self.keystore_type == 'pkcs12':
|
||||||
# Preserve properties of the destination file, if any.
|
# Preserve properties of the destination file, if any.
|
||||||
self.module.atomic_move(keystore_p12_path, self.keystore_path)
|
self.module.atomic_move(os.path.abspath(keystore_p12_path), os.path.abspath(self.keystore_path))
|
||||||
self.update_permissions()
|
self.update_permissions()
|
||||||
self.result['changed'] = True
|
self.result['changed'] = True
|
||||||
return self.result
|
return self.result
|
||||||
|
|
|
@ -685,7 +685,7 @@ class JenkinsPlugin(object):
|
||||||
|
|
||||||
# Move the updates file to the right place if we could read it
|
# Move the updates file to the right place if we could read it
|
||||||
if tmp_updates_file != updates_file:
|
if tmp_updates_file != updates_file:
|
||||||
self.module.atomic_move(tmp_updates_file, updates_file)
|
self.module.atomic_move(os.path.abspath(tmp_updates_file), os.path.abspath(updates_file))
|
||||||
|
|
||||||
# Check if we have the plugin data available
|
# Check if we have the plugin data available
|
||||||
if not data.get('plugins', {}).get(self.params['name']):
|
if not data.get('plugins', {}).get(self.params['name']):
|
||||||
|
@ -718,7 +718,7 @@ class JenkinsPlugin(object):
|
||||||
details=to_native(e))
|
details=to_native(e))
|
||||||
|
|
||||||
# Move the file onto the right place
|
# Move the file onto the right place
|
||||||
self.module.atomic_move(tmp_f, f)
|
self.module.atomic_move(os.path.abspath(tmp_f), os.path.abspath(f))
|
||||||
|
|
||||||
def uninstall(self):
|
def uninstall(self):
|
||||||
changed = False
|
changed = False
|
||||||
|
|
|
@ -214,7 +214,7 @@ def run_module(module, tmpdir, kwriteconfig):
|
||||||
if module.params['backup'] and os.path.exists(b_path):
|
if module.params['backup'] and os.path.exists(b_path):
|
||||||
result['backup_file'] = module.backup_local(result['path'])
|
result['backup_file'] = module.backup_local(result['path'])
|
||||||
try:
|
try:
|
||||||
module.atomic_move(b_tmpfile, b_path)
|
module.atomic_move(b_tmpfile, os.path.abspath(b_path))
|
||||||
except IOError:
|
except IOError:
|
||||||
module.ansible.fail_json(msg='Unable to move temporary file %s to %s, IOError' % (tmpfile, result['path']), traceback=traceback.format_exc())
|
module.ansible.fail_json(msg='Unable to move temporary file %s to %s, IOError' % (tmpfile, result['path']), traceback=traceback.format_exc())
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ def main():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Move tempfile to newfile
|
# Move tempfile to newfile
|
||||||
module.atomic_move(nf.name, limits_conf)
|
module.atomic_move(os.path.abspath(nf.name), os.path.abspath(limits_conf))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
nf.close()
|
nf.close()
|
||||||
|
|
Loading…
Reference in New Issue