Skip to content

Commit adcb704

Browse files
unkn0wNameunkn0wName
authored andcommitted
fix: 修复无法注入su到第二个进程
1 parent 0457695 commit adcb704

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

PermissionManager/app/src/main/cpp/root.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ Java_com_linux_permissionmanager_MainActivity_autoSuEnvInject(
236236
}
237237
std::string kill_cmd;
238238
for (pid_t t : vOut) {
239-
err = kill_process(strRootKey.c_str(), t);
239+
err = safe_kill_process(strRootKey.c_str(), t);
240240
sstr << "kill_ret err:"<< err << std::endl;
241241
if (err != 0) {
242242
return env->NewStringUTF(sstr.str().c_str());

testRoot/su_install_helper.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,18 @@ std::string install_su(const char* str_root_key, const char* base_path, const ch
9191
return {};
9292
}
9393
std::string su_hide_full_path = _su_hide_folder_path + "/" + "su";
94-
if (!copy_file(origin_su_full_path, su_hide_full_path.c_str())) {
95-
TRACE("copy file error.\n");
96-
err = -504;
97-
return {};
98-
}
99-
if (!set_file_allow_access_mode(su_hide_full_path.c_str())) {
100-
TRACE("set file allow access mode error.\n");
101-
err = -505;
102-
return {};
94+
//如果存在了就不要理了
95+
if(access(su_hide_full_path.c_str(), F_OK) == -1) {
96+
if (!copy_file(origin_su_full_path, su_hide_full_path.c_str())) {
97+
TRACE("copy file error.\n");
98+
err = -504;
99+
return {};
100+
}
101+
if (!set_file_allow_access_mode(su_hide_full_path.c_str())) {
102+
TRACE("set file allow access mode error.\n");
103+
err = -505;
104+
return {};
105+
}
103106
}
104107
err = 0;
105108
return su_hide_full_path;

0 commit comments

Comments
 (0)