| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | # Copyright (c) 2012, cPanel, Inc. | 
| 2 |  |  |  |  |  |  | # All rights reserved. | 
| 3 |  |  |  |  |  |  | # http://cpanel.net/ | 
| 4 |  |  |  |  |  |  | # | 
| 5 |  |  |  |  |  |  | # This is free software; you can redistribute it and/or modify it under the same | 
| 6 |  |  |  |  |  |  | # terms as Perl itself.  See the LICENSE file for further details. | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | package Archive::Tar::Builder::UserCache; | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 8 |  |  | 8 |  | 543 | use strict; | 
|  | 8 |  |  |  |  | 22 |  | 
|  | 8 |  |  |  |  | 238 |  | 
| 11 | 8 |  |  | 8 |  | 40 | use warnings; | 
|  | 8 |  |  |  |  | 9 |  | 
|  | 8 |  |  |  |  | 1870 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | sub new { | 
| 14 | 92 |  |  | 92 | 0 | 13243881 | my ($class) = @_; | 
| 15 |  |  |  |  |  |  |  | 
| 16 | 92 |  |  |  |  | 2048 | return bless { | 
| 17 |  |  |  |  |  |  | 'users'  => {}, | 
| 18 |  |  |  |  |  |  | 'groups' => {} | 
| 19 |  |  |  |  |  |  | }, $class; | 
| 20 |  |  |  |  |  |  | } | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | sub lookup { | 
| 23 | 6672 |  |  | 6672 | 0 | 458561 | my ( $self, $uid, $gid ) = @_; | 
| 24 |  |  |  |  |  |  |  | 
| 25 | 6672 | 100 |  |  |  | 20730 | unless ( exists $self->{'users'}->{$uid} ) { | 
| 26 | 45 | 100 |  |  |  | 10852 | if ( my @pwent = getpwuid($uid) ) { | 
| 27 | 44 |  |  |  |  | 632 | $self->{'users'}->{$uid} = $pwent[0]; | 
| 28 |  |  |  |  |  |  | } | 
| 29 |  |  |  |  |  |  | else { | 
| 30 | 1 |  |  |  |  | 5 | $self->{'users'}->{$uid} = undef; | 
| 31 |  |  |  |  |  |  | } | 
| 32 |  |  |  |  |  |  | } | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 6672 | 100 |  |  |  | 13848 | unless ( exists $self->{'groups'}->{$gid} ) { | 
| 35 | 45 | 100 |  |  |  | 2712 | if ( my @grent = getgrgid($gid) ) { | 
| 36 | 44 |  |  |  |  | 240 | $self->{'groups'}->{$gid} = $grent[0]; | 
| 37 |  |  |  |  |  |  | } | 
| 38 |  |  |  |  |  |  | else { | 
| 39 | 1 |  |  |  |  | 4 | $self->{'groups'}->{$gid} = undef; | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 | 6672 |  |  |  |  | 1163557 | return ( $self->{'users'}->{$uid}, $self->{'groups'}->{$gid} ); | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | 1; |