mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-04 16:37:38 +00:00
Always ACK before doing anything
This commit is contained in:
parent
6557070ae1
commit
41b01003fd
@ -192,6 +192,13 @@ int su_client_main(int argc, char *argv[]) {
|
|||||||
// Tell the daemon we are su
|
// Tell the daemon we are su
|
||||||
write_int(fd, SUPERUSER);
|
write_int(fd, SUPERUSER);
|
||||||
|
|
||||||
|
// Wait for ack from daemon
|
||||||
|
if (read_int(fd)) {
|
||||||
|
// Fast fail
|
||||||
|
fprintf(stderr, "%s\n", strerror(EACCES));
|
||||||
|
return DENY;
|
||||||
|
}
|
||||||
|
|
||||||
// Send su_request
|
// Send su_request
|
||||||
xwrite(fd, &su_req, 4 * sizeof(unsigned));
|
xwrite(fd, &su_req, 4 * sizeof(unsigned));
|
||||||
write_string(fd, su_req.shell);
|
write_string(fd, su_req.shell);
|
||||||
@ -220,13 +227,6 @@ int su_client_main(int argc, char *argv[]) {
|
|||||||
// Send stderr
|
// Send stderr
|
||||||
send_fd(fd, (atty & ATTY_ERR) ? -1 : STDERR_FILENO);
|
send_fd(fd, (atty & ATTY_ERR) ? -1 : STDERR_FILENO);
|
||||||
|
|
||||||
// Wait for ack from daemon
|
|
||||||
if (read_int(fd)) {
|
|
||||||
// Fast fail
|
|
||||||
fprintf(stderr, "%s\n", strerror(EACCES));
|
|
||||||
return DENY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (atty & ATTY_IN) {
|
if (atty & ATTY_IN) {
|
||||||
setup_sighandlers(sighandler);
|
setup_sighandlers(sighandler);
|
||||||
pump_stdin_async(ptmx);
|
pump_stdin_async(ptmx);
|
||||||
|
@ -227,8 +227,10 @@ void su_daemon_handler(int client, struct ucred *credential) {
|
|||||||
struct su_info *info = get_su_info(credential->uid);
|
struct su_info *info = get_su_info(credential->uid);
|
||||||
|
|
||||||
// Fail fast
|
// Fail fast
|
||||||
if (info->access.policy == DENY && !info->access.log && !info->access.notify) {
|
if (info->access.policy == DENY && DB_STR(info, SU_MANAGER)[0] == '\0') {
|
||||||
|
LOGD("su: fast deny\n");
|
||||||
write_int(client, DENY);
|
write_int(client, DENY);
|
||||||
|
close(client);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,6 +266,9 @@ void su_daemon_handler(int client, struct ucred *credential) {
|
|||||||
.pid = credential->pid
|
.pid = credential->pid
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ack
|
||||||
|
write_int(client, 0);
|
||||||
|
|
||||||
// Become session leader
|
// Become session leader
|
||||||
xsetsid();
|
xsetsid();
|
||||||
|
|
||||||
@ -334,9 +339,6 @@ void su_daemon_handler(int client, struct ucred *credential) {
|
|||||||
xdup2(errfd, STDERR_FILENO);
|
xdup2(errfd, STDERR_FILENO);
|
||||||
|
|
||||||
close(ptsfd);
|
close(ptsfd);
|
||||||
|
|
||||||
// ack and close
|
|
||||||
write_int(client, 0);
|
|
||||||
close(client);
|
close(client);
|
||||||
|
|
||||||
// Handle namespaces
|
// Handle namespaces
|
||||||
|
Loading…
x
Reference in New Issue
Block a user