summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-helpers.c
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2017-07-12 09:18:02 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2017-07-18 06:48:54 +0000
commit11eb8ba870457337c6067284dde4277e09764c0a (patch)
treea824fa09ca0db7c51689e7471cb2c7c3714feb6b /xlators/storage/posix/src/posix-helpers.c
parentb14f26a869c056fb9951e481ae20f3887edb743d (diff)
storage/posix: Don't allow gfid/volume-id xattr to be removed
Problem: Bulk xattr removal doesn't check if the xattrs that are coming in xdata have gfid/volume-id xattrs, so there is potential for bulkremovexattr removing gfid/volume-id. I also observed that bulkremovexattr is not available for fremovexattr. Fix: Do proper checks in bulk removexattr to remove gfid/volume-id. Refactor [f]removexattr to reduce the differences. BUG: 1470489 Change-Id: Ia845b31846a149500111c0996646e648f72cdce6 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: https://review.gluster.org/17765 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jeff@pl.atyp.us> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Anuradha Talur <atalur@redhat.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 8c1a789..53c8a86 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -148,26 +148,10 @@ out:
return ret;
}
-
-static gf_boolean_t
-_is_in_array (char **str_array, char *str)
-{
- int i = 0;
-
- if (!str)
- return _gf_false;
-
- for (i = 0; str_array[i]; i++) {
- if (strcmp (str, str_array[i]) == 0)
- return _gf_true;
- }
- return _gf_false;
-}
-
static gf_boolean_t
posix_xattr_ignorable (char *key)
{
- return _is_in_array (posix_ignore_xattrs, key);
+ return gf_get_index_by_elem (posix_ignore_xattrs, key) >= 0;
}
static int
@@ -763,7 +747,7 @@ _handle_list_xattr (dict_t *xattr_req, const char *real_path, int fdnum,
while (remaining_size > 0) {
key = list + list_offset;
- if (_is_in_array (list_xattr_ignore_xattrs, key))
+ if (gf_get_index_by_elem (list_xattr_ignore_xattrs, key) >= 0)
goto next;
if (posix_special_xattr (marker_xattrs, key))
@@ -2359,3 +2343,11 @@ posix_inode_ctx_get_all (inode_t *inode, xlator_t *this,
return ret;
}
+
+gf_boolean_t
+posix_is_bulk_removexattr (char *name, dict_t *xdata)
+{
+ if (name && (strlen (name) == 0) && xdata)
+ return _gf_true;
+ return _gf_false;
+}