diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2007-10-17 02:31:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-17 11:43:04 -0400 |
commit | ebc14c4dbeb56195950058db9aa32de06c22de0d (patch) | |
tree | 479813b230af145fd8c08e24b11c405ef6d4a25c /fs/fuse/inode.c | |
parent | 244f6385c2891e366a7de5f6746ccc257efd8952 (diff) |
fuse: fix permission checking on sticky directories
The VFS checks sticky bits on the parent directory even if the filesystem
defines it's own ->permission(). In some situations (sshfs, mountlo, etc) the
user does have permission to delete a file even if the attribute based
checking would not allow it.
So work around this by storing the permission bits separately and returning
them in stat(), but cutting the permission bits off from inode->i_mode.
This is slightly hackish, but it's probably not worth it to add new
infrastructure in VFS and a slight performance penalty for all filesystems,
just for the sake of fuse.
[Jan Engelhardt] cosmetic fixes
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/fuse/inode.c')
-rw-r--r-- | fs/fuse/inode.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 951e760d5c5a..fd0735715c14 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -120,10 +120,11 @@ static void fuse_truncate(struct address_space *mapping, loff_t offset) | |||
120 | void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr) | 120 | void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr) |
121 | { | 121 | { |
122 | struct fuse_conn *fc = get_fuse_conn(inode); | 122 | struct fuse_conn *fc = get_fuse_conn(inode); |
123 | struct fuse_inode *fi = get_fuse_inode(inode); | ||
123 | loff_t oldsize; | 124 | loff_t oldsize; |
124 | 125 | ||
125 | inode->i_ino = attr->ino; | 126 | inode->i_ino = attr->ino; |
126 | inode->i_mode = (inode->i_mode & S_IFMT) + (attr->mode & 07777); | 127 | inode->i_mode = (inode->i_mode & S_IFMT) | (attr->mode & 07777); |
127 | inode->i_nlink = attr->nlink; | 128 | inode->i_nlink = attr->nlink; |
128 | inode->i_uid = attr->uid; | 129 | inode->i_uid = attr->uid; |
129 | inode->i_gid = attr->gid; | 130 | inode->i_gid = attr->gid; |
@@ -135,6 +136,15 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr) | |||
135 | inode->i_ctime.tv_sec = attr->ctime; | 136 | inode->i_ctime.tv_sec = attr->ctime; |
136 | inode->i_ctime.tv_nsec = attr->ctimensec; | 137 | inode->i_ctime.tv_nsec = attr->ctimensec; |
137 | 138 | ||
139 | /* | ||
140 | * Don't set the sticky bit in i_mode, unless we want the VFS | ||
141 | * to check permissions. This prevents failures due to the | ||
142 | * check in may_delete(). | ||
143 | */ | ||
144 | fi->orig_i_mode = inode->i_mode; | ||
145 | if (!(fc->flags & FUSE_DEFAULT_PERMISSIONS)) | ||
146 | inode->i_mode &= ~S_ISVTX; | ||
147 | |||
138 | spin_lock(&fc->lock); | 148 | spin_lock(&fc->lock); |
139 | oldsize = inode->i_size; | 149 | oldsize = inode->i_size; |
140 | i_size_write(inode, attr->size); | 150 | i_size_write(inode, attr->size); |