mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
add permission "A" (alias of "rwmda."); closes #70
This commit is contained in:
parent
bed133d3dd
commit
ab40ff5051
|
@ -374,6 +374,7 @@ permissions:
|
|||
* `G` (upget): same as `g` except uploaders get to see their own [filekeys](#filekeys) (see `fk` in examples below)
|
||||
* `h` (html): same as `g` except folders return their index.html, and filekeys are not necessary for index.html
|
||||
* `a` (admin): can see upload time, uploader IPs, config-reload
|
||||
* 'A' ("all"): same as `rwmda.` (read/write/move/delete/dotfiles)
|
||||
|
||||
examples:
|
||||
* add accounts named u1, u2, u3 with passwords p1, p2, p3: `-a u1:p1 -a u2:p2 -a u3:p3`
|
||||
|
|
|
@ -500,6 +500,7 @@ def get_sects():
|
|||
"h" (html): "get", but folders return their index.html
|
||||
"." (dots): user can ask to show dotfiles in listings
|
||||
"a" (admin): can see uploader IPs, config-reload
|
||||
"A" ("all"): same as "rwmda." (read/write/move/delete/admin/dotfiles)
|
||||
|
||||
too many volflags to list here, see --help-flags
|
||||
|
||||
|
|
|
@ -956,7 +956,7 @@ class AuthSrv(object):
|
|||
try:
|
||||
self._l(ln, 5, "volume access config:")
|
||||
sk, sv = ln.split(":")
|
||||
if re.sub("[rwmdgGha.]", "", sk) or not sk:
|
||||
if re.sub("[rwmdgGhaA.]", "", sk) or not sk:
|
||||
err = "invalid accs permissions list; "
|
||||
raise Exception(err)
|
||||
if " " in re.sub(", *", "", sv).strip():
|
||||
|
@ -966,7 +966,7 @@ class AuthSrv(object):
|
|||
self._read_vol_str(sk, sv.replace(" ", ""), daxs[vp], mflags[vp])
|
||||
continue
|
||||
except:
|
||||
err += "accs entries must be 'rwmdgGha.: user1, user2, ...'"
|
||||
err += "accs entries must be 'rwmdgGhaA.: user1, user2, ...'"
|
||||
raise Exception(err + SBADCFG)
|
||||
|
||||
if cat == catf:
|
||||
|
@ -1004,7 +1004,7 @@ class AuthSrv(object):
|
|||
def _read_vol_str(
|
||||
self, lvl: str, uname: str, axs: AXS, flags: dict[str, Any]
|
||||
) -> None:
|
||||
if lvl.strip("crwmdgGha."):
|
||||
if lvl.strip("crwmdgGhaA."):
|
||||
t = "%s,%s" % (lvl, uname) if uname else lvl
|
||||
raise Exception("invalid config value (volume or volflag): %s" % (t,))
|
||||
|
||||
|
@ -1028,7 +1028,19 @@ class AuthSrv(object):
|
|||
if uname == "":
|
||||
uname = "*"
|
||||
|
||||
junkset = set()
|
||||
for un in uname.replace(",", " ").strip().split():
|
||||
for alias, mapping in [
|
||||
("h", "gh"),
|
||||
("G", "gG"),
|
||||
("A", "rwmda.A"),
|
||||
]:
|
||||
expanded = ""
|
||||
for ch in mapping:
|
||||
if ch not in lvl:
|
||||
expanded += ch
|
||||
lvl = lvl.replace(alias, expanded + alias)
|
||||
|
||||
for ch, al in [
|
||||
("r", axs.uread),
|
||||
("w", axs.uwrite),
|
||||
|
@ -1036,12 +1048,11 @@ class AuthSrv(object):
|
|||
("d", axs.udel),
|
||||
(".", axs.udot),
|
||||
("a", axs.uadmin),
|
||||
("h", axs.uhtml),
|
||||
("h", axs.uget),
|
||||
("A", junkset),
|
||||
("g", axs.uget),
|
||||
("G", axs.uget),
|
||||
("G", axs.upget),
|
||||
]: # b bb bbb
|
||||
("h", axs.uhtml),
|
||||
]:
|
||||
if ch in lvl:
|
||||
if un == "*":
|
||||
t = "└─add permission [{0}] for [everyone] -- {2}"
|
||||
|
@ -1113,7 +1124,7 @@ class AuthSrv(object):
|
|||
|
||||
if self.args.v:
|
||||
# list of src:dst:permset:permset:...
|
||||
# permset is <rwmdgGha.>[,username][,username] or <c>,<flag>[=args]
|
||||
# permset is <rwmdgGhaA.>[,username][,username] or <c>,<flag>[=args]
|
||||
for v_str in self.args.v:
|
||||
m = re_vol.match(v_str)
|
||||
if not m:
|
||||
|
@ -2189,7 +2200,7 @@ def upgrade_cfg_fmt(
|
|||
else:
|
||||
sn = sn.replace(",", ", ")
|
||||
ret.append(" " + sn)
|
||||
elif sn[:1] in "rwmdgGha.":
|
||||
elif sn[:1] in "rwmdgGhaA.":
|
||||
if cat != catx:
|
||||
cat = catx
|
||||
ret.append(cat)
|
||||
|
|
|
@ -104,6 +104,7 @@ permdescs = {
|
|||
"G": 'upget; same as "g" but can see filekeys of their own uploads',
|
||||
"h": 'html; same as "g" but folders return their index.html',
|
||||
"a": "admin; can see uploader IPs, config-reload",
|
||||
"A": "all; same as 'rwmda.' (read/write/move/delete/dotfiles)",
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue