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
c787f547
Commit
c787f547
authored
7 years ago
by
Dan Cashman
Committed by
android-build-merger
7 years ago
Browse files
Options
Downloads
Plain Diff
sepolicy-analyze: Add ability to list all attributes. am:
9d46f9b4
am:
fdb9c018
am:
c45e9b9a
Change-Id: I6af916d823b983581c5f7b33858364af6b2e4456
parents
fe84716c
c45e9b9a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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
+35
-6
35 additions, 6 deletions
tools/sepolicy-analyze/attribute.c
with
39 additions
and
6 deletions
tools/sepolicy-analyze/README
+
4
−
0
View file @
c787f547
...
...
@@ -69,6 +69,10 @@ sepolicy-analyze
Displays the attributes associated with the specified type name.
sepolicy-analyze out/target/product/<board>/root/sepolicy attribute -l
Displays all attributes in the policy.
NEVERALLOW CHECKING (neverallow)
sepolicy-analyze out/target/product/<board>/root/sepolicy neverallow \
[-w] [-d] [-f neverallows.conf] | [-n "neverallow string"]
...
...
This diff is collapsed.
Click to expand it.
tools/sepolicy-analyze/attribute.c
+
35
−
6
View file @
c787f547
...
...
@@ -3,7 +3,7 @@
#include
"attribute.h"
void
attribute_usage
()
{
fprintf
(
stderr
,
"
\t
attribute
<name>
[-r|--reverse]
\n
"
);
fprintf
(
stderr
,
"
\t
attribute
[-l|--list]
[-r|--reverse]
<name>
\n
"
);
}
static
void
retrieve_mapping
(
policydb_t
*
policydb
,
struct
type_datum
*
dat
,
char
*
name
,
int
reverse
)
{
...
...
@@ -53,29 +53,58 @@ static int list_attribute(policydb_t *policydb, char *name, int reverse)
return
0
;
}
static
int
print_attr
(
__attribute__
((
unused
))
hashtab_key_t
k
,
hashtab_datum_t
d
,
void
*
args
)
{
struct
type_datum
*
dat
=
(
struct
type_datum
*
)
d
;
policydb_t
*
pdb
=
(
policydb_t
*
)
args
;
if
(
!
dat
)
{
fprintf
(
stderr
,
"type encountered without datum!
\n
"
);
return
-
1
;
}
if
(
dat
->
flavor
==
TYPE_ATTRIB
)
{
printf
(
"%s
\n
"
,
pdb
->
p_type_val_to_name
[
dat
->
s
.
value
-
1
]);
}
return
0
;
}
static
int
list_all_attributes
(
policydb_t
*
policydb
)
{
return
hashtab_map
(
policydb
->
p_types
.
table
,
print_attr
,
policydb
);
}
int
attribute_func
(
int
argc
,
char
**
argv
,
policydb_t
*
policydb
)
{
int
rc
=
-
1
;
int
list
=
0
;
int
reverse
=
0
;
char
ch
;
struct
option
attribute_options
[]
=
{
{
"list"
,
no_argument
,
NULL
,
'l'
},
{
"reverse"
,
no_argument
,
NULL
,
'r'
},
{
NULL
,
0
,
NULL
,
0
}
};
while
((
ch
=
getopt_long
(
argc
,
argv
,
"r"
,
attribute_options
,
NULL
))
!=
-
1
)
{
while
((
ch
=
getopt_long
(
argc
,
argv
,
"
l
r"
,
attribute_options
,
NULL
))
!=
-
1
)
{
switch
(
ch
)
{
case
'l'
:
list
=
1
;
break
;
case
'r'
:
reverse
=
1
;
break
;
default:
USAGE_ERROR
=
true
;
return
-
1
;
goto
out
;
}
}
if
(
argc
!=
2
&&
!
(
reverse
&&
argc
==
3
))
{
if
(
(
argc
!=
2
&&
!
(
reverse
&&
argc
==
3
))
||
(
list
&&
reverse
))
{
USAGE_ERROR
=
true
;
return
-
1
;
goto
out
;
}
return
list_attribute
(
policydb
,
argv
[
optind
],
reverse
);
if
(
list
)
rc
=
list_all_attributes
(
policydb
);
else
rc
=
list_attribute
(
policydb
,
argv
[
optind
],
reverse
);
out:
return
rc
;
}
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