external/koush/Superuser
Revision | f10f691baa93fed2c0631cfbc8c8ac92e284e076 (tree) |
---|---|
Time | 2014-02-02 10:09:44 |
Author | Koushik Dutta <koushd@gmai...> |
Commiter | Koushik Dutta |
Fix bugreport toast spam.
Change-Id: If6886089aa132694b6aad0a4d3d35646bffbed71
@@ -528,7 +528,7 @@ static void setup_sighandlers(void) { | ||
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
531 | -int connect_daemon(int argc, char *argv[]) { | |
531 | +int connect_daemon(int argc, char *argv[], int ppid) { | |
532 | 532 | int uid = getuid(); |
533 | 533 | int ptmx; |
534 | 534 | char pts_slave[PATH_MAX]; |
@@ -587,7 +587,7 @@ int connect_daemon(int argc, char *argv[]) { | ||
587 | 587 | // User ID |
588 | 588 | write_int(socketfd, uid); |
589 | 589 | // Parent PID |
590 | - write_int(socketfd, getppid()); | |
590 | + write_int(socketfd, ppid); | |
591 | 591 | write_int(socketfd, mount_storage); |
592 | 592 | |
593 | 593 | // Send stdin |
@@ -120,6 +120,11 @@ static int from_init(struct su_initiator *from) { | ||
120 | 120 | from->uid = getuid(); |
121 | 121 | from->pid = getppid(); |
122 | 122 | |
123 | + if (is_daemon) { | |
124 | + from->uid = daemon_from_uid; | |
125 | + from->pid = daemon_from_pid; | |
126 | + } | |
127 | + | |
123 | 128 | /* Get the command line */ |
124 | 129 | snprintf(path, sizeof(path), "/proc/%u/cmdline", from->pid); |
125 | 130 | fd = open(path, O_RDONLY); |
@@ -176,11 +181,6 @@ static int from_init(struct su_initiator *from) { | ||
176 | 181 | strncpy(from->name, pw->pw_name, sizeof(from->name)); |
177 | 182 | } |
178 | 183 | |
179 | - if (is_daemon) { | |
180 | - from->uid = daemon_from_uid; | |
181 | - from->pid = daemon_from_pid; | |
182 | - } | |
183 | - | |
184 | 184 | return 0; |
185 | 185 | } |
186 | 186 |
@@ -639,6 +639,7 @@ int su_main(int argc, char *argv[], int need_client) { | ||
639 | 639 | return run_daemon(); |
640 | 640 | } |
641 | 641 | |
642 | + int ppid = getppid(); | |
642 | 643 | fork_for_samsung(); |
643 | 644 | |
644 | 645 | // Sanitize all secure environment variables (from linker_environ.c in AOSP linker). |
@@ -784,7 +785,7 @@ int su_main(int argc, char *argv[], int need_client) { | ||
784 | 785 | get_api_version() >= 19) { |
785 | 786 | // attempt to connect to daemon... |
786 | 787 | LOGD("starting daemon client %d %d", getuid(), geteuid()); |
787 | - return connect_daemon(argc, argv); | |
788 | + return connect_daemon(argc, argv, ppid); | |
788 | 789 | } |
789 | 790 | } |
790 | 791 |
@@ -169,7 +169,7 @@ static inline char *get_command(const struct su_request *to) | ||
169 | 169 | } |
170 | 170 | |
171 | 171 | int run_daemon(); |
172 | -int connect_daemon(int argc, char *argv[]); | |
172 | +int connect_daemon(int argc, char *argv[], int ppid); | |
173 | 173 | int su_main(int argc, char *argv[], int need_client); |
174 | 174 | // for when you give zero fucks about the state of the child process. |
175 | 175 | // this version of fork understands you don't care about the child. |