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
c9c878c7
Commit
c9c878c7
authored
11 years ago
by
William Roberts
Committed by
Android Git Automerger
11 years ago
Browse files
Options
Downloads
Plain Diff
am
d6f7a63a
: am
61846291
: tools: require that seinfo and packagename be used
* commit '
d6f7a63a
': tools: require that seinfo and packagename be used
parents
b180f2fe
d6f7a63a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/check_seapp.c
+48
-0
48 additions, 0 deletions
tools/check_seapp.c
with
48 additions
and
0 deletions
tools/check_seapp.c
+
48
−
0
View file @
c9c878c7
...
...
@@ -8,6 +8,7 @@
#include
<errno.h>
#include
<stdint.h>
#include
<search.h>
#include
<stdbool.h>
#include
<sepol/sepol.h>
#include
<sepol/policydb/policydb.h>
...
...
@@ -458,6 +459,46 @@ static void free_kvp(kvp *k) {
free
(
k
->
value
);
}
/**
* Checks a rule_map for any variation of KVP's that shouldn't be allowed.
* Note that this function logs all errors.
*
* Current Checks:
* 1. That a specified name entry should have a specified seinfo entry as well.
* @param rm
* The rule map to check for validity.
* @return
* true if the rule is valid, false otherwise.
*/
static
bool
rule_map_validate
(
const
rule_map
*
rm
)
{
int
i
;
bool
found_name
=
false
;
bool
found_seinfo
=
false
;
char
*
name
=
NULL
;
key_map
*
tmp
;
for
(
i
=
0
;
i
<
rm
->
length
;
i
++
)
{
tmp
=
&
(
rm
->
m
[
i
]);
if
(
!
strcmp
(
tmp
->
name
,
"name"
)
&&
tmp
->
data
)
{
name
=
tmp
->
data
;
found_name
=
true
;
}
if
(
!
strcmp
(
tmp
->
name
,
"seinfo"
)
&&
tmp
->
data
)
{
found_seinfo
=
true
;
}
}
if
(
found_name
&&
!
found_seinfo
)
{
log_error
(
"No seinfo specified with name=
\"
%s
\"
, on line: %d
\n
"
,
name
,
rm
->
lineno
);
return
false
;
}
return
true
;
}
/**
* Given a set of key value pairs, this will construct a new rule map.
* On error this function calls exit.
...
...
@@ -473,6 +514,7 @@ static void free_kvp(kvp *k) {
static
rule_map
*
rule_map_new
(
kvp
keys
[],
unsigned
int
num_of_keys
,
int
lineno
)
{
unsigned
int
i
=
0
,
j
=
0
;
bool
valid_rule
;
rule_map
*
new_map
=
NULL
;
kvp
*
k
=
NULL
;
key_map
*
r
=
NULL
,
*
x
=
NULL
;
...
...
@@ -546,6 +588,12 @@ static rule_map *rule_map_new(kvp keys[], unsigned int num_of_keys, int lineno)
goto
err
;
}
valid_rule
=
rule_map_validate
(
new_map
);
if
(
!
valid_rule
)
{
/* Error message logged from rule_map_validate() */
goto
err
;
}
return
new_map
;
oom:
...
...
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