From 9760dfc501d300b06043584328d450c86ac3a720 Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Mon, 4 Oct 2021 06:22:33 -0400 Subject: [PATCH] Added pid_namespace() method to Realm --- libcitadel/src/realm/realm.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libcitadel/src/realm/realm.rs b/libcitadel/src/realm/realm.rs index aa25b27..d41797d 100644 --- a/libcitadel/src/realm/realm.rs +++ b/libcitadel/src/realm/realm.rs @@ -389,6 +389,11 @@ impl Realm { self.leader_pid().map(|pid| PathBuf::from(format!("/proc/{}/root", pid))) } + pub fn pid_namespace(&self) -> Option { + let pid = self.leader_pid()?; + let path = symlink::read(format!("/proc/{}/ns/pid", pid))?; + path.to_str().map(|s| s.to_owned()) + } /// Query for 'leader pid' of realm nspawn instance with machinectl. /// The leader pid is the 'pid 1' of the realm container as seen from