glusterfs
99 строк · 2.5 Кб
1#!/bin/bash
2
3. $(dirname $0)/../../include.rc
4. $(dirname $0)/../../nfs.rc
5
6#G_TESTDEF_TEST_STATUS_CENTOS6=NFS_TEST
7
8cleanup;
9
10TEST glusterd
11TEST pidof glusterd
12TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2};
13TEST $CLI volume set $V0 performance.open-behind off;
14TEST $CLI volume set $V0 nfs.disable false
15TEST $CLI volume start $V0
16
17## Mount FUSE with caching disabled
18TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0;
19
20EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available;
21
22
23useradd tmp_user 2>/dev/null 1>/dev/null;
24mkdir $M0/dir;
25mkdir $M0/other;
26cp /etc/passwd $M0/;
27cp $M0/passwd $M0/file;
28chmod 600 $M0/file;
29
30TEST mount_nfs $H0:/$V0 $N0 nolock;
31
32grep nfsnobody /etc/passwd > /dev/null
33if [ $? -eq 1 ]; then
34usr=nobody
35grp=nobody
36else
37usr=nfsnobody
38grp=nfsnobody
39fi
40chown -R $usr:$grp $M0/dir;
41chown -R tmp_user:tmp_user $M0/other;
42
43TEST $CLI volume set $V0 server.root-squash on;
44
45EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available;
46
47# create files and directories in the root of the glusterfs and nfs mount
48# which is owned by root and hence the right behavior is getting EACCESS
49# as the fops are executed as nfsnobody/nobody.
50touch $M0/foo 2>/dev/null;
51TEST [ $? -ne 0 ]
52touch $N0/foo 2>/dev/null;
53TEST [ $? -ne 0 ]
54mkdir $M0/new 2>/dev/null;
55TEST [ $? -ne 0 ]
56mkdir $N0/new 2>/dev/null;
57TEST [ $? -ne 0 ]
58cp $M0/file $M0/tmp_file 2>/dev/null;
59TEST [ $? -ne 0 ]
60cp $N0/file $N0/tmp_file 2>/dev/null;
61TEST [ $? -ne 0 ]
62cat $M0/file 2>/dev/null;
63TEST [ $? -ne 0 ]
64# here read should be allowed because eventhough file "passwd" is owned
65# by root, the permissions if the file allow other users to read it.
66cat $M0/passwd 1>/dev/null;
67TEST [ $? -eq 0 ]
68cat $N0/passwd 1>/dev/null;
69TEST [ $? -eq 0 ]
70
71# create files and directories should succeed as the fops are being executed
72# inside the directory owned by nfsnobody/nobody
73TEST touch $M0/dir/file;
74TEST touch $N0/dir/foo;
75TEST mkdir $M0/dir/new;
76TEST mkdir $N0/dir/other;
77TEST rm -f $M0/dir/file $M0/dir/foo;
78TEST rmdir $N0/dir/*;
79
80# create files and directories here should fail as other directory is owned
81# by tmp_user.
82touch $M0/other/foo 2>/dev/null;
83TEST [ $? -ne 0 ]
84touch $N0/other/foo 2>/dev/null;
85TEST [ $? -ne 0 ]
86mkdir $M0/other/new 2>/dev/null;
87TEST [ $? -ne 0 ]
88mkdir $N0/other/new 2>/dev/null;
89TEST [ $? -ne 0 ]
90
91userdel tmp_user;
92rm -rf /home/tmp_user;
93
94EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" umount_nfs $N0
95
96TEST $CLI volume stop $V0;
97TEST $CLI volume delete $V0;
98
99cleanup;
100