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
40766b33
Commit
40766b33
authored
Apr 03, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not use psuedo permissive, hide instead
parent
d274e455
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
32 deletions
+9
-32
util.c
jni/magiskhide/util.c
+9
-32
No files found.
jni/magiskhide/util.c
View file @
40766b33
#include "magiskhide.h"
static
int
isMocked
=
0
;
char
**
file_to_str_arr
(
FILE
*
fp
,
int
*
size
)
{
int
allocated
=
16
;
char
*
line
=
NULL
,
**
array
;
...
...
@@ -59,45 +61,20 @@ void run_as_daemon() {
}
void
manage_selinux
()
{
char
*
argv
[]
=
{
SEPOLICY_INJECT
,
"--live"
,
"permissive *"
,
NULL
}
;
if
(
isMocked
)
return
;
char
val
[
1
];
int
fd
,
ret
;
fd
=
open
(
ENFORCE_FILE
,
O_RDWR
);
int
fd
=
open
(
ENFORCE_FILE
,
O_RDONLY
);
if
(
fd
<
0
)
return
;
if
(
read
(
fd
,
val
,
1
)
<
1
)
return
;
lseek
(
fd
,
0
,
SEEK_SET
);
close
(
fd
);
// Permissive
if
(
val
[
0
]
==
'0'
)
{
fprintf
(
logfile
,
"MagiskHide: Permissive detected, hide the state
\n
"
);
fprintf
(
logfile
,
"MagiskHide: Permissive detected
\n
"
);
if
(
write
(
fd
,
"1"
,
1
)
<
1
)
return
;
lseek
(
fd
,
0
,
SEEK_SET
);
if
(
read
(
fd
,
val
,
1
)
<
1
)
return
;
lseek
(
fd
,
0
,
SEEK_SET
);
close
(
fd
);
if
(
val
[
0
]
==
'0'
)
{
fprintf
(
logfile
,
"MagiskHide: Unable to set to enforce, hide the state
\n
"
);
chmod
(
ENFORCE_FILE
,
0640
);
chmod
(
POLICY_FILE
,
0440
);
return
;
}
fprintf
(
logfile
,
"MagiskHide: Calling magiskpolicy for pseudo enforce mode
\n
"
);
switch
(
fork
())
{
case
-
1
:
return
;
case
0
:
execvp
(
argv
[
0
],
argv
);
default:
return
;
}
chmod
(
ENFORCE_FILE
,
0640
);
chmod
(
POLICY_FILE
,
0440
);
isMocked
=
1
;
}
}
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