Denied creating/removing files or directories from $Extend

$Extend is a directory reserved for metadata specific to Windows.
Inserting other files or directories there leads to problems with
some Windows versions.
pull/2/head
Jean-Pierre André 2017-02-11 09:00:49 +01:00
parent b66f5f8241
commit 28c479af6a
2 changed files with 18 additions and 2 deletions

View File

@ -2147,6 +2147,11 @@ static int ntfs_fuse_create(fuse_req_t req, fuse_ino_t parent, const char *name,
res = -errno;
goto exit;
}
/* Deny creating into $Extend */
if (parent == FILE_Extend) {
res = -EPERM;
goto exit;
}
/* Open parent directory. */
dir_ni = ntfs_inode_open(ctx->vol, INODE(parent));
if (!dir_ni) {
@ -2438,6 +2443,11 @@ static int ntfs_fuse_rm(fuse_req_t req, fuse_ino_t parent, const char *name,
struct SECURITY_CONTEXT security;
#endif
/* Deny removing from $Extend */
if (parent == FILE_Extend) {
res = -EPERM;
goto exit;
}
/* Open parent directory. */
dir_ni = ntfs_inode_open(ctx->vol, INODE(parent));
if (!dir_ni) {

View File

@ -1945,9 +1945,12 @@ static int ntfs_fuse_create(const char *org_path, mode_t typemode, dev_t dev,
/* Open parent directory. */
*--name = 0;
dir_ni = ntfs_pathname_to_inode(ctx->vol, NULL, dir_path);
if (!dir_ni) {
/* Deny creating files in $Extend */
if (!dir_ni || (dir_ni->mft_no == FILE_Extend)) {
free(path);
res = -errno;
if (dir_ni->mft_no == FILE_Extend)
res = -EPERM;
goto exit;
}
#if !KERNELPERMS | (POSIXACLS & !KERNELACLS)
@ -2290,8 +2293,11 @@ static int ntfs_fuse_rm(const char *org_path)
/* Open parent directory. */
*--name = 0;
dir_ni = ntfs_pathname_to_inode(ctx->vol, NULL, path);
if (!dir_ni) {
/* deny unlinking metadata files from $Extend */
if (!dir_ni || (dir_ni->mft_no == FILE_Extend)) {
res = -errno;
if (dir_ni->mft_no == FILE_Extend)
res = -EPERM;
goto exit;
}