| 1 | package Ubic::Credentials::OS::MacOSX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | $Ubic::Credentials::OS::MacOSX::VERSION = '1.59'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use parent qw(Ubic::Credentials); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # ABSTRACT: MacOSX-specific credentials implementation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use List::MoreUtils qw(uniq); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Params::Validate qw(:all); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my $params = validate(@_, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | user => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | group => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | service => { optional => 1, isa => 'Ubic::Service' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | if (defined $params->{user}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | if (defined $params->{service}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | croak "Only one of 'user' and 'service' parameters should be specified"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | $self->{user} = $params->{user}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | $self->{group} = $params->{group} if defined $params->{group}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if (ref $self->{group}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | $self->{group} = $self->{group}[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | elsif (defined $params->{service}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $self->{user} = $params->{service}->user; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my @group = $params->{service}->group; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | $self->{group} = $group[0] if @group; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $self->{real_user_id} = $<; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $self->{effective_user_id} = $>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ($self->{real_group_id}) = $( =~ /^(\d+)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ($self->{effective_group_id}) = $) =~ /^(\d+)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # TODO - derive user from real_user_id when user is not specified (or from effective_user_id?!) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | return bless $self => $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | sub user { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
user: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | unless (defined $self->{user}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $self->{user} = getpwuid($>); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return $self->{user}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | sub group { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
group: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | unless (defined $self->{group}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $self->_user2group; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | return $self->{group}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | sub _user2uid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_user2uid: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $user = $self->user; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $id = scalar getpwnam($user); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | unless (defined $id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | croak "user $user not found"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | return $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | sub real_user_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
real_user_id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | return $self->{real_user_id} if defined $self->{real_user_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | return $self->_user2uid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | sub effective_user_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
effective_user_id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | return $self->{effective_user_id} if defined $self->{effective_user_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | return $self->_user2uid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | sub _group2gid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_group2gid: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my $group = $self->group; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my $gid = getgrnam($group); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | unless (defined $gid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | croak "group $group not found"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | return $gid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | sub real_group_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
real_group_id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | return $self->{real_group_id} if defined $self->{real_group_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | return $self->_group2gid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | sub effective_group_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
effective_group_id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | return $self->{effective_group_id} if defined $self->{effective_group_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | return $self->_group2gid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | sub _user2group { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_user2group: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $user = $self->user; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | confess "user not defined" unless defined $user; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $main_group = getgrgid((getpwnam $user)[3]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $self->{group} = $main_group; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | sub set_effective { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_effective: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $current_creds = Ubic::Credentials->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $euid = $current_creds->effective_user_id(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my ($egid) = $current_creds->effective_group_id(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $egid =~ s/^(\d+).*/$1/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $current_user = getpwuid($euid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $current_group = getgrgid($egid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $user = $self->user; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my ($group) = $self->group; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ($group ne $current_group) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $self->{old_egid} = $); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $new_gid = getgrnam($group); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | unless (defined $new_gid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | die "group $group not found"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # AccessGuard don't need to handle supplementary groups correctly, so this is ok | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $) = "$new_gid 0"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my ($current_gid) = $) =~ /^(\d+)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if ($current_gid != $new_gid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | die "Failed to change group from $current_group to $group: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ($user ne $current_user) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $self->{old_euid} = $>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if ($current_user ne 'root') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | die "Can't change user from $current_user to $user"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $new_uid = getpwnam($user); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | unless (defined $new_uid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | die "user $user not found"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $> = $new_uid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if ($> != $new_uid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | die "Failed to change user from $current_user to $user: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | sub _groups_equal { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | my ($self, $g1, $g2) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_groups_equal: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my ($main1) = split / /, $g1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my ($main2) = split / /, $g2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | return ($main1 == $main2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | sub reset_effective { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_effective: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | if (defined $self->{old_euid}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $> = $self->{old_euid}; # return euid back to normal | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ($> != $self->{old_euid}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | warn "Failed to restore euid from $> to $self->{old_euid}: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if (defined $self->{old_egid}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $) = $self->{old_egid}; # return egid back to normal | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if ($) != $self->{old_egid}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | warn "Failed to restore egid from '$)' to '$self->{old_egid}': $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | sub eq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | my ($self, $other) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eq: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$self->effective_user_id == $other->effective_user_id and $self->real_user_id == $other->real_user_id and $self->_groups_equal($self->effective_group_id, $other->effective_group_id) and $self->_groups_equal($self->real_group_id, $other->real_group_id)
$self->effective_user_id == $other->effective_user_id and $self->real_user_id == $other->real_user_id and $self->_groups_equal($self->effective_group_id, $other->effective_group_id)
$self->effective_user_id == $other->effective_user_id and $self->real_user_id == $other->real_user_id
MC/DC0%0/4
$self->effective_user_id == $other->effective_user_id and $self->real_user_id == $other->real_user_id and $self->_groups_equal($self->effective_group_id, $other->effective_group_id) and $self->_groups_equal($self->real_group_id, $other->real_group_id)
$self->effective_user_id == $other->effective_user_id
$self->real_user_id == $other->real_user_id
$self->_groups_equal($self->effective_group_id, $other->effective_group_id)
$self->_groups_equal($self->real_group_id, $other->real_group_id)
Truth table0%0/5
A and B and C and D
A= $self->effective_user_id == $other->effective_user_idB= $self->real_user_id == $other->real_user_idC= $self->_groups_equal($self->effective_group_id, $other->effective_group_id)D= $self->_groups_equal($self->real_group_id, $other->real_group_id)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | $self->effective_user_id == $other->effective_user_id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | and $self->real_user_id == $other->real_user_id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | and $self->_groups_equal($self->effective_group_id, $other->effective_group_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | and $self->_groups_equal($self->real_group_id, $other->real_group_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | sub set { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $effective_gid = $self->effective_group_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $) = $effective_gid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | unless ($self->_groups_equal($), $effective_gid)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | die "Failed to set effective gid to $effective_gid: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $new_euid = $self->effective_user_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $> = $new_euid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | unless ($> == $new_euid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | die "Failed to set effective uid to $new_euid: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my $real_gid = $self->real_group_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $( = $real_gid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | unless ($self->_groups_equal($(, $real_gid)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | die "Failed to set real gid to $real_gid: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my $new_ruid = $self->real_user_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $< = $new_ruid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | unless ($< == $new_ruid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | die "Failed to set real uid to $new_ruid: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||