Skip to content
Snippets Groups Projects
Commit c3a80643 authored by Stephen Smalley's avatar Stephen Smalley Committed by Android Git Automerger
Browse files

am 7c0b328a: am 0233cd80: sepolicy-analyze: Add attribute command.

* commit '7c0b328a':
  sepolicy-analyze:  Add attribute command.
parents 4c1a022d 7c0b328a
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ LOCAL_MODULE := sepolicy-analyze ...@@ -7,7 +7,7 @@ LOCAL_MODULE := sepolicy-analyze
LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := external/libsepol/include LOCAL_C_INCLUDES := external/libsepol/include
LOCAL_CFLAGS := -Wall -Werror LOCAL_CFLAGS := -Wall -Werror
LOCAL_SRC_FILES := sepolicy-analyze.c dups.c neverallow.c perm.c typecmp.c booleans.c utils.c LOCAL_SRC_FILES := sepolicy-analyze.c dups.c neverallow.c perm.c typecmp.c booleans.c attribute.c utils.c
LOCAL_STATIC_LIBRARIES := libsepol LOCAL_STATIC_LIBRARIES := libsepol
include $(BUILD_HOST_EXECUTABLE) include $(BUILD_HOST_EXECUTABLE)
...@@ -60,6 +60,11 @@ sepolicy-analyze ...@@ -60,6 +60,11 @@ sepolicy-analyze
Policy booleans are forbidden in Android policy, so if there is any Policy booleans are forbidden in Android policy, so if there is any
output, the policy will fail CTS. output, the policy will fail CTS.
ATTRIBUTE (attribute)
sepolicy-analyze out/target/product/<board>/root/sepolicy attribute <name>
Displays the types associated with the specified attribute name.
NEVERALLOW CHECKING (neverallow) NEVERALLOW CHECKING (neverallow)
sepolicy-analyze out/target/product/<board>/root/sepolicy neverallow \ sepolicy-analyze out/target/product/<board>/root/sepolicy neverallow \
[-w] [-d] [-f neverallows.conf] | [-n "neverallow string"] [-w] [-d] [-f neverallows.conf] | [-n "neverallow string"]
......
#include "attribute.h"
void attribute_usage() {
fprintf(stderr, "\tattribute <attribute-name>\n");
}
static int list_attribute(policydb_t * policydb, char *name)
{
struct type_datum *attr;
struct ebitmap_node *n;
unsigned int bit;
attr = hashtab_search(policydb->p_types.table, name);
if (!attr) {
fprintf(stderr, "%s is not defined in this policy.\n", name);
return -1;
}
if (attr->flavor != TYPE_ATTRIB) {
fprintf(stderr, "%s is a type not an attribute in this policy.\n", name);
return -1;
}
ebitmap_for_each_bit(&policydb->attr_type_map[attr->s.value - 1], n, bit) {
if (!ebitmap_node_get_bit(n, bit))
continue;
printf("%s\n", policydb->p_type_val_to_name[bit]);
}
return 0;
}
int attribute_func (int argc, char **argv, policydb_t *policydb) {
if (argc != 2) {
USAGE_ERROR = true;
return -1;
}
return list_attribute(policydb, argv[1]);
}
#ifndef ATTRIBUTE_H
#define ATTRIBUTE_H
#include <sepol/policydb/policydb.h>
#include "utils.h"
void attribute_usage(void);
int attribute_func(int argc, char **argv, policydb_t *policydb);
#endif /* ATTRIBUTE_H */
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "perm.h" #include "perm.h"
#include "typecmp.h" #include "typecmp.h"
#include "booleans.h" #include "booleans.h"
#include "attribute.h"
#include "utils.h" #include "utils.h"
#define NUM_COMPONENTS (int) (sizeof(analyze_components)/sizeof(analyze_components[0])) #define NUM_COMPONENTS (int) (sizeof(analyze_components)/sizeof(analyze_components[0]))
...@@ -22,7 +23,8 @@ static struct { ...@@ -22,7 +23,8 @@ static struct {
COMP(neverallow), COMP(neverallow),
COMP(permissive), COMP(permissive),
COMP(typecmp), COMP(typecmp),
COMP(booleans) COMP(booleans),
COMP(attribute)
}; };
void usage(char *arg0) void usage(char *arg0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment