Isolate nested IPC sockets and define session ownership policy
This commit is contained in:
1 parent
97026a0db7
commit
ce024d4794
42 files changed
+635
-147
No files matched your search
@@ -221,7 +221,9 @@ async fn session_subject(
|
||||
connection: &zbus::Connection,
|
||||
) -> Result<(String, HashMap<String, Value<'static>>), Box<dyn std::error::Error>> {
|
||||
// Nested previews must not take over authentication for the host desktop.
|
||||
if std::env::var("FERESE_SESSION_IMPORT_ENV").as_deref() == Ok("0") {
|
||||
if std::env::var("FERESE_SESSION_MODE").as_deref() == Ok("embedded")
|
||||
|| std::env::var("FERESE_SESSION_IMPORT_ENV").as_deref() == Ok("0")
|
||||
{
|
||||
return process_subject().map_err(Into::into);
|
||||
}
|
||||
let manager = zbus::Proxy::new(
|
||||
|
||||
@@ -228,11 +228,10 @@ fn save_with(
|
||||
|
||||
pub fn reload_running() -> bool {
|
||||
use ferese_ipc::{Request, Response, VERSION, read_frame, write_frame};
|
||||
let Some(runtime) = std::env::var_os("XDG_RUNTIME_DIR") else {
|
||||
let Ok(path) = ferese_ipc::socket::resolve(None) else {
|
||||
return false;
|
||||
};
|
||||
let Ok(mut socket) = std::os::unix::net::UnixStream::connect(PathBuf::from(runtime).join("ferese/control.sock"))
|
||||
else {
|
||||
let Ok(mut socket) = std::os::unix::net::UnixStream::connect(path) else {
|
||||
return false;
|
||||
};
|
||||
let _ = socket.set_read_timeout(Some(Duration::from_secs(2)));
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use std::os::unix::net::UnixStream;
|
||||
use std::path::PathBuf;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use serde_json::{Value, json};
|
||||
@@ -15,10 +14,7 @@ struct SessionConnection {
|
||||
|
||||
impl SessionConnection {
|
||||
fn connect() -> Result<Self, String> {
|
||||
let path = std::env::var_os("XDG_RUNTIME_DIR")
|
||||
.map(PathBuf::from)
|
||||
.ok_or("Missing runtime directory")?
|
||||
.join("ferese/control.sock");
|
||||
let path = ferese_ipc::socket::resolve(None).map_err(|error| error.to_string())?;
|
||||
let stream = UnixStream::connect(path).map_err(|error| error.to_string())?;
|
||||
stream
|
||||
.set_read_timeout(Some(Duration::from_secs(2)))
|
||||
|
||||
Reference in new issue
Block a user