1
0
mirror of https://github.com/rancher/os.git synced 2025-08-24 09:28:14 +00:00
os/pkg/selinux/selinux_linux.go

28 lines
550 B
Go
Raw Normal View History

2016-02-20 00:11:32 +00:00
package selinux
// #cgo pkg-config: libselinux libsepol
// #include <selinux/selinux.h>
2022-10-11 13:57:54 +00:00
// #include <stdlib.h>
2016-02-20 00:11:32 +00:00
import "C"
2022-10-11 13:57:54 +00:00
import (
"unsafe"
)
2016-02-20 00:11:32 +00:00
func InitializeSelinux() (int, error) {
enforce := C.int(0)
ret, err := C.selinux_init_load_policy(&enforce)
return int(ret), err
}
func SetFileContext(path string, context string) (int, error) {
2022-10-11 13:57:54 +00:00
cPath := C.CString(path)
defer C.free(unsafe.Pointer(cPath))
cContext := C.CString(context)
defer C.free(unsafe.Pointer(cContext))
ret, err := C.setfilecon(cPath, cContext)
return int(ret), err
}