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
This commit is contained in:
topjohnwu
2026-10-09 07:16:48 +00:00
parent 79bf48d768
commit a77198ea60
2 changed files with 2 additions and 19 deletions
+1 -8
View File
@@ -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()
}
}
+1 -11
View File
@@ -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() {