summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorshishir gowda <sgowda@redhat.com>2013-02-15 11:52:41 +0530
committerVijay Bellur <vbellur@redhat.com>2013-03-04 02:42:19 -0800
commit184adfd07e437d9531ebea88208d14c11f51137e (patch)
treefc4befdfc0efcc52b888a9fc03d0e6ac5b7ad599 /libglusterfs
parent3335a3ded7f46ddcdf2a42edf0c6e78abeb9e898 (diff)
synctask: implement setuid-like SYNCTASK_SETID()
synctasks can now call SYNCTASK_SETID(uid,gid) to set the effective uid/gid of the frame with which the FOP will be performed. Once called, the uid/gid is set either till the end of the synctask or till the next call of SYNCTASK_SETID() Back-porting Avati's patch http://review.gluster.org/#change,4269 BUG: 884597 Change-Id: Id0569da4bb8959636881457217fe004bf30c5b9d Signed-off-by: shishir gowda <sgowda@redhat.com> Reviewed-on: http://review.gluster.org/4611 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/syncop.c20
-rw-r--r--libglusterfs/src/syncop.h10
2 files changed, 30 insertions, 0 deletions
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index c8a9b5848c1..b15ee31ba07 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -173,6 +173,22 @@ synctask_done (struct synctask *task)
int
+synctask_setid (struct synctask *task, uid_t uid, gid_t gid)
+{
+ if (!task)
+ return -1;
+
+ if (uid != -1)
+ task->uid = uid;
+
+ if (gid != -1)
+ task->gid = gid;
+
+ return 0;
+}
+
+
+int
synctask_new (struct syncenv *env, synctask_fn_t fn, synctask_cbk_t cbk,
call_frame_t *frame, void *opaque)
{
@@ -201,6 +217,10 @@ synctask_new (struct syncenv *env, synctask_fn_t fn, synctask_cbk_t cbk,
newtask->synccbk = cbk;
newtask->opaque = opaque;
+ /* default to the uid/gid of the passed frame */
+ newtask->uid = newtask->opframe->root->uid;
+ newtask->gid = newtask->opframe->root->gid;
+
INIT_LIST_HEAD (&newtask->all_tasks);
if (getcontext (&newtask->ctx) < 0) {
diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h
index 6e900e8d0d9..37e2b0e288a 100644
--- a/libglusterfs/src/syncop.h
+++ b/libglusterfs/src/syncop.h
@@ -59,6 +59,9 @@ struct synctask {
int slept;
int ret;
+ uid_t uid;
+ gid_t gid;
+
ucontext_t ctx;
struct syncproc *proc;
@@ -169,6 +172,10 @@ struct syncargs {
frame = task->opframe; \
else \
frame = create_frame (THIS, THIS->ctx->pool); \
+ if (task) { \
+ frame->root->uid = task->uid; \
+ frame->root->gid = task->gid; \
+ } \
\
__yawn (stb); \
\
@@ -195,6 +202,9 @@ int synctask_new (struct syncenv *, synctask_fn_t, synctask_cbk_t, call_frame_t*
void synctask_wake (struct synctask *task);
void synctask_yield (struct synctask *task);
+int synctask_setid (struct synctask *task, uid_t uid, gid_t gid);
+#define SYNCTASK_SETID(uid, gid) synctask_setid (synctask_get(), uid, gid);
+
int syncop_lookup (xlator_t *subvol, loc_t *loc, dict_t *xattr_req,
/* out */
struct iatt *iatt, dict_t **xattr_rsp, struct iatt *parent);