Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AndroidSystemSEPolicy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Werner Sembach
AndroidSystemSEPolicy
Commits
537e9e98
Commit
537e9e98
authored
8 years ago
by
Daniel Cashman
Committed by
android-build-merger
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Add reverse-attribute mapping to sepolicy-analyze." am:
cb6f8f02
am:
22b00be7
Change-Id: Id8e7c42e8e92fed47611c083d40c2d574d3d6918
parents
bb51a941
22b00be7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/sepolicy-analyze/README
+4
-0
4 additions, 0 deletions
tools/sepolicy-analyze/README
tools/sepolicy-analyze/attribute.c
+58
-16
58 additions, 16 deletions
tools/sepolicy-analyze/attribute.c
with
62 additions
and
16 deletions
tools/sepolicy-analyze/README
+
4
−
0
View file @
537e9e98
...
@@ -65,6 +65,10 @@ sepolicy-analyze
...
@@ -65,6 +65,10 @@ sepolicy-analyze
Displays the types associated with the specified attribute name.
Displays the types associated with the specified attribute name.
sepolicy-analyze out/target/product/<board>/root/sepolicy attribute -r <name>
Displays the attributes associated with the specified type 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"]
...
...
This diff is collapsed.
Click to expand it.
tools/sepolicy-analyze/attribute.c
+
58
−
16
View file @
537e9e98
#include
<getopt.h>
#include
"attribute.h"
#include
"attribute.h"
void
attribute_usage
()
{
void
attribute_usage
()
{
fprintf
(
stderr
,
"
\t
attribute <
attribute-name>
\n
"
);
fprintf
(
stderr
,
"
\t
attribute <
name> [-r|--reverse]
\n
"
);
}
}
static
int
list_attribute
(
policydb_t
*
policydb
,
char
*
name
)
static
void
retrieve_mapping
(
policydb_t
*
policydb
,
struct
type_datum
*
dat
,
char
*
name
,
int
reverse
)
{
{
struct
type_datum
*
attr
;
struct
ebitmap_node
*
n
;
struct
ebitmap_node
*
n
;
unsigned
int
bit
;
unsigned
int
bit
;
attr
=
hashtab_search
(
policydb
->
p_types
.
table
,
name
);
if
(
reverse
)
{
if
(
!
attr
)
{
ebitmap_for_each_bit
(
&
policydb
->
type_attr_map
[
dat
->
s
.
value
-
1
],
n
,
bit
)
{
fprintf
(
stderr
,
"%s is not defined in this policy.
\n
"
,
name
);
if
(
!
ebitmap_node_get_bit
(
n
,
bit
))
return
-
1
;
continue
;
if
(
!
strcmp
(
policydb
->
p_type_val_to_name
[
bit
],
name
))
continue
;
printf
(
"%s
\n
"
,
policydb
->
p_type_val_to_name
[
bit
]);
}
}
else
{
ebitmap_for_each_bit
(
&
policydb
->
attr_type_map
[
dat
->
s
.
value
-
1
],
n
,
bit
)
{
if
(
!
ebitmap_node_get_bit
(
n
,
bit
))
continue
;
printf
(
"%s
\n
"
,
policydb
->
p_type_val_to_name
[
bit
]);
}
}
}
}
static
int
list_attribute
(
policydb_t
*
policydb
,
char
*
name
,
int
reverse
)
{
struct
type_datum
*
dat
;
if
(
attr
->
flavor
!=
TYPE_ATTRIB
)
{
dat
=
hashtab_search
(
policydb
->
p_types
.
table
,
name
);
fprintf
(
stderr
,
"%s is a type not an attribute in this policy.
\n
"
,
name
);
if
(
!
dat
)
{
fprintf
(
stderr
,
"%s is not defined in this policy.
\n
"
,
name
);
return
-
1
;
return
-
1
;
}
}
ebitmap_for_each_bit
(
&
policydb
->
attr_type_map
[
attr
->
s
.
value
-
1
],
n
,
bit
)
{
if
(
reverse
)
{
if
(
!
ebitmap_node_get_bit
(
n
,
bit
))
if
(
dat
->
flavor
!=
TYPE_TYPE
)
{
continue
;
fprintf
(
stderr
,
"%s is an attribute not a type in this policy.
\n
"
,
name
);
printf
(
"%s
\n
"
,
policydb
->
p_type_val_to_name
[
bit
]);
return
-
1
;
}
}
else
{
if
(
dat
->
flavor
!=
TYPE_ATTRIB
)
{
fprintf
(
stderr
,
"%s is a type not an attribute in this policy.
\n
"
,
name
);
return
-
1
;
}
}
}
retrieve_mapping
(
policydb
,
dat
,
name
,
reverse
);
return
0
;
return
0
;
}
}
int
attribute_func
(
int
argc
,
char
**
argv
,
policydb_t
*
policydb
)
{
int
attribute_func
(
int
argc
,
char
**
argv
,
policydb_t
*
policydb
)
{
if
(
argc
!=
2
)
{
int
reverse
=
0
;
char
ch
;
struct
option
attribute_options
[]
=
{
{
"reverse"
,
no_argument
,
NULL
,
'r'
},
{
NULL
,
0
,
NULL
,
0
}
};
while
((
ch
=
getopt_long
(
argc
,
argv
,
"r"
,
attribute_options
,
NULL
))
!=
-
1
)
{
switch
(
ch
)
{
case
'r'
:
reverse
=
1
;
break
;
default:
USAGE_ERROR
=
true
;
return
-
1
;
}
}
if
(
argc
!=
2
&&
!
(
reverse
&&
argc
==
3
))
{
USAGE_ERROR
=
true
;
USAGE_ERROR
=
true
;
return
-
1
;
return
-
1
;
}
}
return
list_attribute
(
policydb
,
argv
[
1
]
);
return
list_attribute
(
policydb
,
argv
[
optind
],
reverse
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment