-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Mounted SSH Store #7912
Mounted SSH Store #7912
Conversation
We need to consider the security implications since this allows you to create arbitrary symlinks as the remote user, even if the remote user has a forced SSH command that wouldn't normally allow that kind of access to the remote filesystem. |
@edolstra: Ah, that makes sense. I guess this means we would have to make sure the nix daemon doesn't allow Perhaps a flag on the ssh-ng remote store: Update: The way |
Can we make an |
@Ericson2314: You mean the daemon should check if the user who's requesting We're currently working on a proposal that doesn't need this. In this proposal the daemon will not create symlinks (it will be the client that creates the symlinks). The daemon will only point indirect GC roots to the given symlinks. If all goes well I'll update this PR soon. |
Update: It looks like the solution we're proposing doesn't work. That's because the Next attempt is to let the Update 2: Ah, now I discovered that nix-daemon can be convinced quite easily to process ops rather than just forward streams. 🤔 This might do for us. |
@mupdt A few things
Besides cleanly separating out this use-case, you would also get the performance benefits of the other How do these sound? |
@Ericson2314: I still have to wrap my head around your suggestion, sorry about that. Just a quick question regarding 3. to check if I understand that part correctly: The indirect root would requires a symlink somewhere in client's directories. However, if the client creates the symlink on the local host, then there is a race condition when the remote side creates an indirect root to the symlink (the symlink might not be there yet). This means the symlink has to be created on the same host where the indirect root is created (to avoid the race). Would you say that this must be done by the middle nix daemon? |
@mupdt Interesting point with the race. Looking at Is there any source of The bottom line is a |
@Ericson2314: Re NFS: I believe fsync semantics do not extend beyond the host and won't be useful in this respect, unfortunately (unless we spin-wait; which I think we can avoid if we can make the "symlink on remote" approach). 😢 But yes, Ithe goal is definitely to do something here that is useful for everyone. I'll try to wrap my head around the |
699c33b
to
12b2c73
Compare
@Ericson2314: After a bit more diving and attempts at implementing the In short, I think this implements the |
src/nix/daemon.cc
Outdated
{ | ||
if (stdio) { | ||
if (auto store = openUncachedStore().dynamic_pointer_cast<RemoteStore>()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I extracted this into a function (without changing it), that's why it appears as if a lot has changed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mupdt Maybe lets go PR this separately like you did before?
@Ericson2314 @edolstra: Could I ask you for another look? 🙏 Btw, we ran a suite of integration tests with this patch and are also using it interactively now. It's looking good so far, but we'll keep using it in the long term too from now on. |
@mupdt Sorry you had to give me multiple pings. Looking now. |
@mupdt So the basic idea here is good, but do note that now casts to |
@Ericson2314: Got it, yes. Thankfully the |
@mupdt Sorry agian for some delay. So you are right, that has the right behavior. However, I am not super comfortable making an operation in isolation allowed to fail, merely on the assumption that we always use that operation in an optional/best effort way. Nothing about "add perm root'' says "optional outlink" after all, and arguably one explicitly passing This leads me, surprise surprise, back to the |
@Ericson2314: Ah, I think I misunderstood, sorry about that! I'll go ahead an try to refactor. A quick question before I dive into code: What difference in implementation do you suggest for Btw, what do you think should I add a warning log message that notifies the user that P.s.: No worries at all about the delay, really! Thank you so much for the feedback. 🙏 I do want to make sure this feature is useful for everyone and as great as possible so everyone is comfortable with it. So it's totally okay if it takes a bunch of time. |
@mupdt Yeah I think both root methods ( BTW, you may notice this means
If you like, but I would personally couple that with the more aggressive deduplicating of that code you held off on before, so I am fine if it is again held off and not part of this PR either. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
12b2c73
to
620ac27
Compare
@Ericson2314: I just pushed the implementation of the |
620ac27
to
b480b84
Compare
ab97b95
to
a803817
Compare
@mupdt Thanks! A new test is totally fine --- I had never meant to suggest you literally reuse the same same test, so sorry if you (as it seems perhaps) spent a long while trying to get that to work. It totally makes sense that
is an impossible combination. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other then the CLI flag stuff, looks good to me!
@mupdt Are you able to make the last few small changes for this? |
@Ericson2314: Oh my, I completely dropped the ball on this one. Apologies! Of course, I'll do it asap. |
All good! Looking forward to doing the final review ;) |
a803817
to
a670db8
Compare
@Ericson2314: Suggestions added and rebased on latest master. Please take another look and sorry for the delay. |
It will be implemented in the subsequent commits of this PR.
2b0a42c
to
03c3af1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excited to have this!
Thanks everyone for the hard work getting this over the line! |
Is there a blog post or config on how to experiment with this somewhere? |
Unfortunately, no blog post, but the tests demonstrate a bit how to use it and what to expect. For example, say you have two machines, let's call them client and server. The server is the one where the nix daemon runs, where |
Motivation
To implement the issue #7890, a feature request to implement support for out-links (i.e. the
addPermRoot
feature) in a new remote store calledmounted-ssh-ng://
. This way users will be able to create out-links on remote stores that share the filesystem with the local host (on which the nix client runs).Context
It turns out that the concepts of indirect and permanent GC roots were placed in a slightly inconvenient place in the Store abstractions. This change suggests a slight change in the abstraction for indirect and permanent GC roots that makes them more amenable for implementation in more diverse types of stores (such as remote stores).
This change is backwards compatible (old features will work with older nix daemons). It should be noted that the new
mounted-ssh-ng://
store requires a newer nix daemon, but this is an opt-in feature whose adoption can be managed with a non-disruptive "daemon first, clients later" upgrade path.cc @rickynils @edolstra
Checklist for maintainers
Maintainers: tick if completed or explain if not relevant
tests/**.sh
src/*/tests
tests/nixos/*