3
0

setsebool.c 940 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. * Licensed under GPLv2, see file LICENSE in this source tree.
  9. */
  10. //usage:#define setsebool_trivial_usage
  11. //usage: "boolean value"
  12. //usage:#define setsebool_full_usage "\n\n"
  13. //usage: "Change boolean setting"
  14. #include "libbb.h"
  15. int setsebool_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  16. int setsebool_main(int argc, char **argv)
  17. {
  18. char *p;
  19. int value;
  20. if (argc != 3)
  21. bb_show_usage();
  22. p = argv[2];
  23. if (LONE_CHAR(p, '1') || strcasecmp(p, "true") == 0 || strcasecmp(p, "on") == 0) {
  24. value = 1;
  25. } else if (LONE_CHAR(p, '0') || strcasecmp(p, "false") == 0 || strcasecmp(p, "off") == 0) {
  26. value = 0;
  27. } else {
  28. bb_show_usage();
  29. }
  30. if (security_set_boolean(argv[1], value) < 0)
  31. bb_error_msg_and_die("can't set boolean");
  32. return 0;
  33. }