external/koush/Superuser
Revision | a43f033dc9a1472821e57aab76b67b76263c99c4 (tree) |
---|---|
Time | 2013-11-30 02:17:57 |
Author | Koushik Dutta <koushd@gmai...> |
Commiter | Koushik Dutta |
Merge remote-tracking branch 'cern/multiuser-regression-v1' into cm-11.0
Conflicts:
Superuser/jni/su/su.c
Change-Id: I2474f5048e590592e1baa7f4bb1caf76e1245b74
@@ -607,6 +607,28 @@ static int get_api_version() { | ||
607 | 607 | return ver; |
608 | 608 | } |
609 | 609 | |
610 | +static void fork_for_samsung(void) | |
611 | +{ | |
612 | + // Samsung CONFIG_SEC_RESTRICT_SETUID wants the parent process to have | |
613 | + // EUID 0, or else our setresuid() calls will be denied. So make sure | |
614 | + // all such syscalls are executed by a child process. | |
615 | + int rv; | |
616 | + | |
617 | + switch (fork()) { | |
618 | + case 0: | |
619 | + return; | |
620 | + case -1: | |
621 | + PLOGE("fork"); | |
622 | + exit(1); | |
623 | + default: | |
624 | + if (wait(&rv) < 0) { | |
625 | + exit(1); | |
626 | + } else { | |
627 | + exit(WEXITSTATUS(rv)); | |
628 | + } | |
629 | + } | |
630 | +} | |
631 | + | |
610 | 632 | int main(int argc, char *argv[]) { |
611 | 633 | return su_main(argc, argv, 1); |
612 | 634 | } |
@@ -617,6 +639,8 @@ int su_main(int argc, char *argv[], int need_client) { | ||
617 | 639 | return run_daemon(); |
618 | 640 | } |
619 | 641 | |
642 | + fork_for_samsung(); | |
643 | + | |
620 | 644 | // Sanitize all secure environment variables (from linker_environ.c in AOSP linker). |
621 | 645 | /* The same list than GLibc at this point */ |
622 | 646 | static const char* const unsec_vars[] = { |