toybox/toys/android/getenforce.c
<<
>>
Prefs
   1/* getenforce.c - Get the current SELinux mode
   2 *
   3 * Copyright 2014 The Android Open Source Project
   4
   5USE_GETENFORCE(NEWTOY(getenforce, ">0", TOYFLAG_USR|TOYFLAG_SBIN))
   6
   7config GETENFORCE
   8  bool "getenforce"
   9  default y
  10  depends on TOYBOX_SELINUX
  11  help
  12    usage: getenforce
  13
  14    Shows whether SELinux is disabled, enforcing, or permissive.
  15*/
  16
  17#define FOR_getenforce
  18#include "toys.h"
  19
  20void getenforce_main(void)
  21{
  22  if (!is_selinux_enabled()) puts("Disabled");
  23  else {
  24    int ret = security_getenforce();
  25
  26    if (ret == -1) perror_exit("Couldn't get enforcing status");
  27    else puts(ret ? "Enforcing" : "Permissive");
  28  }
  29}
  30