Conversation
b03b43b to
8421857
Compare
|
This PR will also improve #7461 |
8421857 to
d1481b0
Compare
|
I somehow accidentally removed the review request for @edolstra @fricklerhandwerk and @thufschmitt just by requesting a re-review from @max-privatevoid, this seems to be a bug in the way reviews are handled on GitHub. I am unable to add new reviewers, or add these reviewers back. |
d1481b0 to
2a0406e
Compare
|
I marked the PR as a draft, then unmarked it as a draft. It seems that the GitHub review bug is still in effect. |
c93ae9c to
2a0406e
Compare
2a0406e to
01c67e4
Compare
|
Just pushed to resolve conflicts with the release notes. |
e1a65b2 to
0d28385
Compare
thufschmitt
left a comment
There was a problem hiding this comment.
Thanks, that's a useful command to have I think.
Left some suggestions on the code and docs, but that looks good overall.
(That also makes me realize with horror that we don't have any test for the "non-trusted-user" case 😬 )
src/libstore/store-api.hh
Outdated
| }; | ||
|
|
||
| /* Check if the user making the connection is a trusted-user. */ | ||
| virtual bool isTrustedUser() = 0; |
There was a problem hiding this comment.
I think it's fine to define this to unsupported by default like we do for a bunch of other methods and remove all the custom implementations for the stores that don't support it:
| virtual bool isTrustedUser() = 0; | |
| virtual bool isTrustedUser() | |
| { unsupported("isTrustedUser"); } |
There was a problem hiding this comment.
That definitely makes it a smaller diff too.
There was a problem hiding this comment.
Done. I've left the implementation for legacy ssh though, since it's more helpful to print it.
There was a problem hiding this comment.
@thufschmitt This pattern is counterproductive for discovering such functionality as recursive nix store is not trusted early. Perhaps not a great example, but who knows what else we might have missed because of the bad default?
There was a problem hiding this comment.
@roberth since the default behaviour is to fail loudly, I think it's OK because it's a conservative approach, and we can always refine the implementation after the fact if we realize that we've been missing one
|
I've rebased this PR on 2.14 after the Nix 2.13 release yesterday. |
|
From Nix meeting:
|
|
@MatthewCroughan Do note with #7723 merged the |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-01-20-nix-team-meeting-minutes-25/25432/1 |
|
Have dropped the ball on this temporarily, I'm a bit ill after FOSDEM, will pick this up when I am better, anyone else feel free to contribute by making a PR to this PR! |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-01-23-nix-team-meeting-minutes-26/25433/1 |
a13a7c3 to
7968371
Compare
|
Discussed in the Nix team meeting 2023-04-03:
|
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-04-03-nix-team-meeting-minutes-46/27008/1 |
|
Would be great to have this in for 2.15. |
thufschmitt
left a comment
There was a problem hiding this comment.
The change is good overall, but the wire encoding/decoding logic is a bit too smart imho. Let's keep things simple as much as we can.
This function returns true or false depending on whether the Nix client is trusted or not. Mostly relevant when speaking to a remote store with a daemon. We include this information in `nix ping store` and `nix doctor` Co-Authored-By: John Ericson <John.Ericson@Obsidian.Systems>
7968371 to
9207f94
Compare
|
Good point, I did sort of forget about that mechanism! 😳 |
thufschmitt
left a comment
There was a problem hiding this comment.
Yay!
Just a small suggestion, but fairly minor and not blocking. So let's merge
| case 2: | ||
| return { NotTrusted }; | ||
| default: | ||
| throw Error("Invalid trusted status from remote"); |
There was a problem hiding this comment.
Saving it for a potential follow-up (and fairly low-prio), but it could be nicer to just warn and return std::nullopt in that case. Just to make potential future evolutions of the protocol nicer.
There was a problem hiding this comment.
I had thought about that, but I think it's just better to bunl the protocol version on that case? Maybe I'm forgetting, but I couldn't think of another time we tried to do this sort of week forward compat before.
There was a problem hiding this comment.
We currently have more or less one forward compat mechanism, which is the protocol version handshake.
If we're going to improve the forward compat mechanism, it would make more sense to do it structurally, with a self-describing or schema based serialization where we can add fields as we please.
This PR extends the worker protocol in
worker-protocol-hhby adding a new operation (47) which permits a client to check if they are trusted. I have needed this for some scripts I'm trying to write which use Nix, that need to check.In addition, it also adds a new command
nix store check-trustedwhich will make use of this addition. It will return exit code 0 if trusted, 1 if not trusted or 2 if an unexpected error occurs.I have also added a new
checkInfofunction todoctor.ccwhich will print an inconsequential blue[INFO]telling the user whether they are trusted. This does not change the exit status of thenix doctorcommand.The following Bash function is an example of a fallback mechanism I've implemented in Bash but do not have the skills to implement in C++.
Thanks a lot to @roberth who introduced me to the C++ codebase and answering a lot of questions. And thanks to @tomberek + @pkharvey + @helicalbytes for helping me understand the daemon protocol.