Skip to content

atomic_move - fix preserving the dest attributes when using a tmp file#83986

Draft
s-hertel wants to merge 2 commits intoansible:develfrom
s-hertel:atomic_move-fix-perms
Draft

atomic_move - fix preserving the dest attributes when using a tmp file#83986
s-hertel wants to merge 2 commits intoansible:develfrom
s-hertel:atomic_move-fix-perms

Conversation

@s-hertel
Copy link
Contributor

@s-hertel s-hertel commented Sep 23, 2024

SUMMARY

Fixes #83972

This looks like a long term bug, though #82818 (2.17+) impacted it. The fix is just adding shutil.copystat before attempting the final rename.

In the test case I added, the mode is expected to remain "0664". In 2.17 and later, the mode is "0654". In 2.16 and earlier, the mode is "0644".

ISSUE TYPE
  • Bugfix Pull Request

@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. has_issue labels Sep 23, 2024
@s-hertel s-hertel force-pushed the atomic_move-fix-perms branch from b683b5d to f666b97 Compare September 23, 2024 23:45
if dest_stat and (tmp_stat.st_uid != dest_stat.st_uid or tmp_stat.st_gid != dest_stat.st_gid):
os.chown(b_tmp_dest_name, dest_stat.st_uid, dest_stat.st_gid)
if dest_stat:
shutil.copystat(b_dest, b_tmp_dest_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i had encountered this in my 'copy fix', but simplified it by just making it:
if keep_dest_attrs and dest_stat:

@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Sep 24, 2024
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Oct 8, 2024
@Vanav
Copy link

Vanav commented Nov 28, 2024

I've tested patch, and it seems doesn't fix bug #83972 for me.

@bcoca
Copy link
Member

bcoca commented Nov 29, 2024

I am aware, but while debugging that issue i found many more. This PR started by getting the correct settings through each part of the process, the original issue is caused by the 2 final steps, which i have not had time to fix yet.

@ansibot ansibot added the stale_pr This PR has not been pushed to for more than one year. label Sep 30, 2025
@s-hertel s-hertel force-pushed the atomic_move-fix-perms branch from f666b97 to b1ccb37 Compare January 15, 2026 21:57
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. pending_ci and removed stale_pr This PR has not been pushed to for more than one year. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. pending_ci labels Jan 15, 2026
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This issue/PR relates to a bug. has_issue stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

copy task changes file permissions of the existing destination file when becoming an unprivileged user although mode is not specified

5 participants