summaryrefslogtreecommitdiff
path: root/linuxnamespaces
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2024-04-03 09:21:27 +0200
committerHelmut Grohne <helmut@subdivi.de>2024-04-03 09:22:49 +0200
commit647d19c436c4cc9a767d96db90059750986cc1f1 (patch)
tree9df214912b79c0d5e5b1191d839d5f93ec4423ba /linuxnamespaces
parent4dfc9730200329aa02dfe7d90358f0a8453afbd2 (diff)
downloadpython-linuxnamespaces-647d19c436c4cc9a767d96db90059750986cc1f1.tar.gz
AtLocation.readlink: require AT_SYMLINK_NOFOLLOW
It does not make sense to read a link after having followed it.
Diffstat (limited to 'linuxnamespaces')
-rw-r--r--linuxnamespaces/atlocation.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/linuxnamespaces/atlocation.py b/linuxnamespaces/atlocation.py
index 79f55bb..66b0947 100644
--- a/linuxnamespaces/atlocation.py
+++ b/linuxnamespaces/atlocation.py
@@ -413,7 +413,9 @@ class AtLocation:
def readlink(self) -> str:
"""Wrapper for os.readlink supplying path and dir_fd."""
- if self.flags & ~AtFlags.AT_EMPTY_PATH != AtFlags.NONE:
+ if self.flags & AtFlags.AT_SYMLINK_NOFOLLOW == AtFlags.NONE:
+ raise NotImplementedError("cannot read a link after following it")
+ if self.flags & ~AtFlags.AT_EMPTY_PATH != AtFlags.AT_SYMLINK_NOFOLLOW:
raise NotImplementedError(
"readlink on AtLocation only support flag AT_EMPTY_PATH"
)