From: opensides Date: Sat, 27 Mar 2010 23:16:50 +0000 (+0000) Subject: - Correcting perl syntax for open and FILE instead of $FILE X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0612d896b56174770f1a36ba5d5249eef719b5f3;p=gosa.git - Correcting perl syntax for open and FILE instead of $FILE git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17315 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/client/events/corefunctions.pm b/gosa-si/client/events/corefunctions.pm index 71d783463..016e6b888 100644 --- a/gosa-si/client/events/corefunctions.pm +++ b/gosa-si/client/events/corefunctions.pm @@ -1,27 +1,28 @@ package corefunctions; -use Exporter; -@ISA = qw(Exporter); -my @events = ( - "get_events", - "registered", - 'new_syslog_config', - "new_ntp_config", - "new_ldap_config", - "new_key", - "generate_hw_digest", # no implementations - "detect_hardware", - "confirm_new_key", - "ping", - "import_events", # no implementations - ); -@EXPORT = @events; use strict; use warnings; +use Exporter; use Fcntl; use GOSA::GosaSupportDaemon; use File::Basename; +@ISA = qw(Exporter); +my @events = ( + "get_events", + "registered", + 'new_syslog_config', + "new_ntp_config", + "new_ldap_config", + "new_key", + "generate_hw_digest", # no implementations + "detect_hardware", + "confirm_new_key", + "ping", + "import_events", # no implementations + ); +@EXPORT = @events; + my ($ldap_enabled, $offline_enabled, $ldap_config, $pam_config, $nss_config, $fai_logpath, $ldap_config_exit_hook); my $chrony_file = "/etc/chrony/chrony.conf"; @@ -73,7 +74,7 @@ sub write_to_file { open (FILE, "$file"); close(FILE); } - open(FILE, ">> $file") or &main::daemon_log("ERROR in corefunctions.pm: can not open '$file' to write '$string'", 1);; + 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); } @@ -181,9 +182,9 @@ sub new_syslog_config { } # Substitute existing server with new syslog server - open (FILE, "<$syslog_file"); - my @file = ; - close FILE; + open ($FILE, "<","$syslog_file"); + my @file = <$FILE>; + close($FILE); my $syslog_server_line = "*.*\t@".$syslog_server."\n"; foreach my $line (@file) { if ($line =~ /^\*\.\*\s+@/) { @@ -199,9 +200,9 @@ sub new_syslog_config { } # Write changes to file and close it - open (FILE, "+>$syslog_file"); - print FILE join("", @file); - close FILE; + open ($FILE, "+>","$syslog_file"); + print $FILE join("", @file); + close($FILE); &main::daemon_log("INFO: Wrote new configuration file: $syslog_file", 5); # Restart syslog deamon @@ -238,9 +239,9 @@ sub new_ntp_config { } # Substitute existing server with new ntp server - open (FILE, "<$chrony_file"); - my @file = ; - close FILE; + open ($FILE, "<","$chrony_file"); + my @file = <$FILE>; + close($FILE); my @new_file; foreach my $line (@file) { if ($line =~ /^server\s+/) { @@ -261,9 +262,9 @@ sub new_ntp_config { } # Write changes to file and close it - open (FILE, ">$chrony_file"); - print FILE join("", @new_file); - close FILE; + open ($FILE, ">","$chrony_file"); + print $FILE join("", @new_file); + close($FILE); &main::daemon_log("INFO: Wrote new configuration file: $chrony_file", 5); # Restart chrony deamon @@ -358,52 +359,52 @@ sub new_ldap_config { # Setup ldap.conf my $file1; my $file2; - open(file1, "> $ldap_config"); - print file1 "# This file was automatically generated by gosa-si-client. Do not change.\n"; - print file1 "URI"; + open($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) { - print file1 " $element"; + print $file1 " $element"; } - print file1 "\nBASE $ldap_base\n"; + print $file1 "\nBASE $ldap_base\n"; foreach $element (@ldap_options) { - print file1 "$element\n"; + print $file1 "$element\n"; } - close (file1); + close ($file1); daemon_log("INFO: Wrote $ldap_config", 5); # Setup pam_ldap.conf / libnss-ldap.conf - open(file1, "> $pam_config"); - open(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"; - print file2 "uri"; + open($file1, ">","$pam_config"); + open($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"; + print $file2 "uri"; foreach $element (@ldap_uris) { - print file1 " $element"; - print file2 " $element"; + print $file1 " $element"; + print $file2 " $element"; } - print file1 "\nbase $ldap_base\n"; - print file2 "\nbase $ldap_base\n"; + print $file1 "\nbase $ldap_base\n"; + print $file2 "\nbase $ldap_base\n"; foreach $element (@pam_options) { - print file1 "$element\n"; + print $file1 "$element\n"; } foreach $element (@nss_options) { - print file2 "$element\n"; + print $file2 "$element\n"; } - close (file2); + close ($file2); daemon_log("INFO: Wrote $nss_config", 5); - close (file1); + close ($file1); daemon_log("INFO: Wrote $pam_config", 5); # Create goto.secrets if told so - for compatibility reasons if (defined $goto_admin){ - open(file1, "> /etc/goto/secret"); - close(file1); + open($file1, ">","/etc/goto/secret"); + close($file1); chown(0,0, "/etc/goto/secret"); chmod(0600, "/etc/goto/secret"); - open(file1, "> /etc/goto/secret"); - print file1 "GOTOADMIN=\"$goto_admin\"\nGOTOSECRET=\"$goto_secret\"\n"; - close(file1); + open($file1, ">","/etc/goto/secret"); + print $file1 "GOTOADMIN=\"$goto_admin\"\nGOTOSECRET=\"$goto_secret\"\n"; + close($file1); daemon_log("INFO: Wrote /etc/goto/secret", 5); } @@ -414,16 +415,16 @@ sub new_ldap_config { my $ldap_server= $ldap_uris[0]; $ldap_server=~ s/^ldap:\/\/([^:]+).*$/$1/; - open(file1, "> $cfg_name"); - print file1 "LDAP_BASE=\"$ldap_base\"\n"; - print file1 "LDAP_SERVER=\"$ldap_server\"\n"; - print file1 "LDAP_URIS=\"@ldap_uris\"\n"; - print file1 "ADMIN_BASE=\"$admin_base\"\n"; - print file1 "DEPARTMENT=\"$department\"\n"; - print file1 "RELEASE=\"$release\"\n"; - print file1 "UNIT_TAG=\"".(defined $unit_tag ? "$unit_tag" : "")."\"\n"; - print file1 "UNIT_TAG_FILTER=\"".(defined $unit_tag ? "(gosaUnitTag=$unit_tag)" : "")."\"\n"; - close(file1); + open($file1, ">","$cfg_name"); + print $file1 "LDAP_BASE=\"$ldap_base\"\n"; + print $file1 "LDAP_SERVER=\"$ldap_server\"\n"; + print $file1 "LDAP_URIS=\"@ldap_uris\"\n"; + print $file1 "ADMIN_BASE=\"$admin_base\"\n"; + print $file1 "DEPARTMENT=\"$department\"\n"; + print $file1 "RELEASE=\"$release\"\n"; + print $file1 "UNIT_TAG=\"".(defined $unit_tag ? "$unit_tag" : "")."\"\n"; + print $file1 "UNIT_TAG_FILTER=\"".(defined $unit_tag ? "(gosaUnitTag=$unit_tag)" : "")."\"\n"; + close($file1); daemon_log("INFO: Wrote $cfg_name", 5); # Write offline config @@ -431,16 +432,16 @@ sub new_ldap_config { $cfg_name= "/etc/ldap/ldap-offline.conf"; # Get first LDAP server - open(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"; - print file1 "ADMIN_BASE=\"$admin_base\"\n"; - print file1 "DEPARTMENT=\"$department\"\n"; - print file1 "RELEASE=\"$release\"\n"; - print file1 "UNIT_TAG=\"".(defined $unit_tag ? "$unit_tag" : "")."\"\n"; - print file1 "UNIT_TAG_FILTER=\"".(defined $unit_tag ? "(gosaUnitTag=$unit_tag)" : "")."\"\n"; - close(file1); + open($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"; + print $file1 "ADMIN_BASE=\"$admin_base\"\n"; + print $file1 "DEPARTMENT=\"$department\"\n"; + print $file1 "RELEASE=\"$release\"\n"; + print $file1 "UNIT_TAG=\"".(defined $unit_tag ? "$unit_tag" : "")."\"\n"; + print $file1 "UNIT_TAG_FILTER=\"".(defined $unit_tag ? "(gosaUnitTag=$unit_tag)" : "")."\"\n"; + close($file1); daemon_log("INFO: Wrote $cfg_name", 5); }