From: Andrei Lepikhov <lepihov@gmail.com>
To: pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Cc: dgustafsson@postgresql.org, Michael Paquier <michael@paquier.xyz>
Subject: Skip .DS_Store files in check_mode_recursive
Date: Tue, 28 Jul 2026 10:53:43 +0200
Message-ID: <fd55caa3-0a29-4724-afcb-2e7fd4231514@gmail.com> (raw)
Hi,
I am repeatedly encountering an annoying failing test during 'make check-world'
execution on the macOS platform: pg_resetwal with the result:
Failed test 'check PGDATA permissions'
It happens because a filesystem object .DS_Store exists in the directory.
AFAIK, MacOS manages it on its own. Given that I almost never touch this module,
it seems the OS handles it automatically.
A quick dive into the mailing list history shows that this problem has been
discovered [1] and partly fixed [2] before.
It looks like this approach might be extended to TAP tests too. In the
attachment, see the sketch of the code and a minor test to prove that it works.
[1] pg_basebackup: errors on macOS on directories with ".DS_Store" files
https://www.postgresql.org/message-id/flat/E258CE50-AB0E-455D-8AAD-BB4FE8F882FB%40gmail.com
[2] Commit d3fdfdcd1c7 'Skip .DS_Store files in server side utils'
--
regards, Andrei Lepikhov,
pgEdge
Attachments:v0-0001-Skip-.DS_Store-files-in-check_mode_recursive.patch (text/plain, 3.1K) download
From d12271efd27b9e8c850cdfdd6811d2d220bcb304 Mon Sep 17 00:00:00 2001
From: "Andrei V. Lepikhov" <lepihov@gmail.com>
Date: Tue, 28 Jul 2026 10:35:48 +0200
Subject: [PATCH v0] 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.plindex 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.pmindex d3e6abf7a68..f140b4bd976 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 created by the+macOS Finder (F<.DS_Store>) 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 basename($File::Find::name) eq '.DS_Store';+
# Is file in the ignore list?
foreach my $ignore ($ignore_list ? @{$ignore_list} : [])
{
--
2.55.0
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: lepihov@gmail.com, michael@paquier.xyz
Subject: Re: Skip .DS_Store files in check_mode_recursive
In-Reply-To: <fd55caa3-0a29-4724-afcb-2e7fd4231514@gmail.com>
References: <fd55caa3-0a29-4724-afcb-2e7fd4231514@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox