Pass absolute paths to atomic_move() (#8925)

Pass absolute paths to atmoic_move().
pull/8970/head
Felix Fontein 2024-10-01 21:55:04 +03:00 committed by GitHub
parent a7d1b0fc52
commit 7c913b239a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 12 additions and 6 deletions

View File

@ -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)."

View File

@ -569,7 +569,7 @@ def do_ini(module, filename, section=None, section_has_values=None, option=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())

View File

@ -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

View File

@ -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

View File

@ -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())

View File

@ -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()