File Coverage

blib/lib/Net/DNS/Resolver/UNIX.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Net::DNS::Resolver::UNIX;
2              
3 92     92   824 use strict;
  92         210  
  92         3809  
4 92     92   505 use warnings;
  92         220  
  92         41922  
5             our $VERSION = (qw$Id: UNIX.pm 2007 2025-02-08 16:45:23Z willem $)[2];
6              
7              
8             =head1 NAME
9              
10             Net::DNS::Resolver::UNIX - Unix resolver class
11              
12             =cut
13              
14              
15             my @config_file = grep { -f $_ && -r $_ } '/etc/resolv.conf';
16              
17             my $homedir = $ENV{HOME};
18             my $dotfile = '.resolv.conf';
19             my @dotfile = grep { -f $_ && -o $_ } map {"$_/$dotfile"} grep {$_} $homedir, '.';
20              
21              
22             my $path = $ENV{PATH};
23             local $ENV{PATH} = join ':', grep {$_} qw(/bin /usr/bin), $path;
24             my $uname = eval {`uname -n 2>/dev/null`} || '';
25             chomp $uname;
26             my ( $host, @domain ) = split /\./, $uname, 2;
27              
28              
29             sub _init {
30 8     8   36 my $defaults = shift->_defaults;
31              
32 8         50 $defaults->domain(@domain);
33 8         72 $defaults->_read_config_file($_) foreach @config_file;
34              
35 8         122 %$defaults = Net::DNS::Resolver::Base::_untaint(%$defaults);
36              
37 8         73 $defaults->_read_config_file($_) foreach @dotfile;
38              
39 8         64 $defaults->_read_env;
40 8         18 return;
41             }
42              
43              
44             1;
45             __END__