selinux.go 688 B

12345678910111213141516171819202122232425262728293031323334
  1. // +build linux
  2. package selinux
  3. import (
  4. "io/ioutil"
  5. "github.com/rancher/os/config"
  6. "github.com/rancher/os/pkg/log"
  7. "github.com/rancher/os/pkg/selinux"
  8. )
  9. func Initialize(c *config.CloudConfig) (*config.CloudConfig, error) {
  10. ret, _ := selinux.InitializeSelinux()
  11. if ret != 0 {
  12. log.Debug("Unable to initialize SELinux")
  13. return c, nil
  14. }
  15. // Set allow_execstack boolean to true
  16. if err := ioutil.WriteFile("/sys/fs/selinux/booleans/allow_execstack", []byte("1"), 0644); err != nil {
  17. log.Debug(err)
  18. return c, nil
  19. }
  20. if err := ioutil.WriteFile("/sys/fs/selinux/commit_pending_bools", []byte("1"), 0644); err != nil {
  21. log.Debug(err)
  22. return c, nil
  23. }
  24. return c, nil
  25. }