diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index f56d3b4c..517eb4af 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -99,6 +99,8 @@ SBADCFG = " ({})".format(BAD_CFG) PTN_U_GRP = re.compile(r"\$\{u(%[+-][^}]+)\}") PTN_G_GRP = re.compile(r"\$\{g(%[+-][^}]+)\}") +PTN_U_ANY = re.compile(r"(\${[u][}%])") +PTN_G_ANY = re.compile(r"(\${[g][}%])") PTN_SIGIL = re.compile(r"(\${[ug][}%])") @@ -1131,6 +1133,16 @@ class AuthSrv(object): src0 = src # abspath dst0 = dst # vpath + zsl = [] + for ptn, sigil in ((PTN_U_ANY, "${u}"), (PTN_G_ANY, "${g}")): + if bool(ptn.search(src)) != bool(ptn.search(dst)): + zsl.append(sigil) + if zsl: + t = "ERROR: if %s is mentioned in a volume definition, it must be included in both the filesystem-path [%s] and the volume-url [/%s]" + t = "\n".join([t % (x, src, dst) for x in zsl]) + self.log(t, 1) + raise Exception(t) + un_gn = [(un, gn) for un, gns in un_gns.items() for gn in gns] if not un_gn: # ensure volume creation if there's no users diff --git a/tests/res/idp/3.conf b/tests/res/idp/3.conf index 8e1fd8f8..b8d86a11 100644 --- a/tests/res/idp/3.conf +++ b/tests/res/idp/3.conf @@ -6,11 +6,11 @@ idp-h-grp: x-idp-group [/vu/${u}] - / + /u${u} accs: r: ${u} [/vg/${g}] - /b + /g${g} accs: r: @${g} diff --git a/tests/test_idp.py b/tests/test_idp.py index 21d46758..3378d3b1 100644 --- a/tests/test_idp.py +++ b/tests/test_idp.py @@ -121,6 +121,8 @@ class TestVFS(unittest.TestCase): self.assertNodes(au.vfs.nodes["vg"], ["iga"]) self.assertApEq(au.vfs.nodes["vu"].realpath, "") self.assertApEq(au.vfs.nodes["vg"].realpath, "") + self.assertApEq(au.vfs.nodes["vu"].nodes["iua"].realpath, "/uiua") + self.assertApEq(au.vfs.nodes["vg"].nodes["iga"].realpath, "/giga") self.assertAxs(au.vfs.axs, []) self.assertAxsAt(au, "vu/iua", [["iua"]]) # same as: self.assertAxs(self.nav(au, "vu/iua").axs, [["iua"]])