From: janw Date: Mon, 3 Mar 2008 10:53:50 +0000 (+0000) Subject: Fixed typo. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c62cee2d9f122481cd9415228d440ad0ff48afb8;p=gosa.git Fixed typo. Added option "force-hostname" to client and server. If set, the Environment Variable $HOSTNAME will be used for registration, a force-hostname gets added to the registration hash. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9238 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index afb51ba26..abda025bd 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -61,6 +61,7 @@ our $client_address; our $client_ip; our $client_mac_address; our $client_dnsname; +our $client_force_hostname; our $server_key; # default variables @@ -91,6 +92,7 @@ our $prg= basename($0); "pam-config" => [\$pam_config, "/etc/pam_ldap.conf"], "nss-config" => [\$nss_config, "/etc/libnss_ldap.conf"], "fai-logpath" => [\$fai_logpath, "/var/log/fai/fai.log"], + "force-hostname" => [\$client_force_hostname, "false"], }, "server" => { "ip" => [\$server_ip, "127.0.0.1"], @@ -721,6 +723,17 @@ sub register_at_gosa_si_server { &add_content2xml_hash($register_hash, "events", $events); &add_content2xml_hash($register_hash, "gotoHardwareChecksum", $gotoHardwareChecksum); + # Add $HOSTNAME from ENV if force-hostname is set + if( defined($client_force_hostname) && + $client_force_hostname eq "true") { + if(defined($ENV{HOSTNAME}) && + length($ENV{HOSTNAME}) >0 ) { + &add_content2xml_hash($register_hash, "force-hostname", $ENV{HOSTNAME}); + } else { + &main::daemon_log("force-hostname was set to true, but no \$HOSTNAME was found in Environment!",0); + } + } + # send xml hash to server with general server passwd my $res = &send_msg_hash_to_target($register_hash, $server, $default_server_key); if($res == 0) { diff --git a/gosa-si/modules/SIPackages.pm b/gosa-si/modules/SIPackages.pm index c17608677..385826383 100644 --- a/gosa-si/modules/SIPackages.pm +++ b/gosa-si/modules/SIPackages.pm @@ -575,7 +575,7 @@ sub here_i_am { &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("INFO: send bus msg that client '$source' has registerd at server '$server_address'", 5); + &main::daemon_log("INFO: send bus msg that client '$source' has registered at server '$server_address'", 5); } # give the new client his ldap config diff --git a/gosa-si/server/events/siTriggered.pm b/gosa-si/server/events/siTriggered.pm index 488cc14f1..c6728266c 100644 --- a/gosa-si/server/events/siTriggered.pm +++ b/gosa-si/server/events/siTriggered.pm @@ -156,9 +156,18 @@ sub detected_hardware { # We need to create a base entry first (if not done from ArpHandler) if($mesg->count == 0) { - &main::daemon_log("INFO: Need to create a new LDAP Entry for client $address", 6); + &main::daemon_log("INFO: Need to create a new LDAP Entry for client $address", 4); my $ipaddress= $1 if $address =~ /^([0-9\.]*?):.*$/; - my $dnsname= gethostbyaddr(inet_aton($ipaddress), AF_INET) || $ipaddress; + my $dnsname; + if (defined($msg_hash->{'force-hostname'}) && + defined($msg_hash->{'force-hostname'}[0]) && + length($msg_hash->{'force-hostname'}[0]) > 0){ + $dnsname= $msg_hash->{'force-hostname'}[0]; + &main::daemon_log("INFO: Using forced hostname $dnsname for client $address", 4); + } else { + gethostbyaddr(inet_aton($ipaddress), AF_INET) || $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("INFO: Creating entry for $dn",5);