-
Notifications
You must be signed in to change notification settings - Fork 642
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
Fix symlink resolution when mounting #3673
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3673 +/- ##
==========================================
- Coverage 88.85% 88.82% -0.03%
==========================================
Files 254 254
Lines 14261 14288 +27
==========================================
+ Hits 12672 12692 +20
- Misses 1589 1596 +7 ☔ View full report in Codecov by Sentry. |
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.
Thank you Trevor! Superficial review from my side, but it looks like it's headed in the right direction. I have a couple of comments inline.
src/daemon/daemon.cpp
Outdated
? std::make_unique<SSHFSMountHandler>(vm, config->ssh_key_provider.get(), target, mount) | ||
: vm->make_native_mount_handler(target, mount); | ||
? std::make_unique<SSHFSMountHandler>(vm, config->ssh_key_provider.get(), target, std::move(mount)) | ||
: vm->make_native_mount_handler(target, std::move(mount)); |
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.
This one doesn't help much unless you change make_native_mount_handler
to take by value and move too. Otherwise you're asking for one extra temporary.
@@ -111,6 +113,36 @@ mp::VMMount::VMMount(const QJsonObject& json) : VMMount{parse_json(json)} // del | |||
{ | |||
} | |||
|
|||
void mp::VMMount::resolve_source_path() |
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.
Good call making this a method on the mount. Thinking about it a little further now, I wonder if we should just call this in the constructor and avoid the intermediate state at all. But I haven't looked deep for implications. WDYT?
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 was thinking about the same thing. This seems to be a private function to me.
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 think doing it in the constructor would be good, I'll look into it and any implications it has.
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.
It seems that doing it in the constructor makes it so that the source path is persisted as the place the symlink points to. This changes the behavior a bit so that symlinks are only ever resolved once instead of when the daemon restarts. It's still a fix for the issue but acts a bit different, what do you think?
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.
Hmm. I wouldn't mind just replacing the original path with the target of the symlink, but doing so completely. IOW, making sure that the source path is discarded and has no further effect. I would like to avoid recording something for a while (either persisted or just in memory) and then something else later.
Also, keep in mind that this will need to deal with "legacy" mounts, i.e., mounts that people established before this PR. You may find that they would already be transformed when the daemon restarts, but it is something to check.
fixes #1722
Symbolic links are now resolved when performing a mount.
Previously they were not resolved.