diff options
author | Helmut Grohne <helmut@subdivi.de> | 2024-04-03 09:23:35 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2024-04-03 09:23:35 +0200 |
commit | 9a74a955291e6232543e1a08e48066a930cfca5a (patch) | |
tree | 3b2ab1b6b80c83cfbba18b67086ee99382ecc74a | |
parent | 647d19c436c4cc9a767d96db90059750986cc1f1 (diff) | |
download | python-linuxnamespaces-9a74a955291e6232543e1a08e48066a930cfca5a.tar.gz |
AtLocation.walk: emit nofllow flag when follow_symlinks=False
-rw-r--r-- | linuxnamespaces/atlocation.py | 9 |
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), ) |