From 41fdda1d84ea72b3ae2dbadc3152346d418fa73f Mon Sep 17 00:00:00 2001 From: Christophe de Dinechin Date: Thu, 30 Mar 2023 16:09:13 +0200 Subject: [PATCH] rustjail: Do not unwrap potential error with cgroup manager There can be an error while connecting to the cgroups managager, for example a `ENOENT` if a file is not found. Make sure that this is reported through the proper channels instead of causing a `panic()` that does not provide much information. Fixes: #6561 Signed-off-by: Christophe de Dinechin Reported-by: Greg Kurz --- src/agent/rustjail/src/cgroups/systemd/manager.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/agent/rustjail/src/cgroups/systemd/manager.rs b/src/agent/rustjail/src/cgroups/systemd/manager.rs index c52e727e4c..c34aaf9102 100644 --- a/src/agent/rustjail/src/cgroups/systemd/manager.rs +++ b/src/agent/rustjail/src/cgroups/systemd/manager.rs @@ -41,7 +41,7 @@ pub struct Manager { impl CgroupManager for Manager { fn apply(&self, pid: pid_t) -> Result<()> { let unit_name = self.unit_name.as_str(); - if self.dbus_client.unit_exist(unit_name).unwrap() { + if self.dbus_client.unit_exist(unit_name)? { self.dbus_client.add_process(pid, self.unit_name.as_str())?; } else { self.dbus_client.start_unit(