selinux_linux.go 388 B

1234567891011121314151617
  1. package selinux
  2. // #cgo pkg-config: libselinux libsepol
  3. // #include <selinux/selinux.h>
  4. import "C"
  5. func InitializeSelinux() (int, error) {
  6. enforce := C.int(0)
  7. ret, err := C.selinux_init_load_policy(&enforce)
  8. return int(ret), err
  9. }
  10. func SetFileContext(path string, context string) (int, error) {
  11. ret, err := C.setfilecon(C.CString(path), C.CString(context))
  12. return int(ret), err
  13. }