From f162456794ae78d29edc42a2c040c1037145f24d Mon Sep 17 00:00:00 2001 From: shishir gowda Date: Fri, 26 Apr 2013 15:33:42 +0530 Subject: cluster/dht: getxattr linkto as root:root In path based op's like truncate, we use getxattr instead of fgetxattr call. These can fail with permission denied issues as linkto file creation, and setattr of ownership is not atomic, and in cases where setattr failed (subvols down..) The fix is to perform getxattr as root:root as it is a internal fop. fgetxattr, bypass the access check, as it already has a valid open fd. Change-Id: Ie221c9172e3c1c7ed4e50c8782d362826910756f BUG: 957074 Signed-off-by: shishir gowda Reviewed-on: http://review.gluster.org/4890 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/cluster/dht/src/dht-helper.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c index 52a24acc2..56c139aa9 100644 --- a/xlators/cluster/dht/src/dht-helper.c +++ b/xlators/cluster/dht/src/dht-helper.c @@ -709,13 +709,18 @@ dht_migration_complete_check_task (void *data) if (!local->loc.inode && !local->fd) goto out; - /* getxattr on cached_subvol for 'linkto' value */ - if (!local->loc.inode) + /* getxattr on cached_subvol for 'linkto' value. Do path based getxattr + * as root:root. If a fd is already open, access check wont be done*/ + + if (!local->loc.inode) { ret = syncop_fgetxattr (src_node, local->fd, &dict, conf->link_xattr_name); - else + } else { + SYNCTASK_SETID (0, 0); ret = syncop_getxattr (src_node, &local->loc, &dict, conf->link_xattr_name); + SYNCTASK_SETID (frame->root->uid, frame->root->gid); + } if (!ret) dst_node = dht_linkfile_subvol (this, NULL, NULL, dict); @@ -889,13 +894,17 @@ dht_rebalance_inprogress_task (void *data) if (!local->loc.inode && !local->fd) goto out; - /* getxattr on cached_subvol for 'linkto' value */ - if (local->loc.inode) + /* getxattr on cached_subvol for 'linkto' value. Do path based getxattr + * as root:root. If a fd is already open, access check wont be done*/ + if (local->loc.inode) { + SYNCTASK_SETID (0, 0); ret = syncop_getxattr (src_node, &local->loc, &dict, conf->link_xattr_name); - else + SYNCTASK_SETID (frame->root->uid, frame->root->gid); + } else { ret = syncop_fgetxattr (src_node, local->fd, &dict, conf->link_xattr_name); + } if (ret) { gf_log (this->name, GF_LOG_ERROR, -- cgit