Skip to content

Commit

Permalink
Fix bugreport toast spam.
Browse files Browse the repository at this point in the history
Change-Id: If6886089aa132694b6aad0a4d3d35646bffbed71
  • Loading branch information
marado authored and rmcc committed Feb 2, 2014
1 parent dd7824a commit f465a0a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Superuser/jni/su/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions Superuser/jni/su/su.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Superuser/jni/su/su.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit f465a0a

Please sign in to comment.