require the new admin permission for the admin-panel

This commit is contained in:
ed 2023-07-15 18:39:41 +00:00
parent d19cb32bf3
commit e17bf8f325
4 changed files with 10 additions and 8 deletions

View file

@ -327,7 +327,7 @@ upgrade notes
# accounts and volumes # accounts and volumes
per-folder, per-user permissions - if your setup is getting complex, consider making a [config file](./docs/example.conf) instead of using arguments per-folder, per-user permissions - if your setup is getting complex, consider making a [config file](./docs/example.conf) instead of using arguments
* much easier to manage, and you can modify the config at runtime with `systemctl reload copyparty` or more conveniently using the `[reload cfg]` button in the control-panel (if logged in as admin) * much easier to manage, and you can modify the config at runtime with `systemctl reload copyparty` or more conveniently using the `[reload cfg]` button in the control-panel (if the user has `a`/admin in any volume)
* changes to the `[global]` config section requires a restart to take effect * changes to the `[global]` config section requires a restart to take effect
a quick summary can be seen using `--help-accounts` a quick summary can be seen using `--help-accounts`
@ -346,7 +346,7 @@ permissions:
* `d` (delete): delete files/folders * `d` (delete): delete files/folders
* `g` (get): only download files, cannot see folder contents or zip/tar * `g` (get): only download files, cannot see folder contents or zip/tar
* `G` (upget): same as `g` except uploaders get to see their own filekeys (see `fk` in examples below) * `G` (upget): same as `g` except uploaders get to see their own filekeys (see `fk` in examples below)
* `a` (admin): can see uploader IPs * `a` (admin): can see uploader IPs, config-reload
examples: examples:
* add accounts named u1, u2, u3 with passwords p1, p2, p3: `-a u1:p1 -a u2:p2 -a u3:p3` * add accounts named u1, u2, u3 with passwords p1, p2, p3: `-a u1:p1 -a u2:p2 -a u3:p3`
@ -774,7 +774,7 @@ for the above example to work, add the commandline argument `-e2ts` to also scan
using arguments or config files, or a mix of both: using arguments or config files, or a mix of both:
* config files (`-c some.conf`) can set additional commandline arguments; see [./docs/example.conf](docs/example.conf) and [./docs/example2.conf](docs/example2.conf) * config files (`-c some.conf`) can set additional commandline arguments; see [./docs/example.conf](docs/example.conf) and [./docs/example2.conf](docs/example2.conf)
* `kill -s USR1` (same as `systemctl reload copyparty`) to reload accounts and volumes from config files without restarting * `kill -s USR1` (same as `systemctl reload copyparty`) to reload accounts and volumes from config files without restarting
* or click the `[reload cfg]` button in the control-panel when logged in as admin * or click the `[reload cfg]` button in the control-panel if the user has `a`/admin in any volume
* changes to the `[global]` config section requires a restart to take effect * changes to the `[global]` config section requires a restart to take effect

View file

@ -492,7 +492,7 @@ def get_sects():
"d" (delete): permanently delete files and folders "d" (delete): permanently delete files and folders
"g" (get): download files, but cannot see folder contents "g" (get): download files, but cannot see folder contents
"G" (upget): "get", but can see filekeys of their own uploads "G" (upget): "get", but can see filekeys of their own uploads
"a" (admin): can see uploader IPs "a" (admin): can see uploader IPs, config-reload
too many volflags to list here, see --help-flags too many volflags to list here, see --help-flags

View file

@ -324,6 +324,7 @@ class VFS(object):
self.adel: dict[str, list[str]] = {} self.adel: dict[str, list[str]] = {}
self.aget: dict[str, list[str]] = {} self.aget: dict[str, list[str]] = {}
self.apget: dict[str, list[str]] = {} self.apget: dict[str, list[str]] = {}
self.aadmin: dict[str, list[str]] = {}
if realpath: if realpath:
rp = realpath + ("" if realpath.endswith(os.sep) else os.sep) rp = realpath + ("" if realpath.endswith(os.sep) else os.sep)
@ -1182,7 +1183,7 @@ class AuthSrv(object):
vol.all_vps.sort(key=lambda x: len(x[0]), reverse=True) vol.all_vps.sort(key=lambda x: len(x[0]), reverse=True)
vol.root = vfs vol.root = vfs
for perm in "read write move del get pget".split(): for perm in "read write move del get pget admin".split():
axs_key = "u" + perm axs_key = "u" + perm
unames = ["*"] + list(acct.keys()) unames = ["*"] + list(acct.keys())
umap: dict[str, list[str]] = {x: [] for x in unames} umap: dict[str, list[str]] = {x: [] for x in unames}

View file

@ -149,6 +149,7 @@ class HttpCli(object):
self.dvol = [" "] self.dvol = [" "]
self.gvol = [" "] self.gvol = [" "]
self.upvol = [" "] self.upvol = [" "]
self.avol = [" "]
self.do_log = True self.do_log = True
self.can_read = False self.can_read = False
self.can_write = False self.can_write = False
@ -405,6 +406,7 @@ class HttpCli(object):
self.dvol = self.asrv.vfs.adel[self.uname] self.dvol = self.asrv.vfs.adel[self.uname]
self.gvol = self.asrv.vfs.aget[self.uname] self.gvol = self.asrv.vfs.aget[self.uname]
self.upvol = self.asrv.vfs.apget[self.uname] self.upvol = self.asrv.vfs.apget[self.uname]
self.avol = self.asrv.vfs.aadmin[self.uname]
if self.pw and ( if self.pw and (
self.pw != cookie_pw or self.conn.freshen_pwd + 30 < time.time() self.pw != cookie_pw or self.conn.freshen_pwd + 30 < time.time()
@ -3003,13 +3005,12 @@ class HttpCli(object):
def tx_mounts(self) -> bool: def tx_mounts(self) -> bool:
suf = self.urlq({}, ["h"]) suf = self.urlq({}, ["h"])
avol = [x for x in self.wvol if x in self.rvol]
rvol, wvol, avol = [ rvol, wvol, avol = [
[("/" + x).rstrip("/") + "/" for x in y] [("/" + x).rstrip("/") + "/" for x in y]
for y in [self.rvol, self.wvol, avol] for y in [self.rvol, self.wvol, self.avol]
] ]
if avol and not self.args.no_rescan: if self.avol and not self.args.no_rescan:
x = self.conn.hsrv.broker.ask("up2k.get_state") x = self.conn.hsrv.broker.ask("up2k.get_state")
vs = json.loads(x.get()) vs = json.loads(x.get())
vstate = {("/" + k).rstrip("/") + "/": v for k, v in vs["volstate"].items()} vstate = {("/" + k).rstrip("/") + "/": v for k, v in vs["volstate"].items()}