Record the real uid and gid of backed-up files #241

Merged
clawbot merged 1 commits from issue-216-record-file-ownership into next 2026-10-06 09:46:18 +02:00
Collaborator

Fixes #216.

The scanner read ownership by asserting info.Sys() to an interface with Uid() and Gid() methods. On Linux and macOS the value is a *syscall.Stat_t, whose Uid and Gid are fields, so the assertion never matched and every file, directory and symlink was stored as 0:0. A restore as root then chowned everything to root. The three places in internal/snapshot/scanner.go that read ownership now assert to *syscall.Stat_t and read its fields. The README already says uid and gid are recorded and restored; with this change that is true.

TestScannerRecordsOwnership backs up a real file, directory and symlink in a temp directory and compares the recorded uid and gid with os.Getuid() and os.Getgid().

What the diff does not show:

  • The first backup after this change re-chunks every file not owned by root once, because its stored 0:0 no longer matches the disk.
  • When the tests run as root, as in the Docker build, the new test compares 0 with 0 and cannot catch this defect. Without the fix it fails on a non-root make test.
  • The scanner now names syscall.Stat_t, which Windows lacks. The release targets are Linux and macOS, and internal/snapshot/progress.go already uses syscall.SIGUSR1.

Partially verified: the darwin build compiles (make release-snapshot); the test has not run on macOS.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/vaultik/issues/216. The scanner read ownership by asserting `info.Sys()` to an interface with `Uid()` and `Gid()` methods. On Linux and macOS the value is a `*syscall.Stat_t`, whose `Uid` and `Gid` are fields, so the assertion never matched and every file, directory and symlink was stored as `0:0`. A restore as root then chowned everything to root. The three places in `internal/snapshot/scanner.go` that read ownership now assert to `*syscall.Stat_t` and read its fields. The README already says uid and gid are recorded and restored; with this change that is true. `TestScannerRecordsOwnership` backs up a real file, directory and symlink in a temp directory and compares the recorded uid and gid with `os.Getuid()` and `os.Getgid()`. What the diff does not show: - The first backup after this change re-chunks every file not owned by root once, because its stored `0:0` no longer matches the disk. - When the tests run as root, as in the Docker build, the new test compares 0 with 0 and cannot catch this defect. Without the fix it fails on a non-root `make test`. - The scanner now names `syscall.Stat_t`, which Windows lacks. The release targets are Linux and macOS, and `internal/snapshot/progress.go` already uses `syscall.SIGUSR1`. Partially verified: the darwin build compiles (`make release-snapshot`); the test has not run on macOS. Model: opus-5-5
clawbot added the needs-review label 2026-10-06 09:13:38 +02:00
clawbot self-assigned this 2026-10-06 09:13:38 +02:00
clawbot added 1 commit 2026-10-06 09:13:39 +02:00
Record the real uid and gid of backed-up files (closes #216)
check / check (pull_request) Successful in 5m51s
a77116675d
The scanner read uid and gid by asserting the stat result to an
interface with Uid() and Gid() methods. *syscall.Stat_t has Uid and Gid
fields, not methods, so the assertion never matched and every file,
directory and symlink was stored as 0:0; a restore as root then gave
everything to root. The scanner now reads the fields of
*syscall.Stat_t.

The first backup after this change re-reads every file not owned by
root, because its stored uid and gid no longer match the disk.

When the tests run as root, as in the Docker build, the new test
compares 0 with 0 and cannot catch the defect; a non-root run does.

Model: opus-5-5
Author
Collaborator

Review passed.
Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit 4a167e153a into next 2026-10-06 09:46:18 +02:00
clawbot deleted branch issue-216-record-file-ownership 2026-10-06 09:46:19 +02:00
Sign in to join this conversation.