示例#1
0
 def test_subvolume_iterator_unprivileged(self):
     os.chown(self.mountpoint, NOBODY_UID, -1)
     pwd = os.getcwd()
     try:
         os.chdir(self.mountpoint)
         with drop_privs():
             self._test_subvolume_iterator()
     finally:
         os.chdir(pwd)
 def test_subvolume_iterator_race_unprivileged(self):
     os.chown(self.mountpoint, NOBODY_UID, -1)
     pwd = os.getcwd()
     try:
         os.chdir(self.mountpoint)
         self._skip_unless_have_unprivileged_subvolume_iterator('.')
         with drop_privs():
             self._test_subvolume_iterator_race()
     finally:
         os.chdir(pwd)
 def _skip_unless_have_unprivileged_subvolume_iterator(self, path):
     with drop_privs():
         try:
             for _ in btrfsutil.SubvolumeIterator(path):
                 break
         except OSError as e:
             if e.errno == errno.ENOTTY:
                 self.skipTest('BTRFS_IOC_GET_SUBVOL_ROOTREF is not available')
             else:
                 raise
示例#4
0
    def test_subvolume_info_unprivileged(self):
        subvol = os.path.join(self.mountpoint, 'subvol')
        btrfsutil.create_subvolume(subvol)
        snapshot = os.path.join(self.mountpoint, 'snapshot')
        btrfsutil.create_snapshot(subvol, snapshot)

        with drop_privs():
            try:
                self._test_subvolume_info(subvol, snapshot)
            except OSError as e:
                if e.errno == errno.ENOTTY:
                    self.skipTest('BTRFS_IOC_GET_SUBVOL_INFO is not available')
                else:
                    raise
示例#5
0
    def test_subvolume_info_unprivileged(self):
        subvol = os.path.join(self.mountpoint, 'subvol')
        btrfsutil.create_subvolume(subvol)
        snapshot = os.path.join(self.mountpoint, 'snapshot')
        btrfsutil.create_snapshot(subvol, snapshot)

        with drop_privs():
            try:
                btrfsutil.subvolume_info(self.mountpoint)
            except OSError as e:
                if e.errno == errno.ENOTTY:
                    self.skipTest('BTRFS_IOC_GET_SUBVOL_INFO is not available')
                else:
                    raise
            self._test_subvolume_info(subvol, snapshot)
示例#6
0
 def test_subvolume_iterator_unprivileged(self):
     os.chown(self.mountpoint, NOBODY_UID, -1)
     pwd = os.getcwd()
     try:
         os.chdir(self.mountpoint)
         with drop_privs():
             try:
                 list(btrfsutil.SubvolumeIterator('.'))
             except OSError as e:
                 if e.errno == errno.ENOTTY:
                     self.skipTest('BTRFS_IOC_GET_SUBVOL_ROOTREF is not available')
                 else:
                     raise
             self._test_subvolume_iterator()
     finally:
         os.chdir(pwd)