index 60ee896db11f140fbf7dfbf06ec6ba3e27a76940..c18472eb8047e04df3cc361435786aa55616901c 100644 (file)
package GosaPackages;
-use Exporter;
-@ISA = ("Exporter");
-
use strict;
use warnings;
-use GOSA::GosaSupportDaemon;
+
+use Exporter;
+use GOsaSI::GosaSupportDaemon;
use IO::Socket::INET;
use Socket;
use XML::Simple;
use File::Spec;
use Data::Dumper;
use MIME::Base64;
+use Net::ARP;
+
+our @ISA = ("Exporter");
my $event_dir = "/usr/lib/gosa-si/server/GosaPackages";
use lib "/usr/lib/gosa-si/server/GosaPackages";
sub get_mac {
my $ifreq= shift;
my $result;
- if ($ifreq && length($ifreq) > 0) {
+ if ($ifreq && length($ifreq) > 0) {
if($ifreq eq "all") {
$result = "00:00:00:00:00:00";
} else {
- my $SIOCGIFHWADDR= 0x8927; # man 2 ioctl_list
-
# A configured MAC Address should always override a guessed value
if ($gosa_mac_address and length($gosa_mac_address) > 0) {
$result= $gosa_mac_address;
}
- socket SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('ip')
- or die "socket: $!";
-
- if(ioctl SOCKET, $SIOCGIFHWADDR, $ifreq) {
- my ($if, $mac)= unpack 'h36 H12', $ifreq;
-
- if (length($mac) > 0) {
- $mac=~ m/^([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/;
- $mac= sprintf("%s:%s:%s:%s:%s:%s", $1, $2, $3, $4, $5, $6);
- $result = $mac;
- }
- }
+ $result = Net::ARP::get_mac($ifreq);
}
}
return $result;
&main::daemon_log("$session_id ERROR: GosaPackages: no event handler or core function defined for '$header'", 1);
@out_msg_l = ();
} elsif ($out_msg_l[0] eq 'knownclienterror') {
- &main::daemon_log("$session_id ERROR: no event handler found for '$header', check client registration events!", 1);
- &main::daemon_log("$session_id ERROR: no or more than 1 hits are found at known_clients_db with sql query: '$sql_events'", 1);
- &main::daemon_log("$session_id ERROR: processing is aborted and message will not be forwarded", 1);
+ if ($header eq "ping") {
+ &main::daemon_log("$session_id WARNING: Cannot send '$header' to '$target'. GOsa-si do not know client. Maybe client is offline or gosa-si-client process is not running.", 3);
+ } else {
+ &main::daemon_log("$session_id ERROR: no general event handler found for '$header', check client registration events!", 1);
+ &main::daemon_log("$session_id ERROR: no or more than 1 hits are found at known_clients_db with sql query: '$sql_events'", 1);
+ &main::daemon_log("$session_id ERROR: processing is aborted and message will not be forwarded", 1);
+ }
@out_msg_l = ();
} elsif ($out_msg_l[0] eq 'noeventerror') {
+ &main::daemon_log("$session_id ERROR: no general event handler found for '$header', check client registration events!", 1);
&main::daemon_log("$session_id ERROR: client '$target' is not registered for event '$header', processing is aborted", 1);
@out_msg_l = ();
}
# Check if it is a periodical job
my $periodic = 'none';
- my $periodic_time = 1;
if (exists $msg_hash->{periodic})
{
$periodic = $msg_hash->{periodic}[0];
- if (not defined $periodic) # Periodic tag is not defined
- {
- $periodic = "";
- }
-
- if (not exists $main::check_periodic->{$periodic}) # Periodic tag is not valid
+ if ($periodic ne 'none' and not $periodic =~ /[0-9]+_(hours|minutes|days|weeks|months)/) # Periodic tag is not valid
{
&main::daemon_log("$session_id ERROR: Message contains invalid periodic-tag '$periodic'.".
- " Please use one of the following tags instead: '".join("', '", keys(%$main::check_periodic))."'.".
+ " Please use the following pattern for the tag: 'INTEGER_[minutes|hours|days|weeks|months]'".
" Aborted message: $msg", 1);
$out_msg = "<xml>".
"<header>answer</header><source>$main::server_address</source><target>GOSA</target>".
"</xml>";
return ($out_msg);
}
-
- if (exists $msg_hash->{$periodic}) # Check periodical time tag and set value
- {
- if (ref $msg_hash->{$periodic}[0] eq "HASH") # Periodical time tag is empty
- {
- &main::daemon_log("$session_id ERROR: Message contains no content of periodical time tag.".
- " Please use an integer for this tag (i. e.: <periodic>hours</periodoc><hours>5</hours>)", 1);
- $out_msg = "<xml>".
- "<header>answer</header><source>$main::server_address</source><target>GOSA</target>".
- "<answer1>1</answer1><error_string>Message contains no content of periodic time tag</error_string>".
- "</xml>";
- return ($out_msg);
-
- }
-
- if (not $msg_hash->{$periodic}[0] =~ /[1-9]+\d*/) # Periodical time tag is not an INT > 0
- {
- &main::daemon_log("$session_id ERROR: Message contains invalid periodical time tag '$msg_hash->{$periodic}[0]'.".
- " Please use an integer for this tag (i. e.: <periodic>hours</periodoc><hours>5</hours>)", 1);
- $out_msg = "<xml>".
- "<header>answer</header><source>$main::server_address</source><target>GOSA</target>".
- "<answer1>1</answer1><error_string>Message contains invalid periodic time tag '$msg_hash->{$periodic}[0]'</error_string>".
- "</xml>";
- return ($out_msg);
- }
-
- $periodic_time = $msg_hash->{$periodic}[0];
- }
}
# Add job to job queue
plainname=>$plain_name,
siserver=>"localhost",
modified=>"1",
- periodic=>$periodic_time."_".$periodic,
+ periodic=>$periodic,
};
my $res = $main::job_db->add_dbentry($func_dic);
if (not $res == 0) {