config: allow running commands privileged
This commit is contained in:
parent
4558bdb7c1
commit
affea49e49
11 changed files with 74 additions and 5 deletions
|
|
@ -944,6 +944,12 @@ impl Client {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn get_socket_path(&self) -> Option<String> {
|
||||
let res = self.send_with_response(&ClientMessage::GetSocketPath);
|
||||
get_response!(res, None, GetSocketPath { path });
|
||||
Some(path)
|
||||
}
|
||||
|
||||
pub fn create_pollable(&self, fd: i32) -> Result<PollableId, String> {
|
||||
let res = self.send_with_response(&ClientMessage::AddPollable { fd });
|
||||
get_response!(
|
||||
|
|
|
|||
|
|
@ -431,6 +431,7 @@ pub enum ClientMessage<'a> {
|
|||
SetExplicitSyncEnabled {
|
||||
enabled: bool,
|
||||
},
|
||||
GetSocketPath,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
|
@ -576,6 +577,9 @@ pub enum Response {
|
|||
GetInputDeviceDevnode {
|
||||
devnode: String,
|
||||
},
|
||||
GetSocketPath {
|
||||
path: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
|
|
|||
|
|
@ -82,6 +82,21 @@ impl Command {
|
|||
self.fd(2, fd)
|
||||
}
|
||||
|
||||
/// Runs the application with access to privileged wayland protocols.
|
||||
///
|
||||
/// The default is `false`.
|
||||
pub fn privileged(&mut self) -> &mut Self {
|
||||
match get!(self).get_socket_path() {
|
||||
Some(path) => {
|
||||
self.env("WAYLAND_DISPLAY", &format!("{path}.jay"));
|
||||
}
|
||||
_ => {
|
||||
log::error!("Compositor did not send the socket path");
|
||||
}
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// Executes the command.
|
||||
///
|
||||
/// This consumes all attached file descriptors.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue