Code

gosa-si-server: early prepare UID / GID as daemon_log needs it
[gosa.git] / trunk / gosa-si / gosa-si-server
index 9191d3e858a580cc590816c1af73351ee606f9e7..b3b48e6709017711047dfa4ff405067f66eab402 100755 (executable)
@@ -28,7 +28,7 @@ use Getopt::Long;
 use Config::IniFiles;
 use POSIX;
 
-use Fcntl;
+use Fcntl qw/:flock/;
 use IO::Socket::INET;
 use IO::Handle;
 use IO::Select;
@@ -352,7 +352,10 @@ sub daemon_log {
             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;
             }
@@ -607,7 +610,7 @@ sub check_outgoing_xml_validity {
         }
 
                                # 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+$/) {
@@ -3201,6 +3204,10 @@ GetOptions("h|help" => \&usage,
         "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);
@@ -3248,8 +3255,6 @@ if ($server_headURL =~ /\/tag\// ||
 }
 
 # Prepare log file and set permissons
-$root_uid = getpwnam('root');
-$adm_gid = getgrnam('adm');
 open(FH, ">>$log_file");
 close FH;
 chmod(0440, $log_file);