index d78915395eea8918a6c2e472dbd8792e6a2b3ff2..64c72c0a36f0c3a4905a8df6b0ff164159b847b9 100644 (file)
if((not defined($main::gosa_unit_tag)) || length($main::gosa_unit_tag) == 0) {
# Read gosaUnitTag from LDAP
my $tmp_ldap= Net::LDAP->new($ldap_uri);
- if(defined($tmp_ldap)) {
- &main::daemon_log("Searching for servers gosaUnitTag with mac address $server_mac_address",6);
+ if( defined($tmp_ldap) ) {
+ &main::daemon_log("INFO: Searching for servers gosaUnitTag with mac address $server_mac_address",5);
my $mesg= $tmp_ldap->bind($ldap_admin_dn, password => $ldap_admin_password);
# Perform search for Unit Tag
$mesg = $tmp_ldap->search(
my $entry= $mesg->entry(0);
my $unit_tag= $entry->get_value("gosaUnitTag");
if(defined($unit_tag) && length($unit_tag) > 0) {
- &main::daemon_log("Detected gosaUnitTag $unit_tag for creating entries", 4);
+ &main::daemon_log("INFO: Detected gosaUnitTag $unit_tag for creating entries", 5);
$main::gosa_unit_tag= $unit_tag;
}
} else {
# Perform another search for Unit Tag
my $hostname= `hostname -f`;
chomp($hostname);
- &main::daemon_log("Searching for servers gosaUnitTag with hostname $hostname",6);
+ &main::daemon_log("INFO: Searching for servers gosaUnitTag with hostname $hostname",5);
$mesg = $tmp_ldap->search(
base => $ldap_base,
scope => 'sub',
@@ -104,14 +104,14 @@ if((not defined($main::gosa_unit_tag)) || length($main::gosa_unit_tag) == 0) {
my $entry= $mesg->entry(0);
my $unit_tag= $entry->get_value("gosaUnitTag");
if(defined($unit_tag) && length($unit_tag) > 0) {
- &main::daemon_log("Detected gosaUnitTag $unit_tag for creating entries", 4);
+ &main::daemon_log("INFO: Detected gosaUnitTag $unit_tag for creating entries", 5);
$main::gosa_unit_tag= $unit_tag;
}
} else {
# Perform another search for Unit Tag
$hostname= `hostname -s`;
chomp($hostname);
- &main::daemon_log("Searching for servers gosaUnitTag with hostname $hostname",6);
+ &main::daemon_log("INFO: Searching for servers gosaUnitTag with hostname $hostname",5);
$mesg = $tmp_ldap->search(
base => $ldap_base,
scope => 'sub',
@@ -122,24 +122,20 @@ if((not defined($main::gosa_unit_tag)) || length($main::gosa_unit_tag) == 0) {
my $entry= $mesg->entry(0);
my $unit_tag= $entry->get_value("gosaUnitTag");
if(defined($unit_tag) && length($unit_tag) > 0) {
- &main::daemon_log("Detected gosaUnitTag $unit_tag for creating entries", 4);
+ &main::daemon_log("INFO: Detected gosaUnitTag $unit_tag for creating entries", 5);
$main::gosa_unit_tag= $unit_tag;
}
} else {
- &main::daemon_log("Not using gosaUnitTag", 6);
+ &main::daemon_log("WARNING: No gosaUnitTag detected. Not using gosaUnitTag", 3);
}
}
}
+ $tmp_ldap->unbind;
} else {
- &main::daemon_log("Using gosaUnitTag from config-file: $main::gosa_unit_tag",6);
+ &main::daemon_log("INFO: Using gosaUnitTag from config-file: $main::gosa_unit_tag",5);
}
- $tmp_ldap->unbind;
}
-# complete addresses
-#if( $server_ip eq "0.0.0.0" ) {
-# $server_ip = "127.0.0.1";
-#}
my $server_address = "$server_ip:$server_port";
$main::server_address = $server_address;
# skip PREFIX
$header =~ s/^CLMSG_//;
- &main::daemon_log("SIPackages: msg to process: $header", 3);
+ &main::daemon_log("DEBUG: SIPackages: msg to process: $header", 7);
&main::daemon_log("$msg", 8);
if( 0 == length @target_l){
} else {
if( exists $event_hash->{$header} ) {
# a event exists with the header as name
- &main::daemon_log("found event '$header' at event-module '".$event_hash->{$header}."'", 5);
+ &main::daemon_log("INFO: found event '$header' at event-module '".$event_hash->{$header}."'", 5);
no strict 'refs';
@out_msg_l = &{$event_hash->{$header}."::$header"}($msg, $msg_hash, $session_id);
}
}
}
else {
- &main::daemon_log("msg is not for gosa-si-server '$server_address', deliver it to target '$target'", 5);
+ &main::daemon_log("INFO: msg is not for gosa-si-server '$server_address', deliver it to target '$target'", 5);
push(@out_msg_l, $msg);
}
}
# number of actual activ clients
my $act_nu_clients = $nu_clients;
- &main::daemon_log("number of actual activ clients: $act_nu_clients", 5);
- &main::daemon_log("number of maximal allowed clients: $max_clients", 5);
+ &main::daemon_log("INFO: number of actual activ clients: $act_nu_clients", 5);
+ &main::daemon_log("INFO: number of maximal allowed clients: $max_clients", 5);
if($max_clients <= $act_nu_clients) {
my $out_hash = &create_xml_hash("denied", $server_address, $source);
&add_content2xml_hash($out_hash, "timestamp", $act_timestamp);
my $new_client_out = &create_xml_string($out_hash);
push(@out_msg_l, $new_client_out);
- &main::daemon_log("send bus msg that client '$source' has registerd at server '$server_address'", 3);
+ &main::daemon_log("INFO: send bus msg that client '$source' has registerd at server '$server_address'", 5);
}
# give the new client his ldap config
sub new_ldap_config {
my ($address) = @_ ;
- my $sql_statement= "SELECT * FROM known_clients WHERE hostname='$address'";
+ my $sql_statement= "SELECT * FROM known_clients WHERE hostname='$address' OR macaddress='$address'";
my $res = $main::known_clients_db->select_dbentry( $sql_statement );
# check hit
&main::daemon_log("ERROR: more or no hit found in known_clients_db by query by '$address'", 1);
}
+ $address = $res->{1}->{hostname};
my $macaddress = $res->{1}->{macaddress};
my $hostkey = $res->{1}->{hostkey};
foreach $server (@servers){
# Conversation for backward compatibility
- if ($server !=~ /^ldap[^:]+:\/\// ) {
+ if (not $server =~ /^ldap[^:]+:\/\// ) {
if ($server =~ /^([^:]+):(.*)$/ ) {
- $server= "1:dummy:ldap://$1/$2";
+ $server= "1:dummy:ldap://$1/$2";
}
}
# Unbind
$mesg = $ldap->unbind;
+ if($mesg->code) {
+ &main::daemon_log($mesg->error, 1);
+ return;
+ }
# Send information
return &build_msg("new_ldap_config", $server_address, $address, \%data);
}
-#sub process_detected_hardware {
-# my $msg_hash = shift;
-# my $address = $msg_hash->{source}[0];
-# my $gotoHardwareChecksum= $msg_hash->{detected_hardware}[0]->{gotoHardwareChecksum};
-#
-# my $sql_statement= "SELECT * FROM known_clients WHERE hostname='$address'";
-# my $res = $main::known_clients_db->select_dbentry( $sql_statement );
-#
-# # check hit
-# my $hit_counter = keys %{$res};
-# if( not $hit_counter == 1 ) {
-# &main::daemon_log("ERROR: more or no hit found in known_clients_db by query by '$address'", 1);
-# return;
-# }
-#
-# my $macaddress = $res->{1}->{macaddress};
-# my $hostkey = $res->{1}->{hostkey};
-#
-# if (not defined $macaddress) {
-# &main::daemon_log("ERROR: no mac address found for client $address", 1);
-# return;
-# }
-# # Build LDAP connection
-# my $ldap = Net::LDAP->new($ldap_uri);
-# if( not defined $ldap ) {
-# &main::daemon_log("ERROR: cannot connect to ldap: $ldap_uri", 1);
-# return;
-# }
-#
-# # Bind to a directory with dn and password
-# my $mesg= $ldap->bind($ldap_admin_dn, password => $ldap_admin_password);
-#
-# # Perform search
-# $mesg = $ldap->search(
-# base => $ldap_base,
-# scope => 'sub',
-# filter => "(&(objectClass=GOhard)(|(macAddress=$macaddress)(dhcpHWaddress=ethernet $macaddress)))"
-# );
-#
-# # We need to create a base entry first (if not done from ArpHandler)
-# if($mesg->count == 0) {
-# &main::daemon_log("Need to create a new LDAP Entry for client $address", 1);
-# my $resolver=Net::DNS::Resolver->new;
-# my $ipaddress= $1 if $address =~ /^([0-9\.]*?):.*$/;
-# my $dnsresult= $resolver->search($ipaddress);
-# my $dnsname= (defined($dnsresult))?$dnsresult->{answer}[0]->{ptrdname}:$ipaddress;
-# my $cn = (($dnsname =~ /^(\d){1,3}\.(\d){1,3}\.(\d){1,3}\.(\d){1,3}/) ? $dnsname : sprintf "%s", $dnsname =~ /([^\.]+)\.?/);
-# my $dn = "cn=$cn,ou=incoming,$ldap_base";
-# &main::daemon_log("Creating entry for $dn",6);
-# my $entry= Net::LDAP::Entry->new( $dn );
-# $entry->dn($dn);
-# $entry->add("objectClass" => "goHard");
-# $entry->add("cn" => $cn);
-# $entry->add("macAddress" => $macaddress);
-# $entry->add("gotomode" => "locked");
-# $entry->add("gotoSysStatus" => "new-system");
-# $entry->add("ipHostNumber" => $ipaddress);
-# if(defined($main::gosa_unit_tag) && length($main::gosa_unit_tag) > 0) {
-# $entry->add("objectClass" => "gosaAdministrativeUnit");
-# $entry->add("gosaUnitTag" => $main::gosa_unit_tag);
-# }
-# my $res=$entry->update($ldap);
-# if(defined($res->{'errorMessage'}) &&
-# length($res->{'errorMessage'}) >0) {
-# &main::daemon_log("There was a problem adding the entries to LDAP:", 1);
-# &main::daemon_log($res->{'errorMessage'}, 1);
-# return;
-# } else {
-# # Fill $mesg again
-# $mesg = $ldap->search(
-# base => $ldap_base,
-# scope => 'sub',
-# filter => "(&(objectClass=GOhard)(|(macAddress=$macaddress)(dhcpHWaddress=ethernet $macaddress)))"
-# );
-# }
-# }
-#
-# if($mesg->count == 1) {
-# my $entry= $mesg->entry(0);
-# $entry->changetype("modify");
-# foreach my $attribute (
-# "gotoSndModule", "ghNetNic", "gotoXResolution", "ghSoundAdapter", "ghCpuType", "gotoXkbModel",
-# "ghGfxAdapter", "gotoXMousePort", "ghMemSize", "gotoXMouseType", "ghUsbSupport", "gotoXHsync",
-# "gotoXDriver", "gotoXVsync", "gotoXMonitor", "gotoHardwareChecksum") {
-# if(defined($msg_hash->{detected_hardware}[0]->{$attribute}) &&
-# length($msg_hash->{detected_hardware}[0]->{$attribute}) >0 ) {
-# if(defined($entry->get_value($attribute))) {
-# $entry->delete($attribute);
-# }
-# &main::daemon_log("Adding attribute $attribute with value ".$msg_hash->{detected_hardware}[0]->{$attribute},1);
-# $entry->add($attribute => $msg_hash->{detected_hardware}[0]->{$attribute});
-# }
-# }
-# foreach my $attribute (
-# "gotoModules", "ghScsiDev", "ghIdeDev") {
-# if(defined($msg_hash->{detected_hardware}[0]->{$attribute}) &&
-# length($msg_hash->{detected_hardware}[0]->{$attribute}) >0 ) {
-# if(defined($entry->get_value($attribute))) {
-# $entry->delete($attribute);
-# }
-# foreach my $array_entry (@{$msg_hash->{detected_hardware}[0]->{$attribute}}) {
-# $entry->add($attribute => $array_entry);
-# }
-# }
-# }
-#
-# my $res=$entry->update($ldap);
-# if(defined($res->{'errorMessage'}) &&
-# length($res->{'errorMessage'}) >0) {
-# &main::daemon_log("There was a problem adding the entries to LDAP:", 1);
-# &main::daemon_log($res->{'errorMessage'}, 1);
-# } else {
-# &main::daemon_log("Added Hardware configuration to LDAP", 4);
-# }
-#
-# }
-# return;
-#}
+
#=== FUNCTION ================================================================
# NAME: hardware_config
# PARAMETERS: address - string - ip address and port of a host