X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;ds=sidebyside;f=libseccomp%2Ftests%2F11-basic-basic_errors.c;fp=libseccomp%2Ftests%2F11-basic-basic_errors.c;h=0000000000000000000000000000000000000000;hb=a7f80a138de41255578bc28d034438a295ecbb2e;hp=f6155840b26313bf08f5726573e0ad9f16813ef9;hpb=a8d04cb21e9ce2cfa37d893162df3e4943d9e480;p=linux-seccomp.git diff --git a/libseccomp/tests/11-basic-basic_errors.c b/libseccomp/tests/11-basic-basic_errors.c deleted file mode 100644 index f615584..0000000 --- a/libseccomp/tests/11-basic-basic_errors.c +++ /dev/null @@ -1,176 +0,0 @@ -/** - * Seccomp Library test program - * - * Copyright IBM Corp. 2012 - * Author: Corey Bryant - */ - -/* - * This library is free software; you can redistribute it and/or modify it - * under the terms of version 2.1 of the GNU Lesser General Public License as - * published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#include -#include - -#include - -int main(int argc, char *argv[]) -{ - int rc; - scmp_filter_ctx ctx; - - /* seccomp_init errors */ - ctx = seccomp_init(SCMP_ACT_ALLOW + 1); - if (ctx != NULL) - return -1; - - ctx = seccomp_init(SCMP_ACT_ALLOW); - if (ctx == NULL) - return -1; - seccomp_release(ctx); - ctx = NULL; - - /* seccomp_reset error */ - rc = seccomp_reset(ctx, SCMP_ACT_KILL + 1); - if (rc != -EINVAL) - return -1; - rc = seccomp_reset(ctx, SCMP_ACT_KILL); - if (rc != -EINVAL) - return -1; - - /* seccomp_load error */ - rc = seccomp_load(ctx); - if (rc != -EINVAL) - return -1; - - /* seccomp_syscall_priority errors */ - rc = seccomp_syscall_priority(ctx, SCMP_SYS(read), 1); - if (rc != -EINVAL) - return -1; - - ctx = seccomp_init(SCMP_ACT_ALLOW); - if (ctx == NULL) - return -1; - else { - rc = seccomp_syscall_priority(ctx, -10, 1); - if (rc != -EINVAL) - return -1; - } - seccomp_release(ctx); - ctx = NULL; - - /* seccomp_rule_add errors */ - rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 1, - SCMP_A0(SCMP_CMP_EQ, 0)); - if (rc != -EINVAL) - return -1; - - ctx = seccomp_init(SCMP_ACT_ALLOW); - if (ctx == NULL) - return -1; - else { - rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 0); - if (rc != -EPERM) - return -1; - rc = seccomp_rule_add(ctx, SCMP_ACT_KILL - 1, SCMP_SYS(read), 0); - if (rc != -EINVAL) - return -1; - rc = seccomp_rule_add(ctx, SCMP_ACT_KILL, SCMP_SYS(read), 7); - if (rc != -EINVAL) - return -1; - rc = seccomp_rule_add(ctx, SCMP_ACT_KILL, SCMP_SYS(read), 7, - SCMP_A0(SCMP_CMP_EQ, 0), - SCMP_A1(SCMP_CMP_EQ, 0), - SCMP_A2(SCMP_CMP_EQ, 0), - SCMP_A3(SCMP_CMP_EQ, 0), - SCMP_A4(SCMP_CMP_EQ, 0), - SCMP_A5(SCMP_CMP_EQ, 0), - SCMP_CMP(6, SCMP_CMP_EQ, 0)); - if (rc != -EINVAL) - return -1; - rc = seccomp_rule_add(ctx, SCMP_ACT_KILL, SCMP_SYS(read), 1, - SCMP_A0(_SCMP_CMP_MIN, 0)); - if (rc != -EINVAL) - return -1; - rc = seccomp_rule_add(ctx, SCMP_ACT_KILL, SCMP_SYS(read), 1, - SCMP_A0(_SCMP_CMP_MAX, 0)); - if (rc != -EINVAL) - return -1; - rc = seccomp_rule_add_exact(ctx, SCMP_ACT_KILL, -10001, 0); - if (rc != -EDOM) - return -1; - } - seccomp_release(ctx); - ctx = NULL; - - /* seccomp_rule_add_exact error */ - ctx = seccomp_init(SCMP_ACT_ALLOW); - if (ctx == NULL) - return -1; - rc = seccomp_arch_remove(ctx, SCMP_ARCH_NATIVE); - if (rc != 0) - return -1; - rc = seccomp_arch_add(ctx, SCMP_ARCH_X86); - if (rc != 0) - return -1; - rc = seccomp_rule_add_exact(ctx, SCMP_ACT_KILL, SCMP_SYS(socket), 1, - SCMP_A0(SCMP_CMP_EQ, 2)); - if (rc != -EINVAL) - return -1; - seccomp_release(ctx); - ctx = NULL; - - /* errno values beyond MAX_ERRNO */ - ctx = seccomp_init(SCMP_ACT_ALLOW); - if (ctx == NULL) - return -1; - rc = seccomp_rule_add(ctx, SCMP_ACT_ERRNO(0xffff), 0, 0); - if (rc != -EINVAL) - return -1; - seccomp_release(ctx); - ctx = NULL; - - /* seccomp_export_pfc errors */ - rc = seccomp_export_pfc(ctx, STDOUT_FILENO); - if (rc != -EINVAL) - return -1; - - ctx = seccomp_init(SCMP_ACT_ALLOW); - if (ctx == NULL) - return -1; - else { - rc = seccomp_export_pfc(ctx, sysconf(_SC_OPEN_MAX) - 1); - if (rc != EBADF) - return -1; - } - seccomp_release(ctx); - ctx = NULL; - - /* seccomp_export_bpf errors */ - rc = seccomp_export_bpf(ctx, STDOUT_FILENO); - if (rc != -EINVAL) - return -1; - - ctx = seccomp_init(SCMP_ACT_ALLOW); - if (ctx == NULL) - return -1; - else { - rc = seccomp_export_bpf(ctx, sysconf(_SC_OPEN_MAX) - 1); - if (rc != -EBADF) - return -1; - } - seccomp_release(ctx); - ctx = NULL; - - return 0; -}