safer vfs defaults

This commit is contained in:
ed 2019-06-06 08:47:01 +02:00
parent 7cb3887996
commit a0ccd2b68f
2 changed files with 9 additions and 5 deletions

View file

@ -238,8 +238,12 @@ class AuthSrv(object):
with open(cfg_fn, "rb") as f:
self._parse_config_file(f, user, mread, mwrite, mount)
if not mount:
# -h says our defaults are CWD at root and read/write for everyone
vfs = VFS(os.path.abspath("."), "", ["*"], ["*"])
elif not "" in mount:
# there's volumes but no root; make root inaccessible
vfs = VFS(os.path.abspath("."), "", [], [])
maxdepth = 0
for dst in sorted(mount.keys(), key=lambda x: (x.count("/"), len(x))):

View file

@ -225,11 +225,11 @@ class TestVFS(unittest.TestCase):
self.assertEqual(au.user["a"], "123")
self.assertEqual(au.user["asd"], "fgh:jkl")
n = au.vfs
# root was not defined, so PWD with everyone r/w
# root was not defined, so PWD with no access to anyone
self.assertEqual(n.vpath, "")
self.assertEqual(n.realpath, td)
self.assertEqual(n.uread, ["*"])
self.assertEqual(n.uwrite, ["*"])
self.assertEqual(n.uread, [])
self.assertEqual(n.uwrite, [])
self.assertEqual(len(n.nodes), 1)
n = n.nodes["dst"]
self.assertEqual(n.vpath, "dst")