security_context: Inherit privileged-flag for panel
This commit is contained in:
parent
afffcce548
commit
f0d5ac1c8d
1 changed files with 30 additions and 0 deletions
|
|
@ -1,9 +1,11 @@
|
|||
use crate::state::{ClientState, State};
|
||||
use smithay::{
|
||||
backend::drm::DrmNode,
|
||||
delegate_security_context,
|
||||
wayland::security_context::{
|
||||
SecurityContext, SecurityContextHandler, SecurityContextListenerSource,
|
||||
},
|
||||
xwayland::XWaylandClientData,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use tracing::warn;
|
||||
|
|
@ -17,10 +19,38 @@ impl SecurityContextHandler for State {
|
|||
self.common
|
||||
.event_loop_handle
|
||||
.insert_source(source, move |client_stream, _, state| {
|
||||
let client_data = state
|
||||
.common
|
||||
.display_handle
|
||||
.backend_handle()
|
||||
.get_client_data(security_context.creator_client_id.clone())
|
||||
.ok();
|
||||
|
||||
let privileged = client_data
|
||||
.as_ref()
|
||||
.and_then(|data| data.downcast_ref::<ClientState>())
|
||||
.map(|data| data.privileged)
|
||||
.unwrap_or(false);
|
||||
|
||||
let drm_node = client_data
|
||||
.as_ref()
|
||||
.and_then(|data| data.downcast_ref::<ClientState>())
|
||||
.and_then(|data| data.drm_node.clone())
|
||||
.or_else(|| {
|
||||
client_data
|
||||
.as_ref()
|
||||
.and_then(|data| data.downcast_ref::<XWaylandClientData>())
|
||||
.and_then(|data| data.user_data().get::<DrmNode>().cloned())
|
||||
});
|
||||
|
||||
if let Err(err) = state.common.display_handle.insert_client(
|
||||
client_stream,
|
||||
Arc::new(ClientState {
|
||||
security_context: Some(security_context.clone()),
|
||||
privileged: privileged
|
||||
&& security_context.sandbox_engine.as_deref()
|
||||
== Some("com.system76.CosmicPanel"),
|
||||
drm_node,
|
||||
..state.new_client_state()
|
||||
}),
|
||||
) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue