summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9bbfb86)
raw | patch | inline | side by side (parent: 9bbfb86)
author | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 25 Feb 2008 09:03:10 +0000 (09:03 +0000) | ||
committer | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 25 Feb 2008 09:03:10 +0000 (09:03 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9095 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-client | patch | blob | history |
diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index 2252d5960b9e50ef380d149d6b8f1dc8c01e8c12..f23bd11724fc97e332f832e67ceade3e76ab88b0 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
if( $error == 0 ) {
foreach my $hit (@hits) {
my ($hit_name, $hit_port) = split(/:/, $hit);
+ chomp($hit_name);
+ chomp($hit_port);
my $address_query = $res->send($hit_name);
if( 1 == length($address_query->answer) ) {
return;
}
+sub get_dns_domains() {
+ my $line;
+ my @searches;
+ open(RESOLV, "</etc/resolv.conf");
+ while(<RESOLV>){
+ $line= $_;
+ chomp $line;
+ $line =~ s/^\s+//;
+ $line =~ s/\s+$//;
+ $line =~ s/\s+/ /;
+ if ($line =~ /^domain (.*)$/ ){
+ push(@searches, $1);
+ } elsif ($line =~ /^search (.*)$/ ){
+ push(@searches, split(/ /, $1));
+ }
+ }
+ close(RESOLV);
+
+ my %tmp = map { $_ => 1 } @searches;
+ @searches = sort keys %tmp;
+
+ return @searches;
+}
+
#==== MAIN = main ==============================================================
# parse commandline options
Getopt::Long::Configure( "bundling" );
my $server_check_cfg = Config::IniFiles->new( -file => $cfg_file );
my $server_check = $server_check_cfg->val( "server", "ip");
if( defined $server_check ) {
- unshift(@servers, $server_address);
- my $servers_string = join(", ", @servers);
- daemon_log("found servers in configuration file: $servers_string", 5);
-}
-else {
- if ( !$server_domain) {
- daemon_log("ERROR: please specify a gosa-si-server address or a domain in config file", 1);
- kill 2, $$;
- }
- my @tmp_servers = &get_server_addresses($server_domain);
- if( 0 == @tmp_servers ) {
- daemon_log("ERROR: no gosa-si-server found in DNS for domain '$server_domain'",1);
- daemon_log("ERROR: please specify a gosa-si-server address or a domain in config file", 1);
- kill 2, $$;
- }
-
- foreach my $server (@tmp_servers) {
- unshift(@servers, $server);
- }
- my $servers_string = join(", ", @servers);
- daemon_log("found servers in DNS: $servers_string", 5);
+ unshift(@servers, $server_address);
+ my $servers_string = join(", ", @servers);
+ daemon_log("found servers in configuration file: $servers_string", 5);
+} else {
+ my @tmp_servers;
+ if ( !$server_domain) {
+ # Try our DNS Searchlist
+ for my $domain(get_dns_domains()) {
+ chomp($domain);
+ my @tmp_domains= &get_server_addresses($domain);
+ if(@tmp_domains) {
+ for my $tmp_server(@tmp_domains) {
+ push @tmp_servers, $tmp_server;
+ }
+ }
+ }
+ if(@tmp_servers && length(@tmp_servers)==0) {
+ daemon_log("ERROR: please specify a gosa-si-server address or a domain in config file", 1);
+ kill 2, $$;
+ }
+ } else {
+ @tmp_servers = &get_server_addresses($server_domain);
+ if( 0 == @tmp_servers ) {
+ daemon_log("ERROR: no gosa-si-server found in DNS for domain '$server_domain'",1);
+ daemon_log("ERROR: please specify a gosa-si-server address or a domain in config file", 1);
+ kill 2, $$;
+ }
+ }
+
+ foreach my $server (@tmp_servers) {
+ unshift(@servers, $server);
+ }
+ my $servers_string = join(", ", @servers);
+ daemon_log("found servers in DNS: $servers_string", 5);
}