diff options
author | Csaba Henk <csaba@redhat.com> | 2012-03-07 05:29:41 +0100 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2012-03-07 23:05:37 -0800 |
commit | e1ab347720f25ed2e7db633a7202f7b873f4b90a (patch) | |
tree | 1462618a55937f33644319e8da0dceb13828c1c4 /xlators/mount/fuse/src/fuse-helpers.c | |
parent | 33e9f9da8546dc57ecf6b3705f6b6474150ec78c (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>
Diffstat (limited to 'xlators/mount/fuse/src/fuse-helpers.c')
-rw-r--r-- | xlators/mount/fuse/src/fuse-helpers.c | 30 |
1 files changed, 18 insertions, 12 deletions
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); |