Commit f269695d authored by topjohnwu's avatar topjohnwu

Improve compatibility and remove unnecessary fork

parent 0cf13f63
......@@ -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 = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment