summaryrefslogtreecommitdiffstats
path: root/xlators/features/marker/utils
diff options
context:
space:
mode:
authorCsaba Henk <csaba@redhat.com>2012-02-29 10:21:03 +0100
committerVijay Bellur <vijay@gluster.com>2012-03-05 07:52:54 -0800
commit5b9d47a3a39fac39e3fbccd4083f2f45c9ce5b49 (patch)
tree357901d5a535fb9af4f1c8f326649b81e867fac0 /xlators/features/marker/utils
parenteb3bab1c6d391131cdff48a458fbfec2f53d7c6c (diff)
geo-rep / syncdaemon: determine suitable xattr namespace based on privilege
Change-Id: I91fe16d7e5e4c21f138eab4ee0b9334aec40e41b BUG: 765433 Signed-off-by: Csaba Henk <csaba@redhat.com> Reviewed-on: http://review.gluster.com/2838 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'xlators/features/marker/utils')
-rw-r--r--xlators/features/marker/utils/syncdaemon/resource.py10
-rw-r--r--xlators/features/marker/utils/syncdaemon/syncdutils.py3
2 files changed, 7 insertions, 6 deletions
diff --git a/xlators/features/marker/utils/syncdaemon/resource.py b/xlators/features/marker/utils/syncdaemon/resource.py
index 3454c38234a..64923e0e5f4 100644
--- a/xlators/features/marker/utils/syncdaemon/resource.py
+++ b/xlators/features/marker/utils/syncdaemon/resource.py
@@ -17,7 +17,7 @@ import repce
from repce import RepceServer, RepceClient
from master import GMaster
import syncdutils
-from syncdutils import GsyncdError, select
+from syncdutils import GsyncdError, select, privileged
UrlRX = re.compile('\A(\w+)://([^ *?[]*)\Z')
HostRX = re.compile('[a-z\d](?:[a-z\d.-]*[a-z\d])?', re.I)
@@ -204,7 +204,7 @@ class Server(object):
and classmethods and is used directly, without instantiation.)
"""
- GX_NSPACE = "trusted.glusterfs"
+ GX_NSPACE = (privileged() and "trusted" or "user") + ".glusterfs"
NTV_FMTSTR = "!" + "B"*19 + "II"
FRGN_XTRA_FMT = "I"
FRGN_FMTSTR = NTV_FMTSTR + FRGN_XTRA_FMT
@@ -715,10 +715,8 @@ class GLUSTER(AbstractUrl, SlaveLocal, SlaveRemote):
"""
label = getattr(gconf, 'mountbroker', None)
- if not label:
- uid = os.geteuid()
- if uid != 0:
- label = syncdutils.getusername(uid)
+ if not label and not privileged():
+ label = syncdutils.getusername()
mounter = label and self.MountbrokerMounter or self.DirectMounter
params = gconf.gluster_params.split() + \
(gconf.gluster_log_level and ['log-level=' + gconf.gluster_log_level] or []) + \
diff --git a/xlators/features/marker/utils/syncdaemon/syncdutils.py b/xlators/features/marker/utils/syncdaemon/syncdutils.py
index b91b328b965..11c2063b750 100644
--- a/xlators/features/marker/utils/syncdaemon/syncdutils.py
+++ b/xlators/features/marker/utils/syncdaemon/syncdutils.py
@@ -225,6 +225,9 @@ def getusername(uid = None):
uid = os.geteuid()
return pwd.getpwuid(uid).pw_name
+def privileged():
+ return os.geteuid() == 0
+
def boolify(s):
"""
Generic string to boolean converter