| 1 | package QuadPres::FS; | ||||||||||||||||||||||||||||
| 2 | 1 | $QuadPres::FS::VERSION = '0.32.0'; | |||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.016; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use parent 'QuadPres::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | __PACKAGE__->mk_acc_ref( [qw( gid group )] ); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | sub _init | ||||||||||||||||||||||||||||
| 12 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_init: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 13 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | my $group; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 0 | $group = $args{group}; | |||||||||||||||||||||||||||
| 20 | 0 | $self->set_group($group); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # Set the umask to ensure that other users which are a member of $group | ||||||||||||||||||||||||||||
| 23 | # can write to the files and directories generated by the program. | ||||||||||||||||||||||||||||
| 24 | 0 | umask(0002); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | return 0; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | sub set_group | ||||||||||||||||||||||||||||
| 30 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
set_group: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | my $group = shift; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | $self->group($group); | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | my $gid; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # Check if the group is not empty. | ||||||||||||||||||||||||||||
| 40 | 0 | ▶ | if ( defined($group) && ( $group !~ /^\s*$/ ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $group and not $group =~ /^\s*$/u
MC/DC0%0/2
defined $group and not $group =~ /^\s*$/u
defined $group
not $group =~ /^\s*$/u
Truth table0%0/3
A and not(B)
A= defined $groupB= not $group =~ /^\s*$/u
| |||||||||||||||||||||||||||||
| 41 | { | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ( $group =~ /^\d+$/ ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||
| 44 | 0 | $gid = $group; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | else | ||||||||||||||||||||||||||||
| 47 | { | ||||||||||||||||||||||||||||
| 48 | 0 | my @group_info = getgrnam($group); | |||||||||||||||||||||||||||
| 49 | 0 | ▶ | if (@group_info) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | { | ||||||||||||||||||||||||||||
| 51 | 0 | $gid = $group_info[2]; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | $self->gid($gid); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | return 0; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | sub my_chown | ||||||||||||||||||||||||||||
| 62 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
my_chown: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 63 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | my $path = shift; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if ( !defined( $self->gid ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||
| 69 | 0 | return; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | chown( -1, $self->gid, $path ); | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | return; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | sub make_dest_dir | ||||||||||||||||||||||||||||
| 78 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
make_dest_dir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 79 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | my $dest_dir = shift; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | # Check if the destination directory exists and if not - | ||||||||||||||||||||||||||||
| 84 | # create it. | ||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if ( !-e $dest_dir ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||
| 87 | 0 | mkdir($dest_dir); | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | # Make it belong to the common group | ||||||||||||||||||||||||||||
| 90 | 0 | $self->my_chown($dest_dir); | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | # Make it a SGID directory | ||||||||||||||||||||||||||||
| 93 | # This means that subsequent files will belong to its group. | ||||||||||||||||||||||||||||
| 94 | # And that subsequent directories inside will also be SGID. | ||||||||||||||||||||||||||||
| 95 | 0 | chmod( 02775, $dest_dir ); | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | return; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 1 | 1; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | __END__ | ||||||||||||||||||||||||||||