@@ -508,11 +508,10 @@ pub async fn run_server(config: Config) -> anyhow::Result<()> {
508508
509509 // Remove existing socket if it exists
510510 if Path :: new ( DAEMON_SOCKET_PATH ) . exists ( ) {
511+ debug ! ( "Removing existing socket file at {DAEMON_SOCKET_PATH}" ) ;
511512 fs:: remove_file ( DAEMON_SOCKET_PATH ) ?;
512513 }
513514
514- let uds = UnixListener :: bind ( DAEMON_SOCKET_PATH ) ?;
515-
516515 // change owner group for socket file
517516 // get the group ID by name
518517 let group = Group :: from_name ( DAEMON_SOCKET_GROUP ) ?. ok_or_else ( || {
@@ -521,12 +520,16 @@ pub async fn run_server(config: Config) -> anyhow::Result<()> {
521520 } ) ?;
522521
523522 // change ownership - keep current user, change group
523+ debug ! ( "Changing owner group of socket file at {DAEMON_SOCKET_PATH} to group {DAEMON_SOCKET_GROUP}" ) ;
524524 chown ( DAEMON_SOCKET_PATH , None , Some ( group. gid ) ) ?;
525525
526526 // Set socket permissions to allow client access
527527 // 0o660 allows read/write for owner and group only
528+ debug ! ( "Setting permissions for socket file at {DAEMON_SOCKET_PATH} to 0x660" ) ;
528529 fs:: set_permissions ( DAEMON_SOCKET_PATH , fs:: Permissions :: from_mode ( 0o660 ) ) ?;
529530
531+ debug ! ( "Binding socket file at {DAEMON_SOCKET_PATH}" ) ;
532+ let uds = UnixListener :: bind ( DAEMON_SOCKET_PATH ) ?;
530533 let uds_stream = UnixListenerStream :: new ( uds) ;
531534
532535 info ! ( "Defguard daemon version {VERSION} started, listening on socket {DAEMON_SOCKET_PATH}" , ) ;
0 commit comments