From c133a4561dff94798cdaa51faee7ae6938a409a5 Mon Sep 17 00:00:00 2001 From: "fupan.lfp" Date: Wed, 9 Sep 2020 15:57:26 +0800 Subject: [PATCH] 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 --- src/agent/rustjail/src/cgroups/fs/mod.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/agent/rustjail/src/cgroups/fs/mod.rs b/src/agent/rustjail/src/cgroups/fs/mod.rs index 70657398a8..e93d9df145 100644 --- a/src/agent/rustjail/src/cgroups/fs/mod.rs +++ b/src/agent/rustjail/src/cgroups/fs/mod.rs @@ -1389,10 +1389,6 @@ impl Manager { pub fn new(cpath: &str) -> Result { 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);