pg_recvlogical: honor source cluster file permissions for output files
Hi,
The pg_recvlogical documentation says:
pg_recvlogical will preserve group permissions on the received WAL files
if group permissions are enabled on the source cluster.
However, a user let me know that pg_recvlogical does not actually preserve
group permissions on its output files, even when group permissions are enabled
on the source cluster. This seems a bug.
Commit c37b3d08ca6 attempted to preserve group permissions when group
access is enabled on the source cluster. However, the output files are still
created with a hard-coded S_IRUSR | S_IWUSR mode, so group-read permission
is never applied.
The attached patch fixes this by creating output files with pg_file_create_mode
instead of the hard-coded mode. Since pg_recvlogical already sets
umask(pg_mode_mask) based on the source cluster settings, this makes
the output file permissions match the source cluster configuration as intended.
The patch also updates the documentation wording from "received WAL files"
to "output files", which better reflects what pg_recvlogical actually writes.
I think this should be backpatched to all supported branches.
Regards,
--
Fujii Masao
Attachments:
v1-0001-pg_recvlogical-Honor-source-cluster-file-permissi.patchapplication/octet-stream; name=v1-0001-pg_recvlogical-Honor-source-cluster-file-permissi.patchDownload+2-3
Hi Fujii-san,
On Fri, May 15, 2026 at 8:29 PM Fujii Masao <masao.fujii@gmail.com> wrote:
Hi,
The pg_recvlogical documentation says:
pg_recvlogical will preserve group permissions on the received WAL
files
if group permissions are enabled on the source cluster.However, a user let me know that pg_recvlogical does not actually preserve
group permissions on its output files, even when group permissions are
enabled
on the source cluster. This seems a bug.Commit c37b3d08ca6 attempted to preserve group permissions when group
access is enabled on the source cluster. However, the output files are
still
created with a hard-coded S_IRUSR | S_IWUSR mode, so group-read permission
is never applied.The attached patch fixes this by creating output files with
pg_file_create_mode
instead of the hard-coded mode. Since pg_recvlogical already sets
umask(pg_mode_mask) based on the source cluster settings, this makes
the output file permissions match the source cluster configuration as
intended.The patch also updates the documentation wording from "received WAL files"
to "output files", which better reflects what pg_recvlogical actually
writes.
i have reviewed, tested the patch and it LGTM, i think we can add
a TAP test to verify the group permission, attached a diff patch
for the same,
I think this should be backpatched to all supported branches.
+1
--
Thanks,
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/
Attachments:
nocfbot-test.patchapplication/octet-stream; name=nocfbot-test.patchDownload+13-1
On Sun, May 17, 2026 at 12:22 AM Srinath Reddy Sadipiralla
<srinath2133@gmail.com> wrote:
i have reviewed, tested the patch and it LGTM,
Thanks for the review!
i think we can add
a TAP test to verify the group permission, attached a diff patch
for the same,
Thanks for the patch!
The test you added checks that pg_recvlogical creates output files with
mode 0640 when the cluster is initialized with group access enabled.
However, it does not check the opposite case, i.e., that pg_recvlogical
creates output files with mode 0600 when group access is disabled.
It seems we should test both cases, similar to what 010_basebackup.pl does?
As far as I can tell, 010_basebackup.pl initializes the cluster without group
access and checks the backup permissions, then enables group access using
chmod_recursive() and verifies that group permissions are also applied to
the backup. I updated the TAP test following this approach and attached
a revised patch.
I think this should be backpatched to all supported branches.
+1
I'm currently thinking of backpatching the fix itself to all supported branches,
but adding the test only to master. Because it does not seem worthwhile to
spend much time backporting the test to older branches, where the test code
differs much from master. Thought?
Regards,
--
Fujii Masao
On Mon, May 18, 2026 at 7:47 PM Fujii Masao <masao.fujii@gmail.com> wrote:
As far as I can tell, 010_basebackup.pl initializes the cluster without group
access and checks the backup permissions, then enables group access using
chmod_recursive() and verifies that group permissions are also applied to
the backup. I updated the TAP test following this approach and attached
a revised patch.
Sorry, I forgot to attach the patch.
I've attached it in this email.
Regards,
--
Fujii Masao
Attachments:
v2-0001-pg_recvlogical-Honor-source-cluster-file-permissi.patchapplication/octet-stream; name=v2-0001-pg_recvlogical-Honor-source-cluster-file-permissi.patchDownload+48-3
On Mon, May 18, 2026 at 4:17 PM Fujii Masao <masao.fujii@gmail.com> wrote:
The test you added checks that pg_recvlogical creates output files with
mode 0640 when the cluster is initialized with group access enabled.
However, it does not check the opposite case, i.e., that pg_recvlogical
creates output files with mode 0600 when group access is disabled.It seems we should test both cases, similar to what 010_basebackup.pl
does?As far as I can tell, 010_basebackup.pl initializes the cluster without
group
access and checks the backup permissions, then enables group access using
chmod_recursive() and verifies that group permissions are also applied to
the backup. I updated the TAP test following this approach and attached
a revised patch.
+1 , I totally missed this case :), patch LGTM.
I'm currently thinking of backpatching the fix itself to all supported
branches,
but adding the test only to master. Because it does not seem worthwhile to
spend much time backporting the test to older branches, where the test code
differs much from master. Thought?
makes sense.
--
Thanks,
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/