]>
git.proxmox.com Git - mirror_libseccomp.git/blob - tests/13-basic-attrs.c
2 * Seccomp Library test program
4 * Copyright (c) 2012 Red Hat <pmoore@redhat.com>
5 * Author: Paul Moore <paul@paul-moore.com>
9 * This library is free software; you can redistribute it and/or modify it
10 * under the terms of version 2.1 of the GNU Lesser General Public License as
11 * published by the Free Software Foundation.
13 * This library is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this library; if not, see <http://www.gnu.org/licenses>.
29 int main(int argc
, char *argv
[])
32 uint32_t val
= (uint32_t)(-1);
33 scmp_filter_ctx ctx
= NULL
;
35 rc
= seccomp_api_set(4);
39 ctx
= seccomp_init(SCMP_ACT_ALLOW
);
43 rc
= seccomp_attr_get(ctx
, SCMP_FLTATR_ACT_DEFAULT
, &val
);
46 if (val
!= SCMP_ACT_ALLOW
) {
50 rc
= seccomp_attr_set(ctx
, SCMP_FLTATR_ACT_DEFAULT
, val
);
56 rc
= seccomp_attr_set(ctx
, SCMP_FLTATR_ACT_BADARCH
, SCMP_ACT_ALLOW
);
59 rc
= seccomp_attr_get(ctx
, SCMP_FLTATR_ACT_BADARCH
, &val
);
62 if (val
!= SCMP_ACT_ALLOW
) {
67 rc
= seccomp_attr_set(ctx
, SCMP_FLTATR_CTL_NNP
, 0);
70 rc
= seccomp_attr_get(ctx
, SCMP_FLTATR_CTL_NNP
, &val
);
78 rc
= seccomp_attr_set(ctx
, SCMP_FLTATR_CTL_TSYNC
, 1);
79 if (rc
!= 0 && rc
!= -EOPNOTSUPP
)
81 rc
= seccomp_attr_get(ctx
, SCMP_FLTATR_CTL_TSYNC
, &val
);
89 rc
= seccomp_attr_set(ctx
, SCMP_FLTATR_API_TSKIP
, 1);
92 rc
= seccomp_attr_get(ctx
, SCMP_FLTATR_API_TSKIP
, &val
);
100 rc
= seccomp_attr_set(ctx
, SCMP_FLTATR_CTL_LOG
, 1);
103 rc
= seccomp_attr_get(ctx
, SCMP_FLTATR_CTL_LOG
, &val
);
112 rc
= seccomp_attr_set(ctx
, SCMP_FLTATR_CTL_SSB
, 1);
115 rc
= seccomp_attr_get(ctx
, SCMP_FLTATR_CTL_SSB
, &val
);
125 seccomp_release(ctx
);
126 return (rc
< 0 ? -rc
: rc
);