/selinux

binding libselinux to golang

Primary LanguageGo

selinux

WHATS:

binding libselinux to golang

INSTALL:

To experment with selinux, you can just compile and run the test example

go get github.com/sndnvaps/selinux
cd /path/to/selinux
go test 
  

example

// example.go 
package main

import (
	"github.com/sndnvaps/selinux"
	"fmt"
)

func main() {

	if selinux.Selinux_enabled() {
		fmt.Println("SELinux status = Enabled\n")
		} else {
		fmt.Println("SELinux status = Disabled\n")
		}
		
		
	path := "selinux_test"
	scon := "system_u:object_r:usr_t:s0"
	f, err := os.Create(path)
	var fd int 
	
	if err == nil {
	fd = int(f.Fd())
	}
	_ , e := selinux.Fsetfilecon(fd,scon) 
	
	if e == nil {
	fmt.Println("setfilecon success\n")
   }
   
}

AUTHOR: