Skip to content

Commit 36c5522

Browse files
authored
Merge pull request #93 from pylerSM/patch-16
Fixed wrapping on LP and newer
2 parents 0a9c953 + 54fa570 commit 36c5522

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

app/src/main/java/com/devadvance/rootcloak2/NativeRootDetectionReceiver.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.content.SharedPreferences;
77
import android.content.pm.ApplicationInfo;
88
import android.content.pm.PackageManager;
9+
import android.os.Build;
910
import android.preference.PreferenceManager;
1011

1112
import java.io.File;
@@ -40,6 +41,7 @@ public void onReceive(Context context, Intent intent) {
4041
if (Common.REFRESH_APPS_INTENT.equals(intent.getAction())) {
4142
resetNativeHooks(context);
4243
}
44+
4345
applyNativeHooks(context);
4446
}
4547

@@ -56,10 +58,16 @@ private void applyNativeHooks(Context context) {
5658
mRootShell.runCommand("am force-stop " + app);
5759
}
5860

59-
if (libraryInstalled) {
61+
if (libraryInstalled && !nativeHookingApps.isEmpty()) {
6062
mRootShell.runCommand("chmod 755 /data/local/");
6163
mRootShell.runCommand("chmod 755 /data/local/librootcloak.so");
6264
mRootShell.runCommand("chmod 755 /data/local/rootcloak-wrapper.sh");
65+
66+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
67+
// Allowing wrapping on Lollipop and newer
68+
WrappingSELinuxPolicy policy = new WrappingSELinuxPolicy();
69+
policy.inject();
70+
}
6371
}
6472
}
6573

@@ -105,6 +113,13 @@ private void upgradeLibrary(Context context) {
105113
mRootShell.runCommand("cp '" + library + "' /data/local/");
106114
mRootShell.runCommand("chmod 755 /data/local/librootcloak.so");
107115
}
108-
109-
116+
117+
private class WrappingSELinuxPolicy extends eu.chainfire.libsuperuser.Policy {
118+
@Override
119+
protected String[] getPolicies() {
120+
return new String[]{
121+
"allow untrusted_app zygote fifo_file { write }"
122+
};
123+
}
124+
}
110125
}

0 commit comments

Comments
 (0)