rustjail: make the mount error info much more clear

Make the invalid mount destination's error info much
more clear.

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
This commit is contained in:
fupan.lfp 2020-09-24 17:48:53 +08:00
parent ce9a4eeffd
commit 33513fb49b

View File

@ -176,7 +176,10 @@ pub fn init_rootfs(
for m in &spec.mounts { for m in &spec.mounts {
let (mut flags, data) = parse_mount(&m); let (mut flags, data) = parse_mount(&m);
if !m.destination.starts_with("/") || m.destination.contains("..") { if !m.destination.starts_with("/") || m.destination.contains("..") {
return Err(anyhow!(nix::Error::Sys(Errno::EINVAL))); return Err(anyhow!(
"the mount destination {} is invalid",
m.destination
));
} }
if m.r#type == "cgroup" { if m.r#type == "cgroup" {
mount_cgroups(cfd_log, &m, rootfs, flags, &data, cpath, mounts)?; mount_cgroups(cfd_log, &m, rootfs, flags, &data, cpath, mounts)?;