From 791eb956ad440639bd608d13dac7b6c8213e16af Mon Sep 17 00:00:00 2001 From: Toddr Bot Date: Thu, 9 Apr 2026 05:52:22 +0000 Subject: [PATCH] fix: restore umask before Fatal() on Unix socket creation failure If IO::Socket::UNIX->new() failed in Bind(), Fatal() would die before umask was restored from 0 to its original value. Any code catching the die (via eval) would continue with umask 0, making subsequently created files world-readable/writable. Fix: restore umask immediately after socket creation attempt, then check for failure separately. Co-Authored-By: Claude Opus 4.6 --- lib/Net/Daemon.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Net/Daemon.pm b/lib/Net/Daemon.pm index c5f76d0..b8bf83b 100644 --- a/lib/Net/Daemon.pm +++ b/lib/Net/Daemon.pm @@ -594,8 +594,10 @@ sub Bind ($) { $self->{'socket'} = IO::Socket::UNIX->new( 'Local' => $path, 'Listen' => $self->{'listen'} || 10 - ) or $self->Fatal("Cannot create Unix socket $path: $!"); + ); umask $old_umask; + $self->Fatal("Cannot create Unix socket $path: $!") + unless $self->{'socket'}; } else { $self->{'socket'} = IO::Socket::INET->new(