summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCsaba Henk <csaba@redhat.com>2012-03-07 05:29:41 +0100
committerVijay Bellur <vijay@gluster.com>2012-03-07 23:05:37 -0800
commite1ab347720f25ed2e7db633a7202f7b873f4b90a (patch)
tree1462618a55937f33644319e8da0dceb13828c1c4
parent33e9f9da8546dc57ecf6b3705f6b6474150ec78c (diff)
cleanup and fix xattr namespace flip
- function of actual flipping made static - clean out references to particular namespaces from flipping logic - namespaces involved in flipping defined at single location - fix fnmatch(3) invocation with reversed pattern and string arguments - instead of "user", use "system" to flip from, because latter is free from supervision of the VFS layer (cf. attr(5)) Change-Id: I3cc5836fadcad5b237fd5c67d0dcaea63aee9164 BUG: 798716 Signed-off-by: Csaba Henk <csaba@redhat.com> Reviewed-on: http://review.gluster.com/2890 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Venky Shankar <vshankar@redhat.com>
-rw-r--r--xlators/features/marker/utils/syncdaemon/resource.py2
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.h1
-rw-r--r--xlators/mount/fuse/src/fuse-helpers.c30
3 files changed, 19 insertions, 14 deletions
diff --git a/xlators/features/marker/utils/syncdaemon/resource.py b/xlators/features/marker/utils/syncdaemon/resource.py
index 64923e0e5f4..7fcc53964f9 100644
--- a/xlators/features/marker/utils/syncdaemon/resource.py
+++ b/xlators/features/marker/utils/syncdaemon/resource.py
@@ -204,7 +204,7 @@ class Server(object):
and classmethods and is used directly, without instantiation.)
"""
- GX_NSPACE = (privileged() and "trusted" or "user") + ".glusterfs"
+ GX_NSPACE = (privileged() and "trusted" or "system") + ".glusterfs"
NTV_FMTSTR = "!" + "B"*19 + "II"
FRGN_XTRA_FMT = "I"
FRGN_FMTSTR = NTV_FMTSTR + FRGN_XTRA_FMT
diff --git a/xlators/mount/fuse/src/fuse-bridge.h b/xlators/mount/fuse/src/fuse-bridge.h
index 13c026bcff7..b7f0dfd5034 100644
--- a/xlators/mount/fuse/src/fuse-bridge.h
+++ b/xlators/mount/fuse/src/fuse-bridge.h
@@ -347,7 +347,6 @@ inode_t *fuse_ino_to_inode (uint64_t ino, xlator_t *fuse);
int send_fuse_err (xlator_t *this, fuse_in_header_t *finh, int error);
int fuse_gfid_set (fuse_state_t *state);
int fuse_flip_xattr_ns (struct fuse_private *priv, char *okey, char **nkey);
-int fuse_flip_user_to_trusted (char *okey, char **nkey);
int fuse_xattr_alloc_default (char *okey, char **nkey);
fuse_fd_ctx_t * __fuse_fd_ctx_check_n_create (fd_t *fd, xlator_t *this);
fuse_fd_ctx_t * fuse_fd_ctx_check_n_create (fd_t *fd, xlator_t *this);
diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c
index 6aee697158c..91a6cba5314 100644
--- a/xlators/mount/fuse/src/fuse-helpers.c
+++ b/xlators/mount/fuse/src/fuse-helpers.c
@@ -422,21 +422,24 @@ gf_fuse_stat2attr (struct iatt *st, struct fuse_attr *fa)
#endif
}
-int
-fuse_flip_user_to_trusted (char *okey, char **nkey)
+static int
+fuse_do_flip_xattr_ns (char *okey, const char *nns, char **nkey)
{
int ret = 0;
char *key = NULL;
- key = GF_CALLOC (1, strlen(okey) + 10, gf_common_mt_char);
+ okey = strchr (okey, '.');
+ GF_ASSERT (okey);
+
+ key = GF_CALLOC (1, strlen (nns) + strlen(okey) + 1,
+ gf_common_mt_char);
if (!key) {
ret = -1;
goto out;
}
- okey += 5;
- strncpy(key, "trusted.", 8);
- strncat(key+8, okey, strlen(okey));
+ strcpy (key, nns);
+ strcat (key, okey);
*nkey = key;
@@ -455,6 +458,9 @@ fuse_xattr_alloc_default (char *okey, char **nkey)
return ret;
}
+#define PRIV_XA_NS "trusted"
+#define UNPRIV_XA_NS "system"
+
int
fuse_flip_xattr_ns (fuse_private_t *priv, char *okey, char **nkey)
{
@@ -482,9 +488,9 @@ fuse_flip_xattr_ns (fuse_private_t *priv, char *okey, char **nkey)
/* valid xattr(s): *xtime, volume-mark* */
gf_log("glusterfs-fuse", GF_LOG_DEBUG, "PID: %d, checking xattr(s): "
"volume-mark*, *xtime", npid);
- if ( (strcmp (okey, "user.glusterfs.volume-mark") == 0)
- || (fnmatch (okey, "user.glusterfs.volume-mark.*", FNM_PERIOD) == 0)
- || (fnmatch ("user.glusterfs.*.xtime", okey, FNM_PERIOD) == 0) )
+ if ( (strcmp (okey, UNPRIV_XA_NS".glusterfs.volume-mark") == 0)
+ || (fnmatch (UNPRIV_XA_NS".glusterfs.volume-mark.*", okey, FNM_PERIOD) == 0)
+ || (fnmatch (UNPRIV_XA_NS".glusterfs.*.xtime", okey, FNM_PERIOD) == 0) )
need_flip = _gf_true;
break;
@@ -492,15 +498,15 @@ fuse_flip_xattr_ns (fuse_private_t *priv, char *okey, char **nkey)
/* valid xattr(s): pathinfo */
gf_log("glusterfs-fuse", GF_LOG_DEBUG, "PID: %d, checking xattr(s): "
"pathinfo", npid);
- if (strcmp (okey, "user.glusterfs.pathinfo") == 0)
+ if (strcmp (okey, UNPRIV_XA_NS".glusterfs.pathinfo") == 0)
need_flip = _gf_true;
break;
}
if (need_flip) {
- gf_log ("glusterfs-fuse", GF_LOG_DEBUG, "flipping %s to trusted equivalent",
+ gf_log ("glusterfs-fuse", GF_LOG_DEBUG, "flipping %s to "PRIV_XA_NS" equivalent",
okey);
- ret = fuse_flip_user_to_trusted (okey, nkey);
+ ret = fuse_do_flip_xattr_ns (okey, PRIV_XA_NS, nkey);
} else {
/* if we cannot match, continue with what we got */
ret = fuse_xattr_alloc_default (okey, nkey);