1 |
slords |
1.1 |
diff -Nur -x '*.orig' -x '*.rej' e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/templates.pm mezzanine_patched_e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/templates.pm |
2 |
|
|
--- e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/templates.pm 2006-10-11 11:14:18.000000000 -0400 |
3 |
|
|
+++ mezzanine_patched_e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/templates.pm 2007-03-16 11:41:15.000000000 -0400 |
4 |
|
|
@@ -1,5 +1,5 @@ |
5 |
|
|
#---------------------------------------------------------------------- |
6 |
|
|
-# Copyright 1999-2003 Mitel Networks Corporation |
7 |
|
|
+# Copyright 1999-2007 Mitel Networks Corporation |
8 |
|
|
# This program is free software; you can redistribute it and/or |
9 |
|
|
# modify it under the same terms as Perl itself. |
10 |
|
|
#---------------------------------------------------------------------- |
11 |
|
|
@@ -22,6 +22,7 @@ |
12 |
|
|
use File::Basename; |
13 |
|
|
use File::stat; |
14 |
|
|
use FileHandle; |
15 |
|
|
+use DirHandle; |
16 |
|
|
|
17 |
|
|
$TEMPLATE_COUNT = 0; |
18 |
|
|
|
19 |
|
|
@@ -322,6 +323,7 @@ |
20 |
|
|
GID => 0, |
21 |
|
|
PERMS => 0644, |
22 |
|
|
OUTPUT_TYPE => 'file', # [file|string] |
23 |
|
|
+ DELETE => 0, |
24 |
|
|
); |
25 |
|
|
|
26 |
|
|
# store the valid output types so we can do a quick sanity check |
27 |
|
|
@@ -347,7 +349,8 @@ |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
# Read additional metadata assocated with the templated file |
31 |
|
|
- if (open(FILE, "/etc/e-smith/templates.metadata/$params_hash{TEMPLATE_PATH}")) |
32 |
|
|
+ my $metadata_path = "/etc/e-smith/templates.metadata/$params_hash{TEMPLATE_PATH}"; |
33 |
|
|
+ if (open(FILE, $metadata_path)) |
34 |
|
|
{ |
35 |
|
|
while (<FILE>) |
36 |
|
|
{ |
37 |
|
|
@@ -356,6 +359,22 @@ |
38 |
|
|
} |
39 |
|
|
close(FILE); |
40 |
|
|
} |
41 |
|
|
+ if (my $d = DirHandle->new($metadata_path)) |
42 |
|
|
+ { |
43 |
|
|
+ while ($_ = $d->read) |
44 |
|
|
+ { |
45 |
|
|
+ /(\w+)/ or next; # skip . and .. |
46 |
|
|
+ my $file = $1; |
47 |
|
|
+ unless (open(FILE, "$metadata_path/$file")) |
48 |
|
|
+ { |
49 |
|
|
+ warn("Could not open metadata file $metadata_path/$file: $!"); |
50 |
|
|
+ next; |
51 |
|
|
+ } |
52 |
|
|
+ # Read and untaint content of file |
53 |
|
|
+ $params_hash{$file} = eval do { local $/; $_ = <FILE>; /(.*)/s ; "{ $1 }" }; |
54 |
|
|
+ close(FILE); |
55 |
|
|
+ } |
56 |
|
|
+ } |
57 |
|
|
|
58 |
|
|
# warn on deprecated or unknown parameters |
59 |
|
|
foreach my $key ( keys %params_hash ) { |
60 |
|
|
@@ -419,6 +438,13 @@ |
61 |
|
|
return; |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
+ # delete the file and do no more if we're told to by metadata |
65 |
|
|
+ if ($p{'DELETE'}) |
66 |
|
|
+ { |
67 |
|
|
+ unlink "$outputfile"; |
68 |
|
|
+ return; |
69 |
|
|
+ } |
70 |
|
|
+ |
71 |
|
|
# use POSIX::open to set permissions on create |
72 |
|
|
require POSIX; |
73 |
|
|
my $fd = |