Skip to content

Improve decrypt_and_execute #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Flamefire
Copy link

This is our current approach in case you might find it useful.

  • (Better) ensure cleanup of /keys (might be skipped due to set -e)
  • Add usage message
  • Improved error handling (e.g. missing parameters, status/error messages)
  • Use a unique script filename
  • Decrypt "inplace" to avoid need to change directory
  • Exit with "correct" exit code, e.g. a failure when the (decrypted) script didn't succeed.

Noteworthy changes compare to original:

  1. Cleanup is not performed by sudo user, but that should be OK
  2. The working directory is not changed

Especially the latter point might make it easier for users to reason about their scripts behavior as an encrypted script will behave (more) similar to the unencrypted one.
However the naive approach of a cd to the original $PWD inside the "sudo"-part of the script triggered a failure when the PWD is in a user-readable directory with rootsquash enabled where root hence cannot enter.
Hence the approach of decrypting the script inplace (at least it appears so) and switching back to the user context for running it.

- (Better) ensure cleanup of /keys (might be skipped due to `set -e`)
- Add usage message
- Use a unique script filename
- Decrypt "inplace" to avoid need to change directory
- Exit with "correct" exit code
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