Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
370951ab
Commit
370951ab
authored
Nov 01, 2015
by
Pierre-Hugues Husson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change add_type to update constraints when adding new types
parent
a0632a57
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
sepolicy-inject.c
sepolicy-inject.c
+28
-0
No files found.
sepolicy-inject.c
View file @
370951ab
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include <sepol/policydb/services.h>
#include <sepol/policydb/services.h>
#include <sepol/policydb/avrule_block.h>
#include <sepol/policydb/avrule_block.h>
#include <sepol/policydb/conditional.h>
#include <sepol/policydb/conditional.h>
#include <sepol/policydb/constraint.h>
void
usage
(
char
*
arg0
)
{
void
usage
(
char
*
arg0
)
{
fprintf
(
stderr
,
"%s -s <source type> -t <target type> -c <class> -p <perm> -P <policy file> -o <output file>
\n
"
,
arg0
);
fprintf
(
stderr
,
"%s -s <source type> -t <target type> -c <class> -p <perm> -P <policy file> -o <output file>
\n
"
,
arg0
);
...
@@ -49,6 +50,17 @@ int get_attr(char *type, int value, policydb_t *policy) {
...
@@ -49,6 +50,17 @@ int get_attr(char *type, int value, policydb_t *policy) {
//return !! ebitmap_get_bit(&policy->type_attr_map[value-1], attr->s.value-1);
//return !! ebitmap_get_bit(&policy->type_attr_map[value-1], attr->s.value-1);
}
}
int
get_attr_id
(
char
*
type
,
policydb_t
*
policy
)
{
type_datum_t
*
attr
=
hashtab_search
(
policy
->
p_types
.
table
,
type
);
if
(
!
attr
)
exit
(
1
);
if
(
attr
->
flavor
!=
TYPE_ATTRIB
)
exit
(
1
);
return
attr
->
s
.
value
;
}
int
set_attr
(
char
*
type
,
int
value
,
policydb_t
*
policy
)
{
int
set_attr
(
char
*
type
,
int
value
,
policydb_t
*
policy
)
{
type_datum_t
*
attr
=
hashtab_search
(
policy
->
p_types
.
table
,
type
);
type_datum_t
*
attr
=
hashtab_search
(
policy
->
p_types
.
table
,
type
);
if
(
!
attr
)
if
(
!
attr
)
...
@@ -271,6 +283,22 @@ int add_type(char *domainS, char *typeS, policydb_t *policy) {
...
@@ -271,6 +283,22 @@ int add_type(char *domainS, char *typeS, policydb_t *policy) {
}
}
set_attr
(
typeS
,
domain
->
s
.
value
,
policy
);
set_attr
(
typeS
,
domain
->
s
.
value
,
policy
);
int
typeId
=
get_attr_id
(
typeS
,
policy
);
//Now let's update all constraints!
//(kernel doesn't support (yet?) type_names rules)
for
(
int
i
=
0
;
i
<
policy
->
p_classes
.
nprim
;
++
i
)
{
class_datum_t
*
cl
=
policy
->
class_val_to_struct
[
i
];
for
(
constraint_node_t
*
n
=
cl
->
constraints
;
n
;
n
=
n
->
next
)
{
for
(
constraint_expr_t
*
e
=
n
->
expr
;
e
;
e
=
e
->
next
)
{
if
(
e
->
expr_type
==
CEXPR_NAMES
)
{
if
(
ebitmap_get_bit
(
&
e
->
type_names
->
types
,
typeId
-
1
))
{
ebitmap_set_bit
(
&
e
->
names
,
domain
->
s
.
value
-
1
,
1
);
}
}
}
}
}
return
0
;
return
0
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment