From 9a74a955291e6232543e1a08e48066a930cfca5a Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Wed, 3 Apr 2024 09:23:35 +0200 Subject: AtLocation.walk: emit nofllow flag when follow_symlinks=False --- linuxnamespaces/atlocation.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'linuxnamespaces') 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), ) -- cgit v1.2.3