Skip to content

Commit 453fc63

Browse files
authored
Show default selinux context as untrusted_app (#871)
In the CONFIG_FILE, there is a field for selinux context label. Though this field is not wildely used by APatch or Android modules, it is confusing to have its default always to be `magisk`. For example, if one sets an app to be excluded, then in the file `/data/adb/ap/package_config`, its selinux context is shown to be `u:r:magisk:s0`, which is not reasonable. It is better to use the Android default context for applications to avoid confusions (of module developers who parse this file).
1 parent eb8959b commit 453fc63

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

app/src/main/java/me/bmax/apatch/APatchApp.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class APApplication : Application(), Thread.UncaughtExceptionHandler {
6464
private const val BUSYBOX_BIN_PATH = APATCH_BIN_FOLDER + "busybox"
6565
private const val RESETPROP_BIN_PATH = APATCH_BIN_FOLDER + "resetprop"
6666
private const val MAGISKBOOT_BIN_PATH = APATCH_BIN_FOLDER + "magiskboot"
67+
const val DEFAULT_SCONTEXT = "u:r:untrusted_app:s0"
6768
const val MAGISK_SCONTEXT = "u:r:magisk:s0"
6869

6970
private const val DEFAULT_SU_PATH = "/system/bin/kp"

app/src/main/java/me/bmax/apatch/Natives.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object Natives {
1616
data class Profile(
1717
var uid: Int = 0,
1818
var toUid: Int = 0,
19-
var scontext: String = APApplication.MAGISK_SCONTEXT,
19+
var scontext: String = APApplication.DEFAULT_SCONTEXT,
2020
) : Parcelable
2121

2222
@Keep
@@ -140,4 +140,4 @@ object Natives {
140140
return nativeGetSafeMode(APApplication.superKey)
141141
}
142142

143-
}
143+
}

app/src/main/java/me/bmax/apatch/util/PkgConfig.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ object PkgConfig {
7777
// Root App should not be excluded
7878
if (config.allow == 1) {
7979
config.exclude = 0
80+
config.profile.scontext = APApplication.MAGISK_SCONTEXT
8081
}
8182
if (config.allow == 0 && configs[uid] != null && config.exclude != 0) {
8283
configs.remove(uid)
@@ -88,4 +89,4 @@ object PkgConfig {
8889
}
8990
}
9091
}
91-
}
92+
}

0 commit comments

Comments
 (0)