pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Skip .DS_Store files in check_mode_recursive
6+ messages / 3 participants
[nested] [flat]

* Skip .DS_Store files in check_mode_recursive
@ 2026-07-28 08:53 Andrei Lepikhov <lepihov@gmail.com>
  2026-07-28 11:56 ` Re: Skip .DS_Store files in check_mode_recursive Andrew Dunstan <andrew@dunslane.net>
  0 siblings, 1 reply; 6+ messages in thread

From: Andrei Lepikhov @ 2026-07-28 08:53 UTC (permalink / raw)
  To: pgsql-hackers <pgsql-hackers@lists.postgresql.org>; +Cc: dgustafsson@postgresql.org, Michael Paquier <michael@paquier.xyz>

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.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..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
^ permalink raw reply [nested|flat] 6+ messages in thread

* Re: Skip .DS_Store files in check_mode_recursive
  2026-07-28 08:53 Skip .DS_Store files in check_mode_recursive Andrei Lepikhov <lepihov@gmail.com>
@ 2026-07-28 11:56 ` Andrew Dunstan <andrew@dunslane.net>
  2026-07-28 13:21   ` Re: Skip .DS_Store files in check_mode_recursive Daniel Gustafsson <dgustafsson@postgresql.org>
  2026-07-28 13:37   ` Re: Skip .DS_Store files in check_mode_recursive Andrei Lepikhov <lepihov@gmail.com>
  0 siblings, 2 replies; 6+ messages in thread

From: Andrew Dunstan @ 2026-07-28 11:56 UTC (permalink / raw)
  To: Andrei Lepikhov <lepihov@gmail.com>; pgsql-hackers <pgsql-hackers@lists.postgresql.org>; +Cc: dgustafsson@postgresql.org, Michael Paquier <michael@paquier.xyz>


On 2026-07-28 Tu 4:53 AM, Andrei Lepikhov wrote:
> 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'


Minor perl nit:


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


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com







^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Skip .DS_Store files in check_mode_recursive
  2026-07-28 08:53 Skip .DS_Store files in check_mode_recursive Andrei Lepikhov <lepihov@gmail.com>
  2026-07-28 11:56 ` Re: Skip .DS_Store files in check_mode_recursive Andrew Dunstan <andrew@dunslane.net>
@ 2026-07-28 13:21   ` Daniel Gustafsson <dgustafsson@postgresql.org>
  2026-09-01 09:19     ` Re: Skip .DS_Store files in check_mode_recursive Andrei Lepikhov <lepihov@gmail.com>
  1 sibling, 1 reply; 6+ messages in thread

From: Daniel Gustafsson @ 2026-07-28 13:21 UTC (permalink / raw)
  To: Andrew Dunstan <andrew@dunslane.net>; +Cc: Andrei Lepikhov <lepihov@gmail.com>; pgsql-hackers <pgsql-hackers@lists.postgresql.org>; Michael Paquier <michael@paquier.xyz>

> On 28 Jul 2026, at 13:56, Andrew Dunstan <andrew@dunslane.net> wrote:
> On 2026-07-28 Tu 4:53 AM, Andrei Lepikhov wrote:

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

Off the cuff, seems reasonable.

> Minor perl nit:
> 
> 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';

Since the rest of the function use $File::Find::name it does however seem a bit
clearer for those less well versed in Perl to use the proposed programming?  I
had to go read File::Find and I assume I am not the only one =)

--
Daniel Gustafsson







^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Skip .DS_Store files in check_mode_recursive
  2026-07-28 08:53 Skip .DS_Store files in check_mode_recursive Andrei Lepikhov <lepihov@gmail.com>
  2026-07-28 11:56 ` Re: Skip .DS_Store files in check_mode_recursive Andrew Dunstan <andrew@dunslane.net>
  2026-07-28 13:21   ` Re: Skip .DS_Store files in check_mode_recursive Daniel Gustafsson <dgustafsson@postgresql.org>
@ 2026-09-01 09:19     ` Andrei Lepikhov <lepihov@gmail.com>
  2026-09-01 09:22       ` Re: Skip .DS_Store files in check_mode_recursive Daniel Gustafsson <dgustafsson@postgresql.org>
  0 siblings, 1 reply; 6+ messages in thread

From: Andrei Lepikhov @ 2026-09-01 09:19 UTC (permalink / raw)
  To: Daniel Gustafsson <dgustafsson@postgresql.org>; Andrew Dunstan <andrew@dunslane.net>; +Cc: pgsql-hackers <pgsql-hackers@lists.postgresql.org>; Michael Paquier <michael@paquier.xyz>

On 28/07/2026 15:21, Daniel Gustafsson wrote:
>> On 28 Jul 2026, at 13:56, Andrew Dunstan <andrew@dunslane.net> wrote:
>> On 2026-07-28 Tu 4:53 AM, Andrei Lepikhov wrote:
> 
>>> 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.
> 
> Off the cuff, seems reasonable.

Quick reminder: it still fails the ‘make check-world’ pass. Has it been
rejected, or should I add something else to the patch?

-- 
regards, Andrei Lepikhov,
pgEdge





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Skip .DS_Store files in check_mode_recursive
  2026-07-28 08:53 Skip .DS_Store files in check_mode_recursive Andrei Lepikhov <lepihov@gmail.com>
  2026-07-28 11:56 ` Re: Skip .DS_Store files in check_mode_recursive Andrew Dunstan <andrew@dunslane.net>
  2026-07-28 13:21   ` Re: Skip .DS_Store files in check_mode_recursive Daniel Gustafsson <dgustafsson@postgresql.org>
  2026-09-01 09:19     ` Re: Skip .DS_Store files in check_mode_recursive Andrei Lepikhov <lepihov@gmail.com>
@ 2026-09-01 09:22       ` Daniel Gustafsson <dgustafsson@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Daniel Gustafsson @ 2026-09-01 09:22 UTC (permalink / raw)
  To: Andrei Lepikhov <lepihov@gmail.com>; +Cc: Andrew Dunstan <andrew@dunslane.net>; pgsql-hackers <pgsql-hackers@lists.postgresql.org>; Michael Paquier <michael@paquier.xyz>

> On 1 Sep 2026, at 11:19, Andrei Lepikhov <lepihov@gmail.com> wrote:
> 
> On 28/07/2026 15:21, Daniel Gustafsson wrote:
>>> On 28 Jul 2026, at 13:56, Andrew Dunstan <andrew@dunslane.net> wrote:
>>> On 2026-07-28 Tu 4:53 AM, Andrei Lepikhov wrote:
>> 
>>>> 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.
>> 
>> Off the cuff, seems reasonable.
> 
> Quick reminder: it still fails the ‘make check-world’ pass. Has it been
> rejected, or should I add something else to the patch?

Sorry for the delay.  Things are just a bit slow at the moment due to everyone
being very busy with preparing 19 for GA.  I'll try to get to it soon.

--
Daniel Gustafsson







^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Skip .DS_Store files in check_mode_recursive
  2026-07-28 08:53 Skip .DS_Store files in check_mode_recursive Andrei Lepikhov <lepihov@gmail.com>
  2026-07-28 11:56 ` Re: Skip .DS_Store files in check_mode_recursive Andrew Dunstan <andrew@dunslane.net>
@ 2026-07-28 13:37   ` Andrei Lepikhov <lepihov@gmail.com>
  1 sibling, 0 replies; 6+ messages in thread

From: Andrei Lepikhov @ 2026-07-28 13:37 UTC (permalink / raw)
  To: Andrew Dunstan <andrew@dunslane.net>; pgsql-hackers <pgsql-hackers@lists.postgresql.org>; +Cc: dgustafsson@postgresql.org, Michael Paquier <michael@paquier.xyz>

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

Attachments:

v1-0001-Skip-.DS_Store-files-in-check_mode_recursive.patch (text/plain, 3.1K) download From b63b60e45cfede769bdc8b971c43084b3a214e72 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 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
^ permalink raw reply [nested|flat] 6+ messages in thread


end of thread, other threads:[~2026-09-01 09:22 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-07-28 08:53 Skip .DS_Store files in check_mode_recursive Andrei Lepikhov <lepihov@gmail.com>
2026-07-28 11:56 ` Andrew Dunstan <andrew@dunslane.net>
2026-07-28 13:21   ` Daniel Gustafsson <dgustafsson@postgresql.org>
2026-09-01 09:19     ` Andrei Lepikhov <lepihov@gmail.com>
2026-09-01 09:22       ` Daniel Gustafsson <dgustafsson@postgresql.org>
2026-07-28 13:37   ` Andrei Lepikhov <lepihov@gmail.com>

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