| 1 | package Working::Daemon; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use 5.008; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use File::Copy; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | our $VERSION = 0.31; | |||||||||||||||||||||||||||
| 12 | 2 | our $SVN = 5236; | |||||||||||||||||||||||||||
| 13 | 2 | our %config; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | #these are all default configs | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # perl really need the protocols file to function | ||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub chroot_files { return ("/etc/protocols") } | ||||||||||||||||||||||||||
|
Subroutine
chroot_files: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub chroot_dirs { return ("/etc/") } | ||||||||||||||||||||||||||
|
Subroutine
chroot_dirs: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub default_action { return "start" } | ||||||||||||||||||||||||||
|
Subroutine
default_action: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub exit_success { exit(0) } | ||||||||||||||||||||||||||
|
Subroutine
exit_success: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub exit_error { exit(1) } | ||||||||||||||||||||||||||
|
Subroutine
exit_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub default_options { | ||||||||||||||||||||||||||
|
Subroutine
default_options: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | return ( | ||||||||||||||||||||||||||||
| 30 | 0 | "help" => undef() => "This help", | |||||||||||||||||||||||||||
| 31 | "version" => undef() => "Version number", | ||||||||||||||||||||||||||||
| 32 | "loglevel=i" => undef() => "The higher the loglevel, the more detailed messages. Default to 0", | ||||||||||||||||||||||||||||
| 33 | "daemon!" => undef() => "Set to --no-daemon if you don't want it to daemonize. Default is true", | ||||||||||||||||||||||||||||
| 34 | "chroot!" => undef() => "Set to --no-chroot if you don't want it to chroot. Default is true", | ||||||||||||||||||||||||||||
| 35 | "foreground" => undef() => "Inverse of daemonize, default is off", | ||||||||||||||||||||||||||||
| 36 | "user=s" => undef() => "User to run this app as. Default is 'nobody'", | ||||||||||||||||||||||||||||
| 37 | "group=s" => undef() => "Group to run this app as. Default is 'nobody'", | ||||||||||||||||||||||||||||
| 38 | "pidfile=s" => undef() => "Where to store the pidfile. Default is /var/run/\$name.pid", | ||||||||||||||||||||||||||||
| 39 | "name=s" => undef() => "Name of this app") | ||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub tmpdir { | ||||||||||||||||||||||||||
|
Subroutine
tmpdir: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 45 | 0 | return "/tmp/" . $self->name . ".$$"; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | # end of config methods | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub standard { | ||||||||||||||||||||||||||
|
Subroutine
standard: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 52 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 53 | 0 | $self->parse_options(@_); | |||||||||||||||||||||||||||
| 54 | 0 | $self->do_action(); | |||||||||||||||||||||||||||
| 55 | 0 | $self->change_root(); | |||||||||||||||||||||||||||
| 56 | 0 | $self->drop_privs(); | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 60 | 2 | my $class = shift; | |||||||||||||||||||||||||||
| 61 | 2 | my $self = bless {}, $class; | |||||||||||||||||||||||||||
| 62 | 2 | return $self; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub do_action { | ||||||||||||||||||||||||||
|
Subroutine
do_action: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 68 | 0 | ▶ | my $action = shift @ARGV || $self->default_action; | ||||||||||||||||||||||||||
|
Condition0%0/3
shift @ARGV || $self->default_action
MC/DC0%0/2
shift @ARGV || $self->default_action
shift @ARGV
$self->default_action
Truth table0%0/3
A || B
A= shift @ARGVB= $self->default_action
| |||||||||||||||||||||||||||||
| 69 | 0 | my $action_method = "action_$action"; | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | $self->print_version if($self->options->{version}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ($self->options->{help}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | $self->show_help; | |||||||||||||||||||||||||||
| 73 | 0 | exit; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if($self->can($action_method)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 0 | my $exit_value = $self->$action_method; | |||||||||||||||||||||||||||
| 78 | 0 | ▶ | exit $exit_value unless ($action eq 'start' || $action eq 'restart'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$action eq "start" or $action eq "restart"
MC/DC0%0/2
$action eq "start" or $action eq "restart"
$action eq "start"
$action eq "restart"
Truth table0%0/3
A or B
A= $action eq "start"B= $action eq "restart"
| |||||||||||||||||||||||||||||
| 79 | } else { | ||||||||||||||||||||||||||||
| 80 | 0 | print STDERR "Unknown command '$action'\n"; | |||||||||||||||||||||||||||
| 81 | 0 | $self->show_help; | |||||||||||||||||||||||||||
| 82 | 0 | exit; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub show_help { | ||||||||||||||||||||||||||
|
Subroutine
show_help: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 87 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 88 | 0 | my %options_desc = %{$self->options_desc}; | |||||||||||||||||||||||||||
| 89 | 0 | ▶ | %options_desc = $self->default_options if (!%options_desc); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 0 | my $max_length = 0; | |||||||||||||||||||||||||||
| 91 | 0 | my @commands; | |||||||||||||||||||||||||||
| 92 | my @desc; | ||||||||||||||||||||||||||||
| 93 | 0 | my @values; | |||||||||||||||||||||||||||
| 94 | 0 | foreach my $option (keys %options_desc) { | |||||||||||||||||||||||||||
| 95 | 0 | my $command = $option; | |||||||||||||||||||||||||||
| 96 | 0 | ▶ | if($command =~s/\=(.)%?//g) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | $command .= "=str" if($1 eq 's'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $command .= "=int" if($1 eq 'i'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | 0 | ▶ | $command = "no-$command" if($command =~s/\!$//); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | $max_length = length($command) if(length($command) > $max_length); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 0 | push @commands, $command; | |||||||||||||||||||||||||||
| 103 | 0 | push @desc, $options_desc{$option}; | |||||||||||||||||||||||||||
| 104 | 0 | $option =~s/(\w+)/$1/; | |||||||||||||||||||||||||||
| 105 | 0 | my $raw_option = $1; | |||||||||||||||||||||||||||
| 106 | 0 | ▶ | if ($self->can($raw_option)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 0 | push @values, $self->$raw_option; | |||||||||||||||||||||||||||
| 108 | } else { | ||||||||||||||||||||||||||||
| 109 | 0 | ▶ | push @values, ($self->options->{$raw_option}||""); | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->options->{$raw_option} || ''
MC/DC0%0/1
$self->options->{$raw_option} || ''
$self->options->{$raw_option}
Truth table0%0/2
A
A= $self->options->{$raw_option}
| |||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | 0 | $max_length += 4; | |||||||||||||||||||||||||||
| 113 | 0 | print STDERR "[start | stop | restart | status]\n"; | |||||||||||||||||||||||||||
| 114 | 0 | foreach my $command (@commands) { | |||||||||||||||||||||||||||
| 115 | 0 | my $cmd = sprintf(" --%-${max_length}s", $command); | |||||||||||||||||||||||||||
| 116 | 0 | my $desc = shift @desc; | |||||||||||||||||||||||||||
| 117 | 0 | my $value = shift @values; | |||||||||||||||||||||||||||
| 118 | 0 | print STDERR "$cmd$desc: $value\n"; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | 0 | exit; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 0 | ▶ | sub parse_options { | ||||||||||||||||||||||||||
|
Subroutine
parse_options: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 124 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 0 | my %options; | |||||||||||||||||||||||||||
| 127 | my %option_keys; | ||||||||||||||||||||||||||||
| 128 | 0 | my @options = ($self->default_options, @_); | |||||||||||||||||||||||||||
| 129 | 0 | ▶ | while(@options) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 0 | my $option = shift @options; | |||||||||||||||||||||||||||
| 131 | 0 | my $default_value = shift @options; | |||||||||||||||||||||||||||
| 132 | 0 | my $help = shift @options; | |||||||||||||||||||||||||||
| 133 | 0 | $option_keys{$option} = $help; | |||||||||||||||||||||||||||
| 134 | 0 | my ($key) = $option =~/(\w+)/; | |||||||||||||||||||||||||||
| 135 | 0 | ▶ | $options{$key} = $default_value if(defined $default_value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | 0 | GetOptions(\%options, keys %option_keys); | |||||||||||||||||||||||||||
| 138 | 0 | $self->options(\%options); | |||||||||||||||||||||||||||
| 139 | 0 | $self->options_desc(\%option_keys); | |||||||||||||||||||||||||||
| 140 | 0 | $self->assign_options(qw(user group name chroot foreground daemon pidfile)); | |||||||||||||||||||||||||||
| 141 | 0 | $self->init(); | |||||||||||||||||||||||||||
| 142 | 0 | return \%options; | |||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 0 | ▶ | sub init {} | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 0 | ▶ | sub print_version { | ||||||||||||||||||||||||||
|
Subroutine
print_version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 149 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 150 | 0 | my $name = $self->name; | |||||||||||||||||||||||||||
| 151 | 0 | my $version = $self->version; | |||||||||||||||||||||||||||
| 152 | 0 | print STDERR "$name $version (Working::Daemon: $VERSION)\n"; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 0 | ▶ | sub assign_options { | ||||||||||||||||||||||||||
|
Subroutine
assign_options: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 157 | 0 | my ($self, @options) = @_; | |||||||||||||||||||||||||||
| 158 | 0 | foreach my $option (@options) { | |||||||||||||||||||||||||||
| 159 | $self->$option($self->options->{$option}) | ||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if (exists $self->options->{$option}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub change_root { | ||||||||||||||||||||||||||
|
Subroutine
change_root: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 166 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 167 | 0 | ▶ | return unless $self->chroot; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | my $tmpdir = $self->tmpdir; | |||||||||||||||||||||||||||
| 170 | 0 | ▶ | mkdir ($tmpdir) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | || croak "Cannot create directory '$tmpdir': $!"; | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 0 | ▶ | chown($self->uid,$self->gid, $tmpdir) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 174 | || croak("Cannot chown $tmpdir to (". $self->uid . ":". $self->gid . "): $!"); | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 0 | my $dirs = $self->{__PACKAGE__}->{chroot_clean_dirs} = []; | |||||||||||||||||||||||||||
| 177 | 0 | my $files = $self->{__PACKAGE__}->{chroot_clean_files} = []; | |||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 0 | foreach my $dir ($self->chroot_dirs) { | |||||||||||||||||||||||||||
| 180 | 0 | push @$dirs, "$tmpdir/$dir"; | |||||||||||||||||||||||||||
| 181 | 0 | ▶ | mkdir("$tmpdir/$dir") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | || croak "Cannot create $tmpdir/$dir: $!"; | ||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 0 | foreach my $file_to_copy ($self->chroot_files) { | |||||||||||||||||||||||||||
| 186 | 0 | push @$files, "$tmpdir/$file_to_copy"; | |||||||||||||||||||||||||||
| 187 | 0 | ▶ | copy("$file_to_copy", "$tmpdir/$file_to_copy") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | || croak "Cannot copy $file_to_copy -> $tmpdir/$file_to_copy: $!"; | ||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 0 | ▶ | chroot("$tmpdir/") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | || croak ("Can't chroot to $tmpdir: $!"); | ||||||||||||||||||||||||||||
| 193 | 0 | ▶ | chdir("/") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 194 | || croak ("Can't chdir to '/': $!"); | ||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub version { | ||||||||||||||||||||||||||
|
Subroutine
version: not called CC=2 SCAR=12.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 198 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 199 | 0 | my $caller = caller(2); | |||||||||||||||||||||||||||
| 200 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 201 | 0 | my $varname = "${caller}::VERSION"; | |||||||||||||||||||||||||||
| 202 | 0 | my $version = $$varname; | |||||||||||||||||||||||||||
| 203 | 0 | ▶ | return $version || ""; | ||||||||||||||||||||||||||
|
Condition0%0/2
$version || ''
MC/DC0%0/1
$version || ''
$version
Truth table0%0/2
A
A= $version
| |||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 0 | ▶ | sub write_pidfile { | ||||||||||||||||||||||||||
|
Subroutine
write_pidfile: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 207 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 208 | 0 | my $pidfile = $self->pidfile; | |||||||||||||||||||||||||||
| 209 | 0 | ▶ | open(my $pidfh, "+>$pidfile") || croak "Cannot open '$pidfile': $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | 0 | print $pidfh "$$"; | |||||||||||||||||||||||||||
| 211 | 0 | close $pidfh; | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 0 | ▶ | sub delete_pidfile { | ||||||||||||||||||||||||||
|
Subroutine
delete_pidfile: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 216 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 217 | 0 | ▶ | unlink($self->pidfile) || croak "Cannot remove pidfile '".$self->pidfile."': $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 0 | ▶ | sub cleanup_chroot { | ||||||||||||||||||||||||||
|
Subroutine
cleanup_chroot: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 222 | # unlink("/tmp/glbdns.$pid/etc/protocols") || die "$!"; | ||||||||||||||||||||||||||||
| 223 | # rmdir("/tmp/glbdns.$pid/etc/") || die; | ||||||||||||||||||||||||||||
| 224 | # rmdir("/tmp/glbdns.$pid/") || die; | ||||||||||||||||||||||||||||
| 225 | # unlink($config{pidfile}) || die $!; | ||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 0 | ▶ | sub action_start { | ||||||||||||||||||||||||||
|
Subroutine
action_start: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 229 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 230 | 0 | my $name = $self->name; | |||||||||||||||||||||||||||
| 231 | 0 | ▶ | if(my $pid = $self->get_pid) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 0 | $self->log(0, "fatal", "Cannot start '$name' because it is already running at $pid"); | |||||||||||||||||||||||||||
| 233 | 0 | $self->exit_error; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | 0 | $self->log(0, 'info', "Starting '$name'"); | |||||||||||||||||||||||||||
| 236 | 0 | $self->daemonize; | |||||||||||||||||||||||||||
| 237 | 0 | $self->spawn_worker_child; | |||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 0 | ▶ | sub spawn_worker_child { | ||||||||||||||||||||||||||
|
Subroutine
spawn_worker_child: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 241 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 242 | 0 | ▶ | if(my $pid = fork()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | 0 | my $name = $self->name; | |||||||||||||||||||||||||||
| 244 | # this is the master session | ||||||||||||||||||||||||||||
| 245 | # it makes sure to cleanup from the slave | ||||||||||||||||||||||||||||
| 246 | # it stays as superuser | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 0 | $self->write_pidfile; | |||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 0 | $self->openlog; | |||||||||||||||||||||||||||
| 252 | 0 | $self->log(1, 'info', "started master session $name - child is $pid"); | |||||||||||||||||||||||||||
| 253 | 0 | ▶ | $SIG{INT} = sub { kill(2,$pid) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 254 | 0 | $0 = "$name - waiting for child $pid"; | |||||||||||||||||||||||||||
| 255 | 0 | $self->wait_for_worker_child($pid); | |||||||||||||||||||||||||||
| 256 | 0 | $self->log(1, 'info', "exiting master session $name - child is $pid"); | |||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 0 | $self->cleanup_chroot; | |||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 0 | $self->delete_pidfile; | |||||||||||||||||||||||||||
| 261 | 0 | exit; | |||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 0 | return 1; | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 0 | ▶ | sub wait_for_worker_child { | ||||||||||||||||||||||||||
|
Subroutine
wait_for_worker_child: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 268 | 0 | my ($self, $pid) = @_; | |||||||||||||||||||||||||||
| 269 | 0 | waitpid($pid, 0); | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 0 | ▶ | sub action_restart { | ||||||||||||||||||||||||||
|
Subroutine
action_restart: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 273 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 274 | 0 | ▶ | if ($self->is_running) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 275 | 0 | $self->action_stop | |||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | 0 | $self->action_start; | |||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 0 | ▶ | sub action_status { | ||||||||||||||||||||||||||
|
Subroutine
action_status: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 281 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 282 | 0 | ▶ | if (my $pid = $self->is_running) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 283 | 0 | print STDERR $self->name . " is running on $pid\n"; | |||||||||||||||||||||||||||
| 284 | 0 | return 0; | |||||||||||||||||||||||||||
| 285 | } else { | ||||||||||||||||||||||||||||
| 286 | 0 | print STDERR $self->name . " is not running\n"; | |||||||||||||||||||||||||||
| 287 | 0 | return 1; | |||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 0 | ▶ | sub action_stop { | ||||||||||||||||||||||||||
|
Subroutine
action_stop: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 292 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 293 | 0 | my $pid = $self->is_running; | |||||||||||||||||||||||||||
| 294 | 0 | ▶ | if ($pid) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 295 | 0 | ▶ | while($self->is_running) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 296 | 0 | kill(2, $pid); | |||||||||||||||||||||||||||
| 297 | 0 | $self->log(0, 'info', "sent SIGINT to $pid - waiting on stopped pid $pid"); | |||||||||||||||||||||||||||
| 298 | 0 | sleep 1; | |||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | 0 | $self->log(0, 'info',"Stopped " . $self->name . " on $pid"); | |||||||||||||||||||||||||||
| 301 | } else { | ||||||||||||||||||||||||||||
| 302 | 0 | $self->log(0, 'info', $self->name . " is not running"); | |||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||
| 304 | 0 | return 0; | |||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 0 | ▶ | sub is_running { | ||||||||||||||||||||||||||
|
Subroutine
is_running: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 308 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 309 | 0 | my $pid = $self->get_pid; | |||||||||||||||||||||||||||
| 310 | 0 | ▶ | return $pid | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | if($self->check_pid($pid)); | ||||||||||||||||||||||||||||
| 312 | 0 | return 0; | |||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 0 | ▶ | sub openlog { | ||||||||||||||||||||||||||
|
Subroutine
openlog: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 316 | # openlog("$config{name}", 'ndelay,pid', LOG_DAEMON) if($config{syslog});} | ||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sub get_pid { | ||||||||||||||||||||||||||
|
Subroutine
get_pid: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 321 | # pid code needs serious overhaul to use flock | ||||||||||||||||||||||||||||
| 322 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 323 | 0 | my $pidfile = $self->pidfile; | |||||||||||||||||||||||||||
| 324 | 0 | ▶ | if(-r $pidfile) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 325 | 0 | ▶ | open(my $pidfh, "<$pidfile") || croak "Cannot open pidfile ($pidfile): $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 326 | 0 | my $line = <$pidfh>; | |||||||||||||||||||||||||||
| 327 | 0 | close($pidfh); | |||||||||||||||||||||||||||
| 328 | 0 | $line =~/(\d+)/; | |||||||||||||||||||||||||||
| 329 | 0 | ▶ | if(my $pid_to_check = $1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 330 | 0 | $ENV{PATH} = ''; | |||||||||||||||||||||||||||
| 331 | 0 | ▶ | return $pid_to_check if($self->check_pid($pid_to_check)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||
| 334 | 0 | return 0; | |||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 0 | ▶ | sub check_pid { | ||||||||||||||||||||||||||
|
Subroutine
check_pid: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 339 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 340 | 0 | my $pid = shift; | |||||||||||||||||||||||||||
| 341 | 0 | ▶ | return 0 unless $pid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 342 | 0 | my $grep = "/bin/grep"; | |||||||||||||||||||||||||||
| 343 | 0 | ▶ | $grep = "/usr/bin/grep" if ($^O eq 'darwin'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 344 | 0 | my $name = $self->name; | |||||||||||||||||||||||||||
| 345 | 0 | my $rv = qx{/bin/ps ax | $grep $pid | $grep -v grep | $grep $name}; | |||||||||||||||||||||||||||
| 346 | 0 | $rv =~s/\s+$//; | |||||||||||||||||||||||||||
| 347 | 0 | print STDERR "$rv\n"; | |||||||||||||||||||||||||||
| 348 | 0 | return !$?; | |||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | 0 | ▶ | sub daemonize { | ||||||||||||||||||||||||||
|
Subroutine
daemonize: not called CC=8 SCAR=39.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 353 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 354 | 0 | ▶ | return 0 unless $self->daemon; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 355 | 2 | ▶ | use POSIX qw(setsid); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 356 | 0 | my $name = $self->name; | |||||||||||||||||||||||||||
| 357 | 0 | ▶ | defined(my $pid = fork) || croak "Can't fork: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 358 | 0 | ▶ | if ($pid) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | 0 | print "$name started on $pid\n"; | |||||||||||||||||||||||||||
| 360 | 0 | exit 0; | |||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||
| 362 | 0 | ▶ | setsid() || croak "Can't start a new session: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 363 | 0 | ▶ | open (STDIN , '/dev/null') || croak "Can't read /dev/null: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 364 | 0 | ▶ | open (STDOUT, '>/dev/null') || croak "Can't write to /dev/null: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 365 | 0 | ▶ | open (STDERR, '>/dev/null') || croak "Can't write to /dev/null: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 366 | 0 | return 1; | |||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | 0 | ▶ | sub log { | ||||||||||||||||||||||||||
|
Subroutine
log: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 371 | 0 | my ($self, $level, $prio, $msg) = @_; | |||||||||||||||||||||||||||
| 372 | 0 | ▶ | return if ($level > $self->log_level); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 373 | 0 | $self->do_log($prio, $msg); | |||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | 0 | ▶ | sub do_log { | ||||||||||||||||||||||||||
|
Subroutine
do_log: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 378 | 0 | my ($self, $prio, $msg) = @_; | |||||||||||||||||||||||||||
| 379 | 0 | print STDERR "$prio - $msg\n"; | |||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | 0 | ▶ | sub drop_privs { | ||||||||||||||||||||||||||
|
Subroutine
drop_privs: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 384 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 385 | # drop user | ||||||||||||||||||||||||||||
| 386 | 0 | $< = $self->uid; | |||||||||||||||||||||||||||
| 387 | 0 | $> = $self->uid; | |||||||||||||||||||||||||||
| 388 | # drop group | ||||||||||||||||||||||||||||
| 389 | 0 | $( = $self->gid; | |||||||||||||||||||||||||||
| 390 | 0 | $) = $self->gid; | |||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | 0 | ▶ | sub uid { | ||||||||||||||||||||||||||
|
Subroutine
uid: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 395 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 396 | 0 | return scalar getpwnam($self->user); | |||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | 0 | ▶ | sub gid { | ||||||||||||||||||||||||||
|
Subroutine
gid: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 401 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 402 | 0 | return scalar getpwnam($self->group); | |||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | # accessors | ||||||||||||||||||||||||||||
| 408 | # yes they are nearly identical | ||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | 0 | ▶ | sub user { | ||||||||||||||||||||||||||
|
Subroutine
user: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 411 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 412 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 413 | 0 | return $self->{__PACKAGE__}->{user} = shift; | |||||||||||||||||||||||||||
| 414 | } elsif (exists($self->{__PACKAGE__}->{user})) { | ||||||||||||||||||||||||||||
| 415 | 0 | return $self->{__PACKAGE__}->{user}; | |||||||||||||||||||||||||||
| 416 | } else { | ||||||||||||||||||||||||||||
| 417 | 0 | return "nobody"; | |||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | 0 | ▶ | sub pidfile { | ||||||||||||||||||||||||||
|
Subroutine
pidfile: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 423 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 424 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 425 | 0 | return $self->{__PACKAGE__}->{pidfile} = shift; | |||||||||||||||||||||||||||
| 426 | } elsif (exists($self->{__PACKAGE__}->{pidfile})) { | ||||||||||||||||||||||||||||
| 427 | 0 | return $self->{__PACKAGE__}->{pidfile}; | |||||||||||||||||||||||||||
| 428 | } else { | ||||||||||||||||||||||||||||
| 429 | 0 | return "/var/run/". $self->name . ".pid"; | |||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | 10 | ▶ | sub daemon { | ||||||||||||||||||||||||||
|
Subroutine
daemon: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 435 | 10 | my $self = shift; | |||||||||||||||||||||||||||
| 436 | 10 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 437 | 2 | return $self->{__PACKAGE__}->{daemon} = shift; | |||||||||||||||||||||||||||
| 438 | } elsif (exists($self->{__PACKAGE__}->{daemon})) { | ||||||||||||||||||||||||||||
| 439 | 4 | return $self->{__PACKAGE__}->{daemon}; | |||||||||||||||||||||||||||
| 440 | } else { | ||||||||||||||||||||||||||||
| 441 | 4 | return 1; | |||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | 5 | ▶ | sub foreground { | ||||||||||||||||||||||||||
|
Subroutine
foreground: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 447 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 448 | 5 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 449 | 1 | return $self->daemon(!$_[0]); | |||||||||||||||||||||||||||
| 450 | } else { | ||||||||||||||||||||||||||||
| 451 | 4 | return !$self->daemon; | |||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | 0 | ▶ | sub chroot { | ||||||||||||||||||||||||||
|
Subroutine
chroot: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 457 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 458 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 459 | 0 | return $self->{__PACKAGE__}->{chroot} = shift; | |||||||||||||||||||||||||||
| 460 | } elsif (exists($self->{__PACKAGE__}->{chroot})) { | ||||||||||||||||||||||||||||
| 461 | 0 | return $self->{__PACKAGE__}->{chroot}; | |||||||||||||||||||||||||||
| 462 | } else { | ||||||||||||||||||||||||||||
| 463 | 0 | return 1; | |||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | 0 | ▶ | sub log_level { | ||||||||||||||||||||||||||
|
Subroutine
log_level: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 469 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 470 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 471 | 0 | return $self->{__PACKAGE__}->{log_level} = shift; | |||||||||||||||||||||||||||
| 472 | } elsif (exists($self->{__PACKAGE__}->{log_level})) { | ||||||||||||||||||||||||||||
| 473 | 0 | return $self->{__PACKAGE__}->{log_level}; | |||||||||||||||||||||||||||
| 474 | } else { | ||||||||||||||||||||||||||||
| 475 | 0 | return 1; | |||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | 0 | ▶ | sub group { | ||||||||||||||||||||||||||
|
Subroutine
group: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 481 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 482 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 483 | 0 | return $self->{__PACKAGE__}->{group} = shift; | |||||||||||||||||||||||||||
| 484 | } elsif (exists($self->{__PACKAGE__}->{group})) { | ||||||||||||||||||||||||||||
| 485 | 0 | return $self->{__PACKAGE__}->{group}; | |||||||||||||||||||||||||||
| 486 | } else { | ||||||||||||||||||||||||||||
| 487 | 0 | return "nobody"; | |||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | 0 | ▶ | sub name { | ||||||||||||||||||||||||||
|
Subroutine
name: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 493 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 494 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 495 | 0 | return $self->{__PACKAGE__}->{name} = shift; | |||||||||||||||||||||||||||
| 496 | } elsif (exists($self->{__PACKAGE__}->{name})) { | ||||||||||||||||||||||||||||
| 497 | 0 | return $self->{__PACKAGE__}->{name}; | |||||||||||||||||||||||||||
| 498 | } else { | ||||||||||||||||||||||||||||
| 499 | 0 | return "unnamed app"; | |||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | 0 | ▶ | sub options { | ||||||||||||||||||||||||||
|
Subroutine
options: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 505 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 506 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 507 | 0 | return $self->{__PACKAGE__}->{options} = shift; | |||||||||||||||||||||||||||
| 508 | } elsif (exists($self->{__PACKAGE__}->{options})) { | ||||||||||||||||||||||||||||
| 509 | 0 | return $self->{__PACKAGE__}->{options}; | |||||||||||||||||||||||||||
| 510 | } else { | ||||||||||||||||||||||||||||
| 511 | 0 | return {}; | |||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | 0 | ▶ | sub options_desc { | ||||||||||||||||||||||||||
|
Subroutine
options_desc: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 516 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 517 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 518 | 0 | return $self->{__PACKAGE__}->{options_desc} = shift; | |||||||||||||||||||||||||||
| 519 | } elsif (exists($self->{__PACKAGE__}->{options_desc})) { | ||||||||||||||||||||||||||||
| 520 | 0 | return $self->{__PACKAGE__}->{options_desc}; | |||||||||||||||||||||||||||
| 521 | } else { | ||||||||||||||||||||||||||||
| 522 | 0 | return {}; | |||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | # Preloaded methods go here. | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | 2 | 1; | |||||||||||||||||||||||||||
| 536 | __END__ | ||||||||||||||||||||||||||||