From 0188b81d4aec29ede081156a7defc3bfab5a6a55 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Mon, 1 Aug 2022 10:22:16 -0400 Subject: [PATCH] dbus_manager: verify stat path exists Signed-off-by: Eric Callahan --- moonraker/components/dbus_manager.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/moonraker/components/dbus_manager.py b/moonraker/components/dbus_manager.py index b53f770..49f8827 100644 --- a/moonraker/components/dbus_manager.py +++ b/moonraker/components/dbus_manager.py @@ -16,11 +16,13 @@ from typing import ( TYPE_CHECKING, List, Optional, + Any, ) if TYPE_CHECKING: from confighelper import ConfigHelper +STAT_PATH = "/proc/self/stat" DOC_URL = ( "https://moonraker.readthedocs.io/en/latest/" "installation/#policykit-permissions" @@ -34,7 +36,11 @@ class DbusManager: self.bus: Optional[MessageBus] = None self.polkit: Optional[ProxyInterface] = None self.warned: bool = False - proc_data = pathlib.Path(f"/proc/self/stat").read_text() + st_path = pathlib.Path(STAT_PATH) + self.polkit_subject: List[Any] = [] + if not st_path.is_file(): + return + proc_data = st_path.read_text() start_clk_ticks = int(proc_data.split()[21]) self.polkit_subject = [ "unix-process",