GeezerVison is showing github.com — fix: 修复无法注入su到第二个进程 · RASSec/SKRoot-linuxKernelRoot@adcb704
File tree
Expand file treeCollapse file tree
Open diff view settings
PermissionManager/app/src/main/cpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: PermissionManager/app/src/main/cpp/root.cpp +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -236,7 +236,7 @@ Java_com_linux_permissionmanager_MainActivity_autoSuEnvInject( |
236 | 236 | } |
237 | 237 | std::string kill_cmd; |
238 | 238 | for (pid_t t : vOut) { |
239 | | - err = kill_process(strRootKey.c_str(), t); |
| 239 | + err = safe_kill_process(strRootKey.c_str(), t); |
240 | 240 | sstr << "kill_ret err:"<< err << std::endl; |
241 | 241 | if (err != 0) { |
242 | 242 | return env->NewStringUTF(sstr.str().c_str()); |
|
Collapse file
Copy file name to clipboardExpand all lines: testRoot/su_install_helper.cpp +12-9Lines changed: 12 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -91,15 +91,18 @@ std::string install_su(const char* str_root_key, const char* base_path, const ch |
91 | 91 | return {}; |
92 | 92 | } |
93 | 93 | 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 | + } |
103 | 106 | } |
104 | 107 | err = 0; |
105 | 108 | return su_hide_full_path; |
|