summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/syncop.c
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2012-12-04 22:35:58 -0800
committerAnand Avati <avati@redhat.com>2013-02-13 09:31:33 -0800
commit1ffb2558fb4bb896883ad71497bac0cc13df4f18 (patch)
tree573a9663976238f2cab42bd33b1d2c046ed7d905 /libglusterfs/src/syncop.c
parent311a5df884c0d2320dd43191e6e6ba0a033eb683 (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() Change-Id: I7eb74f7c473099bcae39310d2ab353d58f8eb2ba BUG: 884597 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/4269 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Shishir Gowda <sgowda@redhat.com>
Diffstat (limited to 'libglusterfs/src/syncop.c')
-rw-r--r--libglusterfs/src/syncop.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index c8a9b584..b15ee31b 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) {