rustjail: fix the issue of invalid cgroup_parent path

The cgroup_parent path is expected to be absolute path,
add an '/' prefix to the passed cgroup_parent path to make
sure it's an absolute path.

Fixes: #336

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
This commit is contained in:
fupan.lfp 2020-09-09 15:57:26 +08:00
parent 7f20587433
commit c133a4561d

View File

@ -1389,10 +1389,6 @@ impl Manager {
pub fn new(cpath: &str) -> Result<Self> {
let mut m = HashMap::new();
if !cpath.starts_with('/') {
return Err(nix::Error::Sys(Errno::EINVAL).into());
}
let paths = get_paths()?;
let mounts = get_mounts()?;
@ -1404,9 +1400,9 @@ impl Manager {
}
let p = if value == "/" {
format!("{}{}", mnt.unwrap(), cpath)
format!("{}/{}", mnt.unwrap(), cpath)
} else {
format!("{}{}{}", mnt.unwrap(), value, cpath)
format!("{}{}/{}", mnt.unwrap(), value, cpath)
};
m.insert(key.to_string(), p);