Code

Added get_dns_domains
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 22 Feb 2008 16:25:29 +0000 (16:25 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 22 Feb 2008 16:25:29 +0000 (16:25 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9088 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/modules/GosaSupportDaemon.pm

index 813ea4f02f3395385d231a5b28735ccd52d2eb92..219a2fde5193f0bda81941d569453c231bd2e41e 100644 (file)
@@ -15,6 +15,7 @@ my @functions = (
     "get_update_statement",
     "get_limit_statement",
     "get_orderby_statement",
+    "get_dns_domains",
     ); 
 @EXPORT = @functions;
 use strict;
@@ -412,4 +413,28 @@ sub get_orderby_statement {
     return $order_str;
 }
 
+sub get_dns_domains() {
+        my $line;
+        my @searches;
+        open(RESOLV, "</etc/resolv.conf") or return @searches;
+        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;
+}
+
 1;