-
Notifications
You must be signed in to change notification settings - Fork 923
Disallow mounting folders on the guest's root for WASIX modules #5475
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -495,7 +495,10 @@ impl Wasi { | |
| Ok(Vec::new()) | ||
| } | ||
|
|
||
| pub fn build_mapped_directories(&self) -> Result<(bool, Vec<MappedDirectory>), anyhow::Error> { | ||
| pub fn build_mapped_directories( | ||
| &self, | ||
| is_wasix: bool, | ||
| ) -> Result<(bool, Vec<MappedDirectory>), anyhow::Error> { | ||
| let mut mapped_dirs = Vec::new(); | ||
|
|
||
| // Process the --dirs flag and merge it with --mapdir. | ||
|
|
@@ -514,8 +517,16 @@ impl Wasi { | |
|
|
||
| MappedDirectory { | ||
| host: current_dir, | ||
| guest: MAPPED_CURRENT_DIR_DEFAULT_PATH.to_string(), | ||
| guest: if is_wasix { | ||
| MAPPED_CURRENT_DIR_DEFAULT_PATH.to_string() | ||
| } else { | ||
| "/".to_string() | ||
| }, | ||
| } | ||
| } else if dir == Path::new("/") && is_wasix { | ||
| bail!( | ||
| "Cannot pre-open the root directory with --dir=/ as mounting on the guest's virtual root is not allowed" | ||
| ); | ||
| } else { | ||
| let resolved = dir.canonicalize().with_context(|| { | ||
| format!( | ||
|
|
@@ -551,11 +562,18 @@ impl Wasi { | |
| } | ||
|
|
||
| for MappedDirectory { host, guest } in &self.mapped_dirs { | ||
| if guest == "/" && is_wasix { | ||
| // Note: it appears we canonicalize the path before this point and showing the value of | ||
| // `host` in the error message may throw users off, so we use a placeholder. | ||
| bail!( | ||
| "Mounting on the guest's virtual root with --mapdir /:<HOST_PATH> is not allowed" | ||
| ); | ||
| } | ||
| let resolved_host = host.canonicalize().with_context(|| { | ||
| format!( | ||
| "could not canonicalize path for argument '--mapdir {}:{}'", | ||
| host.display(), | ||
| guest, | ||
| host.display(), | ||
| ) | ||
| })?; | ||
|
|
||
|
|
@@ -569,7 +587,11 @@ impl Wasi { | |
|
|
||
| MappedDirectory { | ||
| host: resolved_host, | ||
| guest: MAPPED_CURRENT_DIR_DEFAULT_PATH.to_string(), | ||
| guest: if is_wasix { | ||
| MAPPED_CURRENT_DIR_DEFAULT_PATH.to_string() | ||
| } else { | ||
| "/".to_string() | ||
| }, | ||
|
Comment on lines
-572
to
+596
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only thing that really changed. I don't understand why this change is made and if it is an improvement.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Arshia001 If you are 100% certain this is a good idea, then go ahead and merge
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zebreus this is kind of the main issue! With WASI modules, nothing is mounted in the module's FS by default, so it's OK to mount wherever. With WASIX, we mount a lot of stuff in by default, so you don't want a mount on the root. Now, with WASI, since there is no host-side CWD and you're at
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I don't understand is that when If I understand you correctly the reason for the change is to make sure that the mountpoint is always the CWD, which it can't be for WASI. But we also can't always mount to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So in the past, the dir was just mounted to |
||
| } | ||
| } else { | ||
| MappedDirectory { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.