summaryrefslogtreecommitdiffstats
path: root/geo-replication
diff options
context:
space:
mode:
authorAravinda VK <avishwan@redhat.com>2016-02-29 14:05:54 +0530
committerAravinda VK <avishwan@redhat.com>2016-03-09 03:02:36 -0800
commit2199acfd04b1e70fc6484a89196e7b9e4abb7208 (patch)
tree6382fcd62676be0c9f0eb43b27fbae5e4a4b53c0 /geo-replication
parentf125bb78b5a2abb41dec011d2f4fd525cb57ec93 (diff)
geo-rep: Fix Entry Creation issue with non root UID/GID
During entry_ops RENAME Geo-rep sends stat info along with the recorded info from Changelog. In Slave side if Source file exists Geo-rep renames to Target file by calling os.rename. If source file does not exists, it tries to create Target file directly using available stat info from Master. If UID and GID are different in Master for that file then stat info will have different UID/GID during Create. Geo-rep gets EACCES when it tries to create a new entry using gfid-access with different UID/GID. With this patch, Entry creation with different UID/GID is split into two operations. Create Entry with UID:0 and GID:0 and then set UID/GID. Change-Id: I4987e3a205d8513c06fa66198cde145a87003a01 BUG: 1312762 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on:http://review.gluster.org/13542 Reviewed-on: http://review.gluster.org/13643 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'geo-replication')
-rw-r--r--geo-replication/syncdaemon/resource.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py
index 81edfaa4a49..27f7e84a2ce 100644
--- a/geo-replication/syncdaemon/resource.py
+++ b/geo-replication/syncdaemon/resource.py
@@ -690,6 +690,16 @@ class Server(object):
op = e['op']
gfid = e['gfid']
entry = e['entry']
+ uid = 0
+ gid = 0
+ if e.get("stat", {}):
+ # Copy UID/GID value and then reset to zero. Copied UID/GID
+ # will be used to run chown once entry is created.
+ uid = e['stat']['uid']
+ gid = e['stat']['gid']
+ e['stat']['uid'] = 0
+ e['stat']['gid'] = 0
+
(pg, bname) = entry2pb(entry)
if op in ['RMDIR', 'UNLINK']:
# Try once, if rmdir failed with ENOTEMPTY
@@ -768,6 +778,16 @@ class Server(object):
[EEXIST, ENOENT],
[ESTALE, EINVAL])
collect_failure(e, cmd_ret)
+
+ # If UID/GID is different than zero that means we are trying
+ # create Entry with different UID/GID. Create Entry with
+ # UID:0 and GID:0, and then call chown to set UID/GID
+ if uid != 0 or gid != 0:
+ path = os.path.join(pfx, gfid)
+ cmd_ret = errno_wrap(os.chown, [path, uid, gid], [ENOENT],
+ [ESTALE, EINVAL])
+ collect_failure(e, cmd_ret)
+
return failures
@classmethod