Skip to content
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

Do not render templates when decrypting neededForUsers secrets #664

Merged
merged 2 commits into from
Nov 17, 2024

Conversation

jfly
Copy link
Contributor

@jfly jfly commented Nov 17, 2024

This fixes #659

In #649, we started rendering templates twice:

  1. When rendering neededForUsers secrets (if there are any neededForUsers secrets).
  2. When decrypting "regular" secrets.

This alone was weird and wrong, but didn't cause issues for people until #655, which triggered #659. The cause is not super obvious:

  1. When rendering neededForUsers secrets, we'd generate templates in /run/secrets-for-users/rendered.
  2. However, the path for these templates is in /run/secrets/rendered, which is not inside of the /run/secrets-for-users directory we're dealing with, so we'd generate a symlink from /run/secrets/rendered/<foo> to /run/secrets-for-users/rendered/<foo>, which required making the parent directory of the symlink (/run/secrets/rendered/).
  3. This breaks sops-nix's assumption that /run/secrets either doesn't exist, or is a symlink, and you get the symptoms described in I'm running into a super strange issue with /run/secrets not working #659.

Reproducing this in a test was straightforward: just expand our existing template test to also have a neededForUsers secret.

Fixing this was also straightforward: don't render templates during the neededForUsers phase (if we want to add support for neededForUsers templates in the future, that would be straightforward to do, but I opted not do that here).

This fixes Mic92#659

In Mic92#649, we started rendering
templates twice:

1. When rendering `neededForUsers` secrets (if there are any
   `neededForUsers` secrets).
2. When decrypting "regular" secrets.

This alone was weird and wrong, but didn't cause issues
for people until Mic92#655, which
triggered Mic92#659. The cause is not
super obvious:

1. When rendering `neededForUsers` secrets, we'd generate templates in
   `/run/secrets-for-users/rendered`.
2. However, the `path` for these templates is in
   `/run/secrets/rendered`, which is not inside of the
   `/run/secrets-for-users` directory we're dealing with, so we'd
   generate a symlink from `/run/secrets/rendered/<foo>` to
   `/run/secrets-for-users/rendered/<foo>`, which required making
   the parent directory of the symlink (`/run/secrets/rendered/`).
3. This breaks sops-nix's assumption that `/run/secrets` either doesn't
   exist, or is a symlink, and you get the symptoms described in
   <Mic92#659>.

Reproducing this in a test was straightforward: just expand our existing
template test to also have a `neededForUsers` secret.

Fixing this was also straightforward: don't render templates during the
`neededForUsers` phase (if we want to add support for `neededForUsers`
templates in the future, that would be straightforward to do, but I
opted not do that here).
@Mic92
Copy link
Owner

Mic92 commented Nov 17, 2024

@mergify queue

Copy link
Contributor

mergify bot commented Nov 17, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at eee831a

@mergify mergify bot merged commit eee831a into Mic92:master Nov 17, 2024
6 checks passed
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.

I'm running into a super strange issue with /run/secrets not working
2 participants