distribute: perform self-heal as root

prerserve original frame uid and gid and perform self-heal by changing
uid/gid to root (0) temporarily.

Signed-off-by: Shehjar Tikoo <shehjart@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>

BUG: 597 (miscellaneous fixes for xlators to work well with NFS xlator)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=597
This commit is contained in:
Shehjar Tikoo 2010-02-25 15:38:08 +00:00 committed by Anand V. Avati
parent a8f10e72f2
commit fa19417943
3 changed files with 37 additions and 0 deletions

View File

@ -53,6 +53,8 @@ dht_lookup_selfheal_cbk (call_frame_t *frame, void *cookie,
local = frame->local;
ret = op_ret;
dht_frame_su_undo (frame);
if (ret == 0) {
layout = local->selfheal.layout;
ret = dht_layout_set (this, local->inode, layout);
@ -191,6 +193,7 @@ unlock:
return 0;
selfheal:
dht_frame_su_do (frame);
ret = dht_selfheal_directory (frame, dht_lookup_selfheal_cbk,
&local->loc, layout);

View File

@ -107,6 +107,8 @@ struct dht_local {
dht_selfheal_dir_cbk_t dir_cbk;
dht_layout_t *layout;
} selfheal;
uint32_t uid;
uint32_t gid;
/* needed by nufa */
int32_t flags;
@ -272,6 +274,8 @@ void dht_layout_unref (xlator_t *this, dht_layout_t *layout);
dht_layout_t *dht_layout_ref (xlator_t *this, dht_layout_t *layout);
xlator_t *dht_first_up_subvol (xlator_t *this);
xlator_t *dht_last_up_subvol (xlator_t *this);
int dht_frame_su_do (call_frame_t *frame);
int dht_frame_su_undo (call_frame_t *frame);
int dht_build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name);

View File

@ -367,6 +367,36 @@ dht_stat_merge (xlator_t *this, struct stat *to,
return 0;
}
int
dht_frame_su_do (call_frame_t *frame)
{
dht_local_t *local = NULL;
local = frame->local;
local->uid = frame->root->uid;
local->gid = frame->root->gid;
frame->root->uid = 0;
frame->root->gid = 0;
return 0;
}
int
dht_frame_su_undo (call_frame_t *frame)
{
dht_local_t *local = NULL;
local = frame->local;
frame->root->uid = local->uid;
frame->root->gid = local->gid;
return 0;
}
int
dht_build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name)