summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2024-04-03 09:23:35 +0200
committerHelmut Grohne <helmut@subdivi.de>2024-04-03 09:23:35 +0200
commit9a74a955291e6232543e1a08e48066a930cfca5a (patch)
tree3b2ab1b6b80c83cfbba18b67086ee99382ecc74a
parent647d19c436c4cc9a767d96db90059750986cc1f1 (diff)
downloadpython-linuxnamespaces-9a74a955291e6232543e1a08e48066a930cfca5a.tar.gz
AtLocation.walk: emit nofllow flag when follow_symlinks=False
-rw-r--r--linuxnamespaces/atlocation.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/linuxnamespaces/atlocation.py b/linuxnamespaces/atlocation.py
index 66b0947..24c2cce 100644
--- a/linuxnamespaces/atlocation.py
+++ b/linuxnamespaces/atlocation.py
@@ -509,6 +509,9 @@ class AtLocation:
raise NotImplementedError(
"walk is not supported for an AtLocation with flags"
)
+ flags = AtFlags.AT_SYMLINK_NOFOLLOW
+ if follow_symlinks:
+ flags = AtFlags.NONE
for dirpath, dirnames, filenames, dirfd in os.fwalk(
self.location,
topdown=topdown,
@@ -517,9 +520,9 @@ class AtLocation:
dir_fd=self.fd_or_none,
):
yield (
- AtLocation(self.fd, dirpath),
- [AtLocation(dirfd, dirname) for dirname in dirnames],
- [AtLocation(dirfd, filename) for filename in filenames],
+ AtLocation(self.fd, dirpath, flags),
+ [AtLocation(dirfd, dirname, flags) for dirname in dirnames],
+ [AtLocation(dirfd, filename, flags) for filename in filenames],
AtLocation(dirfd),
)