Improve path readability check (#2967)

On modern system e.g. render nodes are made accessible via the udev
uaccess functionality, which adds the logged in user to the ACL of the
device. This means just checking for user and group is bound to give
false positives. Instead use os.access as a first check

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
此提交包含在:
Sjoerd Simons
2026-01-30 18:34:39 +01:00
提交者 GitHub
父節點 327778ef18
當前提交 7e6b7cb50b
+5
查看文件
@@ -1358,6 +1358,11 @@ class AMDSMIHelpers():
if os.geteuid() == 0: if os.geteuid() == 0:
return True, None, None return True, None, None
# Use os.access to check read permission (including ACLs), so that
# permissions granted via mechanisms like udev/uaccess are respected.
if os.access(path, os.R_OK):
return True, None, None
mode = st.st_mode mode = st.st_mode
uid = st.st_uid uid = st.st_uid
gid = st.st_gid gid = st.st_gid