| 1 | package Langertha::Holmgang::Sim::Linux::SshAccess; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Whether a user can log in over SSH: port, firewall, Match, account, authorized_keys, StrictModes | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Langertha::Holmgang::Sim::Linux::Nft (); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | my $MAIN = '/etc/ssh/sshd_config'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 168 | ▶ | sub _files { my ($dev) = @_; return ref $dev->{files} eq 'HASH' ? $dev->{files} : {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_files: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 304 | ▶ | sub _svc { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_svc: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 304 | my ($dev) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 304 | ▶ | my $s = $dev->{services} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$dev{'services'} || {}
MC/DC0%0/1
$$dev{'services'} || {}
$$dev{'services'}
Truth table50%1/2
A
A= $$dev{'services'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 304 | ▶ | return $s->{ssh} // $s->{sshd}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$$s{"ssh"} // $$s{"sshd"}
MC/DC0%0/2
$$s{"ssh"} // $$s{"sshd"}
$$s{"ssh"}
$$s{"sshd"}
Truth table33%1/3
A // B
A= $$s{"ssh"}B= $$s{"sshd"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 145 | ▶ | sub _text { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_text: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 145 | my ( $files, $p ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 145 | my $e = $files->{$p}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 145 | ▶ | return undef unless defined $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 145 | ▶ | return ref $e eq 'HASH' ? ( $e->{content} // '' ) : $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$e{"content"} // ""
MC/DC0%0/1
$$e{"content"} // ""
$$e{"content"}
Truth table50%1/2
A
A= $$e{"content"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 174 | ▶ | sub remember { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remember: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 174 | my ($dev) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 174 | ▶ | my $svc = _svc($dev) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 174 | ▶ | return if exists $svc->{_loaded}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 37 | loaded($dev); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 37 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 44 | ▶ | sub loaded { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loaded: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 44 | my ($dev) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 44 | ▶ | my $svc = _svc($dev) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 44 | my $f = _files($dev); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 44 | ▶ | $svc->{_loaded} = { map { $_ => _text( $f, $_ ) } grep { m{\A/etc/ssh/} && !m{/ssh_host_} } keys %$f }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
m[\A/etc/ssh/] && !m[/ssh_host_]
MC/DC100%2/2
m[\A/etc/ssh/] && !m[/ssh_host_]
m[\A/etc/ssh/]
!m[/ssh_host_]
Truth table100%3/3
A && not(B)
A= m[\A/etc/ssh/]B= !m[/ssh_host_]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 44 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 56 | ▶ | sub _snapshot { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_snapshot: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 56 | my ($dev) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 56 | ▶ | my $svc = _svc($dev) || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
_svc($dev) || {}
MC/DC0%0/1
_svc($dev) || {}
_svc($dev)
Truth table50%1/2
A
A= _svc($dev)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 56 | ▶ | return $svc->{_loaded} if ref $svc->{_loaded} eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 29 | my $f = _files($dev); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 29 | return { map { $_ => _text( $f, $_ ) } grep { m{\A/etc/ssh/} } keys %$f }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # Zeilen der Konfiguration mit aufgeloesten Include (wie sshd, an Ort und Stelle) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 60 | ▶ | sub _lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lines: called CC=10 SCAR=23.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 60 | my ( $snap, $file, $depth ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 60 | ▶ | return () if $depth > 8; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 60 | ▶ | my $t = $snap->{$file} // return (); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$snap{$file} // (return ())
MC/DC0%0/1
$$snap{$file} // (return ())
$$snap{$file}
Truth table50%1/2
A
A= $$snap{$file}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 60 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 60 | for my $line ( split /\n/, $t ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 125 | ( my $l = $line ) =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 125 | ▶ | next if $l eq '' || $l =~ /\A#/; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$l eq "" or $l =~ /\A#/
MC/DC0%0/2
$l eq "" or $l =~ /\A#/
$l eq ""
$l =~ /\A#/
Truth table33%1/3
A or B
A= $l eq ""B= $l =~ /\A#/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 125 | ▶ | if ( $l =~ /\AInclude\s+(.+)\z/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 40 | for my $pat ( split /\s+/, $1 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 40 | ▶ | $pat = "/etc/ssh/$pat" unless $pat =~ m{\A/}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 40 | ( my $re = quotemeta $pat ) =~ s/\\\*/[^\/]*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 40 | push @out, _lines( $snap, $_, $depth + 1 ) for sort grep {/\A$re\z/} keys %$snap; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 40 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 85 | push @out, $l; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 60 | return @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 85 | ▶ | sub _kv { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_kv: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 85 | my ($l) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 85 | ▶ | my ( $k, $v ) = $l =~ /\A(\S+?)(?:\s*=\s*|\s+)(.*)\z/ or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 85 | $v =~ s/\A"(.*)"\z/$1/; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 85 | return ( lc $k, $v ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 3 | my %LIST = map { $_ => 1 } qw( allowusers allowgroups denyusers denygroups port listenaddress authorizedkeysfile ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 15 | ▶ | sub _ip_in { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ip_in: called CC=9 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 15 | my ( $ip, $pat ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 15 | ▶ | return 0 unless defined $ip; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 15 | ▶ | if ( $pat =~ m{/} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 11 | ▶ | my $r = Langertha::Holmgang::Sim::Linux::Nft::_range($pat) or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 11 | ▶ | my ( $f, $b ) = Langertha::Holmgang::Sim::Linux::Nft::_addr_bin($ip) or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 8 | ▶ | return 0 unless $f == $r->[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 8 | my $bits = unpack( 'B*', $b ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 8 | ▶ | return $bits ge $r->[1] && $bits le $r->[2] ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$bits ge $$r[1] and $bits le $$r[2]
MC/DC100%2/2
$bits ge $$r[1] and $bits le $$r[2]
$bits ge $$r[1]
$bits le $$r[2]
Truth table100%3/3
A and B
A= $bits ge $$r[1]B= $bits le $$r[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 4 | ( my $re = quotemeta $pat ) =~ s/\\\*/.*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 4 | $re =~ s/\\\?/./g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 4 | ▶ | return $ip =~ /\A$re\z/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 8 | ▶ | sub _pat { my ( $p, $v ) = @_; ( my $re = quotemeta $p ) =~ s/\\\*/.*/g; $re =~ s/\\\?/./g; return defined $v && $v =~ /\A$re\z/ ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pat: called CC=3 SCAR=11.0
Branch: 1 branch
Condition66%2/3
defined $v and $v =~ /\A$re\z/
MC/DC50%1/2
defined $v and $v =~ /\A$re\z/
defined $v
$v =~ /\A$re\z/
Truth table66%2/3
A and B
A= defined $vB= $v =~ /\A$re\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # Musterliste wie sshd (Komma, ! verneint: passt ein verneintes, passt die Liste nicht) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 16 | ▶ | sub _list_match { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_list_match: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 16 | my ( $list, $test ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 16 | my $hit = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 16 | for my $p ( split /\s*,\s*/, $list ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 20 | ▶ | if ( $p =~ s/\A!// ) { return 0 if $test->($p) } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 6 | elsif ( $test->($p) ) { $hit = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 15 | return $hit; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 11 | ▶ | sub _criteria_match { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_criteria_match: called CC=13 SCAR=28.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 11 | my ( $crit, $c ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 11 | my @w = split /\s+/, $crit; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 11 | ▶ | return 1 if @w == 1 && lc $w[0] eq 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@w == 1 and lc $w[0] eq "all"
MC/DC0%0/2
@w == 1 and lc $w[0] eq "all"
@w == 1
lc $w[0] eq "all"
Truth table33%1/3
A and B
A= @w == 1B= lc $w[0] eq "all"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 11 | ▶ | while (@w) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 12 | my $k = lc shift @w; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 12 | ▶ | my $v = shift @w // return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @w // (return 0)
MC/DC0%0/1
shift @w // (return 0)
shift @w
Truth table50%1/2
A
A= shift @w
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 12 | ▶ | if ( $k eq 'user' ) { return 0 unless _list_match( $v, sub { _pat( $_[0], $c->{user} ) } ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.3
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 4 | ▶ | elsif ( $k eq 'group' ) { return 0 unless _list_match( $v, sub { my $p = $_[0]; grep { _pat( $p, $_ ) } @{ $c->{groups} } } ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 7 | ▶ | elsif ( $k eq 'address' ) { return 0 unless _list_match( $v, sub { _ip_in( $c->{from}, $_[0] ) } ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | elsif ( $k eq 'localport' ) { return 0 unless _list_match( $v, sub { $_[0] eq $c->{port} } ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | else { return 0 } # Host, LocalAddress, RDomain: hier nicht nachgebildet -> trifft nicht zu | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 56 | ▶ | sub config_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config_for: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 56 | my ( $dev, $c, $files ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 56 | my ( $eff, $over ) = _config( $dev, $c, $files ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 56 | return $eff; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | ▶ | sub match_overrides { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
match_overrides: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | my ( $dev, $c, $files ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | my ( $eff, $over ) = _config( $dev, $c, $files ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | return $over; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 58 | ▶ | sub _config { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_config: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 58 | my ( $dev, $c, $files ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 58 | ▶ | my $snap = $files ? { map { $_ => _text( _files($dev), $_ ) } grep { m{\A/etc/ssh/} } keys %{ _files($dev) } } : _snapshot($dev); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 58 | my ( %glob, @blocks ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 58 | my $cur; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 58 | for my $l ( _lines( $snap, $MAIN, 0 ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 85 | ▶ | my ( $k, $v ) = _kv($l) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 85 | ▶ | if ( $k eq 'match' ) { push @blocks, $cur = { crit => $v, set => {} }; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 74 | ▶ | my $h = $cur ? $cur->{set} : \%glob; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 74 | ▶ | if ( $LIST{$k} ) { push @{ $h->{$k} }, split /\s+/, $v; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 53 | ▶ | $h->{$k} = $v unless exists $h->{$k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 58 | my %eff = %glob; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 58 | my %over; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 58 | for my $b ( grep { _criteria_match( $_->{crit}, $c ) } @blocks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 3 | for my $k ( grep { !/\A_/ } keys %{ $b->{set} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 3 | ▶ | next if exists $over{$k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 3 | $eff{$k} = $over{$k} = $b->{set}{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 58 | return ( \%eff, \%over ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 96 | ▶ | sub _yes { my ( $v, $def ) = @_; return lc( $v // $def ) eq 'yes' ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_yes: called CC=3 SCAR=11.1
Branch: 1 branch
Condition66%2/3
$v // $def
MC/DC0%0/2
$v // $def
$v
$def
Truth table66%2/3
A // B
A= $vB= $def
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 89 | ▶ | sub _entry { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_entry: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 89 | my ( $dev, $p ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 89 | my $f = _files($dev); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 89 | ▶ | return ( ref $f->{$p} eq 'HASH' ? $f->{$p} : { content => $f->{$p} } ) if exists $f->{$p}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 49 | ▶ | return ( { mode => '0755', %{ $dev->{dirs}{$p} } }, 'dir' ) if ( $dev->{dirs} || {} )->{$p}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$dev{'dirs'} || {}
MC/DC0%0/1
$$dev{'dirs'} || {}
$$dev{'dirs'}
Truth table50%1/2
A
A= $$dev{'dirs'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 13 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # StrictModes: Datei und Verzeichnisse bis zum Heimatverzeichnis | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 20 | ▶ | sub _strict_bad { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_strict_bad: called CC=8 SCAR=21.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 20 | my ( $dev, $user, $home, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 20 | my ( $e ) = _entry( $dev, $file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 56 | ▶ | my $chk = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=20.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 56 | my ( $x, $p, $what ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 56 | ▶ | my $o = $x->{owner} // 'root'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$x{"owner"} // "root"
MC/DC0%0/1
$$x{"owner"} // "root"
$$x{"owner"}
Truth table50%1/2
A
A= $$x{"owner"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 56 | ▶ | my $m = oct( $x->{mode} // ( $what eq 'file' ? '0644' : '0755' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$x{"mode"} // ($what eq "file" ? "0644" : "0755")
MC/DC0%0/1
$$x{"mode"} // ($what eq "file" ? "0644" : "0755")
$$x{"mode"}
Truth table50%1/2
A
A= $$x{"mode"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 56 | ▶ | return "bad ownership or modes for $what $p" if ( $o ne $user && $o ne 'root' ) || ( $m & 022 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$o ne $user and $o ne "root" or $m & 18
$o ne $user and $o ne "root"
MC/DC100%3/3
$o ne $user and $o ne "root" or $m & 18
$o ne $user
$o ne "root"
$m & 18
Truth table80%4/5
A and B or C
A= $o ne $userB= $o ne "root"C= $m & 18
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 52 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 20 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 20 | my $bad = $chk->( $e, $file, 'file' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 20 | ▶ | return $bad if $bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 18 | ( my $d = $file ) =~ s{/[^/]+\z}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 18 | ▶ | while ( length $d >= length $home ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 36 | my ($de) = _entry( $dev, $d ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 36 | ▶ | $de //= { mode => '0755', owner => $d eq $home ? $user : 'root' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$de //= {"mode", "0755", "owner", $d eq $home ? $user : "root"}
MC/DC0%0/1
$de //= {"mode", "0755", "owner", $d eq $home ? $user : "root"}
$de
Truth table50%1/2
A
A= $de
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 36 | $bad = $chk->( $de, $d, 'directory' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 36 | ▶ | return $bad if $bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 34 | ▶ | last if $d eq $home; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 18 | ▶ | $d =~ s{/[^/]+\z}{} or last; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 16 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 17 | ▶ | sub _key_parts { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_key_parts: called CC=9 SCAR=22.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 17 | my ($line) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 17 | my @t; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 17 | my $s = $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 17 | ▶ | while ( length $s ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 55 | $s =~ s/\A\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 55 | ▶ | last unless length $s; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | if ( $s =~ s/\A((?:[^\s"]|"[^"]*")+)// ) { push @t, $1 } else { last } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 17 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 17 | ▶ | $i++ while $i < @t && $t[$i] !~ /\A(?:ssh-|ecdsa-|sk-)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$i < @t and not $t[$i] =~ /\A(?:ssh-|ecdsa-|sk-)/
MC/DC50%1/2
$i < @t and not $t[$i] =~ /\A(?:ssh-|ecdsa-|sk-)/
$i < @t
not $t[$i] =~ /\A(?:ssh-|ecdsa-|sk-)/
Truth table66%2/3
A and not(B)
A= $i < @tB= not $t[$i] =~ /\A(?:ssh-|ecdsa-|sk-)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 17 | ▶ | return if $i >= @t; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 17 | ▶ | my $opts = $i ? $t[0] : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 17 | ▶ | return ( $opts, $t[$i], $t[ $i + 1 ] // '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$t[$i + 1] // ""
MC/DC0%0/1
$t[$i + 1] // ""
$t[$i + 1]
Truth table50%1/2
A
A= $t[$i + 1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 11 | ▶ | sub _from_ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_from_ok: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 11 | my ( $opts, $from ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 11 | ▶ | return 1 unless $opts =~ /(?:\A|,)from="([^"]*)"/; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 4 | ▶ | return _list_match( $1, sub { _ip_in( $from, $_[0] ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 30 | ▶ | sub check { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check: called CC=76 SCAR=54.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 30 | my ( $dev, $t, $host ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 30 | ▶ | $host //= 'host'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$host //= "host"
MC/DC0%0/1
$host //= "host"
$host
Truth table50%1/2
A
A= $host
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 30 | ▶ | my $user = $t->{user} // 'root'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$t{"user"} // "root"
MC/DC0%0/1
$$t{"user"} // "root"
$$t{"user"}
Truth table50%1/2
A
A= $$t{"user"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 30 | ▶ | my $from = $t->{from} // '0.0.0.0'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$t{"from"} // "0.0.0.0"
MC/DC0%0/1
$$t{"from"} // "0.0.0.0"
$$t{"from"}
Truth table50%1/2
A
A= $$t{"from"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 30 | ▶ | my $port = $t->{port} // 22; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$t{"port"} // 22
MC/DC100%1/1
$$t{"port"} // 22
$$t{"port"}
Truth table100%2/2
A
A= $$t{"port"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 30 | my $sport = 50000 + ( unpack( '%16C*', "$user$from" ) % 10000 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 30 | ▶ | my $deny = sub { my ( $methods, @log ) = @_; return ( 0, "$user\@$host: Permission denied ($methods).", @log ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 30 | my $svc = _svc($dev); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 30 | ▶ | return ( 0, "ssh: connect to host $host port $port: Connection refused" ) unless $svc && $svc->{active}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$svc and $$svc{"active"}
MC/DC50%1/2
$svc and $$svc{"active"}
$svc
$$svc{"active"}
Truth table66%2/3
A and B
A= $svcB= $$svc{"active"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 29 | my $glob = config_for( $dev, { user => "\0", from => "\0", groups => [], port => $port } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 29 | ▶ | my @ports = @{ $glob->{port} || [22] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$glob{'port'} || [22]
MC/DC100%1/1
$$glob{'port'} || [22]
$$glob{'port'}
Truth table100%2/2
A
A= $$glob{'port'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 29 | ▶ | return ( 0, "ssh: connect to host $host port $port: Connection refused" ) unless grep { $_ == $port } @ports; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 28 | ▶ | if ( ref $dev->{nft} eq 'HASH' && %{ $dev->{nft} } && defined $t->{daddr} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
ref $$dev{"nft"} eq "HASH" and %{$$dev{"nft"};} and defined $$t{"daddr"}
ref $$dev{"nft"} eq "HASH" and %{$$dev{"nft"};}
MC/DC33%1/3
ref $$dev{"nft"} eq "HASH" and %{$$dev{"nft"};} and defined $$t{"daddr"}
ref $$dev{"nft"} eq "HASH"
%{$$dev{"nft"};}
defined $$t{"daddr"}
Truth table50%2/4
A and B and C
A= ref $$dev{"nft"} eq "HASH"B= %{$$dev{"nft"};}C= defined $$t{"daddr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | my ($v) = Langertha::Holmgang::Sim::Linux::Nft::verdict( $dev, { hook => 'input', proto => 'tcp', dport => $port, sport => $sport, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 2 | ▶ | saddr => $from, daddr => $t->{daddr}, ( defined $t->{iif} ? ( iif => $t->{iif} ) : () ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 2 | ▶ | return ( 0, "ssh: connect to host $host port $port: Connection timed out" ) if defined $v && $v eq 'drop'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $v and $v eq "drop"
MC/DC50%1/2
defined $v and $v eq "drop"
defined $v
$v eq "drop"
Truth table66%2/3
A and B
A= defined $vB= $v eq "drop"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | my $u = $user eq 'root' ? { home => '/root', groups => ['root'], %{ ( $dev->{users} || {} )->{root} || {} } } : ( $dev->{users} || {} )->{$user}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
($$dev{'users'} || {})->{'root'} || {}
$$dev{'users'} || {}
$$dev{'users'} || {}
MC/DC0%0/1
($$dev{'users'} || {})->{'root'} || {}
$$dev{'users'}
Truth table0%0/2
A
A= $$dev{'users'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 27 | my $conn = "from $from port $sport"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 27 | ▶ | return $deny->( 'publickey', "Invalid user $user $conn", "Connection closed by invalid user $user $from port $sport [preauth]" ) unless $u; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 26 | ▶ | my @groups = @{ $u->{groups} || [$user] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$u{'groups'} || [$user]
MC/DC0%0/1
$$u{'groups'} || [$user]
$$u{'groups'}
Truth table50%1/2
A
A= $$u{'groups'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 26 | my $eff = config_for( $dev, { user => $user, from => $from, groups => \@groups, port => $port } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | my $methods = join ',', ( _yes( $eff->{pubkeyauthentication}, 'yes' ) ? 'publickey' : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 26 | ▶ | ( _yes( $eff->{passwordauthentication}, 'yes' ) ? 'password' : () ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 26 | ▶ | $methods ||= 'none'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$methods ||= "none"
MC/DC0%0/1
$methods ||= "none"
$methods
Truth table50%1/2
A
A= $methods
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 26 | my $closed = "Connection closed by authenticating user $user $from port $sport [preauth]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 26 | ▶ | my $shell = $u->{shell} // '/bin/bash'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$u{"shell"} // "/bin/bash"
MC/DC0%0/1
$$u{"shell"} // "/bin/bash"
$$u{"shell"}
Truth table50%1/2
A
A= $$u{"shell"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 26 | ▶ | return $deny->( $methods, "User $user not allowed because account has expired", $closed ) if $u->{expired}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 26 | ▶ | return $deny->( $methods, "User $user not allowed because shell $shell does not exist", $closed ) if $shell =~ m{/(?:nologin|false)\z}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 25 | ▶ | if ( $user eq 'root' && lc( $eff->{permitrootlogin} // 'prohibit-password' ) eq 'no' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
$user eq "root" and lc($$eff{"permitrootlogin"} // "prohibit-password") eq "no"
$$eff{"permitrootlogin"} // "prohibit-password"
MC/DC0%0/2
$user eq "root" and lc($$eff{"permitrootlogin"} // "prohibit-password") eq "no"
$user eq "root"
$$eff{"permitrootlogin"}
Truth table33%1/3
A and B
A= $user eq "root"B= $$eff{"permitrootlogin"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | return $deny->( $methods, "ROOT LOGIN REFUSED $conn", $closed ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 25 | ▶ | my $um = sub { my $p = shift; my ( $pu, $ph ) = split /@/, $p, 2; _pat( $pu, $user ) && ( !defined $ph || _ip_in( $from, $ph ) ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.4
Branch: 1 branch
Condition50%3/6
_pat($pu, $user) && (!defined($ph) || _ip_in($from, $ph))
not defined $ph or _ip_in($from, $ph)
MC/DC33%1/3
_pat($pu, $user) && (!defined($ph) || _ip_in($from, $ph))
_pat($pu, $user)
not defined $ph
_ip_in($from, $ph)
Truth table50%2/4
A && not(B) or C
A= _pat($pu, $user)B= not defined $phC= _ip_in($from, $ph)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | my $gm = sub { my $p = shift; grep { _pat( $p, $_ ) } @groups }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | return $deny->( $methods, "User $user from $from not allowed because listed in DenyUsers", $closed ) if grep { $um->($_) } @{ $eff->{denyusers} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$eff{'denyusers'} || []
MC/DC0%0/1
$$eff{'denyusers'} || []
$$eff{'denyusers'}
Truth table50%1/2
A
A= $$eff{'denyusers'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | return $deny->( $methods, "User $user from $from not allowed because not listed in AllowUsers", $closed ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 25 | ▶ | if $eff->{allowusers} && !grep { $um->($_) } @{ $eff->{allowusers} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$$eff{"allowusers"} and not grep({&$um($_);} @{$$eff{"allowusers"};})
MC/DC100%2/2
$$eff{"allowusers"} and not grep({&$um($_);} @{$$eff{"allowusers"};})
$$eff{"allowusers"}
not grep({&$um($_);} @{$$eff{"allowusers"};})
Truth table100%3/3
A and not(B)
A= $$eff{"allowusers"}B= not grep({&$um($_);} @{$$eff{"allowusers"};})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | return $deny->( $methods, "User $user from $from not allowed because a group is listed in DenyGroups", $closed ) if grep { $gm->($_) } @{ $eff->{denygroups} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$eff{'denygroups'} || []
MC/DC0%0/1
$$eff{'denygroups'} || []
$$eff{'denygroups'}
Truth table50%1/2
A
A= $$eff{'denygroups'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | return $deny->( $methods, "User $user from $from not allowed because none of user's groups are listed in AllowGroups", $closed ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if $eff->{allowgroups} && !grep { $gm->($_) } @{ $eff->{allowgroups} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$$eff{"allowgroups"} and not grep({&$gm($_);} @{$$eff{"allowgroups"};})
MC/DC0%0/2
$$eff{"allowgroups"} and not grep({&$gm($_);} @{$$eff{"allowgroups"};})
$$eff{"allowgroups"}
not grep({&$gm($_);} @{$$eff{"allowgroups"};})
Truth table33%1/3
A and not(B)
A= $$eff{"allowgroups"}B= not grep({&$gm($_);} @{$$eff{"allowgroups"};})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 23 | ▶ | my $auth = $t->{auth} // 'publickey'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$t{"auth"} // "publickey"
MC/DC100%1/1
$$t{"auth"} // "publickey"
$$t{"auth"}
Truth table100%2/2
A
A= $$t{"auth"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 23 | ▶ | if ( $auth eq 'password' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2 | ▶ | return $deny->( $methods, $closed ) unless _yes( $eff->{passwordauthentication}, 'yes' ) && $u->{password} && !$u->{locked}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
_yes($$eff{"passwordauthentication"}, "yes") and $$u{"password"} and not $$u{"locked"}
_yes($$eff{"passwordauthentication"}, "yes") and $$u{"password"}
MC/DC33%1/3
_yes($$eff{"passwordauthentication"}, "yes") and $$u{"password"} and not $$u{"locked"}
_yes($$eff{"passwordauthentication"}, "yes")
$$u{"password"}
not $$u{"locked"}
Truth table50%2/4
A and B and not(C)
A= _yes($$eff{"passwordauthentication"}, "yes")B= $$u{"password"}C= not $$u{"locked"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | return $deny->( $methods, "Failed password for root $conn ssh2", $closed ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 1 | ▶ | if $user eq 'root' && lc( $eff->{permitrootlogin} // 'prohibit-password' ) ne 'yes'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
$user eq "root" and lc($$eff{"permitrootlogin"} // "prohibit-password") ne "yes"
$$eff{"permitrootlogin"} // "prohibit-password"
MC/DC0%0/2
$user eq "root" and lc($$eff{"permitrootlogin"} // "prohibit-password") ne "yes"
$user eq "root"
$$eff{"permitrootlogin"}
Truth table33%1/3
A and B
A= $user eq "root"B= $$eff{"permitrootlogin"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | return ( 1, "Linux $host 6.1.0-26-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.112-1 x86_64", "Accepted password for $user $conn ssh2" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 21 | ▶ | return $deny->( $methods, $closed ) unless _yes( $eff->{pubkeyauthentication}, 'yes' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 21 | ▶ | my $home = $u->{home} // ( $user eq 'root' ? '/root' : "/home/$user" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$u{"home"} // ($user eq "root" ? "/root" : "/home/$user")
MC/DC0%0/1
$$u{"home"} // ($user eq "root" ? "/root" : "/home/$user")
$$u{"home"}
Truth table50%1/2
A
A= $$u{"home"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 21 | ▶ | my @akf = @{ $eff->{authorizedkeysfile} || [qw( .ssh/authorized_keys .ssh/authorized_keys2 )] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$eff{'authorizedkeysfile'} || ['.ssh/authorized_keys', '.ssh/authorized_keys2']
MC/DC100%1/1
$$eff{'authorizedkeysfile'} || ['.ssh/authorized_keys', '.ssh/authorized_keys2']
$$eff{'authorizedkeysfile'}
Truth table100%2/2
A
A= $$eff{'authorizedkeysfile'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 21 | my $strict = _yes( $eff->{strictmodes}, 'yes' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 21 | ▶ | my ( $ktype, $kblob ) = split /\s+/, $t->{key} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$t{"key"} // ""
MC/DC0%0/1
$$t{"key"} // ""
$$t{"key"}
Truth table50%1/2
A
A= $$t{"key"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 21 | my @log; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 21 | for my $raw (@akf) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 33 | ▶ | next if lc $raw eq 'none'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 33 | ( my $p = $raw ) =~ s/%h/$home/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 33 | $p =~ s/%u/$user/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 33 | $p =~ s/%%/%/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 33 | ▶ | $p = "$home/$p" unless $p =~ m{\A/}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 33 | my ($e) = _entry( $dev, $p ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 33 | ▶ | next unless $e && defined $e->{content}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$e and defined $$e{"content"}
MC/DC50%1/2
$e and defined $$e{"content"}
$e
defined $$e{"content"}
Truth table66%2/3
A and B
A= $eB= defined $$e{"content"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 20 | ▶ | if ($strict) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 20 | ▶ | if ( my $bad = _strict_bad( $dev, $user, $home, $p ) ) { push @log, "Authentication refused: $bad"; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 16 | ▶ | my $m = oct( $e->{mode} // '0644' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$e{"mode"} // "0644"
MC/DC0%0/1
$$e{"mode"} // "0644"
$$e{"mode"}
Truth table50%1/2
A
A= $$e{"mode"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 16 | ▶ | my $readable = ( $e->{owner} // 'root' ) eq $user ? ( $m & 0400 ) : ( $m & 0004 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$e{"owner"} // "root"
MC/DC0%0/1
$$e{"owner"} // "root"
$$e{"owner"}
Truth table50%1/2
A
A= $$e{"owner"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 16 | ▶ | next unless $readable || $user eq 'root'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$readable or $user eq "root"
MC/DC0%0/2
$readable or $user eq "root"
$readable
$user eq "root"
Truth table33%1/3
A or B
A= $readableB= $user eq "root"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 16 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 16 | for my $line ( split /\n/, $e->{content} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 16 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 16 | ▶ | next if $line =~ /\A\s*(?:#|\z)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 16 | ▶ | my ( $opts, $type, $blob ) = _key_parts($line) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 16 | ▶ | next unless defined $ktype && $type eq $ktype && $blob eq ( $kblob // '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%6/8
defined $ktype and $type eq $ktype and $blob eq ($kblob // "")
defined $ktype and $type eq $ktype
$kblob // ""
MC/DC66%2/3
defined $ktype and $type eq $ktype and $blob eq ($kblob // "")
defined $ktype
$type eq $ktype
$blob eq ($kblob // "")
MC/DC0%0/1
$kblob // ""
$kblob
Truth table75%3/4
A and B and C
A= defined $ktypeB= $type eq $ktypeC= $blob eq ($kblob // "")
Truth table50%1/2
A
A= $kblob
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 11 | ▶ | if ( $user eq 'root' && lc( $eff->{permitrootlogin} // '' ) eq 'forced-commands-only' && $opts !~ /(?:\A|,)command="/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition25%2/8
$user eq "root" and lc($$eff{"permitrootlogin"} // "") eq "forced-commands-only" and not $opts =~ /(?:\A|,)command="/
$user eq "root" and lc($$eff{"permitrootlogin"} // "") eq "forced-commands-only"
$$eff{"permitrootlogin"} // ""
MC/DC0%0/3
$user eq "root" and lc($$eff{"permitrootlogin"} // "") eq "forced-commands-only" and not $opts =~ /(?:\A|,)command="/
$user eq "root"
$$eff{"permitrootlogin"}
not $opts =~ /(?:\A|,)command="/
Truth table25%1/4
A and B and not(C)
A= $user eq "root"B= $$eff{"permitrootlogin"}C= not $opts =~ /(?:\A|,)command="/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | push @log, "ROOT LOGIN REFUSED $conn"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 11 | ▶ | if ( !_from_ok( $opts, $from ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 3 | push @log, "Authentication tried for $user with correct key but not from a permitted host (host=$from, ip=$from)."; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 8 | ▶ | return ( 1, "Linux $host 6.1.0-26-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.112-1 x86_64", | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
($type =~ /ssh-(\w+)/)[0] // "KEY"
MC/DC0%0/1
($type =~ /ssh-(\w+)/)[0] // "KEY"
($type =~ /ssh-(\w+)/)[0]
Truth table50%1/2
A
A= ($type =~ /ssh-(\w+)/)[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | "Accepted publickey for $user $conn ssh2: " . uc( ( $type =~ /ssh-(\w+)/ )[0] // 'KEY' ) . ' SHA256:' . substr( $blob, 12, 43 ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 13 | return $deny->( $methods, @log, $closed ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 2 | ▶ | sub journal { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
journal: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 2 | my ( $dev, $host ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 2 | ▶ | $host //= $dev->{hostname} // 'localhost'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition25%1/4
$host //= $$dev{"hostname"} // "localhost"
$$dev{"hostname"} // "localhost"
MC/DC0%0/1
$host //= $$dev{"hostname"} // "localhost"
$host
Truth table50%1/2
A
A= $host
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 2 | my @l; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 2 | my $min = 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 2 | ▶ | for my $t ( @{ $dev->{ssh_tries} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$dev{'ssh_tries'} || []
MC/DC0%0/1
$$dev{'ssh_tries'} || []
$$dev{'ssh_tries'}
Truth table50%1/2
A
A= $$dev{'ssh_tries'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 2 | my ( $ok, undef, @log ) = check( $dev, $t, $host ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 2 | push @l, map { sprintf( 'Oct 24 07:%02d:%02d %s sshd[%d]: %s', $min, 11, $host, 3100 + $min, $_ ) } @log; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 2 | $min++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 2 | return @l; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||