From 90333660ce4dd1fc94aa8f6b30c085d354f6693e Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 13 Mar 2012 17:26:13 +0530 Subject: storage/posix: don't allow rmdir()/lookup() on HIDDEN_DIRECTORY so that we won't even have a GFID set on the GFID dir itself. Change-Id: I65be7d675a308f51f4c62a86499341412b20c47f Signed-off-by: Amar Tumballi BUG: 802726 Reviewed-on: http://review.gluster.com/2936 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/storage/posix/src/posix.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'xlators') diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index f699e4c4d..2df5702cb 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -114,6 +114,18 @@ posix_lookup (call_frame_t *frame, xlator_t *this, VALIDATE_OR_GOTO (loc, out); VALIDATE_OR_GOTO (loc->path, out); + /* The Hidden directory should be for housekeeping purpose and it + should not get any gfid on it */ + if (__is_root_gfid (loc->pargfid) && + (strcmp (loc->name, GF_HIDDEN_PATH) == 0)) { + gf_log (this->name, GF_LOG_WARNING, + "Lookup issued on %s, which is not permitted", + GF_HIDDEN_PATH); + op_errno = EPERM; + op_ret = -1; + goto out; + } + if (uuid_is_null (loc->pargfid)) { /* nameless lookup */ MAKE_INODE_HANDLE (real_path, this, loc, &buf); @@ -1098,9 +1110,22 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, VALIDATE_OR_GOTO (this, out); VALIDATE_OR_GOTO (loc, out); + SET_FS_ID (frame->root->uid, frame->root->gid); + + /* The Hidden directory should be for housekeeping purpose and it + should not get deleted from inside process */ + if (__is_root_gfid (loc->pargfid) && + (strcmp (loc->name, GF_HIDDEN_PATH) == 0)) { + gf_log (this->name, GF_LOG_WARNING, + "rmdir issued on %s, which is not permitted", + GF_HIDDEN_PATH); + op_errno = EPERM; + op_ret = -1; + goto out; + } + priv = this->private; - SET_FS_ID (frame->root->uid, frame->root->gid); MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &stbuf); op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent); -- cgit