Skip to content

Conversation

@hristost
Copy link
Contributor

@hristost hristost commented Mar 4, 2024

In __CFWriteBytesToFileWithAtomicity(), we first write the contents of the plist to an auxiliary copy file, and then move that copy to where the original used to be. Because that file needs to have the same owner as the original, we would use chown() to change ownership as the last step. This allows a race condition where the new file is in its final location, but doesn't have the correct permissions. To fix this, call chown() on the file before moving.

rdar://121597642

In __CFWriteBytesToFileWithAtomicity(), we first write the contents of the plist
to an auxiliary copy file, and then move that copy to where the original used to
be. Because that file needs to have the same owner as the original, we would use
chown() to change ownership as the last step. This allows a race condition where
the new file is in its final location, but doesn't have the correct permissions.
To fix this, call chown() on the file before moving.

rdar://121597642
@hristost
Copy link
Contributor Author

hristost commented Mar 4, 2024

@swift-ci please test

@parkera parkera merged commit 41b71f9 into main Mar 12, 2024
@parkera parkera deleted the hs/fix-cfpreferences-race branch March 12, 2024 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants