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
109891d6
Commit
109891d6
authored
Dec 05, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make apk_install more portable
parent
bdea7961
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
26 deletions
+8
-26
bootstages.cpp
native/jni/daemon/bootstages.cpp
+8
-6
utils.h
native/jni/utils/include/utils.h
+0
-1
misc.cpp
native/jni/utils/misc.cpp
+0
-19
No files found.
native/jni/daemon/bootstages.cpp
View file @
109891d6
...
@@ -561,17 +561,19 @@ static void install_apk(const char *apk) {
...
@@ -561,17 +561,19 @@ static void install_apk(const char *apk) {
setfilecon
(
apk
,
"u:object_r:"
SEPOL_FILE_DOMAIN
":s0"
);
setfilecon
(
apk
,
"u:object_r:"
SEPOL_FILE_DOMAIN
":s0"
);
while
(
1
)
{
while
(
1
)
{
sleep
(
5
);
sleep
(
5
);
LOGD
(
"apk_install: attempting to install APK"
);
LOGD
(
"apk_install: attempting to install APK
\n
"
);
int
apk_res
=
-
1
,
pid
;
int
fd
=
-
1
,
pid
;
pid
=
exec_command
(
true
,
&
apk_res
,
nullptr
,
"/system/bin/pm"
,
"install"
,
"-r"
,
apk
,
nullptr
);
pid
=
exec_command
(
true
,
&
fd
,
nullptr
,
"/system/bin/sh"
,
"/system/bin/pm"
,
"install"
,
"-r"
,
apk
,
nullptr
);
FILE
*
res
=
fdopen
(
fd
,
"r"
);
if
(
pid
!=
-
1
)
{
if
(
pid
!=
-
1
)
{
int
err
=
0
;
bool
err
=
false
;
while
(
f
dgets
(
buf
,
PATH_MAX
,
apk_res
)
>
0
)
{
while
(
f
gets
(
buf
,
PATH_MAX
,
res
)
)
{
LOGD
(
"apk_install: %s"
,
buf
);
LOGD
(
"apk_install: %s"
,
buf
);
err
|=
strstr
(
buf
,
"Error:"
)
!=
nullptr
;
err
|=
strstr
(
buf
,
"Error:"
)
!=
nullptr
;
}
}
waitpid
(
pid
,
nullptr
,
0
);
waitpid
(
pid
,
nullptr
,
0
);
close
(
apk_
res
);
fclose
(
res
);
// Keep trying until pm is started
// Keep trying until pm is started
if
(
err
)
if
(
err
)
continue
;
continue
;
...
...
native/jni/utils/include/utils.h
View file @
109891d6
...
@@ -92,7 +92,6 @@ int xpoll(struct pollfd *fds, nfds_t nfds, int timeout);
...
@@ -92,7 +92,6 @@ int xpoll(struct pollfd *fds, nfds_t nfds, int timeout);
unsigned
get_shell_uid
();
unsigned
get_shell_uid
();
unsigned
get_system_uid
();
unsigned
get_system_uid
();
unsigned
get_radio_uid
();
unsigned
get_radio_uid
();
ssize_t
fdgets
(
char
*
buf
,
size_t
size
,
int
fd
);
int
exec_command_sync
(
const
char
*
argv0
,
...);
int
exec_command_sync
(
const
char
*
argv0
,
...);
int
fork_dont_care
();
int
fork_dont_care
();
void
gen_rand_str
(
char
*
buf
,
int
len
);
void
gen_rand_str
(
char
*
buf
,
int
len
);
...
...
native/jni/utils/misc.cpp
View file @
109891d6
...
@@ -39,25 +39,6 @@ unsigned get_radio_uid() {
...
@@ -39,25 +39,6 @@ unsigned get_radio_uid() {
return
ppwd
->
pw_uid
;
return
ppwd
->
pw_uid
;
}
}
/* Read a whole line from file descriptor */
ssize_t
fdgets
(
char
*
buf
,
const
size_t
size
,
int
fd
)
{
ssize_t
len
=
0
;
buf
[
0
]
=
'\0'
;
while
(
len
<
size
-
1
)
{
int
ret
=
read
(
fd
,
buf
+
len
,
1
);
if
(
ret
<
0
)
return
-
1
;
if
(
ret
==
0
)
break
;
if
(
buf
[
len
]
==
'\0'
||
buf
[
len
++
]
==
'\n'
)
{
buf
[
len
]
=
'\0'
;
break
;
}
}
buf
[
size
-
1
]
=
'\0'
;
return
len
;
}
int
fork_dont_care
()
{
int
fork_dont_care
()
{
int
pid
=
xfork
();
int
pid
=
xfork
();
if
(
pid
)
{
if
(
pid
)
{
...
...
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