On 28/07/2026 21:56, Andrew Dunstan wrote:
>
> On 2026-07-28 Tu 4:53 AM, Andrei Lepikhov wrote:
> I don't think you need to say
>
> return if basename($File::Find::name) eq '.DS_Store';
>
> you can just say
>
> return if $_ eq '.DS_Store';
Thank you, done.
I implemented it this way for consistency and to be independent of the value of
the 'no_chdir' option.
--
regards, Andrei Lepikhov,
pgEdge
From b63b60e45cfede769bdc8b971c43084b3a214e72 Mon Sep 17 00:00:00 2001
From: "Andrei V. Lepikhov" <[email protected]>
Date: Tue, 28 Jul 2026 10:35:48 +0200
Subject: [PATCH v1] Skip .DS_Store files in check_mode_recursive
The macOS Finder application creates .DS_Store files in directories when
opened. These files do not carry PostgreSQL's permissions, so a data
directory that happens to contain one makes check_mode_recursive() report
a spurious failure. This may break the "check PGDATA permissions" tests in
initdb, pg_resetwal, pg_rewind, pg_ctl, pg_basebackup and pg_receivewal on
macOS development trees.
Commit d3fdfdcd1c7 taught the server-side utilities (pg_basebackup,
pg_checksums and pg_rewind) to skip .DS_Store files. Apply the same
treatment to the shared TAP test helper so the test suite is equally
tolerant of them. A regression test is added to the initdb TAP suite,
guarded to run only on non-macOS systems since creating bogus .DS_Store
files where the Finder can see them may have unintended side effects,
matching the convention established by that commit.
---
src/bin/initdb/t/001_initdb.pl | 11 +++++++++++
src/test/perl/PostgreSQL/Test/Utils.pm | 9 ++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/bin/initdb/t/001_initdb.pl b/src/bin/initdb/t/001_initdb.pl
index 081535a22e4..45ba73dd58f 100644
--- a/src/bin/initdb/t/001_initdb.pl
+++ b/src/bin/initdb/t/001_initdb.pl
@@ -64,6 +64,17 @@ mkdir $datadir;
skip "unix-style permissions not supported on Windows", 1
if ($windows_os);
+ # A .DS_Store file created by the macOS Finder has permissions
that
+ # do not conform to the expected data directory mode. Make
sure the
+ # permission check ignores it. Only create it on non-macOS
systems,
+ # since writing bogus .DS_Store files where the Finder might
see them
+ # could have unintended side effects.
+ if ($Config::Config{osname} ne 'darwin')
+ {
+ append_to_file("$datadir/.DS_Store", "macOS system
file");
+ chmod(0644, "$datadir/.DS_Store");
+ }
+
ok(check_mode_recursive($datadir, 0700, 0600),
"check PGDATA permissions");
}
diff --git a/src/test/perl/PostgreSQL/Test/Utils.pm
b/src/test/perl/PostgreSQL/Test/Utils.pm
index d3e6abf7a68..3de4caf4d5a 100644
--- a/src/test/perl/PostgreSQL/Test/Utils.pm
+++ b/src/test/perl/PostgreSQL/Test/Utils.pm
@@ -669,7 +669,8 @@ sub read_head_tail
=item check_mode_recursive(dir, expected_dir_mode, expected_file_mode,
ignore_list)
Check that all file/dir modes in a directory match the expected values,
-ignoring files in C<ignore_list> (basename only).
+ignoring files in C<ignore_list> (basename only). Files '.DS_Store' created by
+the macOS Finder are always ignored.
=cut
@@ -684,6 +685,12 @@ sub check_mode_recursive
{
follow_fast => 1,
wanted => sub {
+ # Skip macOS system files. The Finder
application creates
+ # .DS_Store files, which are not PostgreSQL
files and would
+ # otherwise trip the permission check below;
always ignore
+ # them.
+ return if $_ eq '.DS_Store';
+
# Is file in the ignore list?
foreach my $ignore ($ignore_list ?
@{$ignore_list} : [])
{
--
2.55.0