!2449 创建tablespace增加对symlink的检查

Merge pull request !2449 from 仲夏十三/mas4
This commit is contained in:
opengauss-bot
2022-11-26 08:17:26 +00:00
committed by Gitee
3 changed files with 20 additions and 1 deletions

View File

@ -1293,7 +1293,16 @@ static void create_tablespace_directories(const char* location, const Oid tables
ereport(ERROR, (errcode_for_file_access(), errmsg("could not remove symbolic link \"%s\": %m", linkloc)));
}
}
/* do not support symbolic link -> symbolic link */
struct stat st;
if (lstat(location, &st) == 0) {
if (S_ISLNK(st.st_mode)) {
ereport(ERROR,
(errmodule(MOD_TBLSPC),
errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("location \"%s\" is symbolic link", location)));
}
}
/*
* Create the symlink under PGDATA
*/

View File

@ -136,3 +136,8 @@ end;
-- Should succeed
DROP TABLESPACE testspace;
-- symlink location
\! mkdir -p @testtablespace@/symlink/sym1
\! ln -s @testtablespace@/symlink/sym1 @testtablespace@/symlink/sym2
CREATE TABLESPACE test_symlink LOCATION '@testtablespace@/symlink/sym2';

View File

@ -267,3 +267,8 @@ ERROR: DROP TABLESPACE cannot run inside a transaction block
end;
-- Should succeed
DROP TABLESPACE testspace;
-- symlink location
\! mkdir -p @testtablespace@/symlink/sym1
\! ln -s @testtablespace@/symlink/sym1 @testtablespace@/symlink/sym2
CREATE TABLESPACE test_symlink LOCATION '@testtablespace@/symlink/sym2';
ERROR: location "@testtablespace@/symlink/sym2" is symbolic link