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

Commitaeee173

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 parentd21690e commitaeee173

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
@@ -2842,7 +2842,7 @@ The commands accepted in replication mode are:
28422842
<para>
28432843
Files other than regular files and directories, such as symbolic
28442844
links (other than for the directories listed above) and special
2845-
device files, are skipped. (Symbolic links
2845+
deviceand operating systemfiles, are skipped. (Symbolic links
28462846
in <filename>pg_tblspc</filename> are maintained.)
28472847
</para>
28482848
</listitem>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,8 @@ PostgreSQL documentation
832832
The backup will include all files in the data directory and tablespaces,
833833
including the configuration files and any additional files placed in the
834834
directory by third parties, except certain temporary files managed by
835-
PostgreSQL. But only regular files and directories are copied, except that
835+
PostgreSQL and operating system files. But only regular files and
836+
directories are copied, except that
836837
symbolic links used for tablespaces are preserved. Symbolic links pointing
837838
to certain directories known to PostgreSQL are copied as empty directories.
838839
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
@@ -374,8 +374,9 @@ GRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, b
374374
<filename>backup_label</filename>,
375375
<filename>tablespace_map</filename>,
376376
<filename>pg_internal.init</filename>,
377-
<filename>postmaster.opts</filename>, and
378-
<filename>postmaster.pid</filename>, as well as any file or directory
377+
<filename>postmaster.opts</filename>,
378+
<filename>postmaster.pid</filename> and
379+
<filename>.DS_Store</filename> as well as any file or directory
379380
beginning with <filename>pgsql_tmp</filename>, are omitted.
380381
</para>
381382
</step>

‎src/backend/replication/basebackup.c

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

1275+
/* Skip macOS system files */
1276+
if (strcmp(de->d_name,".DS_Store")==0)
1277+
continue;
1278+
12751279
/*
12761280
* Check if the postmaster has signaled us to exit, and abort with an
12771281
* 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
@@ -76,6 +76,16 @@
7676
close$file;
7777
}
7878

79+
# Test that macOS system files are skipped. Only test on non-macOS systems
80+
# however since creating incorrect .DS_Store files on a macOS system may have
81+
# unintended side effects.
82+
if ($Config{osname}ne'darwin')
83+
{
84+
openmy$file,'>>',"$pgdata/.DS_Store";
85+
print$file"DONOTCOPY";
86+
close$file;
87+
}
88+
7989
# Connect to a database to create global/pg_internal.init. If this is removed
8090
# the test to ensure global/pg_internal.init is not copied will return a false
8191
# positive.
@@ -144,6 +154,12 @@
144154
ok(!-f"$tempdir/backup/$filename","$filename not copied");
145155
}
146156

157+
# We only test .DS_Store files being skipped on non-macOS systems
158+
if ($Config{osname}ne'darwin')
159+
{
160+
ok(!-f"$tempdir/backup/.DS_Store",".DS_Store not copied");
161+
}
162+
147163
# Unlogged relation forks other than init should not be copied
148164
ok(-f"$tempdir/backup/${baseUnloggedPath}_init",
149165
'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
@@ -338,6 +338,10 @@ scan_directory(const char *basedir, const char *subdir, bool sizeonly)
338338
strlen(PG_TEMP_FILES_DIR))==0)
339339
continue;
340340

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

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

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

77
use strict;
88
use warnings;
9+
use Config;
910
use PostgresNode;
1011
use TestLib;
1112

@@ -114,6 +115,12 @@ sub check_relation_corruption
114115
append_to_file"$pgdata/global/pg_internal.init","foo";
115116
append_to_file"$pgdata/global/pg_internal.init.123","foo";
116117

118+
# These are non-postgres macOS files, which should be ignored by the scan.
119+
# Only perform this test on non-macOS systems though as creating incorrect
120+
# system files may have side effects on macOS.
121+
append_to_file"$pgdata/global/.DS_Store","foo"
122+
unless ($Config{osname}eq'darwin');
123+
117124
# Enable checksums.
118125
command_ok(['pg_checksums','--enable','--no-sync','-D',$pgdata ],
119126
"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
@@ -648,6 +648,10 @@ decide_file_action(file_entry_t *entry)
648648
if (strcmp(path,"global/pg_control")==0)
649649
returnFILE_ACTION_NONE;
650650

651+
/* Skip macOS system files */
652+
if (strstr(path,".DS_Store")!=NULL)
653+
returnFILE_ACTION_NONE;
654+
651655
/*
652656
* Remove all files matching the exclusion filters in the target.
653657
*/

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

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

66
use strict;
77
use warnings;
8+
use Config;
89
use TestLib;
910
use Test::Moretests=> 5;
1011

@@ -53,6 +54,10 @@ sub run_test
5354
append_to_file
5455
"$test_standby_datadir/tst_standby_dir/standby_subdir/standby_file4",
5556
"in standby4";
57+
# Skip testing .DS_Store files on macOS to avoid risk of side effects
58+
append_to_file
59+
"$test_standby_datadir/tst_standby_dir/.DS_Store",
60+
"macOS system file"unless ($Config{osname}eq'darwin');
5661

5762
mkdir"$test_primary_datadir/tst_primary_dir";
5863
append_to_file"$test_primary_datadir/tst_primary_dir/primary_file1",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp