ryantm / agenix

age-encrypted secrets for NixOS and Home manager
https://matrix.to/#/#agenix:nixos.org
Creative Commons Zero v1.0 Universal
1.51k stars 117 forks source link

Improve keys function for keys with extra newlines #249

Closed c4710n closed 4 months ago

c4710n commented 6 months ago

This PR improves keys function to make it more robust.


Sometimes, keys contains "\n" at the tail of themselves. In that case, keys function will return content like:

ssh-ed25519 ...
          # <- here is an extra \n
ssh-ed25519 ...

When other functions use the result of keys function, it may leads errors. Let's say here, it will build bad arguments:

--recipient 'ssh-ed25519...' --recipient '' --recipient 'ssh-ed25519...'
                                         |
                                        bad

which will lead an error:

age: error: unknown recipient type: ""

This PR uses gnused to remove the empty lines in the list of keys, which make it more robust.

martijnboers commented 6 months ago

I have this issue when I'm using builtins.readFile to read my pub files and my editor adds a newline to the .pub files. Minor, but would be great if this was fixed.

zowoq commented 4 months ago

This should have been resolved by https://github.com/ryantm/agenix/pull/256.