« blib/lib/Langertha/Holmgang/Sim/Linux/Monitoring.pm
↑ Summary
blib/lib/Langertha/Holmgang/World.pm »
| 1 | package Langertha::Holmgang::Sim::Linux::Logrotate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: logrotate 3.21 (Debian 12) for the Linux simulator — reads the configuration, checks (-d), rotates (-f) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | my $L = 'Langertha::Holmgang::Sim::Linux'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | sub _l { my $n = shift; no strict 'refs'; return &{"${L}::$n"}(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_l: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | my %FLAG = map { $_ => 1 } qw( compress nocompress delaycompress nodelaycompress copytruncate nocopytruncate copy nocopy | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | missingok nomissingok notifempty ifempty sharedscripts nosharedscripts dateext nodateext nocreate nomail maillast mailfirst | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | shred noshred renamecopy createolddir nocreateolddir noolddir dateyesterday datehourago nosharedscripts ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | my %ARG = map { $_ => 1 } qw( rotate size maxsize minsize maxage olddir su compresscmd uncompresscmd compressext compressoptions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | dateformat extension start tabooext mail shredcycles addextension ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | my %PERIOD = map { $_ => 1 } qw( hourly daily weekly monthly yearly ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | my %SCRIPT = map { $_ => 1 } qw( postrotate prerotate firstaction lastaction preremove ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | my @TABOO = qw( .rpmsave .rpmorig ~ .disabled .dpkg-old .dpkg-dist .dpkg-new .cfsaved .ucf-old .ucf-dist .ucf-new .rpmnew .swp .cfsaved .rhn-cfg-tmp-* ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 16 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=32 SCAR=43.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 16 | my ( $dev, $av, $ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 16 | my ( $debug, $force, $verbose, @conf ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 16 | my @a = @$av; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 16 | ▶ | while (@a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 33 | my $x = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 33 | ▶ | if ( $x eq '-d' || $x eq '--debug' ) { $debug = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 9 branches
Condition66%2/3
$x eq "-d" or $x eq "--debug"
MC/DC50%1/2
$x eq "-d" or $x eq "--debug"
$x eq "-d"
$x eq "--debug"
Truth table66%2/3
A or B
A= $x eq "-d"B= $x eq "--debug"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 7 | ▶ | elsif ( $x eq '-f' || $x eq '--force' ) { $force = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$x eq "-f" or $x eq "--force"
MC/DC50%1/2
$x eq "-f" or $x eq "--force"
$x eq "-f"
$x eq "--force"
Truth table66%2/3
A or B
A= $x eq "-f"B= $x eq "--force"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | elsif ( $x eq '-v' || $x eq '--verbose' ) { $verbose = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$x eq "-v" or $x eq "--verbose"
MC/DC50%1/2
$x eq "-v" or $x eq "--verbose"
$x eq "-v"
$x eq "--verbose"
Truth table66%2/3
A or B
A= $x eq "-v"B= $x eq "--verbose"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | elsif ( $x =~ /\A-[dfv]{2,}\z/ ) { $debug = 1 if $x =~ /d/; $force = 1 if $x =~ /f/; $verbose = 1 if $x =~ /v/ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | elsif ( $x eq '-s' || $x eq '--state' || $x eq '-l' || $x eq '--log' || $x eq '-m' || $x eq '--mail' ) { shift @a } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%5/15
$x eq "-s" or $x eq "--state" or $x eq "-l" or $x eq "--log" or $x eq "-m" or $x eq "--mail"
$x eq "-s" or $x eq "--state" or $x eq "-l" or $x eq "--log" or $x eq "-m"
$x eq "-s" or $x eq "--state" or $x eq "-l" or $x eq "--log"
$x eq "-s" or $x eq "--state" or $x eq "-l"
$x eq "-s" or $x eq "--state"
MC/DC0%0/6
$x eq "-s" or $x eq "--state" or $x eq "-l" or $x eq "--log" or $x eq "-m" or $x eq "--mail"
$x eq "-s"
$x eq "--state"
$x eq "-l"
$x eq "--log"
$x eq "-m"
$x eq "--mail"
Truth table14%1/7
A or B or C or D or E or F
A= $x eq "-s"B= $x eq "--state"C= $x eq "-l"D= $x eq "--log"E= $x eq "-m"F= $x eq "--mail"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | elsif ( $x =~ /\A--(?:state|log|mail)=/ ) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | elsif ( $x eq '--version' || $x eq '-V' ) { return ( _version(), 1 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$x eq "--version" or $x eq "-V"
MC/DC50%1/2
$x eq "--version" or $x eq "-V"
$x eq "--version"
$x eq "-V"
Truth table66%2/3
A or B
A= $x eq "--version"B= $x eq "-V"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | elsif ( $x eq '--help' || $x eq '-?' || $x eq '--usage' ) { return ( _usage(), 1 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$x eq "--help" or $x eq "-?" or $x eq "--usage"
$x eq "--help" or $x eq "-?"
MC/DC0%0/3
$x eq "--help" or $x eq "-?" or $x eq "--usage"
$x eq "--help"
$x eq "-?"
$x eq "--usage"
Truth table25%1/4
A or B or C
A= $x eq "--help"B= $x eq "-?"C= $x eq "--usage"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | elsif ( $x =~ /\A-/ ) { return ( "logrotate: bad argument $x: unknown option\n" . _usage(), 1 ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 16 | else { push @conf, $x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 15 | ▶ | return ( "logrotate 3.21.0 - Copyright (C) 1995-2001 Red Hat, Inc.\nThis may be freely redistributed under the terms of the GNU General Public License\n\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | . _usage(), 0 ) unless @conf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 15 | my ( @out, @logs, %seen ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 15 | my $err = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 15 | ▶ | push @out, 'warning: logrotate in debug mode does nothing except printing debug messages! Consider using verbose mode (-v) instead if this is not what you want.', '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | if $debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 15 | for my $c (@conf) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 16 | $err += _read_config( $dev, $c, {}, \@logs, \@out, \%seen, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 15 | push @out, 'Reading state from file: /var/lib/logrotate/status', 'Allocating hash table for state file, size 64 entries'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 15 | push @out, '', 'Handling ' . scalar(@logs) . ' logs'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 15 | for my $b (@logs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 15 | $err += _rotate_block( $dev, $b, $ctx, \@out, debug => $debug, force => $force ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 15 | ▶ | my $show = $debug || $verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$debug || $verbose
MC/DC100%2/2
$debug || $verbose
$debug
$verbose
Truth table100%3/3
A || B
A= $debugB= $verbose
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 15 | ▶ | my @shown = $show ? @out : grep {/\Aerror:/} @out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 15 | ▶ | return ( join( "\n", @shown ), $err ? 0 : 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | sub _version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_version: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | return join "\n", 'logrotate 3.21.0', '', ' Default mail command: /usr/bin/mail', ' Default compress command: /bin/gzip', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ' Default uncompress command: /bin/gunzip', ' Default compress extension: .gz', ' Default state file path: /var/lib/logrotate/status', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | ' ACL support: yes', ' SELinux support: yes'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub _usage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_usage: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return join "\n", 'Usage: logrotate [-dfv?] [-d|--debug] [-f|--force] [-m|--mail=command] [-s|--state=statefile]', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ' [--skip-state-lock] [-v|--verbose] [-l|--log=logfile] [--version] [-?|--help] [--usage]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | ' [OPTION...] <configfile>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # Liest eine Konfigurationsdatei (oder ein Verzeichnis); haengt Bloecke an @$logs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # Rueckgabe: Zahl der Fehler. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 17 | ▶ | sub _read_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_config: called CC=11 SCAR=24.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 17 | my ( $dev, $path, $g, $logs, $out, $seen, $depth ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 17 | my $err = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 17 | ▶ | if ( _l( '_is_dir', $dev, $path ) && !_l( '_file_entry', $dev, $path ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
_l("_is_dir", $dev, $path) and not _l("_file_entry", $dev, $path)
MC/DC50%1/2
_l("_is_dir", $dev, $path) and not _l("_file_entry", $dev, $path)
_l("_is_dir", $dev, $path)
not _l("_file_entry", $dev, $path)
Truth table66%2/3
A and not(B)
A= _l("_is_dir", $dev, $path)B= not _l("_file_entry", $dev, $path)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | push @$out, "including $path" if $depth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | my $names = _l( '_ls_names', $dev, $path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | for my $n ( sort keys %$names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 4 | ▶ | my ($t) = grep { my $x = $_; $x =~ s/\*\z//; $x =~ /\A\./ ? substr( $n, -length $x ) eq $x : $n eq $x } @TABOO; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 4 | ▶ | if ( $t || $n =~ /\.rhn-cfg-tmp-/ ) { push @$out, "Ignoring $n, because of " . ( $t // '.rhn-cfg-tmp-*' ) . ' ending'; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$t or $n =~ /\.rhn-cfg-tmp-/
$t // ".rhn-cfg-tmp-*"
MC/DC50%1/2
$t or $n =~ /\.rhn-cfg-tmp-/
$t
$n =~ /\.rhn-cfg-tmp-/
MC/DC0%0/1
$t // ".rhn-cfg-tmp-*"
$t
Truth table66%2/3
A or B
A= $tB= $n =~ /\.rhn-cfg-tmp-/
Truth table50%1/2
A
A= $t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | ▶ | next if _l( '_is_dir', $dev, "$path/$n" ) && !_l( '_file_entry', $dev, "$path/$n" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
_l("_is_dir", $dev, "$path/$n") and not _l("_file_entry", $dev, "$path/$n")
MC/DC0%0/2
_l("_is_dir", $dev, "$path/$n") and not _l("_file_entry", $dev, "$path/$n")
_l("_is_dir", $dev, "$path/$n")
not _l("_file_entry", $dev, "$path/$n")
Truth table33%1/3
A and not(B)
A= _l("_is_dir", $dev, "$path/$n")B= not _l("_file_entry", $dev, "$path/$n")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 3 | $err += _read_file( $dev, "$path/$n", $n, $g, $logs, $out, $seen, $depth ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | return $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 16 | return _read_file( $dev, $path, $path, $g, $logs, $out, $seen, $depth ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 19 | ▶ | sub _read_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_file: called CC=43 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 19 | my ( $dev, $path, $shown, $g, $logs, $out, $seen, $depth ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 19 | my $e = _l( '_file_entry', $dev, $path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 19 | my $text = _l( '_file_text', $dev, $path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if ( !defined $text ) { push @$out, "error: cannot stat $path: No such file or directory"; return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 19 | push @$out, "reading config file $shown"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 19 | ▶ | my $mode = oct( $e->{mode} // '0644' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$e{"mode"} // "0644"
MC/DC100%1/1
$$e{"mode"} // "0644"
$$e{"mode"}
Truth table100%2/2
A
A= $$e{"mode"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 19 | ▶ | if ( $mode & 022 ) { push @$out, "error: Ignoring $shown because of bad file mode - must be 0644 or 0444."; return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if ( ( $e->{owner} // 'root' ) ne 'root' ) { push @$out, "error: Ignoring $shown because the file owner is wrong (should be root or user with uid 0)."; return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 18 | my $err = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 18 | my ( $block, $script, $pending ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 18 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 18 | for my $raw ( split /\n/, $text ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 161 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 161 | ▶ | if ($script) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 20 | ▶ | if ( $raw =~ /\A\s*endscript\s*\z/ ) { $script = undef; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 10 | push @{ $block->{scripts}{$script} }, $raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 10 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 141 | ( my $l = $raw ) =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 141 | ▶ | 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#/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 141 | ▶ | my $cur = $block ? $block->{opt} : $g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 141 | ▶ | if ($pending) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if ( $l eq '{' ) { $l = "$pending {"; $pending = undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | else { push @$out, "error: $shown:" . ( $n - 1 ) . " missing '{' after log files definition"; $err++; $pending = undef } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 141 | ▶ | if ( !$block && ( $l =~ m{\A["/]} || $l =~ /\{\s*\z/ && $l !~ /\A\w+\s*\{/ ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
not $block and $l =~ m[\A["/]] || $l =~ /\{\s*\z/ && !($l =~ /\A\w+\s*\{/)
$l =~ m[\A["/]] or $l =~ /\{\s*\z/ and not $l =~ /\A\w+\s*\{/
$l =~ /\{\s*\z/ and not $l =~ /\A\w+\s*\{/
MC/DC50%2/4
not $block and $l =~ m[\A["/]] || $l =~ /\{\s*\z/ && !($l =~ /\A\w+\s*\{/)
not $block
$l =~ m[\A["/]]
$l =~ /\{\s*\z/
not $l =~ /\A\w+\s*\{/
Truth table60%3/5
not(A) and B or C and not(D)
A= not $blockB= $l =~ m[\A["/]]C= $l =~ /\{\s*\z/D= not $l =~ /\A\w+\s*\{/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | if ( $l !~ /\{\s*\z/ ) { $pending = $l; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 17 | ( my $pats = $l ) =~ s/\s*\{\s*\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 17 | my @p = map { s/\A"|"\z//gr } split /\s+/, $pats; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 17 | $block = { patterns => \@p, opt => { %$g }, scripts => {}, file => $shown, line => $n }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # wie logrotate: dieselbe Datei (nach dem Aufloesen der Muster) nur in einem Block | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 17 | my %skip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 17 | for my $f ( map { _expand( $dev, $_ ) } @p ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 17 | ▶ | if ( $seen->{$f} ) { push @$out, "error: $shown:$n duplicate log entry for $f"; $err++; $skip{$f} = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 17 | $seen->{$f} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 17 | $block->{skip} = \%skip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 17 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 124 | ▶ | if ( $l eq '}' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if ( !$block ) { push @$out, "error: $shown:$n unexpected }"; $err++; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 15 | push @$logs, $block; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 15 | $block = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 15 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 109 | my ( $kw, $rest ) = $l =~ /\A(\S+)\s*(.*)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 109 | ▶ | if ( $SCRIPT{$kw} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if ( !$block ) { push @$out, "error: $shown:$n $kw outside of log file definition"; $err++; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 10 | $script = $kw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 10 | $block->{scripts}{$kw} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 10 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 99 | ▶ | if ( $kw eq 'include' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if ($block) { push @$out, "error: $shown:$n include not allowed inside a log file definition"; $err++; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | $err += _read_config( $dev, $rest, $g, $logs, $out, $seen, $depth + 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 98 | ▶ | if ( $PERIOD{$kw} ) { $cur->{period} = $kw; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 80 | ▶ | if ( $kw eq 'create' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 11 | my @c = split /\s+/, $rest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if ( @c && $c[0] !~ /\A0?[0-7]{3,4}\z/ ) { push @$out, "error: $shown:$n unknown unix user $c[0]"; $err++; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@c and not $c[0] =~ /\A0?[0-7]{3,4}\z/
MC/DC0%0/2
@c and not $c[0] =~ /\A0?[0-7]{3,4}\z/
@c
not $c[0] =~ /\A0?[0-7]{3,4}\z/
Truth table66%2/3
A and not(B)
A= @cB= not $c[0] =~ /\A0?[0-7]{3,4}\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 11 | $cur->{create} = [@c]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 11 | delete $cur->{nocreate}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 11 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 69 | ▶ | if ( $kw eq 'rotate' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if ( $rest !~ /\A-?\d+\z/ ) { push @$out, "error: $shown:$n bad rotation count '$rest'"; $err++; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 15 | $cur->{rotate} = $rest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 15 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 54 | ▶ | if ( $FLAG{$kw} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 48 | ( my $base = $kw ) =~ s/\Ano(?!tifempty)//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 48 | ▶ | $base = 'notifempty' if $kw eq 'ifempty'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if ( $kw eq 'ifempty' ) { delete $cur->{notifempty} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | elsif ( $kw =~ /\Ano/ && $kw ne 'notifempty' ) { delete $cur->{$base}; delete $cur->{create} if $kw eq 'nocreate' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$kw =~ /\Ano/ and $kw ne "notifempty"
MC/DC0%0/2
$kw =~ /\Ano/ and $kw ne "notifempty"
$kw =~ /\Ano/
$kw ne "notifempty"
Truth table66%2/3
A and B
A= $kw =~ /\Ano/B= $kw ne "notifempty"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 48 | else { $cur->{$kw} = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 48 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 6 | ▶ | if ( $ARG{$kw} ) { $cur->{$kw} = $rest; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 3 | push @$out, "error: $shown:$n unknown option '$kw' -- ignoring line"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | $err++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if ($pending) { push @$out, "error: $shown:$n missing '{' after log files definition"; $err++ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if ($script) { push @$out, "error: $shown:$n missing endscript"; $err++ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 18 | ▶ | if ($block) { push @$out, "error: $shown:$n missing '}' at end of file"; $err++ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 18 | return $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # Dateien eines Musters im Zustand (Shell-Muster * und ? im letzten Teil) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 32 | ▶ | sub _expand { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 32 | my ( $dev, $pat ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 32 | ▶ | return ($pat) unless $pat =~ /[*?]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 22 | ( my $re = quotemeta $pat ) =~ s/\\\*/[^\/]*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 22 | $re =~ s/\\\?/[^\/]/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 22 | ▶ | return sort grep {/\A$re\z/} keys %{ $dev->{files} || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$dev{'files'} || {}
MC/DC0%0/1
$$dev{'files'} || {}
$$dev{'files'}
Truth table50%1/2
A
A= $$dev{'files'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 15 | ▶ | sub _rotate_block { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rotate_block: called CC=29 SCAR=35.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 15 | my ( $dev, $b, $ctx, $out, %o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 15 | my $opt = $b->{opt}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 15 | ▶ | my $rot = $opt->{rotate} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$opt{"rotate"} // 1
MC/DC100%1/1
$$opt{"rotate"} // 1
$$opt{"rotate"}
Truth table100%2/2
A
A= $$opt{"rotate"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 15 | my $err = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | my $crit = $o{force} ? 'forced from command line' : ( $opt->{period} // 'weekly' ) eq 'daily' ? 'after 1 days' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 15 | ▶ | : ( $opt->{period} // 'weekly' ) eq 'hourly' ? 'hourly' : $opt->{period} // 'weekly'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition50%3/6
$$opt{"period"} // "weekly"
$$opt{"period"} // "weekly"
$$opt{"period"} // "weekly"
MC/DC0%0/1
$$opt{"period"} // "weekly"
$$opt{"period"}
MC/DC0%0/1
$$opt{"period"} // "weekly"
$$opt{"period"}
MC/DC0%0/1
$$opt{"period"} // "weekly"
$$opt{"period"}
Truth table50%1/2
A
A= $$opt{"period"}
Truth table50%1/2
A
A= $$opt{"period"}
Truth table50%1/2
A
A= $$opt{"period"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 15 | push @$out, '', 'rotating pattern: ' . join( ' ', @{ $b->{patterns} } ) . " $crit ($rot rotations)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 15 | ▶ | push @$out, 'empty log files ' . ( $opt->{notifempty} ? 'are not' : 'are' ) . ' rotated, old logs are removed'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 15 | my @files = grep { !$b->{skip}{$_} } map { _expand( $dev, $_ ) } @{ $b->{patterns} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 15 | my @done; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 15 | for my $f (@files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 14 | push @$out, "considering log $f"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 14 | my $e = _l( '_file_entry', $dev, $f ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 14 | ▶ | if ( !$e ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | ▶ | if ( $opt->{missingok} ) { push @$out, " log $f does not exist -- skipping" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | else { push @$out, "error: stat of $f failed: No such file or directory"; $err++ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 13 | ( my $dir = $f ) =~ s{/[^/]+\z}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 13 | ▶ | my $d = ( $dev->{dirs} || {} )->{$dir} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
($$dev{'dirs'} || {})->{$dir} || {}
$$dev{'dirs'} || {}
MC/DC100%1/1
($$dev{'dirs'} || {})->{$dir} || {}
$$dev{'dirs'}
Truth table100%2/2
A
A= $$dev{'dirs'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 13 | ▶ | my $dm = oct( $d->{mode} // '0755' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$d{"mode"} // "0755"
MC/DC100%1/1
$$d{"mode"} // "0755"
$$d{"mode"}
Truth table100%2/2
A
A= $$d{"mode"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 13 | ▶ | if ( !$opt->{su} && ( $dm & 002 || ( $dm & 020 && ( $d->{group} // 'root' ) ne 'root' ) ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition72%8/11
not $$opt{"su"} and $dm & 2 || $dm & 16 && ($$d{"group"} // "root") ne "root"
$dm & 2 or $dm & 16 and ($$d{"group"} // "root") ne "root"
$dm & 16 and ($$d{"group"} // "root") ne "root"
$$d{"group"} // "root"
MC/DC50%2/4
not $$opt{"su"} and $dm & 2 || $dm & 16 && ($$d{"group"} // "root") ne "root"
not $$opt{"su"}
$dm & 2
$dm & 16
$$d{"group"}
Truth table60%3/5
not(A) and B or C and D
A= not $$opt{"su"}B= $dm & 2C= $dm & 16D= $$d{"group"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | push @$out, "error: skipping \"$f\" because parent directory has insecure permissions (It's world writable or writable by group which is not \"root\") Set \"su\" directive in the config file to tell logrotate which user/group should be used for rotation."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | $err++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 11 | push @$out, ' Now: 2026-10-20 14:00', ' Last rotated at 2026-10-20 00:00'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 11 | ▶ | if ( !$o{force} ) { push @$out, ' log does not need rotating (log has been rotated at 2026-10-20 00:00, which is less than a day ago)'; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if ( $opt->{notifempty} && _l( '_file_size', $e ) == 0 ) { push @$out, ' log does not need rotating (log is empty)'; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$$opt{"notifempty"} and _l("_file_size", $e) == 0
MC/DC0%0/2
$$opt{"notifempty"} and _l("_file_size", $e) == 0
$$opt{"notifempty"}
_l("_file_size", $e) == 0
Truth table66%2/3
A and B
A= $$opt{"notifempty"}B= _l("_file_size", $e) == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 7 | push @$out, ' log needs rotating'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 7 | push @done, $f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 15 | ▶ | return $err unless @done; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 7 | my $shared = $opt->{sharedscripts}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 14 | ▶ | my $run = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=10 SCAR=27.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 14 | my ( $which, $arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 14 | ▶ | my $lines = $b->{scripts}{$which} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 5 | push @$out, "running $which script"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 5 | ▶ | return if $o{debug}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 4 | for my $line (@$lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 4 | ( my $x = $line ) =~ s/\A\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 4 | ▶ | next if $x eq '' || $x =~ /\A#/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$x eq "" or $x =~ /\A#/
MC/DC0%0/2
$x eq "" or $x =~ /\A#/
$x eq ""
$x =~ /\A#/
Truth table33%1/3
A or B
A= $x eq ""B= $x =~ /\A#/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 4 | ▶ | $x =~ s/\$1\b/$arg/g if defined $arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 4 | my ( $so, $ok ) = $L->_run_inner( $dev, $x, $ctx ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 4 | ▶ | push @$out, $so if defined $so && length $so; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $so and length $so
MC/DC0%0/2
defined $so and length $so
defined $so
length $so
Truth table33%1/3
A and B
A= defined $soB= length $so
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | if ( !$ok ) { push @$out, "error: error running shared $which script for '" . join( ' ', @{ $b->{patterns} } ) . "'"; $err++; last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 7 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 7 | ▶ | $run->( 'prerotate', join ' ', @{ $b->{patterns} } ) if $shared; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 7 | for my $f (@done) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 7 | ▶ | $run->( 'prerotate', $f ) unless $shared; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 7 | _rotate_one( $dev, $f, $opt, $out, $o{debug} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 7 | ▶ | $run->( 'postrotate', $f ) unless $shared; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 7 | ▶ | $run->( 'postrotate', join ' ', @{ $b->{patterns} } ) if $shared; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 7 | return $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 3 | ▶ | sub _gz { my ($e) = @_; my %n = %$e; $n{size} = _l( '_human', int( _l( '_file_size', $e ) / 10 ) + 1 ); $n{content} = ''; delete $n{open_by}; return \%n } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_gz: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 7 | ▶ | sub _rotate_one { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rotate_one: called CC=40 SCAR=41.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 7 | my ( $dev, $f, $opt, $out, $debug ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 7 | ▶ | my $rot = $opt->{rotate} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$opt{"rotate"} // 1
MC/DC0%0/1
$$opt{"rotate"} // 1
$$opt{"rotate"}
Truth table50%1/2
A
A= $$opt{"rotate"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 7 | my $files = $dev->{files}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 7 | my $comp = $opt->{compress}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 7 | ▶ | my $delay = $comp && $opt->{delaycompress}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$comp && $$opt{'delaycompress'}
MC/DC50%1/2
$comp && $$opt{'delaycompress'}
$comp
$$opt{'delaycompress'}
Truth table66%2/3
A && B
A= $compB= $$opt{'delaycompress'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 7 | push @$out, "rotating log $f, log->rotateCount is $rot", "dateext suffix '-20261020'", "glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 7 | ▶ | push @$out, 'compressing log with: /bin/gzip' if $comp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # aeltere Generationen weiterschieben, die letzte faellt weg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 7 | ▶ | for ( my $i = $rot; $i >= 1; $i-- ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 37 | for my $ext ( '.gz', '' ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 74 | my $src = "$f.$i$ext"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 74 | ▶ | next unless exists $files->{$src}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 10 | ▶ | if ( $i == $rot ) { push @$out, "removing old log $src"; delete $files->{$src} unless $debug; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 7 | ▶ | my $dst = "$f." . ( $i + 1 ) . ( $ext eq '' && $comp && $i == 1 && $delay ? '.gz' : $ext ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$ext eq "" and $comp and $i == 1 and $delay
$ext eq "" and $comp and $i == 1
$ext eq "" and $comp
MC/DC25%1/4
$ext eq "" and $comp and $i == 1 and $delay
$ext eq ""
$comp
$i == 1
$delay
Truth table40%2/5
A and B and C and D
A= $ext eq ""B= $compC= $i == 1D= $delay
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 7 | push @$out, "renaming $src to $dst (rotatecount $rot, logstart 1, i $i),"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 7 | ▶ | next if $debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 5 | my $e = delete $files->{$src}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 5 | ▶ | $files->{$dst} = $dst =~ /\.gz\z/ && $src !~ /\.gz\z/ ? _gz( ref $e ? $e : { content => $e } ) : $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$dst =~ /\.gz\z/ and not $src =~ /\.gz\z/
MC/DC50%1/2
$dst =~ /\.gz\z/ and not $src =~ /\.gz\z/
$dst =~ /\.gz\z/
not $src =~ /\.gz\z/
Truth table66%2/3
A and not(B)
A= $dst =~ /\.gz\z/B= not $src =~ /\.gz\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 7 | ▶ | my $one = "$f.1" . ( $comp && !$delay ? '.gz' : '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$comp and not $delay
MC/DC0%0/2
$comp and not $delay
$comp
not $delay
Truth table66%2/3
A and not(B)
A= $compB= not $delay
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 7 | my $e = _l( '_file_entry', $dev, $f ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 7 | ▶ | if ( $opt->{copytruncate} || $opt->{copy} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$$opt{"copytruncate"} or $$opt{"copy"}
MC/DC50%1/2
$$opt{"copytruncate"} or $$opt{"copy"}
$$opt{"copytruncate"}
$$opt{"copy"}
Truth table66%2/3
A or B
A= $$opt{"copytruncate"}B= $$opt{"copy"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 2 | push @$out, "copying $f to $f.1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 2 | ▶ | push @$out, "truncating $f" if $opt->{copytruncate}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 2 | ▶ | return if $debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 2 | my %c = %$e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 2 | delete $c{open_by}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 2 | ▶ | $files->{$one} = $comp && !$delay ? _gz( \%c ) : \%c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$comp and not $delay
MC/DC0%0/2
$comp and not $delay
$comp
not $delay
Truth table66%2/3
A and not(B)
A= $compB= not $delay
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 2 | ▶ | if ( $opt->{copytruncate} ) { my %t = %$e; $t{content} = ''; $t{size} = '0'; $files->{$f} = \%t } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 5 | push @$out, "renaming $f to $f.1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 5 | ▶ | my $cr = $opt->{create} && !$opt->{nocreate}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$$opt{'create'} && !$$opt{'nocreate'}
MC/DC0%0/2
$$opt{'create'} && !$$opt{'nocreate'}
$$opt{'create'}
!$$opt{'nocreate'}
Truth table33%1/3
A && not(B)
A= $$opt{'create'}B= !$$opt{'nocreate'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 5 | ▶ | my ( $m, $u, $g ) = @{ $opt->{create} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$opt{'create'} || []
MC/DC0%0/1
$$opt{'create'} || []
$$opt{'create'}
Truth table50%1/2
A
A= $$opt{'create'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 5 | ▶ | $m //= $e->{mode} // '0644'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition25%1/4
$m //= $$e{"mode"} // "0644"
$$e{"mode"} // "0644"
MC/DC0%0/1
$m //= $$e{"mode"} // "0644"
$m
Truth table50%1/2
A
A= $m
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 5 | ▶ | $u //= $e->{owner} // 'root'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition25%1/4
$u //= $$e{"owner"} // "root"
$$e{"owner"} // "root"
MC/DC0%0/1
$u //= $$e{"owner"} // "root"
$u
Truth table50%1/2
A
A= $u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 5 | ▶ | $g //= $e->{group} // 'root'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition25%1/4
$g //= $$e{"group"} // "root"
$$e{"group"} // "root"
MC/DC0%0/1
$g //= $$e{"group"} // "root"
$g
Truth table50%1/2
A
A= $g
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 5 | ▶ | push @$out, sprintf( 'creating new %s mode = %04o uid = %d gid = %d', $f, oct $m, _l( '_uid', $dev, $u ), _l( '_gid', $dev, $g ) ) if $cr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 5 | ▶ | return if $debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 4 | my %r = %$e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 4 | ▶ | $r{opened_as} = $f if defined $r{open_by}; # der Dienst schreibt weiter hierhin, bis er neu oeffnet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 4 | delete $files->{$f}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 4 | $files->{"$f.1"} = \%r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | if ( $comp && !$delay ) { $files->{$one} = _gz( \%r ); delete $files->{"$f.1"} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$comp and not $delay
MC/DC0%0/2
$comp and not $delay
$comp
not $delay
Truth table33%1/3
A and not(B)
A= $compB= not $delay
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 4 | ▶ | $files->{$f} = { content => '', size => '0', mode => sprintf( '%04o', oct $m ), owner => $u, group => $g, mtime => 'Oct 20 14:00' } if $cr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||