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
08e98eeb
Commit
08e98eeb
authored
Jun 13, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fail fast when possible
parent
b2f71998
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
su_daemon.c
su_daemon.c
+16
-8
No files found.
su_daemon.c
View file @
08e98eeb
...
@@ -174,13 +174,13 @@ static struct su_info *get_su_info(unsigned uid) {
...
@@ -174,13 +174,13 @@ static struct su_info *get_su_info(unsigned uid) {
break
;
break
;
case
ROOT_ACCESS_ADB_ONLY
:
case
ROOT_ACCESS_ADB_ONLY
:
if
(
info
->
uid
!=
UID_SHELL
)
{
if
(
info
->
uid
!=
UID_SHELL
)
{
LOGE
(
"Root access
is disabled for ADB
!
\n
"
);
LOGE
(
"Root access
limited to ADB only
!
\n
"
);
info
->
access
=
NO_SU_ACCESS
;
info
->
access
=
NO_SU_ACCESS
;
}
}
break
;
break
;
case
ROOT_ACCESS_APPS_ONLY
:
case
ROOT_ACCESS_APPS_ONLY
:
if
(
info
->
uid
==
UID_SHELL
)
{
if
(
info
->
uid
==
UID_SHELL
)
{
LOGE
(
"Root access
limited to ADB only
!
\n
"
);
LOGE
(
"Root access
is disabled for ADB
!
\n
"
);
info
->
access
=
NO_SU_ACCESS
;
info
->
access
=
NO_SU_ACCESS
;
}
}
break
;
break
;
...
@@ -221,6 +221,13 @@ void su_daemon_receiver(int client, struct ucred *credential) {
...
@@ -221,6 +221,13 @@ void su_daemon_receiver(int client, struct ucred *credential) {
.
pipefd
=
{
-
1
,
-
1
}
.
pipefd
=
{
-
1
,
-
1
}
};
};
// Fail fast
if
(
ctx
.
info
->
access
.
policy
==
DENY
&&
!
ctx
.
info
->
access
.
log
&&
!
ctx
.
info
->
access
.
notify
)
{
UNLOCK_UID
();
write_int
(
client
,
DENY
);
return
;
}
// If still not determined, open a pipe and wait for results
// If still not determined, open a pipe and wait for results
if
(
ctx
.
info
->
access
.
policy
==
QUERY
)
if
(
ctx
.
info
->
access
.
policy
==
QUERY
)
xpipe2
(
ctx
.
pipefd
,
O_CLOEXEC
);
xpipe2
(
ctx
.
pipefd
,
O_CLOEXEC
);
...
@@ -230,10 +237,7 @@ void su_daemon_receiver(int client, struct ucred *credential) {
...
@@ -230,10 +237,7 @@ void su_daemon_receiver(int client, struct ucred *credential) {
* The parent process will wait for the result and
* The parent process will wait for the result and
* send the return code back to our client
* send the return code back to our client
*/
*/
int
child
=
fork
();
int
child
=
xfork
();
if
(
child
<
0
)
PLOGE
(
"fork"
);
if
(
child
)
{
if
(
child
)
{
// Wait for results
// Wait for results
if
(
ctx
.
pipefd
[
0
]
>=
0
)
{
if
(
ctx
.
pipefd
[
0
]
>=
0
)
{
...
@@ -284,7 +288,7 @@ void su_daemon_receiver(int client, struct ucred *credential) {
...
@@ -284,7 +288,7 @@ void su_daemon_receiver(int client, struct ucred *credential) {
UNLOCK_UID
();
UNLOCK_UID
();
// ack
// ack
write_int
(
client
,
1
);
write_int
(
client
,
0
);
// Become session leader
// Become session leader
xsetsid
();
xsetsid
();
...
@@ -445,7 +449,11 @@ int su_client_main(int argc, char *argv[]) {
...
@@ -445,7 +449,11 @@ int su_client_main(int argc, char *argv[]) {
}
}
// Wait for acknowledgement from daemon
// Wait for acknowledgement from daemon
read_int
(
socketfd
);
if
(
read_int
(
socketfd
))
{
// Fast fail
fprintf
(
stderr
,
"%s
\n
"
,
strerror
(
EACCES
));
return
DENY
;
}
if
(
atty
&
ATTY_IN
)
{
if
(
atty
&
ATTY_IN
)
{
setup_sighandlers
(
sighandler
);
setup_sighandlers
(
sighandler
);
...
...
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