From 547fa5bbe5b3438d981de50ac5b2497683a4d9e2 Mon Sep 17 00:00:00 2001 From: yatipadia Date: Tue, 31 Dec 2019 14:47:03 +0530 Subject: mgmt/glusterd: Adding validation for statedump path Description of problem: server.statedump-path is the path where statedumps are stored, by default it is /var/run/gluster. And can be set to any valid directory path. It was observed that server.statedump-path was also accepting file, non-existent file and non-existent paths as well. And statedump command was successful even when statedumps with all the invalid paths. a. A file b. A non-existent path Solution: Added a validation function in gluster-volume-set.c which will allow volume set to success if it's a valid directory and in all other cases, volume set should fail. Fixes: bz#1787122 Change-Id: Ia66e2b3d35f23efc5444c829928779a79d827b42 Signed-off-by: yatipadia Signed-off-by: Sanju Rakonde --- tests/basic/volume.t | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) mode change 100755 => 100644 tests/basic/volume.t (limited to 'tests/basic/volume.t') diff --git a/tests/basic/volume.t b/tests/basic/volume.t old mode 100755 new mode 100644 index 7648ae1d6e1..27fe093d07d --- a/tests/basic/volume.t +++ b/tests/basic/volume.t @@ -11,7 +11,6 @@ TEST $CLI volume info; TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{1,2,3,4,5,6}; - EXPECT "$V0" volinfo_field $V0 'Volume Name'; EXPECT 'Created' volinfo_field $V0 'Status'; EXPECT '6' brick_count $V0 @@ -28,10 +27,34 @@ EXPECT '6' brick_count $V0 TEST $CLI volume top $V0 read-perf bs 4096 count 1000 TEST $CLI volume top $V0 write-perf bs 1048576 count 2 -TEST $CLI volume stop $V0; -EXPECT 'Stopped' volinfo_field $V0 'Status'; +TEST touch $M0/foo + +# statedump path should be a directory, setting it to a file path should fail + +TEST ! $CLI v set $V0 server.statedump-path $M0/foo; +EXPECT '/var/run/gluster' $CLI v get $V0 server.statedump-path + +#set the statedump path to an existing ditectory which should succeed +TEST mkdir $D0/level; +TEST $CLI v set $V0 server.statedump-path $D0/level +EXPECT '/level' volinfo_field $V0 'server.statedump-path' + +ret=$(ls $D0/level | wc -l); +TEST [ $ret == 0 ] +TEST $CLI v statedump $V0; +ret=$(ls $D0/level | wc -l); +TEST ! [ $ret == 0 ] + +#set the statedump path to a non - existing directory which should fail +TEST ! $CLI v set $V0 server.statedump-path /root/test +EXPECT '/level' volinfo_field $V0 'server.statedump-path' + +TEST rm -rf $D0/level + +TEST $CLI volume stop $V0 +EXPECT 'Stopped' volinfo_field $V0 'Status' -TEST $CLI volume delete $V0; -TEST ! $CLI volume info $V0; +TEST $CLI volume delete $V0 +TEST ! $CLI volume info $V0 cleanup; -- cgit