wayland: prevent unprivileged clients from binding secure globals
This commit is contained in:
parent
6c9e058c3f
commit
1e9cc60693
2 changed files with 13 additions and 7 deletions
|
|
@ -174,8 +174,16 @@ impl Globals {
|
|||
self.broadcast(state, global.secure(), |r| r.send_global(&global));
|
||||
}
|
||||
|
||||
pub fn get(&self, name: GlobalName) -> Result<Rc<dyn Global>, GlobalsError> {
|
||||
self.take(name, false)
|
||||
pub fn get(
|
||||
&self,
|
||||
name: GlobalName,
|
||||
allow_secure: bool,
|
||||
) -> Result<Rc<dyn Global>, GlobalsError> {
|
||||
let global = self.take(name, false)?;
|
||||
if global.secure() && !allow_secure {
|
||||
return Err(GlobalsError::GlobalDoesNotExist(name));
|
||||
}
|
||||
Ok(global)
|
||||
}
|
||||
|
||||
pub fn remove<T: WaylandGlobal>(&self, state: &State, global: &T) -> Result<(), GlobalsError> {
|
||||
|
|
|
|||
|
|
@ -44,11 +44,9 @@ impl WlRegistry {
|
|||
|
||||
fn bind(&self, parser: MsgParser<'_, '_>) -> Result<(), WlRegistryError> {
|
||||
let bind: Bind = self.client.parse(self, parser)?;
|
||||
let global = self
|
||||
.client
|
||||
.state
|
||||
.globals
|
||||
.get(GlobalName::from_raw(bind.name))?;
|
||||
let name = GlobalName::from_raw(bind.name);
|
||||
let globals = &self.client.state.globals;
|
||||
let global = globals.get(name, self.client.secure)?;
|
||||
if global.interface().name() != bind.interface {
|
||||
return Err(WlRegistryError::InvalidInterface(InterfaceError {
|
||||
name: global.name(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue