-
Notifications
You must be signed in to change notification settings - Fork 157
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
Access secret from systemd service with DynamicUser=true #198
Comments
As usual, you find a solution right after explaining the problem... The solution might be systemd's As an example, my tiddlywiki config now looks like this:
Of course, this might be simplified and integrated in some way or another... |
A different alternative is to set the |
Oh, that's a lot more elegant, as it does not make assumptions about the location of the systemd credentials directory. Thanks! Should this issue be closed then, or do you see some way in which sops-nix could be improved here? |
Actually, this does not the seem to work for me. With the following configuration:
I get the error:
If I also specify the group for the secret, then I get an error at activation:
|
If you specify a group, than you need to do the same in the systemd service:
|
If you get uid errors during upgrade, is it possible that nscd was restarted when you got this issue? |
Yes, that is what I did. Unfortunately it does not work for me.
I do not think so. The full activation output when I am testing this is
(I am using deploy-rs for this server and skipped the output before and after the activation step) |
@Mic92 I'm also having the same problem, I have set both the user and the group. let goerliUser = "goerli"; in
{
sops.secrets."goerli.jwt" = {
owner = goerliUser;
group = goerliUser;
};
# Note that in nixpkgs, that service has DynamicUser = true
systemd.services.geth-goerli.serviceConfig = {
User = goerliUser;
Group = goerliUser;
};
} and it errors out with
|
There is a known race condition if nscd is stopped in the second systemd wants resolve this user. I think there has been some fixes added in nixpkgs-unstable and the upcoming release to resolve this. You might also want to try Update mhm, since this happens in activation phase, I am actually not so sure if this is the same issue. Do these issues go away on the second deploy? |
If you can I would try to make use of systemd's LoadCredential as it solves these types of problems. |
@Mic92 I confirm the issues go away on the second deploy. I'm working from nixpkgs#master branch, so any fixes that are there, are not fixing the problem yet. I'll try to go with the credentials route |
Fixing the issue is in sops-nix interest however need to happen in nixos, I am afraid. The only workaround I could think of just now is to retry resolving users if they are not found... |
Since a dynamic user doesn't exist in any form before systemd (enables? loads?) a module that declares one, how is sops-nix supposed to check if the user exists? I don't see how this could be fixed in nixos :) |
It would be great to have an example of how
Edit: Oh wait, maybe Harmonia's module is already a great example of this in action— as long as you set the |
@matrss Hi, I would be interested in a working configuration. There is a forum post at Talk-TiddlyWiki, which imo would be the best way to let us know. Thx in advance. |
@pmario I am currently running tiddlywiki with the nixpkgs' provided service and requiring authentication for both readers and writers. You can see most of my configuration regarding that in tiddlywiki.nix. It is still using the |
It enables passing a sops-nix secret as a `settingsFile` @see Mic92/sops-nix#198. By default sops-nix secrets are accessible by only root. We can change owner to another user, but the xray service is defined with `dynamicUser=true`, which means, there is no user in the compile time. Systemd `loadCredential` passes the secret file to the service, which is exactly what we need here.
It enables passing a sops-nix secret as a `settingsFile` @see Mic92/sops-nix#198. By default sops-nix secrets are accessible by only root. We can change owner to another user, but the xray service is defined with `dynamicUser=true`, which means, there is no user in the compile time. Systemd `loadCredential` passes the secret file to the service, which is exactly what we need here.
I use a nixos service which utilizes systemd's DynamicUser feature (tiddlywiki). I am unsure how to make a secret accessible only to this service. The usual approach of setting the owner of the secret to the user the service runs as does not work, as there is no static user created.
For now I have added the keys group as a supplementary group to the service and made the secret accessible to it, but this would mean that every service configured this way would have access to all the secrets available, which I would rather like to avoid.
The text was updated successfully, but these errors were encountered: