• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

external/koush/Superuser


Commit MetaInfo

Revisionf10f691baa93fed2c0631cfbc8c8ac92e284e076 (tree)
Time2014-02-02 10:09:44
AuthorKoushik Dutta <koushd@gmai...>
CommiterKoushik Dutta

Log Message

Fix bugreport toast spam.

Change-Id: If6886089aa132694b6aad0a4d3d35646bffbed71

Change Summary

Incremental Difference

--- a/Superuser/jni/su/daemon.c
+++ b/Superuser/jni/su/daemon.c
@@ -528,7 +528,7 @@ static void setup_sighandlers(void) {
528528 }
529529 }
530530
531-int connect_daemon(int argc, char *argv[]) {
531+int connect_daemon(int argc, char *argv[], int ppid) {
532532 int uid = getuid();
533533 int ptmx;
534534 char pts_slave[PATH_MAX];
@@ -587,7 +587,7 @@ int connect_daemon(int argc, char *argv[]) {
587587 // User ID
588588 write_int(socketfd, uid);
589589 // Parent PID
590- write_int(socketfd, getppid());
590+ write_int(socketfd, ppid);
591591 write_int(socketfd, mount_storage);
592592
593593 // Send stdin
--- a/Superuser/jni/su/su.c
+++ b/Superuser/jni/su/su.c
@@ -120,6 +120,11 @@ static int from_init(struct su_initiator *from) {
120120 from->uid = getuid();
121121 from->pid = getppid();
122122
123+ if (is_daemon) {
124+ from->uid = daemon_from_uid;
125+ from->pid = daemon_from_pid;
126+ }
127+
123128 /* Get the command line */
124129 snprintf(path, sizeof(path), "/proc/%u/cmdline", from->pid);
125130 fd = open(path, O_RDONLY);
@@ -176,11 +181,6 @@ static int from_init(struct su_initiator *from) {
176181 strncpy(from->name, pw->pw_name, sizeof(from->name));
177182 }
178183
179- if (is_daemon) {
180- from->uid = daemon_from_uid;
181- from->pid = daemon_from_pid;
182- }
183-
184184 return 0;
185185 }
186186
@@ -639,6 +639,7 @@ int su_main(int argc, char *argv[], int need_client) {
639639 return run_daemon();
640640 }
641641
642+ int ppid = getppid();
642643 fork_for_samsung();
643644
644645 // 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) {
784785 get_api_version() >= 19) {
785786 // attempt to connect to daemon...
786787 LOGD("starting daemon client %d %d", getuid(), geteuid());
787- return connect_daemon(argc, argv);
788+ return connect_daemon(argc, argv, ppid);
788789 }
789790 }
790791
--- a/Superuser/jni/su/su.h
+++ b/Superuser/jni/su/su.h
@@ -169,7 +169,7 @@ static inline char *get_command(const struct su_request *to)
169169 }
170170
171171 int run_daemon();
172-int connect_daemon(int argc, char *argv[]);
172+int connect_daemon(int argc, char *argv[], int ppid);
173173 int su_main(int argc, char *argv[], int need_client);
174174 // for when you give zero fucks about the state of the child process.
175175 // this version of fork understands you don't care about the child.