File Coverage

blib/lib/Scripting/Security.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             # File: $Source: /Users/clajac/cvsroot//Scripting/Scripting/Security.pm,v $
2             # Author: $Author: clajac $
3             # Date: $Date: 2003/07/21 10:10:05 $
4             # Revision: $Revision: 1.3 $
5              
6             package Scripting::Security;
7              
8 1     1   3927 use DB_File;
  0            
  0            
9             use strict;
10              
11             my %Signed;
12             my $use_signing = 0;
13              
14             my $current;
15              
16             sub open {
17             my ($pkg, $file) = @_;
18            
19             warn "Signature database not found\n" unless(-e $file && -f $file);
20             if(tie(%Signed, 'DB_File', $file, O_RDONLY, 0666, $DB_HASH)) {
21             $use_signing = 1;
22             } else {
23             warn "Failed to open signature database\n";
24             }
25              
26             1;
27             }
28              
29             sub executing {
30             my ($pkg, $path) = @_;
31              
32             $current = $path;
33             }
34              
35             sub match {
36             my ($pkg, $path, $digest) = @_;
37             return 1 unless($use_signing);
38             return 0 unless(exists $Signed{$path});
39             return 0 unless($Signed{$path} eq $digest);
40             return 1;
41             }
42              
43             sub secure {
44             return 1 unless($use_signing);
45             if(exists $Signed{$current}) {
46             return 1;
47             }
48             }
49              
50             1;