From a9623ada6f7b39ac2d567f66a496072487d8e6ec Mon Sep 17 00:00:00 2001 From: Vijaykumar M Date: Thu, 12 Dec 2013 11:40:36 +0530 Subject: pathinfo: Provide user namespace access. Locality can be now queried by unprivileged users with key "glusterfs.pathinfo". Setting both "glusterfs.pathinfo" and "trusted.glusterfs.pathinfo" on disk is prevented with this patch. Original Author: Vijay Bellur Change-Id: I4f7a0db8ad59165c4aeda04b23173255157a8b79 Signed-off-by: Vijaykumar M Reviewed-on: http://review.gluster.org/5101 Reviewed-by: Krishnan Parthasarathi Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/storage/posix/src/posix-helpers.c | 5 ++++- xlators/storage/posix/src/posix.c | 6 ++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'xlators/storage') diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index 0e187e020..86ce08cb3 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -781,7 +781,10 @@ posix_handle_pair (xlator_t *this, const char *real_path, int sys_ret = -1; int ret = 0; - if (ZR_FILE_CONTENT_REQUEST(key)) { + if (XATTR_IS_PATHINFO (key)) { + ret = -EACCES; + goto out; + } else if (ZR_FILE_CONTENT_REQUEST(key)) { ret = posix_set_file_contents (this, real_path, key, value, flags); } else { diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 1ebf42150..7695289fa 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -3430,8 +3430,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, } goto done; } - if (loc->inode && name && - (strcmp (name, GF_XATTR_PATHINFO_KEY) == 0)) { + if (loc->inode && name && (XATTR_IS_PATHINFO (name))) { if (LOC_HAS_ABSPATH (loc)) MAKE_REAL_PATH (rpath, this, loc->path); else @@ -3451,8 +3450,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, goto done; } size = strlen (dyn_rpath) + 1; - ret = dict_set_dynstr (dict, GF_XATTR_PATHINFO_KEY, - dyn_rpath); + ret = dict_set_dynstr (dict, (char *)name, dyn_rpath); if (ret < 0) { gf_log (this->name, GF_LOG_WARNING, "could not set value (%s) in dictionary", -- cgit