From 5b89a2e3b20fb14e09e8ebfb583c1ed4c42ec385 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 2 Jan 2026 01:39:51 +0000 Subject: [PATCH] config-files can extend groups --- copyparty/authsrv.py | 5 ++++- docs/copyparty.d/more-users/david.conf | 8 ++++++++ docs/copyparty.d/more-users/james.conf | 8 ++++++++ docs/copyparty.d/some.conf | 20 +++++++++++++++++++- 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 docs/copyparty.d/more-users/david.conf create mode 100644 docs/copyparty.d/more-users/james.conf diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index 1120a078..70f1847a 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -1467,7 +1467,10 @@ class AuthSrv(object): t = "group [%s] = " % (gn,) t += ", ".join("user [%s]" % (x,) for x in uns) self._l(ln, 5, t) - grps[gn] = uns + if gn in grps: + grps[gn].extend(uns) + else: + grps[gn] = uns except: t = 'lines inside the [groups] section must be "groupname: user1, user2, user..."' raise Exception(t + SBADCFG) diff --git a/docs/copyparty.d/more-users/david.conf b/docs/copyparty.d/more-users/david.conf new file mode 100644 index 00000000..53a6723e --- /dev/null +++ b/docs/copyparty.d/more-users/david.conf @@ -0,0 +1,8 @@ +[accounts] + david: letmein + +[groups] + friends: david + +# the "friends" group was already created in ../some.conf, +# so we are just adding david into it diff --git a/docs/copyparty.d/more-users/james.conf b/docs/copyparty.d/more-users/james.conf new file mode 100644 index 00000000..7d389514 --- /dev/null +++ b/docs/copyparty.d/more-users/james.conf @@ -0,0 +1,8 @@ +[accounts] + james: metooplease + +[groups] + friends: james + +# the "friends" group was already created in ../some.conf, +# so we are just adding james into it diff --git a/docs/copyparty.d/some.conf b/docs/copyparty.d/some.conf index b43e1bfe..c85cdf93 100644 --- a/docs/copyparty.d/some.conf +++ b/docs/copyparty.d/some.conf @@ -6,7 +6,7 @@ # first declare the accounts just once: [accounts] usr1: passw0rd - usr2: letmein + usr2: touhou [global] i: 127.0.0.1 # listen on 127.0.0.1 only, @@ -31,3 +31,21 @@ # # because another.conf sets the read/write permissions before it # includes sibling.conf which adds the move permission + +# ---------------------------------------------------------------------- + +# we can also create a group here; +[groups] + friends: usr1, usr2 + +# and a volume which the group "friends" can read/write; +[/friends] + /srv/pub/friends + accs: + rw: @friends + +# then we include all the config-files in the folder "more-users", +# which can define more users, and maybe even add them to the "friends" group +# (spoiler: the users "usr1", "usr2", "david", and "james" will have access) + +% more-users/