From faf5d02abe3fc04b016593b922ac52e3ae8bd9f1 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Fri, 16 Oct 2026 02:47:22 -0700 Subject: [PATCH] Retire the legacy Copyparty Public folder Remove the automatic clover/Public mount and its broad account grants in favor of managed shares and folder permissions. Preserve coverage for API wildcard isolation and inherited grants using a fixture mount. Assisted-by: gpt-6.1-sol --- service/copyparty/copyparty.conf | 9 ------ tools/copyparty-test.py | 55 +++++++++++++++++++------------- tools/copyparty.md | 1 + 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/service/copyparty/copyparty.conf b/service/copyparty/copyparty.conf index 5a76744810e3549da97a92eea39b4b2acee94d27..92fae5fa12a0f642b37312304b18e3be31502405 100644 --- a/service/copyparty/copyparty.conf +++ b/service/copyparty/copyparty.conf @@ -44,15 +44,6 @@ flags: chmod_f: 664 chmod_d: 775 -[/clover/Public] - /w/clover/Public - accs: - r.: * - rwm: @acct - rwmd: snow - flags: - chmod_f: 664 - chmod_d: 775 [/logs] /w/logs accs: diff --git a/tools/copyparty-test.py b/tools/copyparty-test.py index 5857eb70fe8a981783e46a3b2c8534bb99303aba..bb4f8600a21c64400057dc520f782833ad83e412 100644 --- a/tools/copyparty-test.py +++ b/tools/copyparty-test.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import copy +from functools import partial import importlib.util import json import os @@ -88,7 +89,7 @@ class Shares(unittest.TestCase): self.assertNotIn('password', state) self.assertNotIn(created['password'], (self.cfg / 'manager.json').read_text()) self.assertNotIn(created['password'], (self.cfg / 'copyparty.conf').read_text()) - self.assertIn('w: @acct,-api-' + identifier, (self.cfg / 'copyparty.conf').read_text()) + self.assertIn('g: *,-api-' + identifier, (self.cfg / 'copyparty.conf').read_text()) self.call('account.delete', id=identifier) self.assertNotIn(key, self.variable['Items']) @@ -123,12 +124,12 @@ class Shares(unittest.TestCase): self.assertNotIn('rw: @snow-user-' + self.subject, config) def test_exact_base_mount_is_rendered_once(self): - (self.root / 'Public').mkdir() - self.call('grant.save', id=None, subject='user:' + self.subject, path=str(self.root / 'Public'), permissions='d') + self.call('grant.save', id=None, subject='user:' + self.subject, path=str(self.root), permissions='d') config = (self.cfg / 'copyparty.conf').read_text() - self.assertEqual(config.count('[/clover/Public]'), 1) - self.assertIn('r.: *', config) - self.assertIn('d: @snow-user-' + self.subject, config) + self.assertEqual(config.count('[/clover]'), 1) + clover = config.split('[/clover]')[1].split('[/media]')[0] + self.assertIn('A: snow', clover) + self.assertIn('d: @snow-user-' + self.subject, clover) def test_untrusted_boundary_and_symlink_escape_reject_before_nomad(self): folder = self.root / 'work' @@ -264,23 +265,31 @@ class Shares(unittest.TestCase): self.assertEqual((self.root / 'Share').stat().st_mode & 0o777, 0o775) self.assertEqual((self.root / 'Share/Clover - Restricted').stat().st_mode & 0o777, 0o775) - def test_api_scope_excludes_wildcards_but_explicit_child_grant_works(self): - account = self.call('account.create', name='Scoped')['account'] - (self.root / 'Public').mkdir() - self.call('grant.save', id=None, subject=account['subject'], path=str(self.root), permissions='r') - config = (self.cfg / 'copyparty.conf').read_text() - public = config.split('[/clover/Public]')[1].split('[/logs]')[0] - self.assertIn('r: *\n', public) - self.assertIn('w: @acct,-' + account['username'], public) - self.assertIn('r: ' + account['username'], public) - logs = config.split('[/logs]')[1] - self.assertIn('g: *,-' + account['username'], logs) - manager = shares.Manager(self.users) - manager.data = json.loads((self.cfg / 'manager.json').read_text()) - manager.items = self.variable['Items'] - manager.owner_permissions(account['username'], self.root / 'Public', 'r') - with self.assertRaises(shares.Error): - manager.owner_permissions(account['username'], self.root / 'Public', 'w') + def test_api_scope_excludes_wildcards_until_ancestor_grant(self): + source = Path(self.temporary.name) / 'base.conf' + source.write_text(Path(shares.__file__).with_name('copyparty.conf').read_text() + + '\n[/clover/scoped]\n /w/clover/scoped\n accs:\n r: *\n w: @acct\n') + (self.root / 'scoped').mkdir() + with patch.object(shares, 'configuration', partial(shares.configuration, source=source)): + account = self.call('account.create', name='Scoped')['account'] + config = (self.cfg / 'copyparty.conf').read_text() + scoped = config.split('[/clover/scoped]')[1] + self.assertIn('r: *,-' + account['username'], scoped) + self.assertIn('w: @acct,-' + account['username'], scoped) + self.call('grant.save', id=None, subject=account['subject'], path=str(self.root), permissions='r') + config = (self.cfg / 'copyparty.conf').read_text() + scoped = config.split('[/clover/scoped]')[1] + self.assertIn('r: *\n', scoped) + self.assertIn('w: @acct,-' + account['username'], scoped) + self.assertIn('r: ' + account['username'], scoped) + logs = config.split('[/logs]')[1].split('[/clover/scoped]')[0] + self.assertIn('g: *,-' + account['username'], logs) + manager = shares.Manager(self.users) + manager.data = json.loads((self.cfg / 'manager.json').read_text()) + manager.items = self.variable['Items'] + manager.owner_permissions(account['username'], self.root / 'scoped', 'r') + with self.assertRaises(shares.Error): + manager.owner_permissions(account['username'], self.root / 'scoped', 'w') def test_admin_can_retarget_other_owner_with_destination_permissions(self): destination = self.root / 'other' diff --git a/tools/copyparty.md b/tools/copyparty.md index 0276b98fdda5273ae6f276a8a00ad322c857681d..bf4fc5b5f48fdf09f50b6e873339a5391dbb6848 100644 --- a/tools/copyparty.md +++ b/tools/copyparty.md @@ -4,6 +4,7 @@ Snowglobe's admin Shares page manages native public links and separate API accounts. A person's page assigns folder permissions. Existing Copyparty permissions remain additive; changing a folder is an explicit retarget or move action. New shared folders default to `Share/Name - Description` under Clover. +The legacy `clover/Public` mount is retired; use managed links and grants. Copyparty owns its native `cfg/copyparty/shares.db` and selected-file records. `cfg/manager.json` stores API account labels, UUID-based folder grants, and link -- 2.54.1