treesum: don't use dir_fd parameter in os.scandir()

This parameter was added in python 3.7, but we're only depending on 3.6
for RHEL.

Pass a path to `/proc/self/fd/...` instead.
This commit is contained in:
Lars Karlitski 2019-11-28 23:34:08 +01:00
parent 2c564afae8
commit 7754fd8e78

View file

@ -19,7 +19,7 @@ def treesum(m, dir_fd):
The file, symlink and directory names and contents are recursively
hashed, together with security-relevant metadata."""
with os.scandir(dir_fd) as it:
with os.scandir(f"/proc/self/fd/{dir_fd}") as it:
for dirent in sorted(it, key=(lambda d: d.name)):
stat_result = dirent.stat(follow_symlinks=False)
metadata = {}