Skip to content

Commit 8d0aa28

Browse files
committed
Improve path readability check
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 simply try to open the device as a test and only if that fails try to determine the cause based on user/groups.
1 parent b5522cc commit 8d0aa28

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎amdsmi_cli/amdsmi_helpers.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,14 @@ def _has_read_access(self, path: str) -> Tuple[bool, Optional[int], Optional[str
12521252
if os.geteuid() == 0:
12531253
return True, None, None
12541254

1255+
# Try to open the file in read mode as the user could have access
1256+
# through ACLs
1257+
try:
1258+
open(path, "rb")
1259+
return True, None, None
1260+
except:
1261+
pass
1262+
12551263
mode = st.st_mode
12561264
uid = st.st_uid
12571265
gid = st.st_gid

0 commit comments

Comments
 (0)