index b616de5ba26a40210210df2b5bef94be229a4479..f03074b18c8fe398cf610294445317ab981cd73c 100644 (file)
#===============================================================================
sub read_configfile {
my $cfg;
- if( defined( $main::cfg_file) && ( length($main::cfg_file) > 0 )) {
+ if( defined( $main::cfg_file) && ( (-s $main::cfg_file) > 0 )) {
if( -r $main::cfg_file ) {
$cfg = Config::IniFiles->new( -file => $main::cfg_file );
} else {
while (defined (my $event = readdir (DIR))) {
if( $event eq "." || $event eq ".." ) { next; }
- if( $event eq "siTriggered.pm" ) { next; } # SI specific events not needed in GosaPackages.pm
- if( $event eq "clMessages.pm" ) { next; } # SI specific events not needed in GosaPackages.pm
+ if( $event eq "siTriggered.pm" ) { next; } # SI specific events not needed in GosaPackages.pm
+ if( $event eq "clMessages.pm" ) { next; } # SI specific events not needed in GosaPackages.pm
eval{ require $event; };
if( $@ ) {
$event_hash->{$event_name} = $event_module;
}
my $events_string = join( ", ", @{$events_l});
- &main::daemon_log("G DEBUG: GosaPackages imported events $events_string", 8);
+ &main::daemon_log("G DEBUG: GosaPackages from '$1' imported events $events_string", 8);
}
}
my $header = @{$msg_hash->{'header'}}[0];
$header =~ s/job_//;
+ my $target = @{$msg_hash->{'target'}}[0];
# if no timestamp is specified, use 19700101000000
my $timestamp = "19700101000000";
"</xml>";
}
- # check wether mac address is already known in known_daemons or known_clients
- my $target = 'none';
+ # if mac address is already known in ldap, set plain_name to 'cn'
+ my $plain_name;
+ my $ldap_handle = &main::get_ldap_handle($session_id);
+ if( not defined $ldap_handle ) {
+ &main::daemon_log("$session_id ERROR: cannot connect to ldap", 1);
+ $plain_name = "none";
+
+ # try to fetch a 'real name'
+ } else {
+ my $mesg = $ldap_handle->search(
+ base => $main::ldap_base,
+ scope => 'sub',
+ attrs => ['cn'],
+ filter => "(macAddress=$macaddress)");
+ if($mesg->code) {
+ &main::daemon_log($mesg->error, 1);
+ $plain_name = "none";
+ } else {
+ my $entry= $mesg->entry(0);
+ $plain_name = $entry->get_value("cn");
+ }
+ }
if( $error == 0 ) {
# add job to job queue
my $func_dic = {table=>$main::job_queue_tn,
- primkey=>['id'],
+ primkey=>[],
timestamp=>$timestamp,
status=>'waiting',
result=>'none',
targettag=>$target,
xmlmessage=>$msg,
macaddress=>$macaddress,
+ plainname=>$plain_name,
};
-
my $res = $main::job_db->add_dbentry($func_dic);
if (not $res == 0) {
&main::daemon_log("$session_id ERROR: GosaPackages: process_job_msg: $res", 1);