Skip to content

Commit

Permalink
Allow toggling unmount setting for all apps (#2450)
Browse files Browse the repository at this point in the history
This fixes #2416.
  • Loading branch information
aviraxp authored Feb 18, 2025
1 parent de29115 commit eeffecb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 0 additions & 5 deletions kernel/allowlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@ static bool profile_valid(struct app_profile *profile)
return false;
}

if (forbid_system_uid(profile->current_uid)) {
pr_err("uid lower than 2000 is unsupported: %d\n", profile->current_uid);
return false;
}

if (profile->version < KSU_APP_PROFILE_VER) {
pr_info("Unsupported profile version: %d\n", profile->version);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ fun AppProfileScreen(
val scope = rememberCoroutineScope()
val failToUpdateAppProfile = stringResource(R.string.failed_to_update_app_profile).format(appInfo.label)
val failToUpdateSepolicy = stringResource(R.string.failed_to_update_sepolicy).format(appInfo.label)
val suNotAllowed = stringResource(R.string.su_not_allowed).format(appInfo.label)

val packageName = appInfo.packageName
val initialProfile = Natives.getAppProfile(packageName, appInfo.uid)
Expand Down Expand Up @@ -143,8 +144,13 @@ fun AppProfileScreen(
},
onProfileChange = {
scope.launch {
if (it.allowSu && !it.rootUseDefault && it.rules.isNotEmpty()) {
if (!setSepolicy(profile.name, it.rules)) {
if (it.allowSu) {
// sync with allowlist.c - forbid_system_uid
if (appInfo.uid < 2000 && appInfo.uid != 1000) {
snackBarHost.showSnackbar(suNotAllowed)
return@launch
}
if (!it.rootUseDefault && it.rules.isNotEmpty() && !setSepolicy(profile.name, it.rules)) {
snackBarHost.showSnackbar(failToUpdateSepolicy)
return@launch
}
Expand Down
1 change: 1 addition & 0 deletions manager/app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<string name="force_stop_app">强制停止</string>
<string name="restart_app">重新启动</string>
<string name="failed_to_update_sepolicy">为:%s 更新翻译失败</string>
<string name="su_not_allowed">不允许授予:%s 超级用户权限</string>
<string name="module_changelog">更新日志</string>
<string name="settings_profile_template">App Profile 模版</string>
<string name="settings_profile_template_summary">管理本地和在线的 App Profile 模版</string>
Expand Down
1 change: 1 addition & 0 deletions manager/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<string name="force_stop_app">Force stop</string>
<string name="restart_app">Restart</string>
<string name="failed_to_update_sepolicy">Failed to update SELinux rules for %s</string>
<string name="su_not_allowed">Granting superuser to %s is not allowed</string>
<string name="module_changelog">Changelog</string>
<string name="settings_profile_template">App Profile Template</string>
<string name="settings_profile_template_summary">Manage local and online template of App Profile</string>
Expand Down

0 comments on commit eeffecb

Please sign in to comment.