Add security context protocol

Currently, excludes some protocols if they have any security context
associated.
This commit is contained in:
Ian Douglas Scott 2023-08-29 17:00:11 -07:00
parent c68625ff78
commit 8dce518ba6
4 changed files with 54 additions and 6 deletions

View file

@ -16,6 +16,7 @@ pub mod primary_selection;
pub mod relative_pointer;
pub mod screencopy;
pub mod seat;
pub mod security_context;
pub mod shm;
pub mod toplevel_info;
pub mod toplevel_management;

View file

@ -0,0 +1,33 @@
use crate::state::{ClientState, State};
use smithay::{
delegate_security_context,
wayland::security_context::{
SecurityContext, SecurityContextHandler, SecurityContextListenerSource,
},
};
use std::sync::Arc;
use tracing::warn;
impl SecurityContextHandler for State {
fn context_created(
&mut self,
source: SecurityContextListenerSource,
security_context: SecurityContext,
) {
self.common
.event_loop_handle
.insert_source(source, move |client_stream, _, data| {
if let Err(err) = data.display.handle().insert_client(
client_stream,
Arc::new(ClientState {
security_context: Some(security_context.clone()),
..data.state.new_client_state()
}),
) {
warn!(?err, "Error adding wayland client");
};
})
.expect("Failed to init the wayland socket source.");
}
}
delegate_security_context!(State);