setsebool.c 718 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * setsebool
  3. * Simple setsebool
  4. * NOTE: -P option requires libsemanage, so this feature is
  5. * omitted in this version
  6. * Yuichi Nakamura <ynakam@hitachisoft.jp>
  7. */
  8. #include "libbb.h"
  9. int setsebool_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  10. int setsebool_main(int argc, char **argv)
  11. {
  12. char *p;
  13. int value;
  14. if (argc != 3)
  15. bb_show_usage();
  16. p = argv[2];
  17. if (LONE_CHAR(p, '1') || strcasecmp(p, "true") == 0 || strcasecmp(p, "on") == 0) {
  18. value = 1;
  19. } else if (LONE_CHAR(p, '0') || strcasecmp(p, "false") == 0 || strcasecmp(p, "off") == 0) {
  20. value = 0;
  21. } else {
  22. bb_show_usage();
  23. }
  24. if (security_set_boolean(argv[1], value) < 0)
  25. bb_error_msg_and_die("can't set boolean");
  26. return 0;
  27. }