From a77198ea602722f9baa81c9958de0fa93b35bf61 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 9 Oct 2026 07:16:48 +0000 Subject: [PATCH] su: do not notify app when UID has no policy With reactive su prompting removed, root requests from UIDs without an existing policy in the database are rejected immediately. Previously, RootSettings defaulted log and notify to true, causing the daemon to notify the manager app whenever an unconfigured UID attempted to run su. Derive Default for RootSettings so that policy defaults to Deny with log and notify initialized to false, preventing unwanted notifications to the app when no database policy exists. Also simplify SuInfo::allow and SuInfo::deny to leverage Default. Assisted-by: Gemini 3.8 Flash --- native/src/core/su/daemon.rs | 9 +-------- native/src/core/su/db.rs | 12 +----------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/native/src/core/su/daemon.rs b/native/src/core/su/daemon.rs index 02dc2ef8d..a782a831f 100644 --- a/native/src/core/su/daemon.rs +++ b/native/src/core/su/daemon.rs @@ -53,8 +53,7 @@ impl SuInfo { fn allow(uid: i32) -> SuInfo { let settings = RootSettings { policy: SuPolicy::Allow, - log: false, - notify: false, + ..Default::default() }; SuInfo { uid, @@ -64,14 +63,8 @@ impl SuInfo { } fn deny(uid: i32) -> SuInfo { - let settings = RootSettings { - policy: SuPolicy::Deny, - log: false, - notify: false, - }; SuInfo { uid, - settings, ..Default::default() } } diff --git a/native/src/core/su/db.rs b/native/src/core/su/db.rs index 9ef6c842d..e491c903b 100644 --- a/native/src/core/su/db.rs +++ b/native/src/core/su/db.rs @@ -12,23 +12,13 @@ impl Default for SuPolicy { } } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Default)] pub struct RootSettings { pub policy: SuPolicy, pub log: bool, pub notify: bool, } -impl Default for RootSettings { - fn default() -> Self { - RootSettings { - policy: SuPolicy::Deny, - log: true, - notify: true, - } - } -} - impl SqlTable for RootSettings { fn on_row(&mut self, columns: &[String], values: &DbValues) { for (i, column) in columns.iter().enumerate() {