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
f31a24b1
Commit
f31a24b1
authored
May 26, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update setenv functions (also fixes uninstalling)
parent
b436bce5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
bootstages.c
native/jni/core/bootstages.c
+12
-8
No files found.
native/jni/core/bootstages.c
View file @
f31a24b1
...
@@ -113,11 +113,11 @@ static struct node_entry *insert_child(struct node_entry *p, struct node_entry *
...
@@ -113,11 +113,11 @@ static struct node_entry *insert_child(struct node_entry *p, struct node_entry *
* setenvs *
* setenvs *
***********/
***********/
static
void
bb_setenv
(
struct
vector
*
v
)
{
static
void
set_path
(
struct
vector
*
v
)
{
for
(
int
i
=
0
;
environ
[
i
];
++
i
)
{
for
(
int
i
=
0
;
environ
[
i
];
++
i
)
{
if
(
strncmp
(
environ
[
i
],
"PATH="
,
5
)
==
0
)
{
if
(
strncmp
(
environ
[
i
],
"PATH="
,
5
)
==
0
)
{
snprintf
(
buf
,
PATH_MAX
,
"PATH=%s:%s"
,
BBPATH
,
strchr
(
environ
[
i
],
'='
)
+
1
);
vec_push_back
(
v
,
strdup
(
"PATH="
BBPATH
":/sbin:"
MIRRDIR
"/system/bin:"
vec_push_back
(
v
,
strdup
(
buf
));
MIRRDIR
"/system/xbin:"
MIRRDIR
"/vendor/bin"
));
}
else
{
}
else
{
vec_push_back
(
v
,
strdup
(
environ
[
i
]));
vec_push_back
(
v
,
strdup
(
environ
[
i
]));
}
}
...
@@ -125,6 +125,11 @@ static void bb_setenv(struct vector *v) {
...
@@ -125,6 +125,11 @@ static void bb_setenv(struct vector *v) {
vec_push_back
(
v
,
NULL
);
vec_push_back
(
v
,
NULL
);
}
}
static
void
uninstall_env
(
struct
vector
*
v
)
{
vec_push_back
(
v
,
strdup
(
"BOOTMODE=true"
));
set_path
(
v
);
}
/***********
/***********
* Scripts *
* Scripts *
***********/
***********/
...
@@ -143,7 +148,7 @@ static void exec_common_script(const char* stage) {
...
@@ -143,7 +148,7 @@ static void exec_common_script(const char* stage) {
if
(
access
(
buf2
,
X_OK
)
==
-
1
)
if
(
access
(
buf2
,
X_OK
)
==
-
1
)
continue
;
continue
;
LOGI
(
"%s.d: exec [%s]
\n
"
,
stage
,
entry
->
d_name
);
LOGI
(
"%s.d: exec [%s]
\n
"
,
stage
,
entry
->
d_name
);
int
pid
=
exec_command
(
0
,
NULL
,
bb_setenv
,
"sh"
,
buf2
,
NULL
);
int
pid
=
exec_command
(
0
,
NULL
,
set_path
,
"sh"
,
buf2
,
NULL
);
if
(
pid
!=
-
1
)
if
(
pid
!=
-
1
)
waitpid
(
pid
,
NULL
,
0
);
waitpid
(
pid
,
NULL
,
0
);
}
}
...
@@ -160,7 +165,7 @@ static void exec_module_script(const char* stage) {
...
@@ -160,7 +165,7 @@ static void exec_module_script(const char* stage) {
if
(
access
(
buf2
,
F_OK
)
==
-
1
||
access
(
buf
,
F_OK
)
==
0
)
if
(
access
(
buf2
,
F_OK
)
==
-
1
||
access
(
buf
,
F_OK
)
==
0
)
continue
;
continue
;
LOGI
(
"%s: exec [%s.sh]
\n
"
,
module
,
stage
);
LOGI
(
"%s: exec [%s.sh]
\n
"
,
module
,
stage
);
int
pid
=
exec_command
(
0
,
NULL
,
bb_setenv
,
"sh"
,
buf2
,
NULL
);
int
pid
=
exec_command
(
0
,
NULL
,
set_path
,
"sh"
,
buf2
,
NULL
);
if
(
pid
!=
-
1
)
if
(
pid
!=
-
1
)
waitpid
(
pid
,
NULL
,
0
);
waitpid
(
pid
,
NULL
,
0
);
}
}
...
@@ -639,13 +644,12 @@ initialize:
...
@@ -639,13 +644,12 @@ initialize:
// uninstall
// uninstall
if
(
access
(
UNINSTALLER
,
F_OK
)
==
0
)
{
if
(
access
(
UNINSTALLER
,
F_OK
)
==
0
)
{
close
(
open
(
UNBLOCKFILE
,
O_RDONLY
|
O_CREAT
));
close
(
open
(
UNBLOCKFILE
,
O_RDONLY
|
O_CREAT
));
setenv
(
"BOOTMODE"
,
"true"
,
1
);
exec_command
(
0
,
NULL
,
uninstall_env
,
"sh"
,
UNINSTALLER
,
NULL
);
exec_command
(
0
,
NULL
,
bb_setenv
,
"sh"
,
UNINSTALLER
,
NULL
);
return
;
return
;
}
}
// Start post-fs-data mode
// Start post-fs-data mode
exec
v
(
"/sbin/magisk"
,
(
char
*
[])
{
"magisk"
,
"--post-fs-data"
,
NULL
}
);
exec
l
(
"/sbin/magisk"
,
"magisk"
,
"--post-fs-data"
,
NULL
);
}
}
void
post_fs_data
(
int
client
)
{
void
post_fs_data
(
int
client
)
{
...
...
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