A subfolder (e.g. Family/Finances) can get its own list of users and groups
with Read or Read & write; nobody else gets in. Users can be set to No access
to keep them out of a listed group. The share's own access still applies.
How it works:
- POSIX ACLs on the subfolder and everything inside, with the same entries as
default ACL so new files inherit them. The kernel enforces them, so SMB, NFS
and local access behave the same (ADR-10).
- The subfolder is given to root (group kept), so whoever created it doesn't
keep owner rights to it.
- The share's create mask / directory mask get group rw / rwx when missing
(journaled smb.conf change, shown in the review). Samba's default 0744
becomes the ACL mask of new files and capped every named user at read:
reproduced with Samba 4.22 on CT 151; "inherit acls = yes" did not help.
- ACLs are written in the kernel's xattr format by internal/adapters/aclfs
(bytes checked against what setfacl stores). The walk uses an os.Root,
skips symlinks, and opens each item with openat + O_NOFOLLOW from its
parent: a share user swapping in a symlink can't redirect the root process.
setfacl -R isn't used because it works on paths. os.Root.OpenFile followed a
symlink despite O_NOFOLLOW (found by a test), hence the explicit openat.
- The ACLs on disk are the source of truth and are read back on every load;
hand changes are listed per subfolder. The app settings only list which
subfolders have rules.
- Removing a rule gives the tree what the folder above gives (its default
ACL, else its permission bits).
- Refused: personal folders, guest shares (force user), storage without ACLs
(greyed out with the reason and a "Why?" link to the limitation), rules
inside or above another rule (v1), more than 32 entries.
- The ACL change is recorded in the history (audit, not undoable; the review
says so); the smb.conf part is undoable as usual.
API: GET/PUT/DELETE /api/v1/shares/{name}/subfolders (PUT/DELETE with
?dry_run=1). UI: "Subfolders with their own access" card on the share page.
Tested: unit tests from acl(5)/kernel bytes (domain/acl 98%), service tests on
real ACLs in a temp dir (92%), adapter (85%), API via the harness, 16 mutants
all caught; e2e on CT 151 (desktop + phone); smbclient checks on CT 151 (ZFS
with ACLs; no-ACL dataset refused) and VM 152 (XFS, ext4; virtiofs refused).
Total coverage 76.8% (minimum raised to 76.0).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>