summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Moore <paul@paul-moore.com>2021-08-12 14:22:57 -0400
committerPaul Moore <paul@paul-moore.com>2021-08-23 11:02:04 -0400
commit6e66206a8e687aa86c00e9b470b56d1be79b6c01 (patch)
tree1b08b9fba5e6d18ff53a390806648d61f88a5348
parentaa0f858aa58d51c93a176c60a4c83a4a303bcffd (diff)
downloadlibseccomp-6e66206a8e687aa86c00e9b470b56d1be79b6c01.tar.gz
python: add the get_notify_fd() method to the SyscallFilter class
The new get_notify_fd() method mimics the seccomp_notify_fd() C API with similar behavior. Reviewed-by: Tom Hromatka <tom.hromatka@oracle.com> Signed-off-by: Paul Moore <paul@paul-moore.com> (imported from commit 8b34512de92decfd51fe900d23a82663711ca008)
-rw-r--r--src/python/seccomp.pyx13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/python/seccomp.pyx b/src/python/seccomp.pyx
index 1a9eb24..2eeabc1 100644
--- a/src/python/seccomp.pyx
+++ b/src/python/seccomp.pyx
@@ -1001,6 +1001,19 @@ cdef class SyscallFilter:
if rc < 0:
raise RuntimeError(str.format("Library error (errno = {0})", rc))
+ def get_notify_fd(self):
+ """ Get the seccomp notification file descriptor
+
+ Description:
+ Returns the seccomp listener file descriptor that was generated when
+ the seccomp policy was loaded. This is only valid after load() with a
+ filter that makes use of the NOTIFY action.
+ """
+ fd = libseccomp.seccomp_notify_fd(self._ctx)
+ if fd < 0:
+ raise RuntimeError("Notifications not enabled/active")
+ return fd
+
def export_pfc(self, file):
""" Export the filter in PFC format.