summaryrefslogtreecommitdiffstats
path: root/gluster
diff options
context:
space:
mode:
authorPrashanth Pai <ppai@redhat.com>2016-03-18 18:25:36 +0530
committerThiago da Silva <thiago@redhat.com>2016-05-04 07:21:14 -0700
commit3451b86a6927ab7b21ae8e8a0421e4c51597df1d (patch)
tree592999d7b5ca5766435c05a7416465a1def50a59 /gluster
parentfddb5d4a918affe7837d523b56e53e33f3ae5408 (diff)
Don't (f)chown when it has no effect
For (f)chown calls which can change both UID and GID at once, -1 is reserved as a sentinel value to indicate "omitted argument" or "do not change". This makes sense when one of the args to (f)chown is -1. When both uid and gid args are -1, it doesn't make sense to call (f)chown as neither is going to be changed. Further, as of today, diskfile doesn't get the information (uid and gid) of the authenticated user from auth middleware. Retained the calls in code for future when such functionality might be added. Change-Id: If8463ae78a32c379d698260879810ed3c207af02 Signed-off-by: Prashanth Pai <ppai@redhat.com> Reviewed-on: http://review.gluster.org/13778 Reviewed-by: Thiago da Silva <thiago@redhat.com> Tested-by: Thiago da Silva <thiago@redhat.com>
Diffstat (limited to 'gluster')
-rw-r--r--gluster/swift/obj/diskfile.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/gluster/swift/obj/diskfile.py b/gluster/swift/obj/diskfile.py
index 2e0837e..f140a62 100644
--- a/gluster/swift/obj/diskfile.py
+++ b/gluster/swift/obj/diskfile.py
@@ -164,7 +164,12 @@ def make_directory(full_path, uid, gid, metadata=None):
# We created it, so we are reponsible for always setting the proper
# ownership.
- do_chown(full_path, uid, gid)
+ if not ((uid == DEFAULT_UID) and (gid == DEFAULT_GID)):
+ # If both UID and GID is -1 (default values), it has no effect.
+ # So don't do a chown.
+ # Further, at the time of this writing, UID and GID information
+ # is not passed to DiskFile.
+ do_chown(full_path, uid, gid)
return True, metadata
@@ -965,7 +970,12 @@ class DiskFile(object):
dw = None
try:
# Ensure it is properly owned before we make it available.
- do_fchown(fd, self._uid, self._gid)
+ if not ((self._uid == DEFAULT_UID) and (self._gid == DEFAULT_GID)):
+ # If both UID and GID is -1 (default values), it has no effect.
+ # So don't do a fchown.
+ # Further, at the time of this writing, UID and GID information
+ # is not passed to DiskFile.
+ do_fchown(fd, self._uid, self._gid)
# NOTE: we do not perform the fallocate() call at all. We ignore
# it completely since at the time of this writing FUSE does not
# support it.