Skip to content

Conversation

@vaintroub
Copy link
Member

  • The Jira issue number for this PR is: MDEV-38226

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_dir value 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 maria­db-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

  • This is a new feature or a refactoring, and the PR is based against the main branch.
  • This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

Copy link

Copilot AI left a 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.

}
}

/* Chánge permissions to be the same as for the output directory*/
Copy link

Copilot AI Dec 12, 2025

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'.

Suggested change
/* Chánge permissions to be the same as for the output directory*/
/* Change permissions to be the same as for the output directory*/

Copilot uses AI. Check for mistakes.
@vaintroub vaintroub force-pushed the 11.8-MDEV-38226 branch 2 times, most recently from 5f29af4 to 84e3c57 Compare December 15, 2025 10:57
@vaintroub vaintroub requested a review from Copilot December 15, 2025 10:59
Copy link

Copilot AI left a 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.

Copy link

Copilot AI left a 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.

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 maria­db-dump does not
create) would already be incorrect.
@vaintroub vaintroub enabled auto-merge (rebase) December 17, 2025 09:15
@vaintroub vaintroub merged commit 514f2e6 into 11.8 Dec 17, 2025
16 of 18 checks passed
@vaintroub vaintroub deleted the 11.8-MDEV-38226 branch December 17, 2025 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants