Ibotta / sopstool

SOPS multi-file wrapper
Apache License 2.0
38 stars 4 forks source link

`sopstool entrypoint` fails to delete cleartext files on non-zero exit codes #29

Closed elementalvoid closed 5 years ago

elementalvoid commented 5 years ago

Current Behavior

When using sopstool entrypoint if the command returns a non-zero exit code the unencrypted file is left on disk.

Expected Behavior

When using sopstool entrypoint if the command returns a non-zero exit code the unencrypted file is removed and the command's exit code is still returned.

Steps to reproduce

$ stat foo.sh
stat: cannot stat 'foo.sh': No such file or directory

$ sopstool entrypoint --files=foo.sh bash -- -c 'set -e; ./i-do-no-exist'
bash: ./i-do-no-exist: No such file or directory
Error: exit status 127
Usage:
  sopstool entrypoint [flags]

Aliases:
  entrypoint, e, enter

Flags:
      --allow-fail      Do not fail if not all files can be decrypted
  -e, --exec            Delegate to the command directly with exec(3), no cleanup
  -f, --files strings   files to decrypt (default all)
  -h, --help            help for entrypoint

Global Flags:
      --configpath string   config file path (default ".")

exit status 127

$ stat foo.sh
  File: foo.sh
  Size: 24075           Blocks: 48         IO Block: 4096   regular file

Versions

OS: macOS 10.14.2 Sopstools: 0.3.0