~ubuntu-branches/ubuntu/quantal/libseccomp/quantal-backports

« back to all changes in this revision

Viewing changes to tests/02-basic.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2013-11-07 16:35:12 UTC
  • mfrom: (3.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20131107163512-gdgfu5c3kuxfpxvg
Tags: 1.0.1-2~ubuntu12.10.1
No-change backport to quantal (LP: #1244340)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 * read, write, exit, and rt_sigreturn
25
25
 */
26
26
 
 
27
#include <unistd.h>
 
28
 
27
29
#include <seccomp.h>
28
30
 
29
31
#include "util.h"
32
34
{
33
35
        int rc;
34
36
        struct util_options opts;
 
37
        scmp_filter_ctx ctx;
35
38
 
36
39
        rc = util_getopt(argc, argv, &opts);
37
40
        if (rc < 0)
38
41
                goto out;
39
42
 
40
 
        rc = seccomp_init(SCMP_ACT_KILL);
41
 
        if (rc != 0)
42
 
                goto out;
43
 
 
44
 
 
45
 
        rc = seccomp_rule_add_exact(SCMP_ACT_ALLOW, SCMP_SYS(read), 0);
46
 
        if (rc != 0)
47
 
                goto out;
48
 
 
49
 
        rc = seccomp_rule_add_exact(SCMP_ACT_ALLOW, SCMP_SYS(write), 0);
50
 
        if (rc != 0)
51
 
                goto out;
52
 
 
53
 
        rc = seccomp_rule_add_exact(SCMP_ACT_ALLOW, SCMP_SYS(close), 0);
54
 
        if (rc != 0)
55
 
                goto out;
56
 
 
57
 
        rc = seccomp_rule_add_exact(SCMP_ACT_ALLOW, SCMP_SYS(rt_sigreturn), 0);
58
 
        if (rc != 0)
59
 
                goto out;
60
 
 
61
 
        rc = util_filter_output(&opts);
 
43
        ctx = seccomp_init(SCMP_ACT_KILL);
 
44
        if (ctx == NULL)
 
45
                goto out;
 
46
 
 
47
 
 
48
        rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 0);
 
49
        if (rc != 0)
 
50
                goto out;
 
51
 
 
52
        rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 0);
 
53
        if (rc != 0)
 
54
                goto out;
 
55
 
 
56
        rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(close), 0);
 
57
        if (rc != 0)
 
58
                goto out;
 
59
 
 
60
        rc = seccomp_rule_add_exact(ctx,
 
61
                                    SCMP_ACT_ALLOW, SCMP_SYS(rt_sigreturn), 0);
 
62
        if (rc != 0)
 
63
                goto out;
 
64
 
 
65
        rc = util_filter_output(&opts, ctx);
62
66
        if (rc)
63
67
                goto out;
64
68
 
65
69
out:
66
 
        seccomp_release();
 
70
        seccomp_release(ctx);
67
71
        return (rc < 0 ? -rc : rc);
68
72
}