Improve compatibility and remove unnecessary fork

This commit is contained in:
topjohnwu 2017-02-04 17:36:45 +08:00
parent 0cf13f6393
commit f269695d4a

17
su.c
View File

@ -621,6 +621,9 @@ int su_main(int argc, char *argv[]) {
int su_main_nodaemon(int argc, char **argv) {
int ppid = getppid();
// Only fork when not running in daemon mode (already forked from daemon)
if (! is_daemon)
fork_for_samsung();
// Sanitize all secure environment variables (from linker_environ.c in AOSP linker).
@ -665,14 +668,12 @@ int su_main_nodaemon(int argc, char **argv) {
LOGD("su invoked.");
//Chainfire compatibility
if(argc >= 3 && (
strcmp(argv[1], "-cn") == 0 ||
strcmp(argv[1], "--context") == 0
)) {
argc-=2;
argv+=2;
// Replace -cn with z, for CF compatibility
for (int i = 0; i < argc; ++i) {
if (strcmp(argv[i], "-cn") == 0) {
strcpy(argv[i], "-z");
break;
}
}
struct su_context ctx = {