int main(int argc, char *argv[]) { struct libmnt_context *cxt; int rc; mnt_init_debug(0); cxt = mnt_new_context(); if (!cxt) { nfs_error(_("Can't initilize libmount: %s"), strerror(errno)); rc = EX_FAIL; goto done; } progname = basename(argv[0]); nfs_mount_data_version = discover_nfs_mount_data_version(&string); if(strncmp(progname, "umount", 6) == 0) rc = umount_main(cxt, argc, argv); else rc = mount_main(cxt, argc, argv); done: mnt_free_context(cxt); return rc; }
int main(int argc, char** argv) { char* hijacked_executable = argv[0]; struct stat info; if (NULL != strstr(hijacked_executable, "hijack")) { // no op if (argc >= 2) { if (strcmp("sh", argv[1]) == 0) { return ash_main(argc - 1, argv + 1); } if (strcmp("mount", argv[1]) == 0) { return mount_main(argc - 1, argv + 1); } if (strcmp("umount", argv[1]) == 0) { return umount_main(argc - 1, argv + 1); } } return 0; } // check to see if hijack was already run, and if so, just continue on. if (argc >= 3 && 0 == strcmp(argv[2], "preinstall")) { if (0 == stat(RECOVERY_MODE_FILE, &info)) { // don't boot into recovery again remove(RECOVERY_MODE_FILE); remount_root(); mkdir("/tmp", S_IRWXU); mkdir("/res", S_IRWXU); mkdir("/res/images", S_IRWXU); remove("/etc"); mkdir("/etc", S_IRWXU); rename("/sbin/adbd", "/sbin/adbd.old"); property_set("ctl.stop", "runtime"); property_set("ctl.stop", "zygote"); property_set("persist.service.adb.enable", "1"); // this will prevent hijack from being called again char* umount_args[] = { "/system/bin/hijack", "umount", "-l", "/system", NULL }; exec_and_wait(umount_args); char* updater_args[] = { UPDATE_BINARY, "2", "0", UPDATE_PACKAGE, NULL }; return exec_and_wait(updater_args); } // mark it in case we don't boot mark_file(RECOVERY_MODE_FILE); } char real_executable[PATH_MAX]; sprintf(real_executable, "%s.bin", hijacked_executable); string* argp = (string*)malloc(sizeof(string) * (argc + 1)); int i; for (i = 0; i < argc; i++) { argp[i]=argv[i]; } argp[argc] = NULL; argp[0] = real_executable; // should clean up memory leaks, but it really doesn't matter since the process immediately exits. return exec_and_wait(argp); }