Bundle libseccomp 2.3.1
[linux-seccomp.git] / libseccomp / doc / man / man3 / seccomp_merge.3
CommitLineData
8befd5cc
MG
1.TH "seccomp_merge" 3 "28 September 2012" "paul@paul-moore.com" "libseccomp Documentation"
2.\" //////////////////////////////////////////////////////////////////////////
3.SH NAME
4.\" //////////////////////////////////////////////////////////////////////////
5seccomp_merge \- Merge two seccomp filters
6.\" //////////////////////////////////////////////////////////////////////////
7.SH SYNOPSIS
8.\" //////////////////////////////////////////////////////////////////////////
9.nf
10.B #include <seccomp.h>
11.sp
12.B typedef void * scmp_filter_ctx;
13.sp
14.BI "int seccomp_merge(scmp_filter_ctx " dst ", scmp_filter_ctx " src ");"
15.sp
16Link with \fI\-lseccomp\fP.
17.fi
18.\" //////////////////////////////////////////////////////////////////////////
19.SH DESCRIPTION
20.\" //////////////////////////////////////////////////////////////////////////
21.P
22The
23.BR seccomp_merge ()
24function merges the seccomp filter in
25.I src
26with the filter in
27.I dst
28and stores the resulting in the
29.I dst
30filter. If successfull, the
31.I src
32seccomp filter is released and all internal memory assocated with the filter
33is freed; there is no need to call
34.BR seccomp_release (3)
35on
36.I src
37and the caller should discard any references to the filter.
38.P
39In order to merge two seccomp filters, both filters must have the same
40attribute values and no overlapping architectures.
41.\" //////////////////////////////////////////////////////////////////////////
42.SH RETURN VALUE
43.\" //////////////////////////////////////////////////////////////////////////
44Returns zero on success and negative values on failure.
45.\" //////////////////////////////////////////////////////////////////////////
46.SH EXAMPLES
47.\" //////////////////////////////////////////////////////////////////////////
48.nf
49#include <seccomp.h>
50
51int main(int argc, char *argv[])
52{
53 int rc = \-1;
54 scmp_filter_ctx ctx_32, ctx_64;
55
56 ctx_32 = seccomp_init(SCMP_ACT_KILL);
57 if (ctx_32 == NULL)
58 goto out_all;
59 ctx_64 = seccomp_init(SCMP_ACT_KILL);
60 if (ctx_64 == NULL)
61 goto out_all;
62
63 if (seccomp_arch_exist(ctx_32, SCMP_ARCH_X86) == \-EEXIST) {
64 rc = seccomp_arch_add(ctx_32, SCMP_ARCH_X86);
65 if (rc != 0)
66 goto out_all;
67 rc = seccomp_arch_remove(ctx_32, SCMP_ARCH_NATIVE);
68 if (rc != 0)
69 goto out_all;
70 }
71 if (seccomp_arch_exist(ctx_64, SCMP_ARCH_X86_64) == \-EEXIST) {
72 rc = seccomp_arch_add(ctx_64, SCMP_ARCH_X86_64);
73 if (rc != 0)
74 goto out_all;
75 rc = seccomp_arch_remove(ctx_64, SCMP_ARCH_NATIVE);
76 if (rc != 0)
77 goto out_all;
78 }
79
80 /* ... */
81
82 rc = seccomp_merge(ctx_64, ctx_32);
83 if (rc != 0)
84 goto out_all;
85
86 /* NOTE: the 'ctx_32' filter is no longer valid at this point */
87
88 /* ... */
89
90out:
91 seccomp_release(ctx_64);
92 return \-rc;
93out_all:
94 seccomp_release(ctx_32);
95 goto out;
96}
97.fi
98.\" //////////////////////////////////////////////////////////////////////////
99.SH NOTES
100.\" //////////////////////////////////////////////////////////////////////////
101.P
102While the seccomp filter can be generated independent of the kernel, kernel
103support is required to load and enforce the seccomp filter generated by
104libseccomp.
105.P
106The libseccomp project site, with more information and the source code
107repository, can be found at https://github.com/seccomp/libseccomp. This tool,
108as well as the libseccomp library, is currently under development, please
109report any bugs at the project site or directly to the author.
110.\" //////////////////////////////////////////////////////////////////////////
111.SH AUTHOR
112.\" //////////////////////////////////////////////////////////////////////////
113Paul Moore <paul@paul-moore.com>
114.\" //////////////////////////////////////////////////////////////////////////
115.SH SEE ALSO
116.\" //////////////////////////////////////////////////////////////////////////
117.BR seccomp_init (3),
118.BR seccomp_reset (3),
119.BR seccomp_arch_add (3),
120.BR seccomp_arch_remove (3),
121.BR seccomp_attr_get (3),
122.BR seccomp_attr_set (3)
This page took 0.01506 seconds and 4 git commands to generate.