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

Commit1f422db

Browse files
committed
Avoid using readlink() on platforms that don't support it
We don't have any such platforms now, but might in the future.Also, detect cases when a tablespace symlink points to a path thatis longer than we can handle, and give a warning.
1 parent16d8e59 commit1f422db

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

‎src/backend/replication/basebackup.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,26 +109,45 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
109109
{
110110
charfullpath[MAXPGPATH];
111111
charlinkpath[MAXPGPATH];
112+
intrllen;
112113

113114
/* Skip special stuff */
114115
if (strcmp(de->d_name,".")==0||strcmp(de->d_name,"..")==0)
115116
continue;
116117

117118
snprintf(fullpath,sizeof(fullpath),"pg_tblspc/%s",de->d_name);
118119

119-
MemSet(linkpath,0,sizeof(linkpath));
120-
if (readlink(fullpath,linkpath,sizeof(linkpath)-1)==-1)
120+
#if defined(HAVE_READLINK)|| defined(WIN32)
121+
rllen=readlink(fullpath,linkpath,sizeof(linkpath)-1);
122+
if (rllen<0)
123+
{
124+
ereport(WARNING,
125+
(errmsg("could not read symbolic link \"%s\": %m",fullpath)));
126+
continue;
127+
}
128+
elseif (rllen >=sizeof(linkpath))
121129
{
122130
ereport(WARNING,
123-
(errmsg("could not readsymbolic link \"%s\": %m",fullpath)));
131+
(errmsg("symbolic link \"%s\" target is too long",fullpath)));
124132
continue;
125133
}
134+
linkpath[rllen]='\0';
126135

127136
ti=palloc(sizeof(tablespaceinfo));
128137
ti->oid=pstrdup(de->d_name);
129138
ti->path=pstrdup(linkpath);
130139
ti->size=opt->progress ?sendDir(linkpath,strlen(linkpath), true) :-1;
131140
tablespaces=lappend(tablespaces,ti);
141+
#else
142+
/*
143+
* If the platform does not have symbolic links, it should not be possible
144+
* to have tablespaces - clearly somebody else created them. Warn about it
145+
* and ignore.
146+
*/
147+
ereport(WARNING,
148+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
149+
errmsg("tablespaces are not supported on this platform")));
150+
#endif
132151
}
133152

134153
/* Add a node for the base directory at the end */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp