getsops / sops

Simple and flexible tool for managing secrets
https://getsops.io/
Mozilla Public License 2.0
16.99k stars 878 forks source link

sops does not respect explicit XDG_CONFIG_HOME #1263

Closed flowchartsman closed 1 year ago

flowchartsman commented 1 year ago

I am on MacOS, and I have explicitly set XDG_CONFIG_HOME in my environment because /Users/me/Library/Application Support is an awkward location to store config files and $HOME/.config is much better. By setting this explicitly, applications should respect it.

However:

$ sops  <encrypted file>
Failed to get the data key required to decrypt the SOPS file.

Group 0: FAILED
  age<pukey>: FAILED
    - | failed to open file: open /Users/me/Library/Application
      | Support/sops/age/keys.txt: no such file or directory

Recovery failed because the file was encrypted with a Shamir threshold of
1, but only 0 part(s) were successfully recovered, one for each successful
key group. In order for SOPS to recover the file, at least 1 groups have to
be successful. In order for a group to be successful, decryption has to
succeed with any of the keys in that key group.

$ echo $XDG_CONFIG_HOME
/Users/me/.config

Sadly, the ship has sailed for os.UserConfigDir(), which is what sops uses, but that doesn't mean there can't be a fallback, so it would be nice if sops could support it.

felixfontein commented 1 year ago

Note that as a workaround (for now) you can use SOPS_AGE_KEY_FILE to point sops to the right path.

flowchartsman commented 1 year ago

You are right, I absolutely should have mentioned that. That's what I'm doing now.

felixfontein commented 1 year ago

1291 fixes this.