1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-05-10 20:01:40 +00:00

[PR #12014/b8659f5c backport][stable-12] pam_limits: only create backup file when content actually changes (#12020)

pam_limits: only create backup file when content actually changes (#12014)

* fix(pam_limits): only create backup when file is actually changed

Fixes #12011



* changelog: add fragment for PR 12014



---------


(cherry picked from commit b8659f5c61)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
patchback[bot] 2026-05-10 10:22:07 +02:00 committed by GitHub
parent b3669957d9
commit b1d88ae3c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- "pam_limits - only create backup file when the target file is actually modified (https://github.com/ansible-collections/community.general/issues/12011, https://github.com/ansible-collections/community.general/pull/12014)."

View file

@ -235,10 +235,7 @@ def main():
_assert_is_valid_value(module, limit_item, value)
# Backup
if backup:
backup_file = module.backup_local(limits_conf)
backup_file = None
space_pattern = re.compile(r"\s+")
if does_not_exist:
@ -356,6 +353,9 @@ def main():
with open(limits_conf, "a"):
pass
if backup and changed and not does_not_exist:
backup_file = module.backup_local(limits_conf)
# Move tempfile to newfile
module.atomic_move(os.path.abspath(nf.name), os.path.abspath(limits_conf))
@ -370,7 +370,7 @@ def main():
diff=dict(before=b"".join(lines), after=content_new),
)
if backup:
if backup_file:
res_args["backup_file"] = backup_file
module.exit_json(**res_args)