vhost_user_fs: Allow specific shared directory to be specified

Because the vhost_user_backend crate needs some changes to support
moving the process to a different mount namespace and perform a pivot
root, it is not possible to change '/' to the given shared directory.

This commit, as a temporary measure, let the code point at the given
shared directory.

The long term solution is to perform the mount namespace change and the
pivot root as this will provide greater security.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2019-11-14 22:29:13 -08:00
committed by Samuel Ortiz
parent ba17758ac0
commit 50b0e58c88
2 changed files with 13 additions and 5 deletions

View File

@@ -199,7 +199,7 @@ fn main() {
.get_matches();
// Retrieve arguments
let _shared_dir = cmd_arguments
let shared_dir = cmd_arguments
.value_of("shared-dir")
.expect("Failed to retrieve shared directory path");
let sock = cmd_arguments
@@ -209,7 +209,11 @@ fn main() {
// Convert into appropriate types
let sock = String::from(sock);
let fs = PassthroughFs::new(passthrough::Config::default()).unwrap();
let fs_cfg = passthrough::Config {
root_dir: shared_dir.to_string(),
..Default::default()
};
let fs = PassthroughFs::new(fs_cfg).unwrap();
let fs_backend = Arc::new(RwLock::new(VhostUserFsBackend::new(fs).unwrap()));
let mut daemon = VhostUserDaemon::new(