From 18950598bef63c11237e7cdc959442e524a74061 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Tue, 24 Jul 2012 01:13:25 +0530 Subject: Fixes for gsyncd / geo-rep and FUSE listxattr This patch fixes two problems with recent changes to Geo-Replication First: ------ Recent changes to geo-replication relies on Rsync to tranfer extended attributes. Essentially Rsync would invoke a listxattr() and then getxattr() the set reutrned by listxattr() and finally transfer it to the remote slave. Xattrs like security.selinux would create problems as they are not allowed to be set explicitly (unless there's a rule that allows this). So, to make Rsync behave sanely we filter out all "*.selinux*" xattrs from listxattr() (which is getxattr() with ->name as NULL). Second: ------- Python's "if {..} else {..}" shortcut ".. and .. or .." was misused here. This is a straightforward fix by interchanging last two variables (classes in this case). Also fix a typo in sendmark_regular() definition. Change-Id: I097b5f5d88a36c7eef5560a78d4332948a545942 BUG: 842330 Signed-off-by: Venky Shankar Reviewed-on: http://review.gluster.com/3714 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/mount/fuse/src/fuse-bridge.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'xlators/mount/fuse/src') diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 2accb0a82..2948aae97 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -2830,6 +2830,24 @@ send_fuse_xattr (xlator_t *this, fuse_in_header_t *finh, const char *value, } } +/* filter out xattrs that need not be visible on the + * mount point. this is _specifically_ for geo-rep + * as of now, to prevent Rsync from crying out loud + * when it tries to setxattr() for selinux xattrs + */ +static int +fuse_filter_xattr(xlator_t *this, char *key) +{ + int need_filter = 0; + struct fuse_private *priv = this->private; + + if ((priv->client_pid == GF_CLIENT_PID_GSYNCD) + && fnmatch ("*.selinux*", key, FNM_PERIOD) == 0) + need_filter = 1; + + return need_filter; +} + static int fuse_xattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, @@ -2868,9 +2886,13 @@ fuse_xattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } /* if(value_data)...else */ } else { /* if callback for listxattr */ + /* we need to invoke fuse_filter_xattr() twice. Once + * while counting size and then while filling buffer + */ trav = dict->members_list; while (trav) { - len += strlen (trav->key) + 1; + if (!fuse_filter_xattr (this, trav->key)) + len += strlen (trav->key) + 1; trav = trav->next; } /* while(trav) */ value = alloca (len + 1); @@ -2879,9 +2901,11 @@ fuse_xattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, len = 0; trav = dict->members_list; while (trav) { - strcpy (value + len, trav->key); - value[len + strlen (trav->key)] = '\0'; - len += strlen (trav->key) + 1; + if (!fuse_filter_xattr (this, trav->key)) { + strcpy (value + len, trav->key); + value[len + strlen (trav->key)] = '\0'; + len += strlen (trav->key) + 1; + } trav = trav->next; } /* while(trav) */ send_fuse_xattr (this, finh, value, len, state->size); -- cgit