aboutsummaryrefslogtreecommitdiffhomepage
path: root/sandbox/seccomp/libseccomp-helper.h
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-07-01 20:23:33 +0900
committerOphestra <cat@gensokyo.uk>2025-07-01 22:11:32 +0900
commit1a8840bebc673672235b6e10b1b9386f24751757 (patch)
treed1e6772bfd685e2162d047e3640bd3ee55c1a1f7 /sandbox/seccomp/libseccomp-helper.h
parent1fb453dffe4c83866fedfa4590be30ec65e815ff (diff)
sandbox/seccomp: resolve rules natively
This enables loading syscall filter policies from external cross-platform config files. This also removes a significant amount of C code. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'sandbox/seccomp/libseccomp-helper.h')
-rw-r--r--sandbox/seccomp/libseccomp-helper.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/sandbox/seccomp/libseccomp-helper.h b/sandbox/seccomp/libseccomp-helper.h
new file mode 100644
index 00000000..79a13de5
--- /dev/null
+++ b/sandbox/seccomp/libseccomp-helper.h
@@ -0,0 +1,24 @@
+#include <seccomp.h>
+#include <stdint.h>
+
+#if (SCMP_VER_MAJOR < 2) || (SCMP_VER_MAJOR == 2 && SCMP_VER_MINOR < 5) || \
+ (SCMP_VER_MAJOR == 2 && SCMP_VER_MINOR == 5 && SCMP_VER_MICRO < 1)
+#error This package requires libseccomp >= v2.5.1
+#endif
+
+typedef enum {
+ HAKUREI_PREPARE_MULTIARCH = 1 << 0,
+ HAKUREI_PREPARE_CAN = 1 << 1,
+ HAKUREI_PREPARE_BLUETOOTH = 1 << 2,
+} hakurei_prepare_flag;
+
+struct hakurei_syscall_rule {
+ int syscall;
+ int m_errno;
+ struct scmp_arg_cmp *arg;
+};
+
+int32_t hakurei_prepare_filter(int *ret_p, int fd, uint32_t arch,
+ uint32_t multiarch,
+ struct hakurei_syscall_rule *rules,
+ size_t rules_sz, hakurei_prepare_flag flags); \ No newline at end of file