test-common-selinux.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # We test if the SELinux tests should be done or not
  2. if [ -z "$SELINUX_TESTS" ]; then
  3. # not yet checked
  4. SELINUX_TESTS=0
  5. if type "selinuxenabled" >/dev/null 2>&1 && selinuxenabled; then
  6. SELINUX_TESTS=1
  7. else
  8. echo "SELinux disabled. SELinux tests will not be executed."
  9. fi
  10. if [ $SELINUX_TESTS = 1 ]; then
  11. # It seems we can run the ACL tests, but was logrotate compiled WITH_ACL=yes ?
  12. # See the Makefile, "pretest" part, for more information
  13. import "test.SELINUX"
  14. if [ -f ./test.SELINUX ]; then
  15. SELINUX_TESTS=`cat ./test.SELINUX`
  16. if [ $SELINUX_TESTS = 0 ]; then
  17. echo "logrotate was NOT compiled with 'WITH_SELINUX=yes'. SELINUX tests will not be executed."
  18. fi
  19. fi
  20. fi
  21. if [ $SELINUX_TESTS = 1 ]; then
  22. # if logrotate_tmp_t, we can't continue with SELinux tests...
  23. touch .selinuxtest
  24. chcon --type=logrotate_tmp_t .selinuxtest 2>/dev/null
  25. if [ $? != 0 ]; then
  26. SELINUX_TESTS=0
  27. echo "SELinux context 'logrotate_tmp_t' does not exist. SELinux tests will not be executed."
  28. fi
  29. rm -f .selinuxtest
  30. fi
  31. fi