Skip to content

feat(stack): let hooks run commands in their stacklet's container - #126

Merged
arthware-dev merged 3 commits into
mainfrom
feat/hook-exec
Sep 23, 2026
Merged

arthware-dev merged 3 commits into
mainfrom
feat/hook-exec

Conversation

@arthware-dev

Copy link
Copy Markdown
Contributor

Summary

  • Hooks get ctx.run_in_container(argv, service=None, user=None): it runs a command in stack-<id> (or stack-<id>-<service>) as an argument list with no shell, and reports a failure with the exit code and the last stderr line, never the arguments.
  • Fixes a password leak: when Forgejo refused an admin account on install, the warning printed the docker exec command with the password in it. The code and docs install hooks now use the new call.
  • Fixes Paperless admin creation for passwords containing a quote. Three commits that each stand alone: merge with rebase, not squash.

Hooks that reach into a container built a `docker exec` string for
`ctx.shell`, or called `subprocess` themselves. The string breaks on
quoting, and a failed `ctx.shell` prints the whole command, including
any password or client secret in it.

`ctx.run_in_container(argv, service=None, user=None)` runs `argv` in
`stack-<id>`, or `stack-<id>-<service>`, as an argument list with no
shell. It returns stdout. On failure it raises with the container, the
exit code and the last stderr line, never the arguments.
When Forgejo refused to create the tech admin or an admin from
`users.toml` for any reason other than "already exists", the warning
printed the failed `docker exec` command, and with it the account's
password.

The accounts are now created with `ctx.run_in_container`, which reports
the reason without the arguments.
Admin accounts are created by a Python script run inside the Paperless
container, with the username, email and password written into it as
'...' strings. A password containing a quote ended the string early,
so the account was not created, or the rest ran as code.

The values are now written as Python literals, and the script runs
through `ctx.run_in_container`, so a failure no longer prints the
password either.
@arthware-dev
arthware-dev merged commit 2a98809 into main Sep 23, 2026
1 check passed
@arthware-dev
arthware-dev deleted the feat/hook-exec branch September 23, 2026 20:20
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