SECCOMP example
authorTomas Mudrunka <tomas@mudrunka.cz>
Mon, 10 Feb 2014 21:52:52 +0000 (22:52 +0100)
committerTomas Mudrunka <tomas@mudrunka.cz>
Mon, 10 Feb 2014 21:52:52 +0000 (22:52 +0100)
c/seccomp.c [new file with mode: 0644]

diff --git a/c/seccomp.c b/c/seccomp.c
new file mode 100644 (file)
index 0000000..0b740f3
--- /dev/null
@@ -0,0 +1,21 @@
+/* seccomp.c
+ *
+ * This demonstrates how to use SECCOMP_MODE_STRICT to sandbox code on Linux.
+ */
+
+#include <string.h>
+#include <sys/prctl.h>
+#include <linux/seccomp.h>
+#include <sys/syscall.h>
+
+#define DISPLAY(msg) (syscall( SYS_write, 2, msg, strlen(msg) ))
+
+int main() {
+       system("echo before");
+
+       if(prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT) == 0)
+               DISPLAY("SECCOMP Enabled!\n"); else DISPLAY("SECCOMP Fail!\n");
+       //fflush(NULL);
+
+       system("echo after");
+}
This page took 0.148445 seconds and 4 git commands to generate.