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