X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-si%2Fgosa-si-server;h=1e56d7ce7066ed3b9cdf0f9ae743cc7880d81eb5;hb=a8f51a95512d866636a6e559a0ab23a5181d8a3f;hp=cf721b234e522445a3ea15a6620e99fe85123e09;hpb=92465e27fd6ff7df7919cd2418d10dec8f66a482;p=gosa.git diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index cf721b234..1e56d7ce7 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -20,8 +20,6 @@ # REVISION: --- #=============================================================================== -my $server_version = '$HeadURL: https://oss.gonicus.de/repositories/gosa/trunk/gosa-si/gosa-si-server $:$Rev$'; - use strict; use warnings; use Getopt::Long; @@ -51,6 +49,7 @@ use POE qw(Component::Server::TCP Wheel::Run Filter::Reference); use Net::LDAP; use Net::LDAP::Util qw(:escape); +my $server_version = '$HeadURL: https://oss.gonicus.de/repositories/gosa/trunk/gosa-si/gosa-si-server $:$Rev$'; # revision number of server and program name my $server_headURL; @@ -455,28 +454,28 @@ sub check_cmdline_param () { sub check_pid { $pid = -1; # Check, if we are already running - if( open(LOCK_FILE, "<$pid_file") ) { - $pid = ; + if( open( my $LOCK_FILE, "<", "$pid_file" ) ) { + $pid = <$LOCK_FILE>; if( defined $pid ) { chomp( $pid ); if( -f "/proc/$pid/stat" ) { my($stat) = `cat /proc/$pid/stat` =~ m/$pid \((.+)\).*/; if( $stat ) { print STDERR "\nERROR: Already running!\n"; - close( LOCK_FILE ); + close( $LOCK_FILE ); exit -1; } } } - close( LOCK_FILE ); + close( $LOCK_FILE ); unlink( $pid_file ); } # create a syslog msg if it is not to possible to open PID file - if (not sysopen(LOCK_FILE, $pid_file, O_WRONLY|O_CREAT|O_EXCL, 0644)) { + if (not sysopen(my $LOCK_FILE, $pid_file, O_WRONLY|O_CREAT|O_EXCL, 0644)) { my($msg) = "Couldn't obtain lockfile '$pid_file' "; - if (open(LOCK_FILE, '<', $pid_file) - && ($pid = )) + if (open(my $LOCK_FILE, '<', $pid_file) + && ($pid = <$LOCK_FILE>)) { chomp($pid); $msg .= "(PID $pid)\n"; @@ -2880,8 +2879,7 @@ sub create_sources_list { &main::daemon_log("$session_id DEBUG: remove an old version of '$result'", 7); } - my $fh; - open($fh, ">$result"); + open(my $fh, ">", "$result"); if (not defined $fh) { &main::daemon_log("$session_id DEBUG: cannot open '$result' for writing", 7); return undef; @@ -2964,14 +2962,14 @@ sub create_packages_list_db { my $line; - open(CONFIG, "<$sources_file") or do { + open(my $CONFIG, "<", "$sources_file") or do { daemon_log( "$session_id ERROR: create_packages_list_db: Failed to open '$sources_file'", 1); unlink($packages_list_under_construction); return; }; # Read lines - while ($line = ){ + while ($line = <$CONFIG>){ # Unify chop($line); $line =~ s/^\s+//; @@ -2998,7 +2996,7 @@ sub create_packages_list_db { } } - close (CONFIG); + close ($CONFIG); if(keys(%repo_dirs)) { find(\&cleanup_and_extract, keys( %repo_dirs )); @@ -3186,7 +3184,6 @@ sub parse_package { my ($path, $dist, $srv_path, $session_id)= @_; if (not defined $session_id) { $session_id = 0;} my ($package, $version, $section, $description); - my $PACKAGES; my $timestamp = &get_time(); if(not stat("$path.in")) { @@ -3194,7 +3191,7 @@ sub parse_package { return; } - open($PACKAGES, "<$path.in"); + open(my $PACKAGES, "<", "$path.in"); if(not defined($PACKAGES)) { daemon_log("$session_id ERROR: create_packages_list_db: parse_package: cannot open '$path.in'",1); return; @@ -3285,9 +3282,9 @@ sub cleanup_and_extract { my $tmpl= ""; { local $/=undef; - open FILE, "$dir/DEBIAN/templates"; - $tmpl = &encode_base64(); - close FILE; + open(my $FILE, "$dir/DEBIAN/templates"); + $tmpl = &encode_base64(<$FILE>); + close($FILE); } rmtree("$dir/DEBIAN/templates"); @@ -3497,9 +3494,9 @@ if( ! $foreground ) { # Do something useful - put our PID into the pid_file if( 0 != $pid ) { - open( LOCK_FILE, ">$pid_file" ); - print LOCK_FILE "$pid\n"; - close( LOCK_FILE ); + open( my $LOCK_FILE, ">", "$pid_file" ); + print $LOCK_FILE "$pid\n"; + close( $LOCK_FILE ); if( !$foreground ) { exit( 0 ) }; @@ -3519,8 +3516,8 @@ if ($server_headURL =~ /\/tag\// || # Prepare log file and set permissions $root_uid = getpwnam('root'); $adm_gid = getgrnam('adm'); -open(FH, ">>$log_file"); -close FH; +open(my $FH, ">>", "$log_file"); +close($FH); chmod(0440, $log_file); chown($root_uid, $adm_gid, $log_file); chown($root_uid, $adm_gid, "/var/lib/gosa-si");