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
fa8900be
Commit
fa8900be
authored
Mar 17, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use standalone magiskpolicy
parent
69c2f407
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
34 deletions
+27
-34
build.py
build.py
+7
-9
Setup.kt
buildSrc/src/main/java/Setup.kt
+5
-5
Android.mk
native/jni/Android.mk
+1
-2
bootstages.cpp
native/jni/core/bootstages.cpp
+5
-0
module.cpp
native/jni/core/module.cpp
+5
-8
mount.cpp
native/jni/init/mount.cpp
+1
-7
avd_magisk.sh
scripts/avd_magisk.sh
+3
-3
No files found.
build.py
View file @
fa8900be
...
@@ -59,8 +59,8 @@ except FileNotFoundError:
...
@@ -59,8 +59,8 @@ except FileNotFoundError:
cpu_count
=
multiprocessing
.
cpu_count
()
cpu_count
=
multiprocessing
.
cpu_count
()
archs
=
[
'armeabi-v7a'
,
'x86'
,
'arm64-v8a'
,
'x86_64'
]
archs
=
[
'armeabi-v7a'
,
'x86'
,
'arm64-v8a'
,
'x86_64'
]
default_targets
=
[
'magisk'
,
'magiskinit'
,
'magiskboot'
,
'busybox'
]
default_targets
=
[
'magisk'
,
'magiskinit'
,
'magiskboot'
,
'
magiskpolicy'
,
'
busybox'
]
support_targets
=
default_targets
+
[
'
magiskpolicy'
,
'
resetprop'
,
'test'
]
support_targets
=
default_targets
+
[
'resetprop'
,
'test'
]
sdk_path
=
os
.
environ
[
'ANDROID_SDK_ROOT'
]
sdk_path
=
os
.
environ
[
'ANDROID_SDK_ROOT'
]
ndk_root
=
op
.
join
(
sdk_path
,
'ndk'
)
ndk_root
=
op
.
join
(
sdk_path
,
'ndk'
)
...
@@ -199,8 +199,8 @@ def clean_elf():
...
@@ -199,8 +199,8 @@ def clean_elf():
execv
([
'g++'
,
'-std=c++11'
,
'tools/termux-elf-cleaner/termux-elf-cleaner.cpp'
,
execv
([
'g++'
,
'-std=c++11'
,
'tools/termux-elf-cleaner/termux-elf-cleaner.cpp'
,
'-o'
,
elf_cleaner
])
'-o'
,
elf_cleaner
])
args
=
[
elf_cleaner
]
args
=
[
elf_cleaner
]
args
.
extend
(
op
.
join
(
'native'
,
'out'
,
arch
,
'magisk'
)
args
.
extend
(
op
.
join
(
'native'
,
'out'
,
arch
,
bin
)
for
arch
in
archs
)
for
arch
in
archs
for
bin
in
[
'magisk'
,
'magiskpolicy'
]
)
execv
(
args
)
execv
(
args
)
...
@@ -327,13 +327,14 @@ def build_binary(args):
...
@@ -327,13 +327,14 @@ def build_binary(args):
if
'magisk'
in
args
.
target
:
if
'magisk'
in
args
.
target
:
flag
+=
' B_MAGISK=1'
flag
+=
' B_MAGISK=1'
if
'magiskpolicy'
in
args
.
target
:
flag
+=
' B_POLICY=1'
if
'test'
in
args
.
target
:
if
'test'
in
args
.
target
:
flag
+=
' B_TEST=1'
flag
+=
' B_TEST=1'
if
flag
:
if
flag
:
run_ndk_build
(
flag
+
' B_SHARED=1'
)
run_ndk_build
(
flag
+
' B_SHARED=1'
)
if
'magisk'
in
args
.
target
:
clean_elf
()
clean_elf
()
flag
=
''
flag
=
''
...
@@ -342,9 +343,6 @@ def build_binary(args):
...
@@ -342,9 +343,6 @@ def build_binary(args):
dump_bin_header
()
dump_bin_header
()
flag
+=
' B_INIT=1'
flag
+=
' B_INIT=1'
if
'magiskpolicy'
in
args
.
target
:
flag
+=
' B_POLICY=1'
if
'resetprop'
in
args
.
target
:
if
'resetprop'
in
args
.
target
:
flag
+=
' B_PROP=1'
flag
+=
' B_PROP=1'
...
...
buildSrc/src/main/java/Setup.kt
View file @
fa8900be
...
@@ -88,30 +88,30 @@ fun Project.setupApp() {
...
@@ -88,30 +88,30 @@ fun Project.setupApp() {
into
(
"src/main/jniLibs"
)
into
(
"src/main/jniLibs"
)
into
(
"armeabi-v7a"
)
{
into
(
"armeabi-v7a"
)
{
from
(
rootProject
.
file
(
"native/out/armeabi-v7a"
))
{
from
(
rootProject
.
file
(
"native/out/armeabi-v7a"
))
{
include
(
"busybox"
,
"magiskboot"
,
"magiskinit"
,
"magisk"
)
include
(
"busybox"
,
"magiskboot"
,
"magiskinit"
,
"magisk
policy"
,
"magisk
"
)
rename
{
if
(
it
==
"magisk"
)
"libmagisk32.so"
else
"lib$it.so"
}
rename
{
if
(
it
==
"magisk"
)
"libmagisk32.so"
else
"lib$it.so"
}
}
}
}
}
into
(
"x86"
)
{
into
(
"x86"
)
{
from
(
rootProject
.
file
(
"native/out/x86"
))
{
from
(
rootProject
.
file
(
"native/out/x86"
))
{
include
(
"busybox"
,
"magiskboot"
,
"magiskinit"
,
"magisk"
)
include
(
"busybox"
,
"magiskboot"
,
"magiskinit"
,
"magisk
policy"
,
"magisk
"
)
rename
{
if
(
it
==
"magisk"
)
"libmagisk32.so"
else
"lib$it.so"
}
rename
{
if
(
it
==
"magisk"
)
"libmagisk32.so"
else
"lib$it.so"
}
}
}
}
}
into
(
"arm64-v8a"
)
{
into
(
"arm64-v8a"
)
{
from
(
rootProject
.
file
(
"native/out/arm64-v8a"
))
{
from
(
rootProject
.
file
(
"native/out/arm64-v8a"
))
{
include
(
"busybox"
,
"magiskboot"
,
"magiskinit"
,
"magisk"
)
include
(
"busybox"
,
"magiskboot"
,
"magiskinit"
,
"magisk
policy"
,
"magisk
"
)
rename
{
if
(
it
==
"magisk"
)
"libmagisk64.so"
else
"lib$it.so"
}
rename
{
if
(
it
==
"magisk"
)
"libmagisk64.so"
else
"lib$it.so"
}
}
}
}
}
into
(
"x86_64"
)
{
into
(
"x86_64"
)
{
from
(
rootProject
.
file
(
"native/out/x86_64"
))
{
from
(
rootProject
.
file
(
"native/out/x86_64"
))
{
include
(
"busybox"
,
"magiskboot"
,
"magiskinit"
,
"magisk"
)
include
(
"busybox"
,
"magiskboot"
,
"magiskinit"
,
"magisk
policy"
,
"magisk
"
)
rename
{
if
(
it
==
"magisk"
)
"libmagisk64.so"
else
"lib$it.so"
}
rename
{
if
(
it
==
"magisk"
)
"libmagisk64.so"
else
"lib$it.so"
}
}
}
}
}
onlyIf
{
onlyIf
{
if
(
inputs
.
sourceFiles
.
files
.
size
!=
16
)
if
(
inputs
.
sourceFiles
.
files
.
size
!=
20
)
throw
StopExecutionException
(
"Please build binaries first! (./build.py binary)"
)
throw
StopExecutionException
(
"Please build binaries first! (./build.py binary)"
)
true
true
}
}
...
...
native/jni/Android.mk
View file @
fa8900be
...
@@ -110,7 +110,7 @@ ifdef B_POLICY
...
@@ -110,7 +110,7 @@ ifdef B_POLICY
include $(CLEAR_VARS)
include $(CLEAR_VARS)
LOCAL_MODULE := magiskpolicy
LOCAL_MODULE := magiskpolicy
LOCAL_STATIC_LIBRARIES := \
LOCAL_STATIC_LIBRARIES := \
libutil
x
\
libutil
s
\
libsepol
libsepol
LOCAL_SRC_FILES := \
LOCAL_SRC_FILES := \
...
@@ -122,7 +122,6 @@ LOCAL_SRC_FILES := \
...
@@ -122,7 +122,6 @@ LOCAL_SRC_FILES := \
magiskpolicy/statement.cpp
magiskpolicy/statement.cpp
LOCAL_CFLAGS := -DAPPLET_STUB_MAIN=magiskpolicy_main
LOCAL_CFLAGS := -DAPPLET_STUB_MAIN=magiskpolicy_main
LOCAL_LDFLAGS := -static
include $(BUILD_EXECUTABLE)
include $(BUILD_EXECUTABLE)
endif
endif
...
...
native/jni/core/bootstages.cpp
View file @
fa8900be
...
@@ -167,6 +167,11 @@ static bool magisk_env() {
...
@@ -167,6 +167,11 @@ static bool magisk_env() {
cp_afc
(
DATABIN
"/busybox"
,
buf
);
cp_afc
(
DATABIN
"/busybox"
,
buf
);
exec_command_async
(
buf
,
"--install"
,
"-s"
,
dirname
(
buf
));
exec_command_async
(
buf
,
"--install"
,
"-s"
,
dirname
(
buf
));
if
(
access
(
DATABIN
"/magiskpolicy"
,
X_OK
)
==
0
)
{
sprintf
(
buf
,
"%s/magiskpolicy"
,
MAGISKTMP
.
data
());
cp_afc
(
DATABIN
"/magiskpolicy"
,
buf
);
}
return
true
;
return
true
;
}
}
...
...
native/jni/core/module.cpp
View file @
fa8900be
...
@@ -513,11 +513,9 @@ public:
...
@@ -513,11 +513,9 @@ public:
xsymlink
(
"./magisk"
,
dest
.
data
());
xsymlink
(
"./magisk"
,
dest
.
data
());
}
}
}
else
{
}
else
{
for
(
int
i
=
0
;
init_applet
[
i
];
++
i
)
{
string
dest
=
dir_name
+
"/supolicy"
;
string
dest
=
dir_name
+
"/"
+
init_applet
[
i
];
VLOGD
(
"create"
,
"./magiskpolicy"
,
dest
.
data
());
VLOGD
(
"create"
,
"./magiskinit"
,
dest
.
data
());
xsymlink
(
"./magiskpolicy"
,
dest
.
data
());
xsymlink
(
"./magiskinit"
,
dest
.
data
());
}
}
}
create_and_mount
(
MAGISKTMP
+
"/"
+
name
());
create_and_mount
(
MAGISKTMP
+
"/"
+
name
());
}
}
...
@@ -532,13 +530,12 @@ static void inject_magisk_bins(root_node *system) {
...
@@ -532,13 +530,12 @@ static void inject_magisk_bins(root_node *system) {
// Insert binaries
// Insert binaries
bin
->
insert
(
new
magisk_node
(
"magisk"
));
bin
->
insert
(
new
magisk_node
(
"magisk"
));
bin
->
insert
(
new
magisk_node
(
"magisk
init
"
));
bin
->
insert
(
new
magisk_node
(
"magisk
policy
"
));
// Also delete all applets to make sure no modules can override it
// Also delete all applets to make sure no modules can override it
for
(
int
i
=
0
;
applet_names
[
i
];
++
i
)
for
(
int
i
=
0
;
applet_names
[
i
];
++
i
)
delete
bin
->
extract
(
applet_names
[
i
]);
delete
bin
->
extract
(
applet_names
[
i
]);
for
(
int
i
=
0
;
init_applet
[
i
];
++
i
)
delete
bin
->
extract
(
"supolicy"
);
delete
bin
->
extract
(
init_applet
[
i
]);
}
}
vector
<
module_info
>
*
module_list
;
vector
<
module_info
>
*
module_list
;
...
...
native/jni/init/mount.cpp
View file @
fa8900be
...
@@ -300,17 +300,11 @@ void MagiskInit::setup_tmp(const char *path) {
...
@@ -300,17 +300,11 @@ void MagiskInit::setup_tmp(const char *path) {
int
fd
=
xopen
(
INTLROOT
"/config"
,
O_WRONLY
|
O_CREAT
,
0
);
int
fd
=
xopen
(
INTLROOT
"/config"
,
O_WRONLY
|
O_CREAT
,
0
);
xwrite
(
fd
,
magisk_cfg
.
buf
,
magisk_cfg
.
sz
);
xwrite
(
fd
,
magisk_cfg
.
buf
,
magisk_cfg
.
sz
);
close
(
fd
);
close
(
fd
);
fd
=
xopen
(
"magiskinit"
,
O_WRONLY
|
O_CREAT
,
0755
);
xwrite
(
fd
,
self
.
buf
,
self
.
sz
);
close
(
fd
);
// The magisk binary will be handled later
// Create applet symlinks
// Create applet symlinks
for
(
int
i
=
0
;
applet_names
[
i
];
++
i
)
for
(
int
i
=
0
;
applet_names
[
i
];
++
i
)
xsymlink
(
"./magisk"
,
applet_names
[
i
]);
xsymlink
(
"./magisk"
,
applet_names
[
i
]);
xsymlink
(
"./magiskinit"
,
"magiskpolicy"
);
xsymlink
(
"./magiskpolicy"
,
"supolicy"
);
xsymlink
(
"./magiskinit"
,
"supolicy"
);
chdir
(
"/"
);
chdir
(
"/"
);
}
}
scripts/avd_magisk.sh
View file @
fa8900be
...
@@ -69,7 +69,6 @@ if [ -d /dev/avd-magisk ]; then
...
@@ -69,7 +69,6 @@ if [ -d /dev/avd-magisk ]; then
fi
fi
# SELinux stuffs
# SELinux stuffs
ln
-sf
./magiskinit magiskpolicy
if
[
-f
/vendor/etc/selinux/precompiled_sepolicy
]
;
then
if
[
-f
/vendor/etc/selinux/precompiled_sepolicy
]
;
then
./magiskpolicy
--load
/vendor/etc/selinux/precompiled_sepolicy
--live
--magisk
2>&1
./magiskpolicy
--load
/vendor/etc/selinux/precompiled_sepolicy
--live
--magisk
2>&1
elif
[
-f
/sepolicy
]
;
then
elif
[
-f
/sepolicy
]
;
then
...
@@ -125,19 +124,20 @@ mkdir $NVBASE/modules 2>/dev/null
...
@@ -125,19 +124,20 @@ mkdir $NVBASE/modules 2>/dev/null
mkdir
$POSTFSDATAD
2>/dev/null
mkdir
$POSTFSDATAD
2>/dev/null
mkdir
$SERVICED
2>/dev/null
mkdir
$SERVICED
2>/dev/null
for
file
in
magisk32 magisk64 magisk
init
;
do
for
file
in
magisk32 magisk64 magisk
policy
;
do
chmod
755 ./
$file
chmod
755 ./
$file
cp
-af
./
$file
$MAGISKTMP
/
$file
cp
-af
./
$file
$MAGISKTMP
/
$file
cp
-af
./
$file
$MAGISKBIN
/
$file
cp
-af
./
$file
$MAGISKBIN
/
$file
done
done
cp
-af
./magiskboot
$MAGISKBIN
/magiskboot
cp
-af
./magiskboot
$MAGISKBIN
/magiskboot
cp
-af
./magiskinit
$MAGISKBIN
/magiskinit
cp
-af
./busybox
$MAGISKBIN
/busybox
cp
-af
./busybox
$MAGISKBIN
/busybox
ln
-s
./magisk64
$MAGISKTMP
/magisk
ln
-s
./magisk64
$MAGISKTMP
/magisk
ln
-s
./magisk
$MAGISKTMP
/su
ln
-s
./magisk
$MAGISKTMP
/su
ln
-s
./magisk
$MAGISKTMP
/resetprop
ln
-s
./magisk
$MAGISKTMP
/resetprop
ln
-s
./magisk
$MAGISKTMP
/magiskhide
ln
-s
./magisk
$MAGISKTMP
/magiskhide
ln
-s
./magisk
init
$MAGISKTMP
/magisk
policy
ln
-s
./magisk
policy
$MAGISKTMP
/su
policy
mkdir
-p
$MAGISKTMP
/.magisk/mirror
mkdir
-p
$MAGISKTMP
/.magisk/mirror
mkdir
$MAGISKTMP
/.magisk/block
mkdir
$MAGISKTMP
/.magisk/block
...
...
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