selinux.go 683 B

123456789101112131415161718192021222324252627282930313233
  1. // +build linux
  2. package init
  3. import (
  4. "github.com/rancher/os/config"
  5. "github.com/rancher/os/log"
  6. "github.com/rancher/os/selinux"
  7. "io/ioutil"
  8. )
  9. func initializeSelinux(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. }