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

Fix symlink resolution when mounting #3673

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

Sploder12
Copy link
Contributor

@Sploder12 Sploder12 commented Sep 12, 2024

fixes #1722

Symbolic links are now resolved when performing a mount.
Previously they were not resolved.

Copy link

codecov bot commented Sep 12, 2024

Codecov Report

Attention: Patch coverage is 68.42105% with 6 lines in your changes missing coverage. Please review.

Project coverage is 88.82%. Comparing base (d2d4a82) to head (06347b0).
Report is 115 commits behind head on main.

Files with missing lines Patch % Lines
src/utils/vm_mount.cpp 68.42% 6 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@ricab ricab left a 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.

? 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));
Copy link
Collaborator

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()
Copy link
Collaborator

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Collaborator

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.

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.

Mount does not follow symlinks
3 participants