OSDN Git Service

Fix bugreport toast spam.
authorMarcos Marado <mindboosternoori@gmail.com>
Sat, 1 Feb 2014 22:58:19 +0000 (22:58 +0000)
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>
Sun, 2 Feb 2014 23:06:02 +0000 (23:06 +0000)
Change-Id: If6886089aa132694b6aad0a4d3d35646bffbed71

Superuser/jni/su/daemon.c
Superuser/jni/su/su.c
Superuser/jni/su/su.h

index e274372..37354bd 100644 (file)
@@ -528,7 +528,7 @@ static void setup_sighandlers(void) {
     }
 }
 
-int connect_daemon(int argc, char *argv[]) {
+int connect_daemon(int argc, char *argv[], int ppid) {
     int uid = getuid();
     int ptmx;
     char pts_slave[PATH_MAX];
@@ -587,7 +587,7 @@ int connect_daemon(int argc, char *argv[]) {
     // User ID
     write_int(socketfd, uid);
     // Parent PID
-    write_int(socketfd, getppid());
+    write_int(socketfd, ppid);
     write_int(socketfd, mount_storage);
 
     // Send stdin
index 55e54a6..0a33b55 100644 (file)
@@ -120,6 +120,11 @@ static int from_init(struct su_initiator *from) {
     from->uid = getuid();
     from->pid = getppid();
 
+    if (is_daemon) {
+        from->uid = daemon_from_uid;
+        from->pid = daemon_from_pid;
+    }
+
     /* Get the command line */
     snprintf(path, sizeof(path), "/proc/%u/cmdline", from->pid);
     fd = open(path, O_RDONLY);
@@ -176,11 +181,6 @@ static int from_init(struct su_initiator *from) {
         strncpy(from->name, pw->pw_name, sizeof(from->name));
     }
 
-    if (is_daemon) {
-        from->uid = daemon_from_uid;
-        from->pid = daemon_from_pid;
-    }
-
     return 0;
 }
 
@@ -639,6 +639,7 @@ int su_main(int argc, char *argv[], int need_client) {
         return run_daemon();
     }
 
+    int ppid = getppid();
     fork_for_samsung();
 
     // 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) {
             get_api_version() >= 19) {
             // attempt to connect to daemon...
             LOGD("starting daemon client %d %d", getuid(), geteuid());
-            return connect_daemon(argc, argv);
+            return connect_daemon(argc, argv, ppid);
         }
     }
 
index d549bcd..5287648 100644 (file)
@@ -169,7 +169,7 @@ static inline char *get_command(const struct su_request *to)
 }
 
 int run_daemon();
-int connect_daemon(int argc, char *argv[]);
+int connect_daemon(int argc, char *argv[], int ppid);
 int su_main(int argc, char *argv[], int need_client);
 // for when you give zero fucks about the state of the child process.
 // this version of fork understands you don't care about the child.