Code

<h1> to <h3>
[gosa.git] / gosa-si / gosa-si-server
index e820b24940a2ad25dddadef16ac358b9433da52b..1e56d7ce7066ed3b9cdf0f9ae743cc7880d81eb5 100755 (executable)
@@ -454,7 +454,7 @@ sub check_cmdline_param () {
 sub check_pid {
     $pid = -1;
     # Check, if we are already running
-    if( open($LOCK_FILE, "<","$pid_file") ) {
+    if( open( my $LOCK_FILE, "<", "$pid_file" ) ) {
         $pid = <$LOCK_FILE>;
         if( defined $pid ) {
             chomp( $pid );
@@ -467,14 +467,14 @@ sub check_pid {
                 }
             }
         }
-        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)
+        if (open(my $LOCK_FILE, '<', $pid_file)
                 && ($pid = <$LOCK_FILE>))
         {
             chomp($pid);
@@ -2879,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;
@@ -2963,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 = <CONFIG>){
+       while ($line = <$CONFIG>){
                # Unify
                chop($line);
                $line =~ s/^\s+//;
@@ -3185,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")) {
@@ -3193,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;
@@ -3284,8 +3282,8 @@ sub cleanup_and_extract {
 
                        my $tmpl= ""; {
                                local $/=undef;
-                               open($FILE, "$dir/DEBIAN/templates");
-                               $tmpl = &encode_base64(<FILE>);
+                               open(my $FILE, "$dir/DEBIAN/templates");
+                               $tmpl = &encode_base64(<$FILE>);
                                close($FILE);
                        }
                        rmtree("$dir/DEBIAN/templates");
@@ -3496,7 +3494,7 @@ if( ! $foreground ) {
 
 # Do something useful - put our PID into the pid_file
 if( 0 != $pid ) {
-    open( $LOCK_FILE, ">","$pid_file" );
+    open( my $LOCK_FILE, ">", "$pid_file" );
     print $LOCK_FILE "$pid\n";
     close( $LOCK_FILE );
     if( !$foreground ) { 
@@ -3518,7 +3516,7 @@ if ($server_headURL =~ /\/tag\// ||
 # Prepare log file and set permissions
 $root_uid = getpwnam('root');
 $adm_gid = getgrnam('adm');
-open($FH, ">>","$log_file");
+open(my $FH, ">>", "$log_file");
 close($FH);
 chmod(0440, $log_file);
 chown($root_uid, $adm_gid, $log_file);