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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Werner Sembach
AndroidSystemSEPolicy
Commits
c6a0feb4
Commit
c6a0feb4
authored
10 years ago
by
Nick Kralevich
Committed by
Gerrit Code Review
10 years ago
Browse files
Options
Downloads
Plain Diff
Merge "checkseapp: Detect duplicate entries within seapp_contexts."
parents
74ddf301
0b820042
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
+12
-43
12 additions, 43 deletions
tools/check_seapp.c
with
12 additions
and
43 deletions
tools/check_seapp.c
+
12
−
43
View file @
c6a0feb4
...
@@ -36,6 +36,12 @@ enum map_match {
...
@@ -36,6 +36,12 @@ enum map_match {
map_matched
map_matched
};
};
const
char
*
map_match_str
[]
=
{
"do not match"
,
"match on all inputs"
,
"match on everything"
};
/**
/**
* Whether or not the "key" from a key vaue pair is considered an
* Whether or not the "key" from a key vaue pair is considered an
* input or an output.
* input or an output.
...
@@ -126,9 +132,6 @@ struct policy_info {
...
@@ -126,9 +132,6 @@ struct policy_info {
/** Set to !0 to enable verbose logging */
/** Set to !0 to enable verbose logging */
static
int
logging_verbose
=
0
;
static
int
logging_verbose
=
0
;
/** set to !0 to enable strict checking of duplicate entries */
static
int
is_strict
=
0
;
/** file handle to the output file */
/** file handle to the output file */
static
FILE
*
output_file
=
NULL
;
static
FILE
*
output_file
=
NULL
;
...
@@ -622,7 +625,6 @@ static void usage() {
...
@@ -622,7 +625,6 @@ static void usage() {
"and allows later declarations to override previous ones on a match.
\n
"
"and allows later declarations to override previous ones on a match.
\n
"
"Options:
\n
"
"Options:
\n
"
"-h - print this help message
\n
"
"-h - print this help message
\n
"
"-s - enable strict checking of duplicates. This causes the program to exit on a duplicate entry with a non-zero exit status
\n
"
"-v - enable verbose debugging informations
\n
"
"-v - enable verbose debugging informations
\n
"
"-p policy file - specify policy file for strict checking of output selectors against the policy
\n
"
"-p policy file - specify policy file for strict checking of output selectors against the policy
\n
"
"-o output file - specify output file, default is stdout
\n
"
);
"-o output file - specify output file, default is stdout
\n
"
);
...
@@ -722,9 +724,6 @@ static void handle_options(int argc, char *argv[]) {
...
@@ -722,9 +724,6 @@ static void handle_options(int argc, char *argv[]) {
case
'p'
:
case
'p'
:
pol
.
policy_file_name
=
optarg
;
pol
.
policy_file_name
=
optarg
;
break
;
break
;
case
's'
:
is_strict
=
1
;
break
;
case
'v'
:
case
'v'
:
log_set_verbose
();
log_set_verbose
();
break
;
break
;
...
@@ -822,7 +821,6 @@ static void rule_add(rule_map *rm) {
...
@@ -822,7 +821,6 @@ static void rule_add(rule_map *rm) {
ENTRY
*
f
;
ENTRY
*
f
;
hash_entry
*
entry
;
hash_entry
*
entry
;
hash_entry
*
tmp
;
hash_entry
*
tmp
;
char
*
preserved_key
;
e
.
key
=
rm
->
key
;
e
.
key
=
rm
->
key
;
...
@@ -839,42 +837,13 @@ static void rule_add(rule_map *rm) {
...
@@ -839,42 +837,13 @@ static void rule_add(rule_map *rm) {
log_info
(
"Existing entry found!
\n
"
);
log_info
(
"Existing entry found!
\n
"
);
tmp
=
(
hash_entry
*
)
f
->
data
;
tmp
=
(
hash_entry
*
)
f
->
data
;
cmp
=
rule_map_cmp
(
rm
,
tmp
->
r
);
cmp
=
rule_map_cmp
(
rm
,
tmp
->
r
);
log_info
(
"Comparing on rule map ret: %d
\n
"
,
cmp
);
/* Override be freeing the old rule map and updating
the pointer */
if
(
cmp
!=
map_matched
)
{
/*
* DO NOT free key pointers given to the hash map, instead
* free the new key. The ordering here is critical!
*/
preserved_key
=
tmp
->
r
->
key
;
rule_map_free
(
tmp
->
r
,
rule_map_preserve_key
);
/* hdestroy() frees comparsion keys for non glibc */
#ifdef __GLIBC__
free
(
rm
->
key
);
#endif
rm
->
key
=
preserved_key
;
tmp
->
r
=
rm
;
}
/* Duplicate */
else
{
/* if is_strict is set, then don't allow duplicates */
if
(
is_strict
)
{
log_error
(
"Duplicate line detected in file: %s
\n
"
log_error
(
"Duplicate line detected in file: %s
\n
"
"Lines %d and %d match!
\n
"
,
"Lines %d and %d %s!
\n
"
,
out_file_name
,
tmp
->
r
->
lineno
,
rm
->
lineno
);
out_file_name
,
tmp
->
r
->
lineno
,
rm
->
lineno
,
map_match_str
[
cmp
]);
rule_map_free
(
rm
,
rule_map_destroy_key
);
rule_map_free
(
rm
,
rule_map_destroy_key
);
goto
err
;
goto
err
;
}
}
/* Allow duplicates, just drop the entry*/
log_info
(
"Duplicate line detected in file: %s
\n
"
"Lines %d and %d match!
\n
"
,
out_file_name
,
tmp
->
r
->
lineno
,
rm
->
lineno
);
rule_map_free
(
rm
,
rule_map_destroy_key
);
}
}
/* It wasn't found, just add the rule map to the table */
/* It wasn't found, just add the rule map to the table */
else
{
else
{
...
...
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