refactor: improve socket security
This commit is contained in:
parent
47bed52851
commit
aeeb17abd0
1 changed files with 7 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::os::unix::fs::PermissionsExt;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::atomic::Ordering::SeqCst;
|
use std::sync::atomic::Ordering::SeqCst;
|
||||||
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
|
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
|
||||||
|
@ -59,6 +60,12 @@ async fn config_reloader(notify: Arc<Notify>) {
|
||||||
|
|
||||||
async fn socket_server(disabled: Arc<AtomicBool>, notify: Arc<Notify>) {
|
async fn socket_server(disabled: Arc<AtomicBool>, notify: Arc<Notify>) {
|
||||||
let listener = UnixListener::bind(SOCKET_PATH).expect("Failed to bind socket");
|
let listener = UnixListener::bind(SOCKET_PATH).expect("Failed to bind socket");
|
||||||
|
|
||||||
|
match std::fs::set_permissions(SOCKET_PATH, std::fs::Permissions::from_mode(0o600)) {
|
||||||
|
Ok(_) => trace!("socket file permissions set"),
|
||||||
|
Err(e) => error!("Failed to set socket file permissions: {e}"),
|
||||||
|
};
|
||||||
|
|
||||||
trace!("socket server bound");
|
trace!("socket server bound");
|
||||||
let notification: NotifyState =
|
let notification: NotifyState =
|
||||||
match hinoirisetr::notify::InitializedNotificationSystem::new("hinoirisetr") {
|
match hinoirisetr::notify::InitializedNotificationSystem::new("hinoirisetr") {
|
||||||
|
|
Loading…
Reference in a new issue