Skip to content

sndnvaps/selinux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

About

binding libselinux to golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages