index c744f9b4c5e45e1f8b6ffe123d61b51148b5f3f7..5791a318eb9fd1d4392f6e43b2da8793fc700782 100644 (file)
if( inet_aton($gosa_ip) ){ $gosa_ip = inet_ntoa(inet_aton($gosa_ip)); }
$main::gosa_address = "$gosa_ip:$gosa_port";
-# create general settings for this module
-#y $gosa_cipher = &create_ciphering($gosa_passwd);
my $xml = new XML::Simple();
# import local events
my ($error, $result, $event_hash) = &import_events($event_dir);
-if ($error == 0) {
- foreach my $log_line (@$result) {
+
+foreach my $log_line (@$result) {
+ if ($log_line =~ / succeed: /) {
&main::daemon_log("0 DEBUG: GosaPackages - $log_line", 7);
- }
-} else {
- foreach my $log_line (@$result) {
+ } else {
&main::daemon_log("0 ERROR: GosaPackages - $log_line", 1);
}
}
}
}
-#=== FUNCTION ================================================================
-# NAME: get_interface_for_ip
-# PARAMETERS: ip address (i.e. 192.168.0.1)
-# RETURNS: array: list of interfaces if ip=0.0.0.0, matching interface if found, undef else
-# DESCRIPTION: Uses proc fs (/proc/net/dev) to get list of interfaces.
-#===============================================================================
-sub get_interface_for_ip {
- my $result;
- my $ip= shift;
- if ($ip && length($ip) > 0) {
- my @ifs= &get_interfaces();
- if($ip eq "0.0.0.0") {
- $result = "all";
- } else {
- foreach (@ifs) {
- my $if=$_;
- if(get_ip($if) eq $ip) {
- $result = $if;
- }
- }
- }
- }
- return $result;
-}
-
-#=== FUNCTION ================================================================
-# NAME: get_interfaces
-# PARAMETERS: none
-# RETURNS: (list of interfaces)
-# DESCRIPTION: Uses proc fs (/proc/net/dev) to get list of interfaces.
-#===============================================================================
-sub get_interfaces {
- my @result;
- my $PROC_NET_DEV= ('/proc/net/dev');
-
- open(PROC_NET_DEV, "<$PROC_NET_DEV")
- or die "Could not open $PROC_NET_DEV";
-
- my @ifs = <PROC_NET_DEV>;
-
- close(PROC_NET_DEV);
-
- # Eat first two line
- shift @ifs;
- shift @ifs;
-
- chomp @ifs;
- foreach my $line(@ifs) {
- my $if= (split /:/, $line)[0];
- $if =~ s/^\s+//;
- push @result, $if;
- }
-
- return @result;
-}
#=== FUNCTION ================================================================
# NAME: get_mac
# DESCRIPTION: Uses ioctl to get mac address directly from system.
#===============================================================================
sub get_mac {
- my $ifreq= shift;
- my $result;
- 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;
- }
- }
- }
- }
- return $result;
-}
+ my $ifreq= shift;
+ my $result;
+ if ($ifreq && length($ifreq) > 0) {
+ if($ifreq eq "all") {
+ $result = "00:00:00:00:00:00";
+ } else {
+ my $SIOCGIFHWADDR= 0x8927; # man 2 ioctl_list
-#=== FUNCTION ================================================================
-# NAME: get_ip
-# PARAMETERS: interface name (i.e. eth0)
-# RETURNS: (ip address)
-# DESCRIPTION: Uses ioctl to get ip address directly from system.
-#===============================================================================
-sub get_ip {
- my $ifreq= shift;
- my $result= "";
- my $SIOCGIFADDR= 0x8915; # man 2 ioctl_list
- my $proto= getprotobyname('ip');
+ # 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, $proto
+ socket SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('ip')
or die "socket: $!";
- if(ioctl SOCKET, $SIOCGIFADDR, $ifreq) {
- my ($if, $sin) = unpack 'a16 a16', $ifreq;
- my ($port, $addr) = sockaddr_in $sin;
- my $ip = inet_ntoa $addr;
+ if(ioctl SOCKET, $SIOCGIFHWADDR, $ifreq) {
+ my ($if, $mac)= unpack 'h36 H12', $ifreq;
- if ($ip && length($ip) > 0) {
- $result = $ip;
+ 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;
}
+ }
}
-
- return $result;
+ }
+ 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 WARNING: processing is aborted and message will not be forwarded", 3);
+ &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 WARNING: client '$target' is not registered for event '$header', processing is aborted", 3);
+ &main::daemon_log("$session_id ERROR: client '$target' is not registered for event '$header', processing is aborted", 1);
@out_msg_l = ();
}
if( $error == 0 ) {
# add job to job queue
my $func_dic = {table=>$main::job_queue_tn,
- primkey=>[],
+ primkey=>['macaddress', 'headertag'],
timestamp=>$timestamp,
status=>'waiting',
result=>'none',
xmlmessage=>$msg,
macaddress=>$macaddress,
plainname=>$plain_name,
+ siserver=>"localhost",
+ modified=>"1",
};
my $res = $main::job_db->add_dbentry($func_dic);
if (not $res == 0) {
return @out_msg_l;
}
+# vim:ts=4:shiftwidth:expandtab
1;
-
-
-
-
-
-
-
-
-
-