Repository navigation
Conversation
galera-healthcheck wrote state.txt with os.WriteFile(..., 0777), and galera-init rewrote grastate.dat with ioutil.WriteFile(..., 0777). Both files could end up world-writable (the final mode depends on umask). Write state.txt with 0600 and grastate.dat with 0640 (what mysqld creates), using renameio so the replacement is atomic and the galera-agent bootstrap/join/single-node endpoints behave like galera-init's existing state writes. renameio.WriteFile preserves the mode of an existing file, so add os_helper.WriteFileAtomic (and an equivalent helper in healthcheck) built on WithStaticPermissions. It forces the mode regardless of umask and corrects files left loose by earlier releases. galera-init's WriteStringToFile, whose only caller writes state.txt, now uses 0600 so both writers agree. The grastate.dat safe_to_bootstrap rewrite also uses the helper, replacing the ioutil read/write in the node starter. This is hardening / defense in depth: bpm already restricts /var/vcap/store/pxc-mysql to 0700, so a non-vcap local user could not reach these files. Only the galera-agent bootstrap path was still creating state.txt with loose permissions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
galera-healthcheck wrote state.txt with os.WriteFile(..., 0777), and galera-init rewrote grastate.dat with ioutil.WriteFile(..., 0777). Both files could end up world-writable (the final mode depends on umask).
Write state.txt with 0600 and grastate.dat with 0640 (what mysqld creates), using renameio so the replacement is atomic and the galera-agent bootstrap/join/single-node endpoints behave like galera-init's existing state writes.
renameio.WriteFile preserves the mode of an existing file, so add os_helper.WriteFileAtomic (and an equivalent helper in healthcheck) built on WithStaticPermissions. It forces the mode regardless of umask and corrects files left loose by earlier releases. galera-init's WriteStringToFile, whose only caller writes state.txt, now uses 0600 so both writers agree. The grastate.dat safe_to_bootstrap rewrite also uses the helper, replacing the ioutil read/write in the node starter.
This is hardening / defense in depth: bpm already restricts /var/vcap/store/pxc-mysql to 0700, so a non-vcap local user could not reach these files. Only the galera-agent bootstrap path was still creating state.txt with loose permissions.