Bugzilla – Attachment 23855 Details for
Bug 11188
Make gather_print_notices.pl die on failed open()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 11188 - Make gather_print_notices.pl die on failed open()
PASSED-QA-Bug-11188---Make-gatherprintnoticespl-di.patch (text/plain), 3.47 KB, created by
Katrin Fischer
on 2013-12-29 08:15:22 UTC
(
hide
)
Description:
[PASSED QA] Bug 11188 - Make gather_print_notices.pl die on failed open()
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2013-12-29 08:15:22 UTC
Size:
3.47 KB
patch
obsolete
>From 3c64d414f320c1a1e5b1ddfe9e9f92405245219a Mon Sep 17 00:00:00 2001 >From: Magnus Enger <magnus@enger.priv.no> >Date: Sat, 23 Nov 2013 22:57:03 +0100 >Subject: [PATCH] [PASSED QA] Bug 11188 - Make gather_print_notices.pl die on > failed open() > >Problem: >If you tell gather_print_notices.pl to write output to a location >you do not have write access to, it will silently fail to write the >data, but still mark unsent messages as sent. > >Solution: >This patch adds two lines of defense: >1. Check that the location given for the output is writable >2. use "open() or die" instead of just "open()" when writing the > output >The first measure should catch most of the potential errors, but >I guess a directory can be writable, but the open() still can fail >because the disk is full or something similar. > >To test: >- Make sure you have some unsent messages in the message_queue table, > that do not have an email adress >- Apply the patch >- Run the script, pointing at a location you do not have access to > write to. Check that the script exits with an appropriate error > message, and that the unsent messages are still unsent. Do this > both with and without the -s option. >- To fake passing the first line of defence, comment out line 62 > and put this in instead: > if ( !$output_directory || !-d $output_directory ) { >- Run the script again as above, check you get an appropriate > error and that the message queue is not touched >- Reset line 62 to how it was >- Run the script against a directory you do have access to write to > and check that output is produced as expected and that messages > are marked as sent >- Sign off > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> >Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> >Passes all tests and QA script. >Works as described. >--- > misc/cronjobs/gather_print_notices.pl | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > >diff --git a/misc/cronjobs/gather_print_notices.pl b/misc/cronjobs/gather_print_notices.pl >index 2d05557..248716e 100755 >--- a/misc/cronjobs/gather_print_notices.pl >+++ b/misc/cronjobs/gather_print_notices.pl >@@ -59,9 +59,9 @@ usage(0) if ($help); > > my $output_directory = $ARGV[0]; > >-if ( !$output_directory || !-d $output_directory ) { >+if ( !$output_directory || !-d $output_directory || !-w $output_directory ) { > print STDERR >-"Error: You must specify a valid directory to dump the print notices in.\n"; >+"Error: You must specify a valid and writeable directory to dump the print notices in.\n"; > usage(1); > } > >@@ -87,9 +87,10 @@ if ($split) { > > foreach my $branchcode ( keys %messages_by_branch ) { > my @messages = @{ $messages_by_branch{$branchcode} }; >- open $OUTPUT, '>', >- File::Spec->catdir( $output_directory, >+ my $output_file = File::Spec->catdir( $output_directory, > "holdnotices-" . $today->output('iso') . "-$branchcode.html" ); >+ open $OUTPUT, '>', $output_file >+ or die "Could not open $output_file: $!"; > > my $template = > C4::Templates::gettemplate( 'batch/print-notices.tmpl', 'intranet', >@@ -112,9 +113,11 @@ if ($split) { > } > } > else { >- open $OUTPUT, '>', >- File::Spec->catdir( $output_directory, >+ my $output_file = File::Spec->catdir( $output_directory, > "holdnotices-" . $today->output('iso') . ".html" ); >+ open $OUTPUT, '>', $output_file >+ or die "Could not open $output_file: $!"; >+ > > my $template = > C4::Templates::gettemplate( 'batch/print-notices.tmpl', 'intranet', >-- >1.8.3.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11188
:
23181
|
23849
| 23855