From 5b9d47a3a39fac39e3fbccd4083f2f45c9ce5b49 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Wed, 29 Feb 2012 10:21:03 +0100 Subject: geo-rep / syncdaemon: determine suitable xattr namespace based on privilege Change-Id: I91fe16d7e5e4c21f138eab4ee0b9334aec40e41b BUG: 765433 Signed-off-by: Csaba Henk Reviewed-on: http://review.gluster.com/2838 Tested-by: Gluster Build System Reviewed-by: Venky Shankar --- xlators/features/marker/utils/syncdaemon/resource.py | 10 ++++------ xlators/features/marker/utils/syncdaemon/syncdutils.py | 3 +++ 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'xlators/features/marker') 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 -- cgit