summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
Diffstat (limited to 'xlators')
-rw-r--r--xlators/features/marker/src/marker.c29
-rw-r--r--xlators/features/marker/src/marker.h16
2 files changed, 39 insertions, 6 deletions
diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c
index d0f01465ffa..2c60c3d50a2 100644
--- a/xlators/features/marker/src/marker.c
+++ b/xlators/features/marker/src/marker.c
@@ -31,6 +31,8 @@
#include "marker-common.h"
#include "byte-order.h"
+#define _GF_UID_GID_CHANGED 1
+
void
fini (xlator_t *this);
@@ -1019,8 +1021,9 @@ marker_rename_release_oldp_lock (call_frame_t *frame, void *cookie,
local->err = op_errno;
}
- //Reset frame uid and gid if reset.
- MARKER_SET_UID_GID (frame->root, local);
+ //Reset frame uid and gid if set.
+ if (cookie == (void *) _GF_UID_GID_CHANGED)
+ MARKER_RESET_UID_GID (frame, frame->root, local);
lock.l_type = F_UNLCK;
lock.l_whence = SEEK_SET;
@@ -1092,9 +1095,7 @@ marker_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* Removexattr requires uid and gid to be 0,
* reset them in the callback.
*/
- MARKER_SET_UID_GID (local, frame->root);
- frame->root->uid = 0;
- frame->root->gid = 0;
+ MARKER_SET_UID_GID (frame, local, frame->root);
STACK_WIND (frame, marker_rename_release_oldp_lock,
FIRST_CHILD(this),
@@ -1145,6 +1146,10 @@ marker_do_rename (call_frame_t *frame, void *cookie, xlator_t *this,
local = frame->local;
oplocal = local->oplocal;
+ //Reset frame uid and gid if set.
+ if (cookie == (void *) _GF_UID_GID_CHANGED)
+ MARKER_RESET_UID_GID (frame, frame->root, local);
+
if ((op_ret < 0) && (op_errno != ENOATTR)) {
local->err = op_errno;
gf_log (this->name, GF_LOG_WARNING,
@@ -1194,6 +1199,10 @@ marker_get_newpath_contribution (call_frame_t *frame, void *cookie,
local = frame->local;
oplocal = local->oplocal;
+ //Reset frame uid and gid if set.
+ if (cookie == (void *) _GF_UID_GID_CHANGED)
+ MARKER_RESET_UID_GID (frame, frame->root, local);
+
if ((op_ret < 0) && (op_errno != ENOATTR)) {
local->err = op_errno;
gf_log (this->name, GF_LOG_WARNING,
@@ -1221,6 +1230,11 @@ marker_get_newpath_contribution (call_frame_t *frame, void *cookie,
goto err;
}
+ /* getxattr requires uid and gid to be 0,
+ * reset them in the callback.
+ */
+ MARKER_SET_UID_GID (frame, local, frame->root);
+
STACK_WIND (frame, marker_do_rename,
FIRST_CHILD(this),
FIRST_CHILD(this)->fops->getxattr, &local->loc,
@@ -1266,6 +1280,11 @@ marker_get_oldpath_contribution (call_frame_t *frame, void *cookie,
goto quota_err;
}
+ /* getxattr requires uid and gid to be 0,
+ * reset them in the callback.
+ */
+ MARKER_SET_UID_GID (frame, local, frame->root);
+
STACK_WIND (frame, marker_get_newpath_contribution, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->getxattr, &oplocal->loc,
contri_key);
diff --git a/xlators/features/marker/src/marker.h b/xlators/features/marker/src/marker.h
index 5502c4ea137..f5ed9df399e 100644
--- a/xlators/features/marker/src/marker.h
+++ b/xlators/features/marker/src/marker.h
@@ -64,7 +64,7 @@ enum {
} \
} while (0)
-#define MARKER_SET_UID_GID(dest, src) \
+#define _MARKER_SET_UID_GID(dest, src) \
do { \
if (src->uid != -1 && \
src->gid != -1) { \
@@ -73,6 +73,20 @@ enum {
} \
} while (0)
+#define MARKER_SET_UID_GID(frame, dest, src) \
+ do { \
+ _MARKER_SET_UID_GID (dest, src); \
+ frame->root->uid = 0; \
+ frame->root->gid = 0; \
+ frame->cookie = (void *) _GF_UID_GID_CHANGED; \
+ } while (0)
+
+#define MARKER_RESET_UID_GID(frame, dest, src) \
+ do { \
+ _MARKER_SET_UID_GID (dest, src); \
+ frame->cookie = NULL; \
+ } while (0)
+
struct marker_local{
uint32_t timebuf[2];
pid_t pid;