aboutsummaryrefslogtreecommitdiff
path: root/test/checkseccomp/checkseccomp.go
blob: 6c188ec0d5534a9b8f05c2edb4322abc7d617694 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//go:build seccomp
// +build seccomp

package main

import (
	"os"

	"golang.org/x/sys/unix"
)

func main() {
	// Check if Seccomp is supported, via CONFIG_SECCOMP.
	if err := unix.Prctl(unix.PR_GET_SECCOMP, 0, 0, 0, 0); err != unix.EINVAL {
		// Make sure the kernel has CONFIG_SECCOMP_FILTER.
		if err := unix.Prctl(unix.PR_SET_SECCOMP, unix.SECCOMP_MODE_FILTER, 0, 0, 0); err != unix.EINVAL {
			os.Exit(0)
		}
	}
	os.Exit(1)
}