android_system_sepolicy/tools/sepolicy-analyze/booleans.c
Stephen Smalley d155914479 sepolicy-analyze: Change booleans command to be more test-friendly.
Instead of displaying the boolean count, display a list of booleans
defined in the policy, if any.  This makes sepolicy-analyze booleans
consistent with sepolicy-analyze permissive and allows automated tests
to simply check whether there was any output at all.

Change-Id: I221b60d94e6e7f6d80399bf0833887af3747fe83
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-03-12 10:01:49 -04:00

23 lines
568 B
C

#include "booleans.h"
void booleans_usage() {
fprintf(stderr, "\tbooleans\n");
}
static int list_booleans(hashtab_key_t k,
__attribute__ ((unused)) hashtab_datum_t d,
__attribute__ ((unused)) void *args)
{
const char *name = k;
printf("%s\n", name);
return 0;
}
int booleans_func (int argc, __attribute__ ((unused)) char **argv, policydb_t *policydb) {
if (argc != 1) {
USAGE_ERROR = true;
return -1;
}
return hashtab_map(policydb->p_bools.table, list_booleans, NULL);
}