Files
Martin Vogel 4623477381 feat(windows): detect and repair cache children left unusable by the old DACL regime
Between v0.9.1-rc and v0.10.2 the runtime directory carried a PROTECTED DACL
whose ACE was not inheritable, so Windows gave every file created inside it
either an empty DACL or the token default (SYSTEM + TokenOwner + logon SID).
Under an elevated token TokenOwner is BUILTIN\Administrators, so the interactive
user is left with no durable grant and the file becomes unreadable after the
next logon. #1601: takeown and icacls both fail non-elevated, and the daemon can
no longer open _config.db.

now, so new children are fine. Nothing repaired the children already damaged,
which is why upgrading rescued nobody whose cache was written under the old
regime. Their only route back was a rename-the-parent dance the reporter worked
out themselves.

The repair runs after the directory is confirmed good, and is deliberately
narrow: immediate children only, no recursion, capped at 4096, regular files
only - directories, reparse points and symlinks are skipped rather than
followed. A child is touched ONLY when demonstrably damaged: an empty DACL, or
an owner that is not the current user. Failures are counted and reported, never
fatal, because this runs inside daemon startup.

Empty-DACL detection needs its own test and cannot reuse the validator:
win_file_acl_secure scans ACEs for untrusted mutation grants, and a DACL with
zero ACEs trivially has none - so the damage reads as compliance.

It only ever touches cbm's own runtime/cache directory, which we created and
own; it does not reach into user directories.

Windows-only code. A clean macOS build says nothing about it - the previous
commit on this branch shipped a five-argument call to a four-argument function
and built green here - so the Windows CI leg is the first venue that can
actually reject this.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-08-14 16:25:11 +02:00
..