#include <errno.h>
#include <unistd.h>
#include <seccomp.h>
#include "util.h"
int main(int argc, char *argv[])
{
int rc;
struct util_options opts;
scmp_filter_ctx ctx = NULL;
rc = util_getopt(argc, argv, &opts);
if (rc < 0)
goto out;
ctx = seccomp_init(SCMP_ACT_KILL);
if (ctx == NULL)
return ENOMEM;
rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, 1000, 3,
SCMP_A0(SCMP_CMP_EQ, 0),
SCMP_A1(SCMP_CMP_EQ, 1),
SCMP_A2(SCMP_CMP_EQ, 2));
if (rc != 0)
goto out;
rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, 1000, 3,
SCMP_A0(SCMP_CMP_EQ, 0),
SCMP_A1(SCMP_CMP_MASKED_EQ, 0x00ff, 1),
SCMP_A2(SCMP_CMP_EQ, 2));
if (rc != 0)
goto out;
rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, 1000, 3,
SCMP_A0(SCMP_CMP_EQ, 0),
SCMP_A1(SCMP_CMP_MASKED_EQ, 0xffff, 11),
SCMP_A2(SCMP_CMP_EQ, 2));
if (rc != 0)
goto out;
rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, 1000, 3,
SCMP_A0(SCMP_CMP_EQ, 0),
SCMP_A1(SCMP_CMP_MASKED_EQ, 0xffff, 111),
SCMP_A2(SCMP_CMP_EQ, 2));
if (rc != 0)
goto out;
rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, 1000, 3,
SCMP_A0(SCMP_CMP_EQ, 0),
SCMP_A1(SCMP_CMP_MASKED_EQ, 0xff00, 1000),
SCMP_A2(SCMP_CMP_EQ, 2));
if (rc != 0)
goto out;
rc = util_filter_output(&opts, ctx);
if (rc)
goto out;
out:
seccomp_release(ctx);
return (rc < 0 ? -rc : rc);
}