log.info(f'write perm was tested was successfully: data '
f'"{data}" was successfully written to file "{path}".')
- def conduct_neg_test_for_write_caps(self):
+ def conduct_neg_test_for_write_caps(self, sudo_write=False):
possible_errmsgs = ('permission denied', 'operation not permitted')
- cmdargs = ['echo', 'some random data', Raw('|'), 'tee']
+ cmdargs = ['echo', 'some random data', Raw('|')]
+ cmdargs += ['sudo', 'tee'] if sudo_write else ['tee']
# don't use data, cmd args to write are set already above.
for mount, path, data in self.test_set:
from io import StringIO
from os.path import join as os_path_join
-from teuthology.orchestra.run import Raw
from teuthology.exceptions import CommandFailedError
from tasks.cephfs.cephfs_test_case import CephFSTestCase
self.captester.run_mds_cap_tests(PERM)
def test_single_path_rootsquash(self):
- filedata, filename = 'some data on fs 1', 'file_on_fs1'
- filepath = os_path_join(self.mount_a.hostfs_mntpt, filename)
- self.mount_a.write_file(filepath, filedata)
+ PERM = 'rw'
+ FS_AUTH_CAPS = (('/', PERM, 'root_squash'),)
+ self.captester = CapTester()
+ self.setup_test_env(FS_AUTH_CAPS)
- keyring = self.fs.authorize(self.client_id, ('/', 'rw', 'root_squash'))
- keyring_path = self.mount_a.client_remote.mktemp(data=keyring)
- self.mount_a.remount(client_id=self.client_id,
- client_keyring_path=keyring_path,
- cephfs_mntpt='/')
-
- if filepath.find(self.mount_a.hostfs_mntpt) != -1:
- # can read, but not write as root
- contents = self.mount_a.read_file(filepath)
- self.assertEqual(filedata, contents)
- cmdargs = ['echo', 'some random data', Raw('|'), 'sudo', 'tee', filepath]
- self.mount_a.negtestcmd(args=cmdargs, retval=1, errmsgs='permission denied')
+ # testing MDS caps...
+ # Since root_squash is set in client caps, client can read but not
+ # write even thought access level is set to "rw".
+ self.captester.conduct_pos_test_for_read_caps()
+ self.captester.conduct_neg_test_for_write_caps(sudo_write=True)
def test_single_path_authorize_on_nonalphanumeric_fsname(self):
"""