summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3b6a7d5)
raw | patch | inline | side by side (parent: 3b6a7d5)
author | opensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Sun, 28 Mar 2010 00:21:19 +0000 (00:21 +0000) | ||
committer | opensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Sun, 28 Mar 2010 00:21:19 +0000 (00:21 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17331 594d385d-05f5-0310-b6e9-bd551577e9d8
index 016e6b888ee0d91d2c9b5db40be6d84c885fdbb8..a25aa98cb89f3ed1fbffa3cf949979c768ab1ad1 100644 (file)
my @events = (
"get_events",
"registered",
- 'new_syslog_config',
+ "new_syslog_config",
"new_ntp_config",
"new_ldap_config",
"new_key",
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;
}
# 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";
}
# 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);
}
# Substitute existing server with new ntp server
- open ($FILE, "<","$chrony_file");
+ open (my $FILE, "<","$chrony_file");
my @file = <$FILE>;
close($FILE);
my @new_file;
}
# 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);
# 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) {
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";
# 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);
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";
$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";
index 57c2f85337f769dfd0f322f4ebe3e62310f26f09..b6a0a6883c3e7e0797743fbbb543a38ea4a25396 100644 (file)
&add_content2xml_hash($out_hash, "error", "DAK Keyring is not writable");
} else {
my $keyfile;
- open($keyfile, ">","/tmp/gosa_si_tmp_dak_key");
+ open(my $keyfile, ">","/tmp/gosa_si_tmp_dak_key");
print $keyfile $key;
close($keyfile);
my $command = "$gpg --import /tmp/gosa_si_tmp_dak_key";
index 3b6f9678a23f141028684689f622d4b3d828451c..fb7c8f8926bc296fcc97805b7ceec1de00f8fb77 100644 (file)
# Check logged in user
my @user_list = &get_logged_in_users;
if( @user_list >= 1 ) {
- open($FILE, ">", "/etc/gosa-si/event");
+ open(my $FILE, ">", "/etc/gosa-si/event");
print $FILE "trigger_action_localboot\n";
close($FILE);
}
my @user_list = &get_logged_in_users;
if( @user_list >= 1 ) {
system( "/usr/bin/goto-notify reboot" );
- open($FILE, ">", "/etc/gosa-si/event");
+ open(my $FILE, ">", "/etc/gosa-si/event");
print $FILE "reboot\n";
close($FILE);
}
my @user_list = &get_logged_in_users;
if( @user_list >= 1 ) {
system( "/usr/bin/goto-notify halt" );
- open($FILE, ">", "/etc/gosa-si/event");
+ open(my $FILE, ">", "/etc/gosa-si/event");
print $FILE "halt\n";
close($FILE);
}
my @user_list = &get_logged_in_users;
if( @user_list >= 1 ) {
system( "/usr/bin/goto-notify install" );
- open($FILE, ">", "/etc/gosa-si/event");
+ open(my $FILE, ">", "/etc/gosa-si/event");
print $FILE "install\n";
close($FILE);
}
index 700adc5a193870f0eaf93fa0ff17b122f0503931..ecd9204fdf945a3452d5eae0b0cb66cfc58a71f9 100644 (file)
my $source = @{$msg_hash->{'source'}}[0];
my $Datei = "/var/run/gosa-si-client.activated";
- open($FILE, ">", "$Datei");
+ open(my $FILE, ">", "$Datei");
print $FILE "$msg\n";
- close $FILE;
+ close($FILE);
return;
}
index 9227b729c1c123c454837dbb4c5e735f3d27f5ed..b9cb41e7b52483e1d22d127d64bcdbda574d2bf6 100644 (file)
my @events = (
"get_events",
"get_terminal_server",
- "get_load",
- "report_load",
- "set_terminal_server",
+ "get_load",
+ "report_load",
+ "set_terminal_server",
);
@EXPORT = @events;
my $file = "/proc/loadavg";
if ((not -f $file) || (not -r $file)) { return }
- open($FHD, "<", "$file");
+ open(my $FHD, "<", "$file");
my $line = <$FHD>;
close($FHD);
chomp($line);
{
$file_content .= "$ts $load\n";
}
- open($FHD, ">", "$ts_load_file.part");
+ open(my $FHD, ">", "$ts_load_file.part");
printf $FHD $file_content;
close($FHD);
diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index 49756c38aedf229af59aead2afeac0d026a629c9..0ffe6e15867442010667644fdf8e93e45a22a9ba 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
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 );
if( -f "/proc/$pid/stat" ) {
my($stat) = `cat /proc/$pid/stat` =~ m/$pid \((.+)\).*/;
if( $0 eq $stat ) {
- close( $LOCK_FILE );
+ close($LOCK_FILE);
exit -1;
}
}
# 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)) {
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);
if($server_ip =~ /^(\d\d?\d?\.){3}\d\d?\d?$/) {
my $PROC_NET_ROUTE= ('/proc/net/route');
- open($PROC_NET_ROUTE, "<","$PROC_NET_ROUTE")
+ open(my $PROC_NET_ROUTE, "<","$PROC_NET_ROUTE")
or die "Could not open $PROC_NET_ROUTE";
my @ifs = <$PROC_NET_ROUTE>;
chomp($string);
- if (open($FILE, ">>", "$file")){
+ if (open(my $FILE, ">>", "$file")){
print $FILE $string."\n";
close($FILE);
}
# Check if file has 'seen' tag
foreach my $goto_file (@goto_files) {
- open($FILE, "$goto_dir/$goto_file");
+ open(my $FILE, "$goto_dir/$goto_file");
my @lines = <$FILE>;
close($FILE);
next;
}
- open($FILE, "<","$log_file");
+ open(my $FILE, "<","$log_file");
my @lines = <$FILE> ;
close ($FILE);
my $log_string = join("", @lines);
# 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 ) {
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index e820b24940a2ad25dddadef16ac358b9433da52b..255fa3391de4ed93aac794f748b6d230a4378c53 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
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 );
# 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)) {
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);
}
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;
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;
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;
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");
# 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 ) {
# 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);
index bed05ab3baee2c54c6683b43e4d154202e37cd50..c19fc4b8d94d2240d8b86bd74ba6b705284d66b3 100644 (file)
package ArpHandler;
-
-
use strict;
use warnings;
index 8fc6318bcf69b87dfd021adf2558e858c0eed3e4..b9d4ff8a9c09baee90cdcf40088243e65de6b2e8 100644 (file)
if ( defined($msg_hash->{'force-hostname'}[0]) &&
length($msg_hash->{'force-hostname'}[0]) > 0){
# $heap->{force-hostname}->{$mac_address}= $msg_hash->{'force-hostname'}[0];
- open ($TFILE, ">", "/var/tmp/$mac_address");
+ open (my $TFILE, ">", "/var/tmp/$mac_address");
print $TFILE $msg_hash->{'force-hostname'}[0];
close ($TFILE);
} else {
} else {
my $PROC_NET_ROUTE= ('/proc/net/route');
- open($FD_PROC_NET_ROUTE, "<", "$PROC_NET_ROUTE")
+ open(my $FD_PROC_NET_ROUTE, "<", "$PROC_NET_ROUTE")
or die "Could not open $PROC_NET_ROUTE";
my @ifs = <$FD_PROC_NET_ROUTE>;
index 14e755aea245aefbb33d4f8df7d8f3dd6ca2c6a2..1e6429b9d156502a6f52c3fd0788334e15ab7e01 100644 (file)
sub get_dns_domains() {
my $line;
my @searches;
- open($RESOLV, "<", "/etc/resolv.conf") or return @searches;
+ open(my $RESOLV, "<", "/etc/resolv.conf") or return @searches;
while(<$RESOLV>){
$line= $_;
chomp $line;
my @result;
my $PROC_NET_DEV= ('/proc/net/dev');
- open($FD_PROC_NET_DEV, "<", "$PROC_NET_DEV")
+ open(my $FD_PROC_NET_DEV, "<", "$PROC_NET_DEV")
or die "Could not open $PROC_NET_DEV";
my @ifs = <$FD_PROC_NET_DEV>;
if($remote_ip =~ /^(\d\d?\d?\.){3}\d\d?\d?$/) {
my $PROC_NET_ROUTE= ('/proc/net/route');
- open($FD_PROC_NET_ROUTE, "<", "$PROC_NET_ROUTE")
+ open(my $FD_PROC_NET_ROUTE, "<", "$PROC_NET_ROUTE")
or die "Could not open $PROC_NET_ROUTE";
my @ifs = <$FD_PROC_NET_ROUTE>;
&main::daemon_log("ERROR: The sudo utility is not available! Please fix this!");
}
my $cmd_line= "$sudo_cmd su - $uid -c '$command'";
- open($PIPE, "$cmd_line |");
+ open(my $PIPE, "$cmd_line |");
my $result = {'command' => $cmd_line};
push @{$result->{'output'}}, <$PIPE>;
close($PIPE);
index b008d01a9fc5b8549cf70f7113da2fc13eb42779..4a1d1a1400af047eb2680fb95d72793c4b0f6b41 100644 (file)
package ServerPackages;
-use Exporter;
-@ISA = ("Exporter");
+
# Each module has to have a function 'process_incoming_msg'. This function works as a interface to gosa-sd and receives the msg hash from gosa-sd. 'process_incoming_function checks, wether it has a function to process the incoming msg and forward the msg to it.
use strict;
use warnings;
+
+use Exporter;
use GOSA::GosaSupportDaemon;
use Data::Dumper;
+@ISA = ("Exporter");
+
my $event_dir = "/usr/lib/gosa-si/server/ServerPackages";
use lib "/usr/lib/gosa-si/server/ServerPackages";