aboutsummaryrefslogtreecommitdiffstats
path: root/test/filters/syscall_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/filters/syscall_test.c')
-rw-r--r--test/filters/syscall_test.c82
1 files changed, 0 insertions, 82 deletions
diff --git a/test/filters/syscall_test.c b/test/filters/syscall_test.c
deleted file mode 100644
index 55ee31afb..000000000
--- a/test/filters/syscall_test.c
+++ /dev/null
@@ -1,82 +0,0 @@
1// This file is part of Firejail project
2// Copyright (C) 2014-2021 Firejail Authors
3// License GPL v2
4
5#include <stdlib.h>
6#include <stdio.h>
7#include <unistd.h>
8#include <sys/types.h>
9#include <sys/socket.h>
10#include <linux/netlink.h>
11#include <net/ethernet.h>
12#include <sys/mount.h>
13
14int main(int argc, char **argv) {
15 if (argc != 2) {
16 printf("Usage: test [sleep|socket|mkdir|mount]\n");
17 return 1;
18 }
19
20 if (strcmp(argv[1], "sleep") == 0) {
21 printf("before sleep\n");
22 sleep(1);
23 printf("after sleep\n");
24 }
25 else if (strcmp(argv[1], "socket") == 0) {
26 int sock;
27
28 printf("testing socket AF_INET\n");
29 if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
30 perror("socket");
31 }
32 else
33 close(sock);
34
35 printf("testing socket AF_INET6\n");
36 if ((sock = socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
37 perror("socket");
38 }
39 else
40 close(sock);
41
42 printf("testing socket AF_NETLINK\n");
43 if ((sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE)) < 0) {
44 perror("socket");
45 }
46 else
47 close(sock);
48
49 printf("testing socket AF_UNIX\n");
50 if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
51 perror("socket");
52 }
53 else
54 close(sock);
55
56 // root needed to be able to handle this
57 printf("testing socket AF_PACKETX\n");
58 if ((sock = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_ARP))) < 0) {
59 perror("socket");
60 }
61 else
62 close(sock);
63 printf("after socket\n");
64 }
65 else if (strcmp(argv[1], "mkdir") == 0) {
66 printf("before mkdir\n");
67 mkdir("tmp", 0777);
68 printf("after mkdir\n");
69 }
70 else if (strcmp(argv[1], "mount") == 0) {
71 printf("before mount\n");
72 if (mount("tmpfs", "/tmp", "tmpfs", MS_NOSUID | MS_STRICTATIME, "mode=755,gid=0") < 0) {
73 perror("mount");
74 }
75 printf("after mount\n");
76 }
77 else {
78 fprintf(stderr, "Error: invalid argument\n");
79 return 1;
80 }
81 return 0;
82}