« blib/lib/Langertha/Holmgang/Sim/Linux/RedisService.pm
↑ Summary
blib/lib/Langertha/Holmgang/Sim/Linux/SshAccess.pm »
| 1 | package Langertha::Holmgang::Sim::Linux::Sshd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: OpenSSH server on a simulated Linux server — sshd -t/-T, Include, effect of reload/restart, login | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use JSON::MaybeXS (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | my %YESNO = map { $_ => 1 } qw( passwordauthentication pubkeyauthentication kbdinteractiveauthentication | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | challengeresponseauthentication usepam x11forwarding permitemptypasswords allowagentforwarding printmotd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | printlastlog tcpkeepalive usedns strictmodes hostbasedauthentication ignorerhosts gssapiauthentication | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | kerberosauthentication disableforwarding x11uselocalhost permittty exposeauthinfo ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | my %ENUM = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | permitrootlogin => [qw( yes no prohibit-password without-password forced-commands-only )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | allowtcpforwarding => [qw( yes no all local remote )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | allowstreamlocalforwarding => [qw( yes no all local remote )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | gatewayports => [qw( yes no clientspecified )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | compression => [qw( yes no delayed )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | permittunnel => [qw( yes no point-to-point ethernet )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | permituserenvironment => [qw( yes no )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | addressfamily => [qw( any inet inet6 )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | loglevel => [qw( quiet fatal error info verbose debug debug1 debug2 debug3 )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | fingerprinthash => [qw( md5 sha256 )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | my %INT = map { $_ => 1 } qw( port maxauthtries maxsessions clientaliveinterval clientalivecountmax x11displayoffset ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | my %LIST = map { $_ => 1 } qw( allowusers allowgroups denyusers denygroups listenaddress port hostkey acceptenv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 4 | my %TEXT = map { $_ => 1 } qw( logingracetime syslogfacility ciphers macs kexalgorithms hostkeyalgorithms | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | pubkeyacceptedalgorithms pubkeyacceptedkeytypes casignaturealgorithms banner authorizedkeysfile chrootdirectory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | forcecommand authenticationmethods pidfile permitlisten permitopen versionaddendum trustedusercakeys revokedkeys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | authorizedprincipalsfile ipqos rekeylimit maxstartups persourcemaxstartups subsystem authorizedkeyscommand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | authorizedkeyscommanduser hostcertificate moduli securitykeyprovider setenv streamlocalbindmask | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | streamlocalbindunlink unusedconnectiontimeout channeltimeout xauthlocation ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # Vorgaben fuer sshd -T (Auszug, Debian 12 / OpenSSH 9.2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | my @DEFAULTS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | [ port => '22' ], [ addressfamily => 'any' ], [ listenaddress => '[::]:22' ], [ listenaddress => '0.0.0.0:22' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | [ usepam => 'no' ], [ logingracetime => '120' ], [ x11displayoffset => '10' ], [ maxauthtries => '6' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | [ maxsessions => '10' ], [ clientaliveinterval => '0' ], [ clientalivecountmax => '3' ], [ permitrootlogin => 'without-password' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | [ ignorerhosts => 'yes' ], [ hostbasedauthentication => 'no' ], [ pubkeyauthentication => 'yes' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | [ kerberosauthentication => 'no' ], [ gssapiauthentication => 'no' ], [ passwordauthentication => 'yes' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | [ kbdinteractiveauthentication => 'yes' ], [ printmotd => 'yes' ], [ printlastlog => 'yes' ], [ x11forwarding => 'no' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | [ x11uselocalhost => 'yes' ], [ permittty => 'yes' ], [ permituserenvironment => 'no' ], [ compression => 'yes' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | [ tcpkeepalive => 'yes' ], [ usedns => 'no' ], [ strictmodes => 'yes' ], [ permitemptypasswords => 'no' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | [ allowtcpforwarding => 'yes' ], [ allowagentforwarding => 'yes' ], [ gatewayports => 'no' ], [ permittunnel => 'no' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | [ loglevel => 'INFO' ], [ syslogfacility => 'AUTH' ], [ authorizedkeysfile => '.ssh/authorized_keys .ssh/authorized_keys2' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | [ maxstartups => '10:30:100' ], [ pidfile => '/run/sshd.pid' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 4 | my $MAIN = '/etc/ssh/sshd_config'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 323 | ▶ | sub _files { my ($dev) = @_; return ref $dev->{files} eq 'HASH' ? $dev->{files} : {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_files: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 185 | ▶ | sub active { my ($dev) = @_; return exists _files($dev)->{$MAIN} ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
active: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 47 | ▶ | sub _text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_text: called CC=4 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 47 | my ( $dev, $p ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 47 | my $e = _files($dev)->{$p}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 47 | ▶ | return undef unless defined $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 47 | ▶ | return ref $e eq 'HASH' ? ( $e->{content} // '' ) : $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$$e{"content"} // ""
MC/DC0%0/1
$$e{"content"} // ""
$$e{"content"}
Truth table0%0/2
A
A= $$e{"content"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 18 | ▶ | sub _glob { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_glob: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 18 | my ( $dev, $pat ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 18 | ▶ | $pat = "/etc/ssh/$pat" unless $pat =~ m{\A/}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 18 | ▶ | return ($pat) unless $pat =~ /[*?]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 18 | ( my $re = quotemeta $pat ) =~ s/\\\*/[^\/]*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 18 | $re =~ s/\\\?/[^\/]/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 18 | return sort grep {/\A$re\z/} keys %{ _files($dev) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 19 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 19 | my ( $dev, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 19 | ▶ | $file //= $MAIN; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$file //= $MAIN
MC/DC0%0/2
$file //= $MAIN
$file
$MAIN
Truth table66%2/3
A //= B
A= $fileB= $MAIN
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 19 | my ( %set, @err ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 19 | my $bad = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 19 | my $read; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 47 | ▶ | $read = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=31 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 47 | my ( $f, $depth ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 47 | my $t = _text( $dev, $f ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if ( !defined $t ) { push @err, "$f: No such file or directory" if $depth == 0; return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 47 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 47 | my $in_match = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 47 | for my $line ( split /\n/, $t ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 119 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 119 | $line =~ s/\A\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 119 | ▶ | next if $line eq '' || $line =~ /\A#/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$line eq "" or $line =~ /\A#/
MC/DC50%1/2
$line eq "" or $line =~ /\A#/
$line eq ""
$line =~ /\A#/
Truth table66%2/3
A or B
A= $line eq ""B= $line =~ /\A#/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 105 | my ( $kw, $rest ) = $line =~ /\A([^\s=]+)(?:\s*=\s*|\s+)?(.*?)\s*\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 105 | ▶ | next unless defined $kw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 105 | my $k = lc $kw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 105 | ▶ | if ( $k eq 'include' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ( $rest eq '' ) { push @err, "$f line $n: missing argument."; $bad++; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 18 | $read->( $_, $depth + 1 ) for map { _glob( $dev, $_ ) } split /\s+/, $rest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 18 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 87 | ▶ | if ( $k eq 'match' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if ( $rest eq '' ) { push @err, "$f line $n: missing argument."; $bad++; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 3 | $in_match = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 84 | ▶ | if ( !$YESNO{$k} && !$ENUM{$k} && !$INT{$k} && !$LIST{$k} && !$TEXT{$k} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%12/12
$YESNO{$k} or $ENUM{$k} or $INT{$k} or $LIST{$k} or $TEXT{$k}
$YESNO{$k} or $ENUM{$k} or $INT{$k} or $LIST{$k}
$YESNO{$k} or $ENUM{$k} or $INT{$k}
$YESNO{$k} or $ENUM{$k}
MC/DC100%5/5
$YESNO{$k} or $ENUM{$k} or $INT{$k} or $LIST{$k} or $TEXT{$k}
$YESNO{$k}
$ENUM{$k}
$INT{$k}
$LIST{$k}
$TEXT{$k}
Truth table100%6/6
A or B or C or D or E
A= $YESNO{$k}B= $ENUM{$k}C= $INT{$k}D= $LIST{$k}E= $TEXT{$k}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 3 | push @err, "$f: line $n: Bad configuration option: $kw"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 3 | $bad++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if ( $rest eq '' ) { push @err, "$f line $n: missing argument."; $bad++; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 81 | my $v = $rest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 81 | $v =~ s/\A"(.*)"\z/$1/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 81 | ▶ | if ( ( $YESNO{$k} || $ENUM{$k} || $INT{$k} ) && $v =~ /\A\S+\s+\S/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
$YESNO{$k} || $ENUM{$k} || $INT{$k} and $v =~ /\A\S+\s+\S/
$YESNO{$k} or $ENUM{$k} or $INT{$k}
$YESNO{$k} or $ENUM{$k}
MC/DC0%0/4
$YESNO{$k} || $ENUM{$k} || $INT{$k} and $v =~ /\A\S+\s+\S/
$YESNO{$k}
$ENUM{$k}
$INT{$k}
$v =~ /\A\S+\s+\S/
Truth table57%4/7
A or B or C and D
A= $YESNO{$k}B= $ENUM{$k}C= $INT{$k}D= $v =~ /\A\S+\s+\S/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | push @err, "$f line $n: keyword $kw extra arguments at end of line"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $bad++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 81 | ▶ | if ( $YESNO{$k} || $ENUM{$k} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$YESNO{$k} or $ENUM{$k}
MC/DC100%2/2
$YESNO{$k} or $ENUM{$k}
$YESNO{$k}
$ENUM{$k}
Truth table100%3/3
A or B
A= $YESNO{$k}B= $ENUM{$k}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 49 | ▶ | my @ok = $YESNO{$k} ? qw( yes no ) : @{ $ENUM{$k} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 49 | ▶ | if ( !grep { $_ eq lc $v } @ok ) { push @err, "$f line $n: unsupported option \"$v\"."; $bad++; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 48 | $v = lc $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if ( $INT{$k} && $v !~ /\A\d+\z/ ) { push @err, "$f line $n: invalid integer value \"$v\"."; $bad++; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$INT{$k} and not $v =~ /\A\d+\z/
MC/DC0%0/2
$INT{$k} and not $v =~ /\A\d+\z/
$INT{$k}
not $v =~ /\A\d+\z/
Truth table66%2/3
A and not(B)
A= $INT{$k}B= not $v =~ /\A\d+\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 80 | ▶ | next if $in_match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 77 | ▶ | if ( $LIST{$k} ) { push @{ $set{$k} }, split /\s+/, $v; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 59 | ▶ | $set{$k} = $v unless exists $set{$k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 19 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 19 | $read->( $file, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 19 | ▶ | push @err, "$file: terminating, $bad bad configuration options" if $bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 19 | return ( \%set, \@err ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 15 | ▶ | sub _hostkey_errors { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hostkey_errors: called CC=10 SCAR=23.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 15 | my ( $dev, $set ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | my @keys = $set->{hostkey} ? @{ $set->{hostkey} } : map {"/etc/ssh/ssh_host_${_}_key"} qw( rsa ecdsa ed25519 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 15 | my @present = grep { exists _files($dev)->{$_} } @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 15 | ▶ | return () unless grep { m{/ssh_host_} } keys %{ _files($dev) }; # Fall ohne Host-Schluessel: nicht pruefen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 13 | my ( @err, $good ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 13 | for my $k (@present) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 13 | my $e = _files($dev)->{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 13 | ▶ | my $m = ref $e eq 'HASH' ? oct( $e->{mode} // '0600' ) : 0600; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$e{"mode"} // "0600"
MC/DC0%0/1
$$e{"mode"} // "0600"
$$e{"mode"}
Truth table50%1/2
A
A= $$e{"mode"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 13 | ▶ | if ( $m & 077 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | push @err, '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | '@ WARNING: UNPROTECTED PRIVATE KEY FILE! @', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | sprintf( "Permissions 0%o for '%s' are too open.", $m & 07777, $k ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 'It is required that your private key files are NOT accessible by others.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 'This private key will be ignored.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | "Unable to load host key \"$k\": bad permissions", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | "Unable to load host key: $k"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 12 | $good++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 13 | ▶ | return ( @err, $good ? () : 'sshd: no hostkeys available -- exiting.' ) if @err || !$good; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
@err or not $good
MC/DC50%1/2
@err or not $good
@err
not $good
Truth table66%2/3
A or not(B)
A= @errB= not $good
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 12 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # Fehler, die sshd am Start hindern (Konfiguration, kein ladbarer Host-Schluessel) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 9 | ▶ | sub _fatal { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fatal: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 9 | my ($dev) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 9 | my ( $set, $err ) = parse($dev); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 9 | ▶ | return ( $set, @$err ) if @$err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 7 | my @hk = _hostkey_errors( $dev, $set ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | return ( $set, ( grep {/no hostkeys/} @hk ) ? @hk : () ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 10 | ▶ | sub sshd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sshd: called CC=18 SCAR=30.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 10 | my ( $dev, $av ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 10 | my @a = @$av; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 10 | my ( $test, $dump, $file ) = ( 0, 0, $MAIN ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 10 | ▶ | while (@a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 12 | my $x = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 12 | ▶ | if ( $x eq '-t' ) { $test = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 5 | elsif ( $x eq '-T' ) { $dump = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | elsif ( $x eq '-f' ) { $file = shift(@a) // return ( 'option requires an argument -- f', 0 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @a // (return "option requires an argument -- f", 0)
MC/DC0%0/1
shift @a // (return "option requires an argument -- f", 0)
shift @a
Truth table0%0/2
A
A= shift @a
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | elsif ( $x =~ /\A-[tT]+\z/ ) { $test = 1; $dump = 1 if $x =~ /T/ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | elsif ( $x eq '-C' ) { shift @a } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | else { return ( "unknown option -- " . substr( $x, 1 ), 0 ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 10 | my ( $set, $err ) = parse( $dev, $file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 10 | ▶ | return ( join( "\n", @$err ), 0 ) if @$err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 8 | my @hk = _hostkey_errors( $dev, $set ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 8 | ▶ | return ( join( "\n", @hk ), 0 ) if grep {/no hostkeys/} @hk; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 7 | ▶ | if ($dump) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 5 | my ( @order, %def ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 5 | ▶ | for (@DEFAULTS) { push @order, $_->[0] unless $def{ $_->[0] }; push @{ $def{ $_->[0] } }, $_->[1] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 5 | my @l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 5 | for my $k ( @order, grep { !$def{$_} } sort keys %$set ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 194 | ▶ | my @v = exists $set->{$k} ? ( ref $set->{$k} ? @{ $set->{$k} } : $set->{$k} ) : @{ $def{$k} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 194 | push @l, map {"$k $_"} @v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 5 | return ( join( "\n", @hk, @l ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | ▶ | return ( join( "\n", @hk ), 1 ) if $test; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | return ( 'sshd re-exec requires execution with an absolute path', 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 9 | ▶ | sub load { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=15 SCAR=28.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 9 | my ( $dev, $name, $verb, $host ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 9 | ▶ | my $svc = $dev->{services}{$name} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 9 | my ( $set, @fatal ) = _fatal($dev); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 9 | ▶ | if (@fatal) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | ▶ | if ( $verb ne 'reload' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 1 | ▶ | $svc->{active} = JSON::MaybeXS::false() if $svc->{active}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | ▶ | $svc->{failed} = JSON::MaybeXS::true() unless $svc->{failed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | push @{ $svc->{journal} }, map {"Oct 20 09:14:07 $host sshd[2207]: $_"} grep { !/\A@/ } @fatal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | die "Job for $name.service failed because the control process exited with error code.\n" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | . "See \"systemctl status $name.service\" and \"journalctl -xeu $name.service\" for details.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 7 | ▶ | my $old = JSON::MaybeXS->new( canonical => 1 )->encode( $svc->{effective} // {} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$svc{"effective"} // {}
MC/DC0%0/1
$$svc{"effective"} // {}
$$svc{"effective"}
Truth table50%1/2
A
A= $$svc{"effective"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 7 | ▶ | $svc->{effective} = $set unless JSON::MaybeXS->new( canonical => 1 )->encode($set) eq $old; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | # wie im echten Journal: sshd lauscht wieder, systemd meldet den Start bzw. das Neuladen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 7 | ▶ | $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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 7 | ▶ | my @ports = @{ $set->{port} || [22] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$set{'port'} || [22]
MC/DC0%0/1
$$set{'port'} || [22]
$$set{'port'}
Truth table50%1/2
A
A= $$set{'port'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 7 | ▶ | push @{ $svc->{journal} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | ( $verb eq 'reload' ? "Oct 20 09:14:07 $host sshd[701]: Received SIGHUP; restarting." : "Oct 20 09:14:07 $host systemd[1]: Starting $name.service - OpenBSD Secure Shell server..." ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 7 | ▶ | ( map { ( "Oct 20 09:14:07 $host sshd[2207]: Server listening on 0.0.0.0 port $_.", "Oct 20 09:14:07 $host sshd[2207]: Server listening on :: port $_." ) } @ports ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | "Oct 20 09:14:07 $host systemd[1]: " . ( $verb eq 'reload' ? 'Reloaded' : 'Started' ) . " $name.service - OpenBSD Secure Shell server."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | sub ssh_keygen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ssh_keygen: not called CC=21 SCAR=61.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my ( $dev, $av, $host ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my %o; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my @a = @$av; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | while (@a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my $x = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if ( $x eq '-f' ) { $file = shift @a; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | if ( $x =~ /\A-([A-Za-z]+)\z/ ) { $o{$_} = 1 for split //, $1; $file = shift @a if $x =~ /f\z/; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | my $files = $dev->{files} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$$dev{"files"} //= {}
MC/DC0%0/1
$$dev{"files"} //= {}
$$dev{"files"}
Truth table0%0/2
A
A= $$dev{"files"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if ( $o{A} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my @made; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | for my $t (qw( rsa ecdsa ed25519 )) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my $k = "/etc/ssh/ssh_host_${t}_key"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | next if exists $files->{$k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $files->{$k} = { content => "-----BEGIN OPENSSH PRIVATE KEY-----\n(neu erzeugt)\n-----END OPENSSH PRIVATE KEY-----\n", mode => '0600' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | $files->{"$k.pub"} = { content => 'ssh-' . ( $t eq 'ecdsa' ? 'ecdsa-sha2-nistp256' : $t ) . " AAAA(neu) root\@$host\n", mode => '0644' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | push @made, uc $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | return ( @made ? 'ssh-keygen: generating new host keys: ' . join( ' ', @made ) . ' ' : '', 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if ( $o{l} && defined $file ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$o{"l"} and defined $file
MC/DC0%0/2
$o{"l"} and defined $file
$o{"l"}
defined $file
Truth table0%0/3
A and B
A= $o{"l"}B= defined $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ( my $pub = $file ) =~ s/(?<!\.pub)\z/.pub/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | my $e = $files->{$pub} // $files->{$file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$$files{$pub} // $$files{$file}
MC/DC0%0/2
$$files{$pub} // $$files{$file}
$$files{$pub}
$$files{$file}
Truth table0%0/3
A // B
A= $$files{$pub}B= $$files{$file}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | return ( "ssh-keygen: $file: No such file or directory", 0 ) unless defined $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my ($t) = $file =~ /ssh_host_(\w+)_key/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my $bits = { rsa => 3072, ecdsa => 256, ed25519 => 256 }->{ $t // '' } // 256; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
{"rsa", 3072, "ecdsa", 256, "ed25519", 256}->{$t // ""} // 256
$t // ""
MC/DC0%0/1
{"rsa", 3072, "ecdsa", 256, "ed25519", 256}->{$t // ""} // 256
{"rsa", 3072, "ecdsa", 256, "ed25519", 256}->{$t // ""}
MC/DC0%0/1
$t // ""
$t
Truth table0%0/2
A
A= {"rsa", 3072, "ecdsa", 256, "ed25519", 256}->{$t // ""}
Truth table0%0/2
A
A= $t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | my $c = ref $e eq 'HASH' ? ( $e->{content} // '' ) : $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$$e{"content"} // ""
MC/DC0%0/1
$$e{"content"} // ""
$$e{"content"}
Truth table0%0/2
A
A= $$e{"content"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my $fp = substr( join( '', map { sprintf '%02x', ord } split //, $c ) . ( '0' x 50 ), 7, 43 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | return ( "$bits SHA256:$fp root\@$host (" . uc( $t // 'ED25519' ) . ')', 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$t // "ED25519"
MC/DC0%0/1
$t // "ED25519"
$t
Truth table0%0/2
A
A= $t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 369 | ▶ | sub _match_pat { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match_pat: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 369 | my ( $pat, $v ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 369 | ( my $re = quotemeta $pat ) =~ s/\\\*/.*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 369 | $re =~ s/\\\?/./g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 369 | ▶ | return $v =~ /\A$re\z/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | sub _match_user { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match_user: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my ( $pat, $user, $from ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my ( $u, $h ) = split /@/, $pat, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | return 0 unless _match_pat( $u, $user ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | return 1 unless defined $h; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | return 0 unless defined $from; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | if ( $h =~ m{\A(\d+\.\d+\.\d+\.\d+)/(\d+)\z} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my ( $net, $len ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | my $n = sub { my $x = 0; $x = $x * 256 + $_ for split /\./, $_[0]; $x }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | my $mask = $len == 0 ? 0 : ( 0xFFFFFFFF << ( 32 - $len ) ) & 0xFFFFFFFF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | return ( ( $n->($net) & $mask ) == ( $n->($from) & $mask ) ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | return _match_pat( $h, $from ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 146 | ▶ | sub login_denied { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
login_denied: called CC=31 SCAR=43.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 146 | my ( $dev, $host ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 146 | my $l = $dev->{ssh_login}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 146 | ▶ | return undef unless ref $l eq 'HASH' && active($dev); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $l eq "HASH" and active($dev)
MC/DC0%0/2
ref $l eq "HASH" and active($dev)
ref $l eq "HASH"
active($dev)
Truth table33%1/3
A and B
A= ref $l eq "HASH"B= active($dev)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 146 | ▶ | my $svc = ( $dev->{services} || {} )->{ $l->{service} // 'ssh' } || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
($$dev{'services'} || {})->{$$l{'service'} // 'ssh'} || {}
$$dev{'services'} || {}
$$l{"service"} // "ssh"
MC/DC0%0/1
($$dev{'services'} || {})->{$$l{'service'} // 'ssh'} || {}
$$dev{'services'}
MC/DC0%0/1
$$l{"service"} // "ssh"
$$l{"service"}
Truth table50%1/2
A
A= $$dev{'services'}
Truth table50%1/2
A
A= $$l{"service"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 146 | ▶ | return "ssh: connect to host $host port 22: Connection refused" unless $svc->{active}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 143 | ▶ | my $user = $l->{user} // 'root'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$l{"user"} // "root"
MC/DC0%0/1
$$l{"user"} // "root"
$$l{"user"}
Truth table50%1/2
A
A= $$l{"user"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 143 | my $from = $l->{from}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 143 | ▶ | my $eff = $svc->{effective} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$svc{'effective'} || {}
MC/DC0%0/1
$$svc{'effective'} || {}
$$svc{'effective'}
Truth table50%1/2
A
A= $$svc{'effective'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 143 | my $no = "$user\@$host: Permission denied (publickey)."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 143 | ▶ | return $no if ( $eff->{pubkeyauthentication} // 'yes' ) eq 'no'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$eff{"pubkeyauthentication"} // "yes"
MC/DC0%0/1
$$eff{"pubkeyauthentication"} // "yes"
$$eff{"pubkeyauthentication"}
Truth table50%1/2
A
A= $$eff{"pubkeyauthentication"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 143 | ▶ | if ( $user eq 'root' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | return $no if ( $eff->{permitrootlogin} // 'prohibit-password' ) eq 'no'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$$eff{"permitrootlogin"} // "prohibit-password"
MC/DC0%0/1
$$eff{"permitrootlogin"} // "prohibit-password"
$$eff{"permitrootlogin"}
Truth table0%0/2
A
A= $$eff{"permitrootlogin"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 143 | ▶ | my $u = ( $dev->{users} || {} )->{$user} or return $no; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$dev{'users'} || {}
MC/DC0%0/1
$$dev{'users'} || {}
$$dev{'users'}
Truth table50%1/2
A
A= $$dev{'users'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 143 | ▶ | return $no if $u->{expired}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 143 | ▶ | return $no if ( $u->{shell} // '/bin/bash' ) =~ m{/(?:nologin|false)\z}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 142 | ▶ | my @groups = $user eq 'root' ? ('root') : @{ ( ( $dev->{users} || {} )->{$user} || {} )->{groups} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
(($$dev{'users'} || {})->{$user} || {})->{'groups'} || []
($$dev{'users'} || {})->{$user} || {}
$$dev{'users'} || {}
MC/DC0%0/1
(($$dev{'users'} || {})->{$user} || {})->{'groups'} || []
$$dev{'users'}
Truth table50%1/2
A
A= $$dev{'users'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | return $no if grep { _match_user( $_, $user, $from ) } @{ $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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | return $no if $eff->{allowusers} && !grep { _match_user( $_, $user, $from ) } @{ $eff->{allowusers} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$$eff{"allowusers"} and not grep({_match_user($_, $user, $from);} @{$$eff{"allowusers"};})
MC/DC0%0/2
$$eff{"allowusers"} and not grep({_match_user($_, $user, $from);} @{$$eff{"allowusers"};})
$$eff{"allowusers"}
not grep({_match_user($_, $user, $from);} @{$$eff{"allowusers"};})
Truth table33%1/3
A and not(B)
A= $$eff{"allowusers"}B= not grep({_match_user($_, $user, $from);} @{$$eff{"allowusers"};})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 142 | ▶ | my $gm = sub { my $p = shift; grep { _match_pat( $p, $_ ) } @groups }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | return $no 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 142 | ▶ | return $no if $eff->{allowgroups} && !grep { $gm->($_) } @{ $eff->{allowgroups} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$$eff{"allowgroups"} and not grep({&$gm($_);} @{$$eff{"allowgroups"};})
MC/DC100%2/2
$$eff{"allowgroups"} and not grep({&$gm($_);} @{$$eff{"allowgroups"};})
$$eff{"allowgroups"}
not grep({&$gm($_);} @{$$eff{"allowgroups"};})
Truth table100%3/3
A and not(B)
A= $$eff{"allowgroups"}B= not grep({&$gm($_);} @{$$eff{"allowgroups"};})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 141 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||