Skip to content

Commit 991ecd3

Browse files
authored
feat: set permissions for Unix Domain Socket in dfdaemon_download (#981)
Signed-off-by: Gaius <[email protected]>
1 parent 04c71e6 commit 991ecd3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

dragonfly-client/src/grpc/dfdaemon_download.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use dragonfly_client_core::{
4242
};
4343
use dragonfly_client_util::http::{get_range, hashmap_to_headermap, headermap_to_hashmap};
4444
use hyper_util::rt::TokioIo;
45+
use std::os::unix::fs::PermissionsExt;
4546
use std::path::{Path, PathBuf};
4647
use std::sync::Arc;
4748
use std::time::{Duration, Instant};
@@ -124,14 +125,16 @@ impl DfdaemonDownloadServer {
124125

125126
// Start download grpc server with unix domain socket.
126127
fs::create_dir_all(self.socket_path.parent().unwrap()).await?;
127-
128128
if self.socket_path.is_file() {
129129
// Remove the old unix domain socket file if it exists.
130130
fs::remove_file(&self.socket_path).await?;
131131
}
132+
132133
let uds = UnixListener::bind(&self.socket_path)?;
133-
let uds_stream = UnixListenerStream::new(uds);
134+
let perms = std::fs::Permissions::from_mode(0o660);
135+
fs::set_permissions(&self.socket_path, perms).await?;
134136

137+
let uds_stream = UnixListenerStream::new(uds);
135138
let server = Server::builder()
136139
.max_frame_size(super::MAX_FRAME_SIZE)
137140
.tcp_keepalive(Some(super::TCP_KEEPALIVE))

0 commit comments

Comments
 (0)