Code

Updated new Config Management
[gosa.git] / gosa-si / modules / GosaPackages.pm
index 64b014917eb432ef4b68ebbca2eeb3fba5906ca4..c18472eb8047e04df3cc361435786aa55616901c 100644 (file)
@@ -1,17 +1,19 @@
 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";
@@ -73,29 +75,16 @@ sub get_module_info {
 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;
@@ -288,7 +277,7 @@ sub process_job_msg {
     if (exists $msg_hash->{periodic})
     {
         $periodic = $msg_hash->{periodic}[0];
-        if (not $periodic =~ /[0-9]+_(hours|minutes|days|weeks|months)/)    # 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 the following pattern for the tag: 'INTEGER_[minutes|hours|days|weeks|months]'".