| author | |
| committer | |
| log | 40e6a664d0b40a2ff5a289d891f0d3a054b4e875 |
| tree | 29bb0e9e0601a4371cdc68d139efb055fd4e2881 |
| parent | c91d7a46860476afe3e52ca3337162ee52396d40 |
| signature | Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU |
Cocoa save routines preserve file permissions, which failed because acl_xattr could not write security.NTACL. Use POSIX permissions and fixed shared modes, with NFS ACE mode updates disabled so Mac clients cannot override the group-write masks.
Use kernel oplocks to invalidate client caches after native service writes, and allow AppleDouble temporary filenames while preserving the resource-fork backend.
Verified nine macOS save/copy/package checks against local rehearsal and a Zenith ZFS preview, shared 0660 files and 2770 directories, native-write cache invalidation, and Blender 5.2 asset save/link/reopen/texture reads. The generated Nomad job validates.
Assisted-by: gpt-6.1-sol3 files changed, 138 insertions(+), 4 deletions(-)
service/samba/service.pkl+15-3| ... | ... | @@ -2,8 +2,6 @@ amends "../../config/Service.pkl" |
| 2 | 2 | |
| 3 | 3 | import "../../config/site.pkl" as site |
| 4 | 4 | |
| 5 | local sharePermissions = "create mask = 0664; force create mode = 0660; directory mask = 0775; force directory mode = 02770; vfs objects = catia fruit streams_xattr acl_xattr; acl_xattr:ignore system acls = yes; inherit permissions = yes" | |
| 6 | ||
| 7 | 5 | meta { name = "Samba" } |
| 8 | 6 | |
| 9 | 7 | container { |
| ... | ... | @@ -35,7 +33,21 @@ container { |
| 35 | 33 | ["WSDD2_DISABLE"] = "1" |
| 36 | 34 | ["SAMBA_CONF_WORKGROUP"] = "PAPER_CLOVER" |
| 37 | 35 | ["SAMBA_CONF_SERVER_STRING"] = "paper clover's nas" |
| 38 | ["SAMBA_VOLUME_CONFIG_clover"] = "[clover]; path = /shares/clover; valid users = clo; read only = \(if (site.cloverReadOnly) "yes" else "no"); \(sharePermissions)" | |
| 36 | // NFS ACE mode changes bypass the masks used for shared editing. | |
| 37 | ["SAMBA_GLOBAL_STANZA"] = "fruit:nfs_aces = no" | |
| 38 | ["SAMBA_VOLUME_CONFIG_clover"] = """ | |
| 39 | [clover] | |
| 40 | path = /shares/clover | |
| 41 | valid users = clo | |
| 42 | read only = \(if (site.cloverReadOnly) "yes" else "no") | |
| 43 | create mask = 0660 | |
| 44 | force create mode = 0660 | |
| 45 | directory mask = 0770 | |
| 46 | force directory mode = 02770 | |
| 47 | vfs objects = catia fruit streams_xattr | |
| 48 | fruit:veto_appledouble = no | |
| 49 | kernel oplocks = yes | |
| 50 | """ | |
| 39 | 51 | } |
| 40 | 52 | } |
| 41 | 53 |
tools/samba-macos-test.swift created+106| ... | ... | @@ -0,0 +1,106 @@ |
| 1 | import AppKit | |
| 2 | import Darwin | |
| 3 | ||
| 4 | final class TestDocument: NSDocument { | |
| 5 | var contents = Data() | |
| 6 | override func data(ofType typeName: String) throws -> Data { contents } | |
| 7 | } | |
| 8 | ||
| 9 | guard CommandLine.arguments.count == 2 else { | |
| 10 | print("Usage: swift tools/samba-macos-test.swift <mounted-share>") | |
| 11 | exit(2) | |
| 12 | } | |
| 13 | ||
| 14 | let fm = FileManager.default | |
| 15 | let directory = URL(fileURLWithPath: CommandLine.arguments[1], isDirectory: true) | |
| 16 | .appendingPathComponent(".studio-smb-test-\(UUID().uuidString)", isDirectory: true) | |
| 17 | var failures = 0 | |
| 18 | ||
| 19 | func check(_ condition: Bool) throws { | |
| 20 | if !condition { throw CocoaError(.fileReadCorruptFile) } | |
| 21 | } | |
| 22 | ||
| 23 | func test(_ name: String, _ operation: () throws -> Void) { | |
| 24 | do { | |
| 25 | try operation() | |
| 26 | print("PASS \(name)") | |
| 27 | } catch { | |
| 28 | failures += 1 | |
| 29 | print("FAIL \(name): \(error as NSError)") | |
| 30 | } | |
| 31 | } | |
| 32 | ||
| 33 | do { | |
| 34 | try fm.createDirectory(at: directory, withIntermediateDirectories: false) | |
| 35 | let file = directory.appendingPathComponent("document.rtf") | |
| 36 | let first = Data("{\\rtf1 first save}".utf8) | |
| 37 | let second = Data("{\\rtf1 updated save}".utf8) | |
| 38 | ||
| 39 | test("atomic save") { | |
| 40 | try first.write(to: file) | |
| 41 | try second.write(to: file, options: .atomic) | |
| 42 | try check(Data(contentsOf: file) == second) | |
| 43 | } | |
| 44 | test("Cocoa replacement preserving permissions") { | |
| 45 | let replacement = directory.appendingPathComponent("replacement.rtf") | |
| 46 | try first.write(to: replacement) | |
| 47 | _ = try fm.replaceItemAt(file, withItemAt: replacement) | |
| 48 | try check(Data(contentsOf: file) == first) | |
| 49 | } | |
| 50 | test("NSDocument Save As, save and autosave") { | |
| 51 | let document = TestDocument() | |
| 52 | let url = directory.appendingPathComponent("café 🍀.rtf") | |
| 53 | document.contents = first | |
| 54 | try document.writeSafely(to: url, ofType: "public.rtf", for: .saveAsOperation) | |
| 55 | document.fileURL = url | |
| 56 | document.fileType = "public.rtf" | |
| 57 | for operation in [NSDocument.SaveOperationType.saveOperation, .autosaveInPlaceOperation] { | |
| 58 | document.contents = second | |
| 59 | try document.writeSafely(to: url, ofType: "public.rtf", for: operation) | |
| 60 | try check(Data(contentsOf: url) == second) | |
| 61 | } | |
| 62 | } | |
| 63 | test("document package") { | |
| 64 | let package = directory.appendingPathComponent("document.rtfd", isDirectory: true) | |
| 65 | let wrapper = FileWrapper(directoryWithFileWrappers: ["TXT.rtf": FileWrapper(regularFileWithContents: first)]) | |
| 66 | try wrapper.write(to: package, options: .atomic, originalContentsURL: nil) | |
| 67 | try wrapper.write(to: package, options: .atomic, originalContentsURL: package) | |
| 68 | try check(Data(contentsOf: package.appendingPathComponent("TXT.rtf")) == first) | |
| 69 | } | |
| 70 | test("metadata and large resource fork copy") { | |
| 71 | let attributes = ["com.apple.studio-smb-test": first, "com.apple.ResourceFork": Data(repeating: 0x5a, count: 128 * 1024)] | |
| 72 | for (name, value) in attributes { | |
| 73 | let result = value.withUnsafeBytes { setxattr(file.path, name, $0.baseAddress, $0.count, 0, 0) } | |
| 74 | guard result == 0 else { throw NSError(domain: NSPOSIXErrorDomain, code: Int(errno)) } | |
| 75 | } | |
| 76 | let copied = directory.appendingPathComponent("copied.rtf") | |
| 77 | try fm.copyItem(at: file, to: copied) | |
| 78 | for (name, value) in attributes { | |
| 79 | var bytes = Data(count: value.count) | |
| 80 | let result = bytes.withUnsafeMutableBytes { getxattr(copied.path, name, $0.baseAddress, $0.count, 0, 0) } | |
| 81 | guard result >= 0 else { throw NSError(domain: NSPOSIXErrorDomain, code: Int(errno)) } | |
| 82 | try check(result == value.count && bytes == value) | |
| 83 | } | |
| 84 | } | |
| 85 | test("Mac archive and temporary filenames") { | |
| 86 | let url = directory.appendingPathComponent("._client-temp") | |
| 87 | try first.write(to: url) | |
| 88 | try check(Data(contentsOf: url) == first) | |
| 89 | } | |
| 90 | test("permission update") { | |
| 91 | guard chmod(file.path, 0o660) == 0 else { throw NSError(domain: NSPOSIXErrorDomain, code: Int(errno)) } | |
| 92 | } | |
| 93 | test("replace while a reader holds the file open") { | |
| 94 | let reader = try FileHandle(forReadingFrom: file) | |
| 95 | defer { try? reader.close() } | |
| 96 | let replacement = directory.appendingPathComponent("open-replacement.rtf") | |
| 97 | try second.write(to: replacement) | |
| 98 | guard rename(replacement.path, file.path) == 0 else { throw NSError(domain: NSPOSIXErrorDomain, code: Int(errno)) } | |
| 99 | try check(Data(contentsOf: file) == second) | |
| 100 | } | |
| 101 | } catch { | |
| 102 | failures += 1 | |
| 103 | print("FAIL fixture: \(error as NSError)") | |
| 104 | } | |
| 105 | test("remove disposable fixture") { try fm.removeItem(at: directory) } | |
| 106 | exit(failures == 0 ? 0 : 1) |
tools/storage-acl-cutover.md+17-1| ... | ... | @@ -10,7 +10,7 @@ The media rename and mountpoint change in [media-cutover.md](media-cutover.md) m |
| 10 | 10 | |
| 11 | 11 | A disposable POSIX-ACL ZFS fixture started with root-owned `0770` directories and a `0660` file that UID 3000 could not read. Granting named group 3000 access and a default ACL on directories, without changing owners, let UID 3000 and Jellyfin UID 3106 read the file. qBittorrent UID 3114 created a file that Copyparty UID 3116 could append to and UID 3000 could edit. The new file kept group 0 from its setgid parent, but inherited the named group 3000 ACL; the fixture was destroyed. This proves local service access on representative modes; SMB has a separate limitation below. |
| 12 | 12 | |
| 13 | A macOS SMB mount reached the VM over Tailscale and wrote a file as `3000:3000` with mode `0644`, despite Samba's `force create mode = 0660`; Copyparty's group identity could not edit it. A temporary Samba configuration with `acl_xattr` and `acl_xattr:ignore system acls = yes` yielded `0666`. Adding a parent default POSIX ACL (`user::rwx,group::rwx,other::---`) yielded files at `0660`, but Mac-created directories at `2777`. Adding `inherit permissions = yes` yielded directories at `2770` and files at `0660`; Copyparty's UID 3116/GID 3000 then appended to a Mac-created file and created a sibling in its directory. `inherit permissions` and the default ACL without `acl_xattr` instead yielded `0755` directories and `0644` files. The tested Samba settings are now in `service/samba/service.pkl`, retaining the image's `catia fruit streams_xattr` Mac VFS modules. A disposable write through the staged Samba share again produced a `0660` file and `2770` directory, both writable by UID 3116/GID 3000; the fixture was removed. VM promotion `b1a2cdde0f6f12a4` passed all 19 HTTP routes and kept four PostgreSQL dumps in its pre-switch backup. The real dataset cutover still needs inherited POSIX ACLs applied through writable directories and verified on clones. [Samba documents the `acl_xattr` behavior](https://www.samba.org/samba/docs/current/man-html/vfs_acl_xattr.8.html). | |
| 13 | A macOS SMB mount reached the VM over Tailscale and wrote a file as `3000:3000` with mode `0644`, despite Samba's `force create mode = 0660`; Copyparty's group identity could not edit it. A temporary Samba configuration with `acl_xattr` and `acl_xattr:ignore system acls = yes` yielded `0666`. Adding a parent default POSIX ACL (`user::rwx,group::rwx,other::---`) yielded files at `0660`, but Mac-created directories at `2777`. Adding `inherit permissions = yes` yielded directories at `2770` and files at `0660`; Copyparty's UID 3116/GID 3000 then appended to a Mac-created file and created a sibling in its directory. `inherit permissions` and the default ACL without `acl_xattr` instead yielded `0755` directories and `0644` files. That rehearsal introduced the ACL-xattr configuration superseded by the 2026-10-13 macOS fix below, while retaining the image's `catia fruit streams_xattr` Mac VFS modules. A disposable write through the staged Samba share again produced a `0660` file and `2770` directory, both writable by UID 3116/GID 3000; the fixture was removed. VM promotion `b1a2cdde0f6f12a4` passed all 19 HTTP routes and kept four PostgreSQL dumps in its pre-switch backup. The real dataset cutover still needs inherited POSIX ACLs applied through writable directories and verified on clones. [Samba documents the `acl_xattr` behavior](https://www.samba.org/samba/docs/current/man-html/vfs_acl_xattr.8.html). | |
| 14 | 14 | |
| 15 | 15 | `acl_xattr:ignore system acls = yes` ignores named POSIX ACL grants for SMB permission checks. A staged Samba version without `acl_xattr` let a Linux SMB client write root-owned files through group ACLs, but a macOS mount then created `0644` files and `0755` directories that Copyparty could not edit. That version was rolled back. With the current Samba settings, a Mac mount created `0660` files and `2770` directories in a group-owned `3000` fixture, and Copyparty could append. The current configuration therefore needs group ownership as well as ACLs on a production clone rehearsal; the local UID test alone does not establish Finder access. |
| 16 | 16 | |
| ... | ... | @@ -31,3 +31,19 @@ Copyparty's previous `df: 16` reserve rejected every upload on the 8 GB VM pool. |
| 31 | 31 | Snow Globe's `zfs clone` of a disposable encrypted Media source stayed AES-256-GCM encrypted under an unencrypted staging parent and shared the Media encryption root; writes to the clone left the source unchanged. [OpenZFS specifies that clones always share their origin's encryption key](https://openzfs.github.io/openzfs-docs/man/master/7/zfsprops.7.html). Fresh stages have no encrypted origin to inherit, so `tools/studio.py stage` now requires an encrypted `pool/staging` mounted at `/srv/staging` when `pool/prod` is encrypted. A disposable pool proved missing and unencrypted staging parents are rejected, while an encrypted parent passes. The VM's existing unencrypted pool still stages normally. |
| 32 | 32 | |
| 33 | 33 | `storage1/apps` is one encrypted dataset with no child datasets: 47.8 GiB live and 65.3 GiB held by 207 snapshots at inspection. It also contains stacks excluded from Snow Globe. Renaming it to `storage1/prod` would preserve that history but leave the service folders as ordinary directories; moving selected data into per-service child datasets would still be necessary. Creating a separate encrypted `prod` root keeps the old tree and its snapshots available during migration. |
| 34 | ||
| 35 | ## macOS saves — 2026-10-13 | |
| 36 | ||
| 37 | Zenith ran Samba 4.23.8 with `acl_xattr` but without `CAP_SYS_ADMIN`. On macOS 15.7.5, ordinary writes succeeded while `NSFileManager.replaceItemAt`, `NSDocument.writeSafely`, package replacement, and `chmod` failed with `EACCES`. The ACL module could not store protected `security.NTACL` attributes; [Samba documents that capability requirement](https://gitlab.com/samba-team/samba/-/merge_requests/3501). Only generated disposable files were opened during these probes. | |
| 38 | ||
| 39 | The [service declaration](../service/samba/service.pkl) now uses POSIX permissions directly. Disabling NFS ACE mode updates keeps Mac clients from bypassing the creation masks. Removing inherited mode handling leaves new regular files at `0660` and directories at `2770`; UID 3116/GID 3000 can edit them. A capability-only alternative fixed Cocoa saving but produced `0644` files that the shared group could not edit. Allowing AppleDouble names also fixes client temporary files and resource-fork copies; [Samba warns that vetoing these names breaks archive tools](https://www.samba.org/samba/docs/current/man-html/vfs_fruit.8.html). | |
| 40 | ||
| 41 | [The macOS regression probe](samba-macos-test.swift) creates and removes its own directory: `swift tools/samba-macos-test.swift <mounted-share>`. Its nine checks cover atomic writes, permission-preserving replacement, Cocoa Save As/save/autosave, RTFD packages, metadata and 128 KiB resource-fork copies, AppleDouble filenames, permission updates, replacement with an open reader, and cleanup. All passed in an isolated local Linux rehearsal and Zenith's ZFS preview `samba-preview-84726d65`. The preview used disposable authentication. Files owned by root and by UID 3116 were also editable through Cocoa in the local rehearsal. Blender 5.2 saved an asset and backup, linked it into a project, reopened the project, and read an external PNG from the share. | |
| 42 | ||
| 43 | Kernel oplocks make native service overwrites and appends invalidate SMB caches. The default SMB leases returned stale data even after reopening a file; the revised configuration returned the updated bytes immediately, including service-owned files. UID 3000 granted a kernel read lease on a disposable Zenith ZFS file without extra capabilities. An external atomic replacement retains the old inode while a Mac reader remains open; closing all old handles makes subsequent readers see the replacement. Disabling oplocks entirely showed the same Mac behavior, so the service retains kernel-backed caching. | |
| 44 | ||
| 45 | The live connection negotiated 1 Gb Ethernet. A disposable 128 MiB synthetic file measured 65.3 MiB/s writes with fsync and 76.6 MiB/s reads with the Mac data cache disabled and the server cache warm. Among 512 random 64 KiB reads, median/p95/maximum latency was 1.23/1.53/178.92 ms. These numbers do not establish real-time sample-library playback. Zenith has four 8 TB WD80EFPX HDDs in one RAIDZ1 vdev with 128 KiB records, a gigabit RTL8168 NIC, and 128 GB RAM; the Mac's unused built-in port supports 10 Gb. [RAIDZ streaming bandwidth scales across data disks, but default-record random-read IOPS are roughly one disk's](https://openzfs.github.io/openzfs-docs/Basic%20Concepts/Pool%20Structure/RAIDZ.html). A cable cannot remove the NAS NIC's speed limit. | |
| 46 | ||
| 47 | REAPER supports VST3, while macOS VST3 files are executable bundles ([REAPER](https://www.reaper.fm/about.php), [Steinberg](https://steinbergmedia.github.io/vst3_dev_portal/pages/Technical%2BDocumentation/Locations%2BFormat/Plugin%2BFormat.html)). Actual vendor plug-ins and sample libraries need their own playback trial. [Kontakt streams samples during playback](https://support.native-instruments.com/support/solutions/articles/69000879768-what-is-dfd-), and [NI advises against active libraries on NAS](https://support.native-instruments.com/support/solutions/articles/69000879313-notes-on-network-drives-and-disk-formats). No existing plug-in or sample-library contents were opened or moved during this work. | |
| 48 | ||
| 49 | Production release `94c1aa0a1f6a4a00` activated on 2026-10-14 at 05:45 UTC from main `f9c3a85e`, with pre-switch backup `20261014T054319Z-54be52`. All 22 HTTP routes and the Samba allocation were healthy. The live Mac mount passed all nine regression checks, shared-group writes became visible immediately, and Blender passed the asset round trip. The old mount disconnected during activation; a background NetFS reconnect restored `/Volumes/clover` using saved credentials. Generated files and the ZFS preview were removed afterward. |