summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith K <pranithk@gluster.com>2011-02-03 21:22:44 +0000
committerAnand V. Avati <avati@dev.gluster.com>2011-02-08 23:20:59 -0800
commit9f2e9fc465361e7821627a8c3a22863bb25b0810 (patch)
treea925446d0cde494c04af8a25b9014cd0d83dd051
parent9cfa22f828f69c9f1f48b5e8994a4dff48d283a6 (diff)
cluster/afr: Perform self-heal as root
Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 2370 (cluster/afr: Perform self-heal as root) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2370
-rw-r--r--libglusterfs/src/stack.h16
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c3
-rw-r--r--xlators/cluster/afr/src/afr.h2
3 files changed, 20 insertions, 1 deletions
diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h
index f06267c38..1c3e3430e 100644
--- a/libglusterfs/src/stack.h
+++ b/libglusterfs/src/stack.h
@@ -182,6 +182,22 @@ STACK_DESTROY (call_stack_t *stack)
#define cbk(x) cbk_##x
+#define FRAME_SU_DO(frm, local_type) \
+ do { \
+ local_type *__local = (frm)->local; \
+ __local->uid = frm->root->uid; \
+ __local->gid = frm->root->gid; \
+ frm->root->uid = 0; \
+ frm->root->gid = 0; \
+ } while (0); \
+
+#define FRAME_SU_UNDO(frm, local_type) \
+ do { \
+ local_type *__local = (frm)->local; \
+ frm->root->uid = __local->uid; \
+ frm->root->gid = __local->gid; \
+ } while (0); \
+
/* make a call */
#define STACK_WIND(frame, rfn, obj, fn, params ...) \
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index 8b0d565f8..710087a55 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -1500,7 +1500,6 @@ afr_local_t *afr_local_copy (afr_local_t *l, xlator_t *this)
return lc;
}
-
int
afr_self_heal_completion_cbk (call_frame_t *bgsh_frame, xlator_t *this)
{
@@ -1524,6 +1523,7 @@ afr_self_heal_completion_cbk (call_frame_t *bgsh_frame, xlator_t *this)
gf_log (this->name, GF_LOG_NORMAL,
"background %s self-heal completed on %s", sh_type_str,
local->loc.path);
+ FRAME_SU_UNDO (bgsh_frame, afr_local_t);
if (!sh->unwound) {
sh->unwind (sh->orig_frame, this);
@@ -1622,6 +1622,7 @@ afr_self_heal (call_frame_t *frame, xlator_t *this)
gf_afr_mt_int32_t);
}
+ FRAME_SU_DO (sh_frame, afr_local_t);
if (local->success_count && local->enoent_count) {
afr_self_heal_missing_entries (sh_frame, this);
} else {
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index b0e434142..3efa484b7 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -276,6 +276,8 @@ typedef struct _afr_locked_fd {
} afr_locked_fd_t;
typedef struct _afr_local {
+ int uid;
+ int gid;
unsigned int call_count;
unsigned int success_count;
unsigned int enoent_count;