mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-04 19:10:47 -05:00
Fix HSUM su policy lookup and manager tracking
Normalize system and shared-UID (< 10000) processes to their app ID when evaluating su policies and uid_granted_root so policies stored by PolicyDao.normalizeUid match across non-zero users on HSUM devices. - Normalize eval_uid in build_su_info and uid in uid_granted_root when app_id < AID_APP_START. - Ensure SECURE_DIR exists before writing settings in boot_complete(), seed SuMultiuserMode on HSUM, and check isHeadlessSystemUser in Info.showSuperUser. - Normalize UID comparisons in PackageManager.getPackageInfo(uid, pid). - Simplify ManagerInfo to track a single TrackedFile instead of a per-user BTreeMap. - Skip negative parse_int results in deny collect_users. Assisted-by: Gemini 4 Argon
This commit is contained in:
@@ -68,7 +68,7 @@ object Info {
|
||||
val isConnected = MutableLiveData(false)
|
||||
|
||||
val showSuperUser: Boolean get() {
|
||||
return env.isActive && (Const.USER_ID == 0
|
||||
return env.isActive && (Const.USER_ID == 0 || isHeadlessSystemUser
|
||||
|| Config.suMultiuserMode == Config.Value.MULTIUSER_MODE_USER)
|
||||
}
|
||||
|
||||
|
||||
@@ -108,13 +108,13 @@ fun PackageManager.getPackageInfo(uid: Int, pid: Int): PackageInfo? {
|
||||
// Try to find package name from PID
|
||||
val proc = RootUtils.getAppProcess(pid)
|
||||
if (proc == null) {
|
||||
if (uid == Process.SHELL_UID) {
|
||||
if (PolicyDao.normalizeUid(uid) == Process.SHELL_UID) {
|
||||
// It is possible that some apps installed are sharing UID with shell.
|
||||
// We will not be able to find a package from the active process list,
|
||||
// because the client is forked from ADB shell, not any app process.
|
||||
return getPackageInfo("com.android.shell", flag)
|
||||
}
|
||||
} else if (uid == proc.uid) {
|
||||
} else if (PolicyDao.normalizeUid(uid) == PolicyDao.normalizeUid(proc.uid)) {
|
||||
return getPackageInfo(proc.pkgList[0], flag)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user