Skip to content

Commit 6f60d66

Browse files
committed
fix: add umask handling in create_ipc_server for Unix compatibility
1 parent ae1d4ff commit 6f60d66

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

src/core/server.rs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,31 @@ async fn init_ipc_state() -> Result<()> {
124124

125125
fn create_ipc_server() -> Result<IpcHttpServer> {
126126
use crate::IPC_PATH;
127-
#[cfg(unix)]
128-
use platform_lib::{S_IRWXG, S_IRWXO, S_IRWXU, mode_t};
127+
129128
let server = IpcHttpServer::new(IPC_PATH)?;
129+
130130
#[cfg(unix)]
131-
let mode: mode_t = platform_lib::mode_t::from(S_IRWXU | S_IRWXG | S_IRWXO);
132-
#[cfg(unix)]
133-
let server = server.with_listener_mode(mode);
134-
#[cfg(windows)]
135-
let server = server.with_listener_security_descriptor("D:(A;;GA;;;WD)");
131+
{
132+
use platform_lib::{S_IRWXG, S_IRWXO, S_IRWXU, mode_t, umask};
136133

137-
Ok(server)
138-
}
134+
let old_mask: mode_t;
135+
unsafe {
136+
old_mask = umask(0);
137+
}
138+
let mode: mode_t = platform_lib::mode_t::from(S_IRWXU | S_IRWXG | S_IRWXO);
139+
let server = server.with_listener_mode(mode);
140+
unsafe {
141+
umask(old_mask);
142+
}
143+
Ok(server)
144+
}
139145

146+
#[cfg(windows)]
147+
{
148+
let server = server.with_listener_security_descriptor("D:(A;;GA;;;WD)");
149+
Ok(server)
150+
}
151+
}
140152
fn create_ipc_router() -> Result<Router> {
141153
let router = Router::new()
142154
.get(IpcCommand::Magic.as_ref(), |_| async move {

0 commit comments

Comments
 (0)