volflags can be -unset

This commit is contained in:
ed 2023-04-23 21:05:29 +00:00
parent a1a8a8c7b5
commit d999f06bb9
3 changed files with 23 additions and 4 deletions

View file

@ -514,8 +514,12 @@ def get_sects():
""" """
volflags are appended to volume definitions, for example, volflags are appended to volume definitions, for example,
to create a write-only volume with the \033[33mnodupe\033[0m and \033[32mnosub\033[0m flags: to create a write-only volume with the \033[33mnodupe\033[0m and \033[32mnosub\033[0m flags:
\033[35m-v /mnt/inc:/inc:w\033[33m:c,nodupe\033[32m:c,nosub""" \033[35m-v /mnt/inc:/inc:w\033[33m:c,nodupe\033[32m:c,nosub\033[0m
)
if global config defines a volflag for all volumes,
you can unset it for a specific volume with -flag
"""
).rstrip()
+ build_flags_desc(), + build_flags_desc(),
], ],
[ [

View file

@ -859,7 +859,7 @@ class AuthSrv(object):
zd = split_cfg_ln(ln) zd = split_cfg_ln(ln)
fstr = "" fstr = ""
for sk, sv in zd.items(): for sk, sv in zd.items():
bad = re.sub(r"[a-z0-9_]", "", sk) bad = re.sub(r"[a-z0-9_-]", "", sk).lstrip("-")
if bad: if bad:
err = "bad characters [{}] in volflag name [{}]; " err = "bad characters [{}] in volflag name [{}]; "
err = err.format(bad, sk) err = err.format(bad, sk)
@ -935,7 +935,14 @@ class AuthSrv(object):
value: Union[str, bool, list[str]], value: Union[str, bool, list[str]],
is_list: bool, is_list: bool,
) -> None: ) -> None:
desc = flagdescs.get(name, "?").replace("\n", " ") desc = flagdescs.get(name.lstrip("-"), "?").replace("\n", " ")
if re.match("^-[^-]+$", name):
t = "└─unset volflag [{}] ({})"
self._e(t.format(name[1:], desc))
flags[name] = True
return
if name not in "mtp xbu xau xiu xbr xar xbd xad xm".split(): if name not in "mtp xbu xau xiu xbr xar xbd xad xm".split():
if value is True: if value is True:
t = "└─add volflag [{}] = {} ({})" t = "└─add volflag [{}] = {} ({})"
@ -1441,6 +1448,12 @@ class AuthSrv(object):
self.log(t, 1) self.log(t, 1)
errors = True errors = True
for vol in vfs.all_vols.values():
for k in list(vol.flags.keys()):
if re.match("^-[^-]+$", k):
vol.flags.pop(k[1:], None)
vol.flags.pop(k)
if errors: if errors:
sys.exit(1) sys.exit(1)

View file

@ -0,0 +1,2 @@
vsftpd a.conf -olisten=YES -olisten_port=3921 -orun_as_launching_user=YES -obackground=NO -olog_ftp_protocol=YES