github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/test/checkseccomp/checkseccomp.go (about)

     1  //go:build seccomp
     2  // +build seccomp
     3  
     4  package main
     5  
     6  import (
     7  	"os"
     8  
     9  	"golang.org/x/sys/unix"
    10  )
    11  
    12  func main() {
    13  	// Check if Seccomp is supported, via CONFIG_SECCOMP.
    14  	if err := unix.Prctl(unix.PR_GET_SECCOMP, 0, 0, 0, 0); err != unix.EINVAL {
    15  		// Make sure the kernel has CONFIG_SECCOMP_FILTER.
    16  		if err := unix.Prctl(unix.PR_SET_SECCOMP, unix.SECCOMP_MODE_FILTER, 0, 0, 0); err != unix.EINVAL {
    17  			os.Exit(0)
    18  		}
    19  	}
    20  	os.Exit(1)
    21  }