-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
File permission issues for mariadb-dump --dir #4478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes file permission issues when using the --dir parameter in mariadb-dump. The change allows mariadb-dump and mariadbd to run under different OS users by ensuring that newly created database subdirectories inherit the same permissions and ownership as the root backup directory.
Key changes:
- Added
fix_permissions_and_owner()function to replicate permissions/ownership from the root backup directory to subdirectories - Integrated the new function into
ensure_out_dir_exists()to apply permission fixes after creating each database directory - Used static variables to cache root directory metadata and track which permission operations have failed
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
client/mysqldump.cc
Outdated
| } | ||
| } | ||
|
|
||
| /* Chánge permissions to be the same as for the output directory*/ |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in comment: "Chánge" should be "Change". The comment contains an accented character instead of a standard 'a'.
| /* Chánge permissions to be the same as for the output directory*/ | |
| /* Change permissions to be the same as for the output directory*/ |
5f29af4 to
84e3c57
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
84e3c57 to
5f4ffd9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5f4ffd9 to
90ee4e5
Compare
When mariadb-dump runs with the --dir parameter, it creates new directories. These directories must allow both mariadb-dump and mariadbd to create new files in them. If mariadb-dump and mariadbd run under different users, this is not guaranteed. One problem is my_mkdir(), which by default creates directories writable only by the current user and group, due to the default my_umask_dir value of 0700. This fix tries to preserve the permissions and owner of the original backup directory passed with --dir when creating subdirectories. If this fails, a warning is issued and mariadb-dump continues. This is a best-effort approach. Failures may still occur later when the server tries to write to a newly created directory. In such cases, the permissions of the backup root directory (which mariadb-dump does not create) would already be incorrect.
90ee4e5 to
9860814
Compare
Description
When mariadb-dump runs with the --dir parameter, it creates new directories. These directories must allow both mariadb-dump and mariadbd to create new files in them.
If mariadb-dump and mariadbd run under different users, this is not guaranteed. One problem is my_mkdir(), which by default creates directories writable only by the current user and group, due to the default
my_umask_dirvalue of 0700.This fix tries to preserve the permissions and owner of the original backup directory passed with --dir when creating subdirectories. This makes mariabackup --dir behave similarly wrt file permissions as with older option --tab.
If setting permissions or owner fail, a warning is issued and mariadb-dump continues. This is a best-effort approach. Failures may still occur later when the server tries to write to a newly created directory. In such cases, the permissions of the backup root directory (which mariadb-dump does not create) would already be incorrect.
Release Notes
mariadb-dump using --dir parameter can now run under different OS user from mariadbd (e.g as root), on Unix-like operating
systems.
How can this PR be tested?
Unfortunately, the changes can't be automatically tested, since MTR runs all processes as the same OS user account.
To test it manually, start mariadbd as non-root user, and backup using mariadb-dump --dir as root.
Or backup , using mariadb-dump as different user in the same group as the one that runs mariadbd.
In all cases, make sure that the server can write into directory pointed to by --dir.
Basing the PR against the correct MariaDB version
mainbranch.PR quality check