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
f24342f1
Commit
f24342f1
authored
Jan 20, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable several features in Jellybean
parent
50b55a77
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
16 deletions
+29
-16
bootstages.cpp
native/jni/daemon/bootstages.cpp
+8
-11
daemon.cpp
native/jni/daemon/daemon.cpp
+18
-5
hide_utils.cpp
native/jni/magiskhide/hide_utils.cpp
+3
-0
No files found.
native/jni/daemon/bootstages.cpp
View file @
f24342f1
...
@@ -32,7 +32,6 @@ static vector<string> module_list;
...
@@ -32,7 +32,6 @@ static vector<string> module_list;
static
bool
seperate_vendor
;
static
bool
seperate_vendor
;
char
*
system_block
,
*
vendor_block
,
*
magiskloop
;
char
*
system_block
,
*
vendor_block
,
*
magiskloop
;
int
SDK_INT
=
-
1
;
static
int
bind_mount
(
const
char
*
from
,
const
char
*
to
);
static
int
bind_mount
(
const
char
*
from
,
const
char
*
to
);
extern
void
auto_start_magiskhide
();
extern
void
auto_start_magiskhide
();
...
@@ -53,7 +52,7 @@ extern void auto_start_magiskhide();
...
@@ -53,7 +52,7 @@ extern void auto_start_magiskhide();
class
node_entry
{
class
node_entry
{
public
:
public
:
node_entry
(
const
char
*
,
uint8_t
status
=
0
,
uint8_t
type
=
0
);
explicit
node_entry
(
const
char
*
,
uint8_t
status
=
0
,
uint8_t
type
=
0
);
~
node_entry
();
~
node_entry
();
void
create_module_tree
(
const
char
*
module
);
void
create_module_tree
(
const
char
*
module
);
void
magic_mount
();
void
magic_mount
();
...
@@ -437,15 +436,6 @@ static bool magisk_env() {
...
@@ -437,15 +436,6 @@ static bool magisk_env() {
xmkdir
(
SECURE_DIR
"/post-fs-data.d"
,
0755
);
xmkdir
(
SECURE_DIR
"/post-fs-data.d"
,
0755
);
xmkdir
(
SECURE_DIR
"/service.d"
,
0755
);
xmkdir
(
SECURE_DIR
"/service.d"
,
0755
);
parse_prop_file
(
"/system/build.prop"
,
[](
auto
key
,
auto
val
)
->
bool
{
if
(
strcmp
(
key
,
"ro.build.version.sdk"
)
==
0
)
{
LOGI
(
"* Device API level: %s
\n
"
,
val
);
SDK_INT
=
atoi
(
val
);
return
false
;
}
return
true
;
});
LOGI
(
"* Mounting mirrors"
);
LOGI
(
"* Mounting mirrors"
);
auto
mounts
=
file_to_vector
(
"/proc/mounts"
);
auto
mounts
=
file_to_vector
(
"/proc/mounts"
);
bool
system_as_root
=
false
;
bool
system_as_root
=
false
;
...
@@ -497,6 +487,13 @@ static bool magisk_env() {
...
@@ -497,6 +487,13 @@ static bool magisk_env() {
LOGI
(
"* Setting up internal busybox"
);
LOGI
(
"* Setting up internal busybox"
);
exec_command_sync
(
MIRRDIR
"/bin/busybox"
,
"--install"
,
"-s"
,
BBPATH
,
nullptr
);
exec_command_sync
(
MIRRDIR
"/bin/busybox"
,
"--install"
,
"-s"
,
BBPATH
,
nullptr
);
xsymlink
(
MIRRDIR
"/bin/busybox"
,
BBPATH
"/busybox"
);
xsymlink
(
MIRRDIR
"/bin/busybox"
,
BBPATH
"/busybox"
);
// Disable/remove magiskhide, resetprop, and modules
if
(
SDK_INT
<
19
)
{
close
(
xopen
(
DISABLEFILE
,
O_RDONLY
|
O_CREAT
,
0
));
unlink
(
"/sbin/resetprop"
);
unlink
(
"/sbin/magiskhide"
);
}
return
true
;
return
true
;
}
}
...
...
native/jni/daemon/daemon.cpp
View file @
f24342f1
...
@@ -19,8 +19,11 @@
...
@@ -19,8 +19,11 @@
#include "daemon.h"
#include "daemon.h"
#include "selinux.h"
#include "selinux.h"
#include "db.h"
#include "db.h"
#include "resetprop.h"
#include "flags.h"
#include "flags.h"
int
SDK_INT
=
-
1
;
static
void
get_client_cred
(
int
fd
,
struct
ucred
*
cred
)
{
static
void
get_client_cred
(
int
fd
,
struct
ucred
*
cred
)
{
socklen_t
ucred_length
=
sizeof
(
*
cred
);
socklen_t
ucred_length
=
sizeof
(
*
cred
);
if
(
getsockopt
(
fd
,
SOL_SOCKET
,
SO_PEERCRED
,
cred
,
&
ucred_length
))
if
(
getsockopt
(
fd
,
SOL_SOCKET
,
SO_PEERCRED
,
cred
,
&
ucred_length
))
...
@@ -44,7 +47,7 @@ static void *request_handler(void *args) {
...
@@ -44,7 +47,7 @@ static void *request_handler(void *args) {
if
(
credential
.
uid
!=
0
)
{
if
(
credential
.
uid
!=
0
)
{
write_int
(
client
,
ROOT_REQUIRED
);
write_int
(
client
,
ROOT_REQUIRED
);
close
(
client
);
close
(
client
);
return
NULL
;
return
nullptr
;
}
}
default:
default:
break
;
break
;
...
@@ -100,6 +103,16 @@ static void main_daemon() {
...
@@ -100,6 +103,16 @@ static void main_daemon() {
xdup2
(
fd
,
STDIN_FILENO
);
xdup2
(
fd
,
STDIN_FILENO
);
close
(
fd
);
close
(
fd
);
// Get API level
parse_prop_file
(
"/system/build.prop"
,
[](
auto
key
,
auto
val
)
->
bool
{
if
(
strcmp
(
key
,
"ro.build.version.sdk"
)
==
0
)
{
LOGI
(
"* Device API level: %s
\n
"
,
val
);
SDK_INT
=
atoi
(
val
);
return
false
;
}
return
true
;
});
struct
sockaddr_un
sun
;
struct
sockaddr_un
sun
;
socklen_t
len
=
setup_sockaddr
(
&
sun
,
MAIN_SOCKET
);
socklen_t
len
=
setup_sockaddr
(
&
sun
,
MAIN_SOCKET
);
fd
=
xsocket
(
AF_LOCAL
,
SOCK_STREAM
|
SOCK_CLOEXEC
,
0
);
fd
=
xsocket
(
AF_LOCAL
,
SOCK_STREAM
|
SOCK_CLOEXEC
,
0
);
...
@@ -116,20 +129,20 @@ static void main_daemon() {
...
@@ -116,20 +129,20 @@ static void main_daemon() {
sigemptyset
(
&
block_set
);
sigemptyset
(
&
block_set
);
sigaddset
(
&
block_set
,
SIGUSR1
);
sigaddset
(
&
block_set
,
SIGUSR1
);
sigaddset
(
&
block_set
,
SIGUSR2
);
sigaddset
(
&
block_set
,
SIGUSR2
);
pthread_sigmask
(
SIG_SETMASK
,
&
block_set
,
NULL
);
pthread_sigmask
(
SIG_SETMASK
,
&
block_set
,
nullptr
);
// Ignore SIGPIPE
// Ignore SIGPIPE
struct
sigaction
act
;
struct
sigaction
act
;
memset
(
&
act
,
0
,
sizeof
(
act
));
memset
(
&
act
,
0
,
sizeof
(
act
));
act
.
sa_handler
=
SIG_IGN
;
act
.
sa_handler
=
SIG_IGN
;
sigaction
(
SIGPIPE
,
&
act
,
NULL
);
sigaction
(
SIGPIPE
,
&
act
,
nullptr
);
// Loop forever to listen for requests
// Loop forever to listen for requests
while
(
1
)
{
while
(
1
)
{
int
*
client
=
new
int
;
int
*
client
=
new
int
;
*
client
=
xaccept4
(
fd
,
NULL
,
NULL
,
SOCK_CLOEXEC
);
*
client
=
xaccept4
(
fd
,
nullptr
,
nullptr
,
SOCK_CLOEXEC
);
pthread_t
thread
;
pthread_t
thread
;
xpthread_create
(
&
thread
,
NULL
,
request_handler
,
client
);
xpthread_create
(
&
thread
,
nullptr
,
request_handler
,
client
);
// Detach the thread, we will never join it
// Detach the thread, we will never join it
pthread_detach
(
thread
);
pthread_detach
(
thread
);
}
}
...
...
native/jni/magiskhide/hide_utils.cpp
View file @
f24342f1
...
@@ -276,6 +276,9 @@ static void set_hide_config() {
...
@@ -276,6 +276,9 @@ static void set_hide_config() {
}
}
int
launch_magiskhide
(
int
client
)
{
int
launch_magiskhide
(
int
client
)
{
if
(
SDK_INT
<
19
)
goto
error
;
if
(
hide_enabled
)
if
(
hide_enabled
)
return
HIDE_IS_ENABLED
;
return
HIDE_IS_ENABLED
;
...
...
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