warn on invalid idp-volume mapping

This commit is contained in:
ed 2025-09-14 23:20:45 +00:00
parent c03b332ec0
commit 83bd197438
3 changed files with 16 additions and 2 deletions

View file

@ -99,6 +99,8 @@ SBADCFG = " ({})".format(BAD_CFG)
PTN_U_GRP = re.compile(r"\$\{u(%[+-][^}]+)\}") PTN_U_GRP = re.compile(r"\$\{u(%[+-][^}]+)\}")
PTN_G_GRP = re.compile(r"\$\{g(%[+-][^}]+)\}") 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][}%])") PTN_SIGIL = re.compile(r"(\${[ug][}%])")
@ -1131,6 +1133,16 @@ class AuthSrv(object):
src0 = src # abspath src0 = src # abspath
dst0 = dst # vpath 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] un_gn = [(un, gn) for un, gns in un_gns.items() for gn in gns]
if not un_gn: if not un_gn:
# ensure volume creation if there's no users # ensure volume creation if there's no users

View file

@ -6,11 +6,11 @@
idp-h-grp: x-idp-group idp-h-grp: x-idp-group
[/vu/${u}] [/vu/${u}]
/ /u${u}
accs: accs:
r: ${u} r: ${u}
[/vg/${g}] [/vg/${g}]
/b /g${g}
accs: accs:
r: @${g} r: @${g}

View file

@ -121,6 +121,8 @@ class TestVFS(unittest.TestCase):
self.assertNodes(au.vfs.nodes["vg"], ["iga"]) self.assertNodes(au.vfs.nodes["vg"], ["iga"])
self.assertApEq(au.vfs.nodes["vu"].realpath, "") self.assertApEq(au.vfs.nodes["vu"].realpath, "")
self.assertApEq(au.vfs.nodes["vg"].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.assertAxs(au.vfs.axs, [])
self.assertAxsAt(au, "vu/iua", [["iua"]]) # same as: self.assertAxsAt(au, "vu/iua", [["iua"]]) # same as:
self.assertAxs(self.nav(au, "vu/iua").axs, [["iua"]]) self.assertAxs(self.nav(au, "vu/iua").axs, [["iua"]])