posix: do not allow to set/get "trusted.glusterfs.volume-id" xattr
Change-Id: I2e9a2264b1fd5ebc1ed0aff30225e89acbd0bcb4 BUG: 1034716 Signed-off-by: Vijaykumar M <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/6361 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
This commit is contained in:
parent
2f218e1335
commit
21f7ad207b
60
tests/bugs/bug-1034716.t
Normal file
60
tests/bugs/bug-1034716.t
Normal file
@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
. $(dirname $0)/../include.rc
|
||||
. $(dirname $0)/../volume.rc
|
||||
|
||||
cleanup;
|
||||
|
||||
#Basic checks
|
||||
TEST glusterd
|
||||
TEST pidof glusterd
|
||||
TEST $CLI volume info
|
||||
|
||||
#Create a distributed volume
|
||||
TEST $CLI volume create $V0 $H0:$B0/${V0}{1..2};
|
||||
TEST $CLI volume start $V0
|
||||
|
||||
# Mount FUSE
|
||||
TEST glusterfs -s $H0 --volfile-id $V0 $M0
|
||||
|
||||
#Create a file and perform fop on a DIR
|
||||
TEST touch $M0/foo
|
||||
|
||||
function xattr_query_check() {
|
||||
local path=$1
|
||||
|
||||
local ret=`getfattr -m . -d $path 2>&1 | grep -c 'trusted.glusterfs'`
|
||||
echo $ret
|
||||
}
|
||||
|
||||
function set_xattr() {
|
||||
local path=$1
|
||||
local xa_name=$2
|
||||
local xa_val=$3
|
||||
|
||||
setfattr -n $xa_name -v $xa_val $path
|
||||
echo $?
|
||||
}
|
||||
|
||||
function remove_xattr() {
|
||||
local path=$1
|
||||
local xa_name=$2
|
||||
|
||||
setfattr -x $xa_name $path
|
||||
echo $?
|
||||
}
|
||||
|
||||
EXPECT 0 xattr_query_check $M0/
|
||||
EXPECT 0 xattr_query_check $M0/foo
|
||||
|
||||
EXPECT 1 set_xattr $M0/ 'trusted.glusterfs.volume-id' 'foo'
|
||||
EXPECT 1 remove_xattr $M0/ 'trusted.glusterfs.volume-id'
|
||||
|
||||
|
||||
## Finish up
|
||||
TEST umount $M0
|
||||
TEST $CLI volume stop $V0
|
||||
TEST $CLI volume delete $V0;
|
||||
TEST ! $CLI volume info $V0;
|
||||
|
||||
cleanup;
|
@ -3048,7 +3048,7 @@ fuse_setxattr (xlator_t *this, fuse_in_header_t *finh, void *msg)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcmp (GFID_XATTR_KEY, name)) {
|
||||
if (!strcmp (GFID_XATTR_KEY, name) || !strcmp (GF_XATTR_VOL_ID_KEY, name)) {
|
||||
send_fuse_err (this, finh, EPERM);
|
||||
GF_FREE (finh);
|
||||
return;
|
||||
@ -3488,7 +3488,7 @@ fuse_removexattr (xlator_t *this, fuse_in_header_t *finh, void *msg)
|
||||
int32_t ret = -1;
|
||||
char *newkey = NULL;
|
||||
|
||||
if (!strcmp (GFID_XATTR_KEY, name)) {
|
||||
if (!strcmp (GFID_XATTR_KEY, name) || !strcmp (GF_XATTR_VOL_ID_KEY, name)) {
|
||||
send_fuse_err (this, finh, EPERM);
|
||||
GF_FREE (finh);
|
||||
return;
|
||||
|
@ -2943,6 +2943,7 @@ posix_setxattr (call_frame_t *frame, xlator_t *this,
|
||||
|
||||
op_ret = -1;
|
||||
dict_del (dict, GFID_XATTR_KEY);
|
||||
dict_del (dict, GF_XATTR_VOL_ID_KEY);
|
||||
|
||||
filler.real_path = real_path;
|
||||
filler.this = this;
|
||||
@ -3667,6 +3668,7 @@ done:
|
||||
|
||||
if (dict) {
|
||||
dict_del (dict, GFID_XATTR_KEY);
|
||||
dict_del (dict, GF_XATTR_VOL_ID_KEY);
|
||||
}
|
||||
|
||||
out:
|
||||
@ -3852,6 +3854,7 @@ done:
|
||||
|
||||
if (dict) {
|
||||
dict_del (dict, GFID_XATTR_KEY);
|
||||
dict_del (dict, GF_XATTR_VOL_ID_KEY);
|
||||
dict_ref (dict);
|
||||
}
|
||||
|
||||
@ -3908,6 +3911,7 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this,
|
||||
_fd = pfd->fd;
|
||||
|
||||
dict_del (dict, GFID_XATTR_KEY);
|
||||
dict_del (dict, GF_XATTR_VOL_ID_KEY);
|
||||
|
||||
filler.fd = _fd;
|
||||
filler.this = this;
|
||||
@ -3967,6 +3971,12 @@ posix_removexattr (call_frame_t *frame, xlator_t *this,
|
||||
op_ret = -1;
|
||||
goto out;
|
||||
}
|
||||
if (!strcmp (GF_XATTR_VOL_ID_KEY, name)) {
|
||||
gf_log (this->name, GF_LOG_WARNING, "Remove xattr called"
|
||||
" on volume-id for file %s", real_path);
|
||||
op_ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
SET_FS_ID (frame->root->uid, frame->root->gid);
|
||||
@ -4023,6 +4033,11 @@ posix_fremovexattr (call_frame_t *frame, xlator_t *this,
|
||||
" on gfid for file");
|
||||
goto out;
|
||||
}
|
||||
if (!strcmp (GF_XATTR_VOL_ID_KEY, name)) {
|
||||
gf_log (this->name, GF_LOG_WARNING, "Remove xattr called"
|
||||
" on volume-id for file");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = posix_fd_ctx_get (fd, this, &pfd);
|
||||
if (ret < 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user