3
0

getenforce.c 611 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * getenforce
  3. *
  4. * Based on libselinux 1.33.1
  5. * Port to BusyBox Hiroshi Shinji <shiroshi@my.email.ne.jp>
  6. *
  7. */
  8. #include "libbb.h"
  9. int getenforce_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  10. int getenforce_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
  11. {
  12. int rc;
  13. rc = is_selinux_enabled();
  14. if (rc < 0)
  15. bb_error_msg_and_die("is_selinux_enabled() failed");
  16. if (rc == 1) {
  17. rc = security_getenforce();
  18. if (rc < 0)
  19. bb_error_msg_and_die("getenforce() failed");
  20. if (rc)
  21. puts("Enforcing");
  22. else
  23. puts("Permissive");
  24. } else {
  25. puts("Disabled");
  26. }
  27. return 0;
  28. }