Skip to content

container mode: a file write honours the requested mode - #30

Merged
lex00 merged 1 commit into
mainfrom
issue-29-container-mode-write-mode
Sep 25, 2026
Merged

lex00 merged 1 commit into
mainfrom
issue-29-container-mode-write-mode

Conversation

@lex00

@lex00 lex00 commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • internal/agent/tools.go's FS write case always chmod'd the temp file to 0644 before renaming it into place, so every file written in container mode landed 0644 regardless of the mode the caller asked for, on both the Docker and Kubernetes runtimes (both exec the same in-sprite agent binary). A script needed a separate exec chmod before it could run. The Sprites API and wisp already honour the requested mode.
  • fsWrite now takes an optional --mode <octal> arg, defaulting to 0644 when absent (unchanged from before).
  • internal/server/real.go's realFSWrite threads the fs/write request's ?mode= query param through to it (validating it parses as octal before the exec).
  • Docs (README.md, docs/container-mode.md) and CHANGELOG.md updated.

Test plan

  • go test ./internal/server/... ./internal/agent/... — new TestFSWriteArgs (query → CLI args, including a bad mode) and TestFSWriteMode (write with --mode 0755 lands 0755; no --mode still lands 0644; a malformed --mode is ExitUsage and writes nothing)
  • just e2e-docker (container mode, Docker runtime) — extended TestContainerModeAcceptance with the issue's acceptance case: a file written with mode=0755 is executed directly in the sprite (would fail with permission denied before this fix, since it landed non-executable)
  • golangci-lint run ./..., gofmt -l ., go vet ./...

Closes #29.

FS's write case in internal/agent/tools.go always chmod'd the temp file to
0644 before renaming it into place, ignoring whatever mode the caller sent, so
every file landed 0644 in the sprite regardless of runtime. A script written
with an executable mode needed a separate exec chmod before it could run.

fsWrite now takes an optional --mode <octal> arg (0644 when absent, unchanged
from before); internal/server/real.go threads the fs/write request's ?mode=
query param through to it, applied to both the Docker and Kubernetes
runtimes since both exec the same in-sprite agent binary. The Sprites API and
wisp already honour this mode.

Closes #29.
@lex00
lex00 merged commit e2e6cc4 into main Sep 25, 2026
3 checks passed
lex00 added a commit to INTENTIUS/fountain-ops that referenced this pull request Sep 26, 2026
…ted mode (#125)

Bumps `spritzerImage` to `ghcr.io/intentius/spritzer:0.6.2`, which fixes
INTENTIUS/spritzer#29: a file write in container mode now honours the
`mode` the caller sends instead of always landing 0644. INTENTIUS/spritzer#30.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Container mode: a file write ignores its mode, so every file lands 0644

1 participant