diff options
author | Kotresh HR <khiremat@redhat.com> | 2017-07-10 10:31:27 -0400 |
---|---|---|
committer | Jeff Darcy <jeff@pl.atyp.us> | 2017-07-24 13:05:48 +0000 |
commit | 96eece8abbb9c06f0b91f37e718ac9e337a3f714 (patch) | |
tree | c5d3498254327ef314ae29c038592ae35df22387 /tests | |
parent | 668df4e7e452aa26f0e0fbd15691fab0edc83014 (diff) |
posix/gfid2path: Block access to gfid2path xattr via mount
gfid2path xattr is an internal xattr and should not be
allowed to modify by other applications via gluster
mount. This patch blocks the same.
Updates: #139
Change-Id: Id2cb29797ee1bd77e0e0d2203a47469fd7203355
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: https://review.gluster.org/17744
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Prashanth Pai <ppai@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-by: Aravinda VK <avishwan@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gfid2path/block-mount-access.t | 54 | ||||
-rw-r--r-- | tests/volume.rc | 6 |
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/gfid2path/block-mount-access.t b/tests/gfid2path/block-mount-access.t new file mode 100644 index 00000000000..2130927504a --- /dev/null +++ b/tests/gfid2path/block-mount-access.t @@ -0,0 +1,54 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../afr.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd + +## Create a 2*2 volume +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; + +## Start the volume +TEST $CLI volume start $V0 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 +TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0; + +## enable gfid2path +TEST $CLI volume set $V0 gfid2path enable + +## Mount the volume +TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0; + +#CREATE +fname=$M0/file1 +touch $fname; +backpath=$B0/${V0}1/file1 + +pgfid="00000000-0000-0000-0000-000000000001" + +#Check for the presence of xattr +key="trusted.gfid2path" +gfid2path_xattr=$(getfattr -h -d -m. $backpath 2>/dev/null | grep -a $key | cut -f1 -d'=') + +#Check getxattr +TEST ! getfattr -h -n $gfid2path_xattr $M0/file1 + +#Check listgetxattr +EXPECT_NOT $gfid2path_xattr get_xattr_key $key $M0/file1 + +#Check removexattr +TEST ! setfattr -h -x $gfid2path_xattr $M0/file1 + +#Check setxattr +TEST ! setfattr -h -n "trusted.gfid2path.d16e15bafe6e4257" -v "$pgfid/file2" $M0/file1 + +#Cleanup +cleanup; diff --git a/tests/volume.rc b/tests/volume.rc index 935382b8531..402bb9dbf19 100644 --- a/tests/volume.rc +++ b/tests/volume.rc @@ -359,6 +359,12 @@ function get_text_xattr { getfattr -h -d -m. -e text $path 2>/dev/null | grep -a $key | cut -f2 -d'=' } +function get_xattr_key { + local key=$1 + local path=$2 + getfattr -h -d -m. -e text $path 2>/dev/null | grep -a $key | cut -f1 -d'=' +} + function gf_check_file_opened_in_brick { vol=$1 host=$2 |