Code

- More open fixes, add missing my in front of filehandle variable
[gosa.git] / gosa-si / client / events / corefunctions.pm
index 016e6b888ee0d91d2c9b5db40be6d84c885fdbb8..a25aa98cb89f3ed1fbffa3cf949979c768ab1ad1 100644 (file)
@@ -11,7 +11,7 @@ use File::Basename;
 my @events = (
   "get_events",
   "registered",
-  'new_syslog_config',
+  "new_syslog_config",
   "new_ntp_config",
   "new_ldap_config",
   "new_key",
@@ -71,12 +71,12 @@ sub write_to_file {
                chomp($string);
                        
                if( not -f $file ) {
-                       open (FILE, "$file");
-                       close(FILE);
+                       open (my $FD_FILE, "$file");
+                       close($FD_FILE);
                }
-               open(FILE, ">>", "$file") or &main::daemon_log("ERROR in corefunctions.pm: can not open '$file' to write '$string'", 1);;
-               print FILE $string."\n";
-               close(FILE);
+               open(my $FD_FILE, ">>", "$file") or &main::daemon_log("ERROR in corefunctions.pm: can not open '$file' to write '$string'", 1);;
+               print $FD_FILE $string."\n";
+               close($FD_FILE);
        }
 
        return;    
@@ -182,7 +182,7 @@ sub new_syslog_config {
        }
        
        # Substitute existing server with new syslog server
-       open ($FILE, "<","$syslog_file");
+       open (my $FILE, "<","$syslog_file");
        my @file = <$FILE>;
        close($FILE);
        my $syslog_server_line = "*.*\t@".$syslog_server."\n"; 
@@ -200,7 +200,7 @@ sub new_syslog_config {
        }
        
        # Write changes to file and close it
-       open ($FILE, "+>","$syslog_file");
+       open (my $FILE, "+>","$syslog_file");
        print $FILE join("", @file); 
        close($FILE);
        &main::daemon_log("INFO: Wrote new configuration file: $syslog_file", 5);
@@ -239,7 +239,7 @@ sub new_ntp_config {
        }
 
        # Substitute existing server with new ntp server
-       open ($FILE, "<","$chrony_file");
+       open (my $FILE, "<","$chrony_file");
        my @file = <$FILE>;
        close($FILE);
        my @new_file;
@@ -262,7 +262,7 @@ sub new_ntp_config {
        }
 
        # Write changes to file and close it
-       open ($FILE, ">","$chrony_file");
+       open (my $FILE, ">","$chrony_file");
        print $FILE join("", @new_file); 
        close($FILE);
        &main::daemon_log("INFO: Wrote new configuration file: $chrony_file", 5);
@@ -359,7 +359,7 @@ sub new_ldap_config {
        # Setup ldap.conf
        my $file1;
        my $file2;
-       open($file1, ">","$ldap_config");
+       open(my $file1, ">","$ldap_config");
        print $file1 "# This file was automatically generated by gosa-si-client. Do not change.\n";
        print $file1 "URI";
        foreach $element (@ldap_uris) {
@@ -373,8 +373,8 @@ sub new_ldap_config {
        daemon_log("INFO: Wrote $ldap_config", 5);
 
        # Setup pam_ldap.conf / libnss-ldap.conf
-       open($file1, ">","$pam_config");
-       open($file2, ">","$nss_config");
+       open(my $file1, ">","$pam_config");
+       open(my $file2, ">","$nss_config");
        print $file1 "# This file was automatically generated by gosa-si-client. Do not change.\n";
        print $file2 "# This file was automatically generated by gosa-si-client. Do not change.\n";
        print $file1 "uri";
@@ -398,11 +398,11 @@ sub new_ldap_config {
 
        # Create goto.secrets if told so - for compatibility reasons
        if (defined $goto_admin){
-               open($file1, ">","/etc/goto/secret");
+               open(my $file1, ">","/etc/goto/secret");
                        close($file1);
                        chown(0,0, "/etc/goto/secret");
                        chmod(0600, "/etc/goto/secret");
-               open($file1, ">","/etc/goto/secret");
+               open(my $file1, ">","/etc/goto/secret");
                        print $file1 "GOTOADMIN=\"$goto_admin\"\nGOTOSECRET=\"$goto_secret\"\n";
                        close($file1);
                        daemon_log("INFO: Wrote /etc/goto/secret", 5);
@@ -415,7 +415,7 @@ sub new_ldap_config {
     my $ldap_server= $ldap_uris[0];
     $ldap_server=~ s/^ldap:\/\/([^:]+).*$/$1/;
 
-    open($file1, ">","$cfg_name");
+    open(my $file1, ">","$cfg_name");
     print $file1 "LDAP_BASE=\"$ldap_base\"\n";
     print $file1 "LDAP_SERVER=\"$ldap_server\"\n";
     print $file1 "LDAP_URIS=\"@ldap_uris\"\n";
@@ -432,7 +432,7 @@ sub new_ldap_config {
            $cfg_name= "/etc/ldap/ldap-offline.conf";
 
            # Get first LDAP server
-           open($file1, ">","$cfg_name");
+           open(my $file1, ">","$cfg_name");
            print $file1 "LDAP_BASE=\"$ldap_base\"\n";
            print $file1 "LDAP_SERVER=\"127.0.0.1\"\n";
            print $file1 "LDAP_URIS=\"ldap://127.0.0.1\"\n";