Set permissions for files and directories created in PGDATA (#2781)

Postgres supports two types of permissions:
1. owner only
2. group readable

By default the first one is used because it provides better security. But, sometimes people want to run a backup tool with the user that is different from postgres. In this case the second option becomes very useful. Unfortunately it didn't work correctly because Patroni was creating files with owner access only permissions.

This PR changes the behavior and permissions on files and directories that are created by Patroni will be calculated based on permissions of PGDATA. I.e., they will get group readable access when it is necessary.

Close #1899
Close #1901
This commit is contained in:
Alexander Kukushkin
2023-08-02 13:15:43 +02:00
committed by GitHub
parent b6fc4bc393
commit 01d07f86cd
8 changed files with 184 additions and 12 deletions
+1
View File
@@ -1421,6 +1421,7 @@ class TestHa(PostgresInit):
@patch('os.open', Mock())
@patch('os.fsync', Mock())
@patch('os.close', Mock())
@patch('os.chmod', Mock())
@patch('os.rename', Mock())
@patch('patroni.postgresql.Postgresql.is_starting', Mock(return_value=False))
@patch('builtins.open', mock_open())