| 1 | package Net::DNS::Resolver::UNIX; | ||||||||||
| 2 | |||||||||||
| 3 | 184 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 184 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 92 | our $VERSION = (qw$Id: UNIX.pm 2053 2026-07-07 10:18:23Z willem $)[2]; | |||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | =head1 NAME | ||||||||||
| 9 | |||||||||||
| 10 | Net::DNS::Resolver::UNIX - Unix resolver class | ||||||||||
| 11 | |||||||||||
| 12 | =cut | ||||||||||
| 13 | |||||||||||
| 14 | |||||||||||
| 15 | 92 | ▶ | my @config_file = grep { -f $_ && -r $_ } '/etc/resolv.conf'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | |||||||||||
| 17 | 92 | my $homedir = $ENV{HOME}; | |||||||||
| 18 | 92 | my $dotfile = '.resolv.conf'; | |||||||||
| 19 | 92 | ▶ | my @dotfile = grep { -f $_ && -o $_ } map {"$_/$dotfile"} grep {$_} $homedir, '.'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | |||||||||||
| 21 | 92 | my ($name) = _nosh(qw(uname -n)); | |||||||||
| 22 | 92 | chomp $name; | |||||||||
| 23 | 92 | my ( undef, @domain ) = split /\./, $name, 2; | |||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | sub _init { | ||||||||||
| 27 | 8 | ▶ | my $defaults = shift->_defaults; | ||||||||
|
Subroutine
_init: called CC=3 SCAR=11.0
| |||||||||||
| 28 | |||||||||||
| 29 | 8 | $defaults->domain(@domain); | |||||||||
| 30 | 8 | $defaults->_read_config_file($_) foreach @config_file; | |||||||||
| 31 | |||||||||||
| 32 | 8 | %$defaults = Net::DNS::Resolver::Base::_untaint(%$defaults); | |||||||||
| 33 | |||||||||||
| 34 | 8 | $defaults->_read_config_file($_) foreach @dotfile; | |||||||||
| 35 | |||||||||||
| 36 | 8 | $defaults->_read_env; | |||||||||
| 37 | 8 | return; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | sub _nosh { ## shell-free backtick emulation | ||||||||||
| 41 | 184 | ▶ | my ( $prog, @arg ) = @_; | ||||||||
|
Subroutine
_nosh: called CC=2 SCAR=6.9
| |||||||||||
| 42 | 184 | ▶ | if ( open( my $pipe, '-|' ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 92 | my @retval = ( <$pipe>, '' ); | |||||||||
| 44 | 92 | close $pipe; | |||||||||
| 45 | 92 | return @retval; | |||||||||
| 46 | } else { | ||||||||||
| 47 | 92 | ▶ | local $SIG{__WARN__} = sub { }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 48 | 92 | warn 'child process fails without warning'; | |||||||||
| 49 | 92 | eval { exec $prog, @arg }; | |||||||||
| 50 | 0 | exit; ## uncoverable statement | |||||||||
| 51 | } | ||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 92 | 1; | |||||||||
| 55 | __END__ | ||||||||||