Skip to content

fix(openbao-env): 🐛 remove every temp file when openbao-env exits - #130

Merged
baxyz merged 1 commit into
mainfrom
fix/openbao-env-tmp-leak
Nov 6, 2026
Merged

baxyz merged 1 commit into
mainfrom
fix/openbao-env-tmp-leak

Conversation

@baxyz

@baxyz baxyz commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Description

openbao-env 1.0.0 left its temp files (curl response bodies, X-Vault-Token header files) in /dev/shm/openbao as .tmp.*. Reported from an end-to-end run on fajro: 8 leftovers after the first devcontainer up. Some may hold tokens. They stay in memory with mode 600, owned by the remote user, but must not stay around.

Cause: tmpfile was called as x="$(tmpfile)". A command substitution runs in a subshell, so the file was added to the subshell's TMP_FILES and the parent's EXIT trap had nothing to remove. Every fetch leaked all of its temp files.

Fix (v1.0.1):

  • All temp files go into one per-run directory, /dev/shm/openbao/.tmp.XXXXXX, created in the parent process (tmpfile now returns the path in REPLY). It is removed on EXIT, and INT/TERM/HUP now exit through that trap.
  • The new token is written to a temp file too, then moved (no token.new left behind).
  • Each run purges .tmp.* entries older than 2 minutes: SIGKILLed runs, and what 1.0.0 left.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

How Has This Been Tested?

dev_server.sh now asserts that no .tmp.* is left after the first load, and after 4 concurrent login shells (one fetches, the others wait for the lock). test.sh and dev_server.sh pass locally in the built base:ubuntu image.

Checklist

  • My commits follow the conventional commit format
  • I have updated the documentation accordingly (version history)
  • I have added tests for my changes

🤖 Generated with Claude Code

tmpfile was called as $(tmpfile): a subshell, so the parent never recorded
the files and the EXIT trap removed none of them. Curl bodies and token
headers stayed in /dev/shm/openbao. Temp files now live in one per-run
directory created in the parent and removed on EXIT, INT, TERM and HUP;
directories older than 2 minutes (SIGKILL, or left by 1.0.0) are purged.
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

✅ PR Validation Passed

All checks passed!


📋 Pipeline Status

Job Status
✅ 🧾 Conventional Commits passing
✅ 🔖 Version Bump passing
✅ 🧪 Feature Tests passing
✅ 🧪 Scenario Tests passing
✅ 🐚 ShellCheck passing

🤖 Generated by @helpers4 CI • 2026-11-06

@baxyz
baxyz merged commit 597075a into main Nov 6, 2026
58 checks passed
@baxyz
baxyz deleted the fix/openbao-env-tmp-leak branch November 6, 2026 23:02
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.

1 participant