Branch Coverage

blib/lib/Sys/Export/Unix/UserDB.pm
Criterion Covered Total %
branch 169 276 61.2


line true false branch
22 13 106 if &Scalar::Util::looks_like_number($_[0])
26 1 12 @args == 1 && isa_hash($args[0]) ? :
36 0 13 if defined $args{'valid_name_regex'}
43 1 4 unless $self->can($_)
46 2 10 if ($g)
47 0 2 if (isa_array $g) { }
2 0 elsif (isa_hash $g) { }
55 2 10 if ($u)
56 0 2 if (isa_array $u) { }
2 0 elsif (isa_hash $u) { }
80 1 2 &isa_userdb($val[0]) ? :
3 63 if (@val) { }
90 0 91 defined $self->{'valid_name_regex'} ? :
95 0 3 unless defined $path
100 3 0 unless ($options{'format'})
102 0 1 -f $passwd_file ? :
0 1 -f $group_file ? :
0 1 -f $shadow_file ? :
2 1 -f $passwd_file && -f $group_file && -f $shadow_file ? :
108 2 0 if ($options{'format'} eq 'Linux') { }
109 2 0 -r $shadow_file ? :
127 7 0 if (my $primary_group = $group_by_gid{$gid}) { }
139 4 5 if (my $members = delete $g->{'members'})
142 0 6 unless (my $u = $user_by_name{$_})
160 4 0 if ($format eq 'Linux') { }
165 2 2 if (isa_hash $target) { }
168 0 2 unless -e $target
171 4 2 $public ? :
178 0 6 unless open my $fh, ">:raw", $name
179 0 6 unless $fh->print($data)
180 0 6 unless $fh->close
181 6 0 if defined $mode
185 0 6 unless open my $fh, "<:raw", $name
188 0 6 unless close $fh
195 6 4 !length($t) ? :
196 4 4 !length($d) ? :
202 0 7 if /^\s*(#|\z)/u
211 0 4 if /^\s*(#|\z)/u
214 0 4 unless (my $r = $users{$name})
222 0 9 if /^\s*(#|\z)/u
238 9 0 if ($user->group) { }
239 0 9 unless my $group = $self->group($user->group)
243 0 0 unless $gid = $user->gid
248 5 4 if (grep defined($_), @{$user;}{@_linux_shadow_fields})
281 0 3 unless ref $name_or_obj or length $name_or_obj
282 2 1 if (isa_hash $name_or_obj or &isa_user($name_or_obj)) { }
0 1 elsif (keys %attrs) { }
287 0 1 unless my $pw = &Sys::Export::Unix::UserDB::getpwnam($name_or_obj)
292 0 1 if pw_has("quota")
293 0 1 if pw_has("class")
294 0 1 if pw_has("comment")
295 1 0 if pw_has("gecos")
298 0 1 if (pw_has("expire"))
303 0 0 $^O eq 'linux' ? :
0 0 $^O eq 'FreeBSD' ? :
309 1 0 if (my $grnam = getgrgid $gid) { }
0 0 elsif ($gid == $pw->uid or $pw->uid < 1000) { }
325 0 3 unless defined $attrs{'uid'}
326 0 3 if ($self->{'uids'}{$attrs{'uid'}})
327 0 0 if ($attrs{'uid'} >= 1000) { }
331 0 0 unless (exists $self->{'uids'}{$_})
337 0 0 if $self->{'uids'}{$attrs{'uid'}}
344 0 0 if ($gname eq $attrs{'name'}) { }
0 0 elsif ($gname =~ /^(nobody|nogroup)/u) { }
360 0 4 unless ref $name_or_obj or length $name_or_obj
361 3 1 if (isa_hash $name_or_obj or &isa_group($name_or_obj)) { }
0 1 elsif (keys %attrs) { }
366 0 1 unless my($grnam, $passwd, $gid, $members) = getgrnam $name_or_obj
378 1 3 if (defined $members)
380 0 1 isa_hash $members ? :
0 1 isa_array $members ? :
389 1 14 if (isa_hash $name_or_obj or &isa_user($name_or_obj)) { }
393 14 0 if (keys %attrs) { }
0 0 elsif ($self->auto_import and not $self->{'users'}{$name}) { }
398 0 0 unless $self->user($name)
408 1 13 if (isa_hash $name_or_obj or &isa_group($name_or_obj)) { }
412 13 0 if (keys %attrs) { }
0 0 elsif ($self->auto_import and not $self->{'groups'}{$name}) { }
417 0 0 unless $self->group($name)
427 0 16 unless length $spec
428 5 11 isa_int $spec ? :
429 3 13 if (not $u and $self->auto_import)
430 2 1 if (&isa_userdb(scalar $self->auto_import)) { }
432 0 2 unless $u = eval { do { $self->import_user($peer_u) } }
434 0 1 isa_int $spec ? :
435 0 1 unless $u = eval { do { $self->import_user($name) } }
442 2 2 isa_int $spec ? :
446 0 69 unless length $spec
447 4 65 isa_int $spec ? :
448 4 65 if (not $g and $self->auto_import)
449 3 1 if (&isa_userdb(scalar $self->auto_import)) { }
451 0 3 unless $g = eval { do { $self->import_group($peer_g) } }
453 0 1 isa_int $spec ? :
454 0 1 unless $g = eval { do { $self->import_group($name) } }
461 2 2 isa_int $spec ? :
468 0 0 if (my $u = $self->{'users'}{$unam}) { }
478 0 25 unless $self->is_valid_name($name)
482 1 24 if defined $self->{'users'}{$name}
486 1 23 if defined $self->{'uids'}{$uid}
490 0 24 isa_int($user->group) ? :
491 0 39 unless $self->is_valid_name($_)
494 6 33 if $self->auto_import
496 0 39 unless $self->group($_)
501 0 24 if (my $lazy = delete $self->{'_lazy_add_user_to_group'}{$name})
513 0 27 unless $self->is_valid_name($name)
517 1 26 if defined $self->{'groups'}{$name}
521 1 25 if defined $self->{'gids'}{$gid}
542 1 29 unless defined $self->{'name'}
543 1 28 unless defined $self->{'uid'}
544 5 23 unless (defined $self->{'group'})
546 4 1 if (isa_array($attrs{'groups'}))
549 1 4 unless length $self->{'group'}
552 0 83 unless $known_attrs{$key}
567 0 84 if (@val) { }
571 14 64 if (@val)
572 0 14 if (@val > 1 or not ref $val[0]) { }
9 5 elsif (isa_array($val[0])) { }
5 0 elsif (isa_hash($val[0])) { }
603 0 0 if (@val) { }
0 0 if (@val) { }
12 11 if (@val) { }
4 5 if (@val) { }
13 11 if (@val) { }
11 11 if (@val) { }
5 6 if (@val) { }
4 5 if (@val) { }
4 5 if (@val) { }
4 5 if (@val) { }
4 5 if (@val) { }
0 0 if (@val) { }
12 11 if (@val) { }
612 0 0 unless exists $known_attrs{$attr} or exists $self->{$attr}
613 0 0 if (@_) { }
634 1 30 unless defined $self->{'name'}
635 1 29 unless defined $self->{'gid'}
637 0 0 unless $known_attrs{$key}
657 0 0 unless exists $known_attrs{$attr} or exists $self->{$attr}
658 1 14 if (@_) { }