config: add uid client criteria
This commit is contained in:
parent
9bf79bf23c
commit
587ffc7ee5
13 changed files with 63 additions and 2 deletions
|
|
@ -1885,6 +1885,7 @@ impl ConfigProxyHandler {
|
|||
}
|
||||
}
|
||||
ClientCriterionIpc::Sandboxed => mgr.sandboxed(),
|
||||
ClientCriterionIpc::Uid(p) => mgr.uid(*p),
|
||||
};
|
||||
let cached = Rc::new(CachedCriterion {
|
||||
crit: criterion.clone(),
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use {
|
|||
clmm_string::{
|
||||
ClmMatchSandboxAppId, ClmMatchSandboxEngine, ClmMatchSandboxInstanceId,
|
||||
},
|
||||
clmm_uid::ClmMatchUid,
|
||||
},
|
||||
crit_graph::{
|
||||
CritMgr, CritRoot, CritRootFixed, CritTarget, CritTargetOwner, WeakCritTargetOwner,
|
||||
|
|
@ -52,6 +53,7 @@ pub struct RootMatchers {
|
|||
sandbox_app_id: ClmRootMatcherMap<ClmMatchSandboxAppId>,
|
||||
sandbox_engine: ClmRootMatcherMap<ClmMatchSandboxEngine>,
|
||||
sandbox_instance_id: ClmRootMatcherMap<ClmMatchSandboxInstanceId>,
|
||||
uid: ClmRootMatcherMap<ClmMatchUid>,
|
||||
}
|
||||
|
||||
pub async fn handle_cl_changes(state: Rc<State>) {
|
||||
|
|
@ -151,6 +153,7 @@ impl ClMatcherManager {
|
|||
unconditional!(sandbox_instance_id);
|
||||
unconditional!(sandbox_app_id);
|
||||
unconditional!(sandbox_engine);
|
||||
unconditional!(uid);
|
||||
fixed!(sandboxed);
|
||||
self.constant[true].handle(data);
|
||||
}
|
||||
|
|
@ -171,6 +174,10 @@ impl ClMatcherManager {
|
|||
pub fn sandboxed(&self) -> Rc<ClmUpstreamNode> {
|
||||
self.sandboxed[true].clone()
|
||||
}
|
||||
|
||||
pub fn uid(&self, pid: i32) -> Rc<ClmUpstreamNode> {
|
||||
self.root(ClmMatchUid(pid as _))
|
||||
}
|
||||
}
|
||||
|
||||
impl CritTarget for Rc<Client> {
|
||||
|
|
|
|||
|
|
@ -19,3 +19,4 @@ macro_rules! fixed_root_criterion {
|
|||
|
||||
pub mod clmm_sandboxed;
|
||||
pub mod clmm_string;
|
||||
pub mod clmm_uid;
|
||||
|
|
|
|||
20
src/criteria/clm/clm_matchers/clmm_uid.rs
Normal file
20
src/criteria/clm/clm_matchers/clmm_uid.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use {
|
||||
crate::{
|
||||
client::Client,
|
||||
criteria::{RootMatcherMap, clm::RootMatchers, crit_graph::CritRootCriterion},
|
||||
},
|
||||
std::rc::Rc,
|
||||
uapi::c,
|
||||
};
|
||||
|
||||
pub struct ClmMatchUid(pub c::uid_t);
|
||||
|
||||
impl CritRootCriterion<Rc<Client>> for ClmMatchUid {
|
||||
fn matches(&self, data: &Rc<Client>) -> bool {
|
||||
data.pid_info.uid == self.0
|
||||
}
|
||||
|
||||
fn nodes(roots: &RootMatchers) -> Option<&RootMatcherMap<Rc<Client>, Self>> {
|
||||
Some(&roots.uid)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue