Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit76bb6dd

Browse files
Skip .DS_Store files in server side utils
The macOS Finder application creates .DS_Store files in directorieswhen opened, which creates problems for serverside utilities whichexpect all files to be PostgreSQL specific files. Skip these fileswhen encountered in pg_checksums, pg_rewind and pg_basebackup.This was extracted from a larger patchset for skipping hidden filesand system files, where the concencus was to just skip these. Sincethis is equally likely to happen in every version, backpatch to allsupported versions.Reported-by: Mark Guertin <markguertin@gmail.com>Reviewed-by: Michael Paquier <michael@paquier.xyz>Reviewed-by: Tobias Bussmann <t.bussmann@gmx.net>Discussion:https://postgr.es/m/E258CE50-AB0E-455D-8AAD-BB4FE8F882FB@gmail.comBackpatch-through: v12
1 parentf38903d commit76bb6dd

File tree

9 files changed

+46
-4
lines changed

9 files changed

+46
-4
lines changed

‎doc/src/sgml/protocol.sgml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2795,7 +2795,7 @@ The commands accepted in replication mode are:
27952795
<para>
27962796
Files other than regular files and directories, such as symbolic
27972797
links (other than for the directories listed above) and special
2798-
device files, are skipped. (Symbolic links
2798+
deviceand operating systemfiles, are skipped. (Symbolic links
27992799
in <filename>pg_tblspc</filename> are maintained.)
28002800
</para>
28012801
</listitem>

‎doc/src/sgml/ref/pg_basebackup.sgml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,8 @@ PostgreSQL documentation
726726
The backup will include all files in the data directory and tablespaces,
727727
including the configuration files and any additional files placed in the
728728
directory by third parties, except certain temporary files managed by
729-
PostgreSQL. But only regular files and directories are copied, except that
729+
PostgreSQL and operating system files. But only regular files and
730+
directories are copied, except that
730731
symbolic links used for tablespaces are preserved. Symbolic links pointing
731732
to certain directories known to PostgreSQL are copied as empty directories.
732733
Other symbolic links and special device files are skipped.

‎doc/src/sgml/ref/pg_rewind.sgml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,9 @@ GRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, b
311311
<filename>backup_label</filename>,
312312
<filename>tablespace_map</filename>,
313313
<filename>pg_internal.init</filename>,
314-
<filename>postmaster.opts</filename> and
315-
<filename>postmaster.pid</filename>.
314+
<filename>postmaster.opts</filename>,
315+
<filename>postmaster.pid</filename> and.
316+
<filename>.DS_Store</filename>.
316317
</para>
317318
</step>
318319
<step>

‎src/backend/replication/basebackup.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,10 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
10961096
strlen(PG_TEMP_FILE_PREFIX))==0)
10971097
continue;
10981098

1099+
/* Skip macOS system files */
1100+
if (strcmp(de->d_name,".DS_Store")==0)
1101+
continue;
1102+
10991103
/*
11001104
* Check if the postmaster has signaled us to exit, and abort with an
11011105
* error in that case. The error handler further up will call

‎src/bin/pg_basebackup/t/010_pg_basebackup.pl‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@
7373
close$file;
7474
}
7575

76+
# Test that macOS system files are skipped. Only test on non-macOS systems
77+
# however since creating incorrect .DS_Store files on a macOS system may have
78+
# unintended side effects.
79+
if ($Config{osname}ne'darwin')
80+
{
81+
openmy$file,'>>',"$pgdata/.DS_Store";
82+
print$file"DONOTCOPY";
83+
close$file;
84+
}
85+
7686
# Connect to a database to create global/pg_internal.init. If this is removed
7787
# the test to ensure global/pg_internal.init is not copied will return a false
7888
# positive.
@@ -140,6 +150,12 @@
140150
ok(!-f"$tempdir/backup/$filename","$filename not copied");
141151
}
142152

153+
# We only test .DS_Store files being skipped on non-macOS systems
154+
if ($Config{osname}ne'darwin')
155+
{
156+
ok(!-f"$tempdir/backup/.DS_Store",".DS_Store not copied");
157+
}
158+
143159
# Unlogged relation forks other than init should not be copied
144160
ok(-f"$tempdir/backup/${baseUnloggedPath}_init",
145161
'unlogged init fork in backup');

‎src/bin/pg_checksums/pg_checksums.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ scan_directory(const char *basedir, const char *subdir, bool sizeonly)
337337
strlen(PG_TEMP_FILES_DIR))==0)
338338
continue;
339339

340+
/* Skip macOS system files */
341+
if (strcmp(de->d_name,".DS_Store")==0)
342+
continue;
343+
340344
snprintf(fn,sizeof(fn),"%s/%s",path,de->d_name);
341345
if (lstat(fn,&st)<0)
342346
{

‎src/bin/pg_checksums/t/002_actions.pl‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use strict;
55
use warnings;
6+
use Config
67
use PostgresNode;
78
use TestLib;
89
use Test::Moretests=> 63;
@@ -110,6 +111,12 @@ sub check_relation_corruption
110111
append_to_file"$pgdata/global/pg_internal.init","foo";
111112
append_to_file"$pgdata/global/pg_internal.init.123","foo";
112113

114+
# These are non-postgres macOS files, which should be ignored by the scan.
115+
# Only perform this test on non-macOS systems though as creating incorrect
116+
# system files may have side effects on macOS.
117+
append_to_file"$pgdata/global/.DS_Store","foo"
118+
unless ($Config{osname}eq'darwin');
119+
113120
# Enable checksums.
114121
command_ok(['pg_checksums','--enable','--no-sync','-D',$pgdata ],
115122
"checksums successfully enabled in cluster");

‎src/bin/pg_rewind/filemap.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,10 @@ isRelDataFile(const char *path)
742742
}
743743
}
744744

745+
/* Skip macOS system files */
746+
if (strstr(path,".DS_Store")!=NULL)
747+
returnFILE_ACTION_NONE;
748+
745749
/*
746750
* The sscanf tests above can match files that have extra characters at
747751
* the end. To eliminate such cases, cross-check that GetRelationPath

‎src/bin/pg_rewind/t/003_extrafiles.pl‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use strict;
44
use warnings;
5+
use Config;
56
use TestLib;
67
use Test::Moretests=> 4;
78

@@ -44,6 +45,10 @@ sub run_test
4445
append_to_file
4546
"$test_standby_datadir/tst_standby_dir/standby_subdir/standby_file3",
4647
"in standby3";
48+
# Skip testing .DS_Store files on macOS to avoid risk of side effects
49+
append_to_file
50+
"$test_standby_datadir/tst_standby_dir/.DS_Store",
51+
"macOS system file"unless ($Config{osname}eq'darwin');
4752

4853
mkdir"$test_master_datadir/tst_master_dir";
4954
append_to_file"$test_master_datadir/tst_master_dir/master_file1",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp