index 9191d3e858a580cc590816c1af73351ee606f9e7..b3b48e6709017711047dfa4ff405067f66eab402 100755 (executable)
use Config::IniFiles;
use POSIX;
-use Fcntl;
+use Fcntl qw/:flock/;
use IO::Socket::INET;
use IO::Handle;
use IO::Select;
my $name = $prg;
my $log_msg = "$month $monthday $hours:$minutes:$seconds $name $msg\n";
+ flock(LOG_HANDLE, LOCK_EX);
+ seek(LOG_HANDLE, 0, 2);
print LOG_HANDLE $log_msg;
+ flock(LOG_HANDLE, LOCK_UN);
if( $foreground ) {
print STDERR $log_msg;
}
}
# Check if source contains hostname instead of ip address
- if(not $source =~ /^[a-z0-9\.]+:\d+$/i) {
+ if($source =~ /^[a-z][a-z0-9\.]+:\d+$/i) {
my ($hostname,$port) = split(/:/, $source);
my $ip_address = inet_ntoa(scalar gethostbyname($hostname));
if(defined($ip_address) && $ip_address =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ && $port =~ /^\d+$/) {
"no-arp+" => \$no_arp,
);
+# Prepare UID / GID as daemon_log may need it quite early
+$root_uid = getpwnam('root');
+$adm_gid = getgrnam('adm');
+
# read and set config parameters
&check_cmdline_param ;
&read_configfile($cfg_file, %cfg_defaults);
}
# Prepare log file and set permissons
-$root_uid = getpwnam('root');
-$adm_gid = getgrnam('adm');
open(FH, ">>$log_file");
close FH;
chmod(0440, $log_file);