Skip to content

macos secrets: use Lwt_io.with_temp_dir for staging#1

Merged
avsm merged 1 commit into
avsm:macos-secretsfrom
mtelvers:pr207
May 18, 2026
Merged

macos secrets: use Lwt_io.with_temp_dir for staging#1
avsm merged 1 commit into
avsm:macos-secretsfrom
mtelvers:pr207

Conversation

@mtelvers
Copy link
Copy Markdown

@mtelvers mtelvers commented May 18, 2026

  • Filename.temp_dir is 5.1+; workers run 4.14. Switched to Lwt_io.with_temp_dir, matching sandbox.runc/jail/hcs/docker_sandbox.
  • Staging dir now cleaned up on failure and cancellation, not just success.
  • Dir perms 0o7550o711 so other local users can't enumerate secret filenames.

Test

((from macos-homebrew-ocaml-5.4)
 (user (uid 1000) (gid 1000))
 (run (secrets (alpha (target /run/secrets/alpha))
                (beta  (target /run/secrets/beta)))
      (shell "set -eu; \
              echo \"OBUILDER_SECRETS_DIR=\$OBUILDER_SECRETS_DIR\"; \
              test \"\$(cat \"\$OBUILDER_SECRETS_DIR/alpha\")\" = 'hello-alpha'; \
              test \"\$(cat \"\$OBUILDER_SECRETS_DIR/beta\")\" = 'hello-beta'; \
              ls -la \"\$OBUILDER_SECRETS_DIR\" 2>&1 | head -5 || true; \
              echo OK"))
)
$ ocluster-client submit-obuilder -c mtelvers.cap --pool=macos-arm64 \
    --local-file=test_secrets.spec \
    --secret=alpha:alpha.txt --secret=beta:beta.txt

Building on m1-worker-04
OBUILDER_SECRETS_DIR=/tmp/obuilder-macos-secrets-d1d761
ls: /tmp/obuilder-macos-secrets-d1d761: Permission denied
total 0
OK
Job succeeded

ocurrent/obuilder#207

Filename.temp_dir is OCaml 5.1+, but workers run 4.14. Switch to
Lwt_io.with_temp_dir, matching the pattern in sandbox.runc/jail/hcs
and docker_sandbox. As a bonus the directory is now removed on
failure and cancellation as well as success, so cleanup_secrets
goes away.

Tighten the staging dir from 0o755 to 0o711 so other local users
can't enumerate secret filenames; the build user only needs traverse.
@avsm avsm merged commit 1641c9b into avsm:macos-secrets May 18, 2026
@mtelvers mtelvers deleted the pr207 branch May 19, 2026 18:35
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.

2 participants