mirror of
https://github.com/kata-containers/cgroups-rs.git
synced 2026-08-05 02:13:23 +00:00
systemd: Do not check systemd version
The systemd version is purely informational and should not be parsed, as documented in the [1]. In practice, systemd version has different formats on OpenShift and Ubuntu. This commit skips the version check and allows all operations. The errors will be thrown from dbus when performing unsupported operations on obsolete versions of systemd. 1: https://www.freedesktop.org/software/systemd/man/latest/org.freedesktop.systemd1.html Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
This commit is contained in:
15
src/lib.rs
15
src/lib.rs
@@ -72,22 +72,11 @@ pub mod tests {
|
||||
child
|
||||
}
|
||||
|
||||
pub fn systemd_version() -> Option<usize> {
|
||||
pub fn systemd_version() -> Option<String> {
|
||||
let output = Command::new("systemd").arg("--version").output().ok()?; // Return None if command execution fails
|
||||
|
||||
if !output.status.success() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
|
||||
// The first line is typically like "systemd 254 (254.5-1-arch)"
|
||||
let first_line = stdout.lines().next()?;
|
||||
let mut words = first_line.split_whitespace();
|
||||
|
||||
words.next()?; // Skip the "systemd" word
|
||||
let version_str = words.next()?; // The version number as string
|
||||
|
||||
version_str.parse::<usize>().ok()
|
||||
Some(String::from_utf8_lossy(&output.stdout).to_string())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user