• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (c) 2019 Richard Palethorpe <rpalethorpe@suse.com>
4  */
5 
6 #include <unistd.h>
7 #include <sys/types.h>
8 
9 #include "tst_test.h"
10 #include "tst_capability.h"
11 #include "tst_safe_net.h"
12 
13 #include "lapi/socket.h"
14 
run(void)15 static void run(void)
16 {
17 	TEST(socket(AF_INET, SOCK_RAW, 1));
18 	if (TST_RET > -1) {
19 		tst_res(TPASS, "Created raw socket");
20 		SAFE_CLOSE(TST_RET);
21 	} else {
22 		tst_res(TFAIL | TTERRNO, "Didn't create raw socket");
23 	}
24 }
25 
26 static struct tst_test test = {
27 	.test_all = run,
28 	.needs_root = 1,
29 	.caps = (struct tst_cap []) {
30 		TST_CAP(TST_CAP_REQ, CAP_NET_RAW),
31 		TST_CAP(TST_CAP_DROP, CAP_AUDIT_READ), /* 64bit capability */
32 		TST_CAP(TST_CAP_DROP, CAP_SYS_ADMIN),
33 		{}
34 	},
35 };
36