Repository navigation
feat(stack): let hooks run commands in their stacklet's container - #126
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ctx.run_in_container(argv, service=None, user=None): it runs a command instack-<id>(orstack-<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.docker execcommand with the password in it. The code and docs install hooks now use the new call.