View | Details | Raw Unified | Return to bug 3754
Collapse All | Expand All

(-)sa-learn.raw (-2 / +7 lines)
Lines 343-348 Link Here
343
  $spamtest->rebuild_learner_caches();
343
  $spamtest->rebuild_learner_caches();
344
}
344
}
345
345
346
# what is the result of the run?  will end up being the exit code.
347
my $exit_status = 0;
348
346
# run this lot in an eval block, so we can catch die's and clear
349
# run this lot in an eval block, so we can catch die's and clear
347
# up the dbs.
350
# up the dbs.
348
eval {
351
eval {
Lines 403-409 Link Here
403
  $init_results = 0;
406
  $init_results = 0;
404
  $start_time = time;
407
  $start_time = time;
405
408
406
  eval { $iter->run(@targets); };
409
  # if exit_status isn't already set to non-zero, set it to the reverse of the
410
  # run result (0 is bad, 1+ is good -- the opposite of exit status codes)
411
  eval { $exit_status ||= ! $iter->run(@targets); };
407
412
408
  print STDERR "\n" if ($opt{showdots});
413
  print STDERR "\n" if ($opt{showdots});
409
  $progress->final() if ($opt{progress} && $progress);
414
  $progress->final() if ($opt{progress} && $progress);
Lines 426-432 Link Here
426
}
431
}
427
432
428
$spamtest->finish_learner();
433
$spamtest->finish_learner();
429
exit 0;
434
exit $exit_status;
430
435
431
###########################################################################
436
###########################################################################
432
437
(-)lib/Mail/SpamAssassin/ArchiveIterator.pm (-11 / +50 lines)
Lines 202-207 Link Here
202
  $self->{s} = [ ];		# spam, of course
202
  $self->{s} = [ ];		# spam, of course
203
  $self->{h} = [ ];		# ham, as if you couldn't guess
203
  $self->{h} = [ ];		# ham, as if you couldn't guess
204
204
205
  $self->{access_problem} = 0;
206
205
  $self;
207
  $self;
206
}
208
}
207
209
Lines 232-237 Link Here
232
The target_paths array is expected to be one element per path in the following
234
The target_paths array is expected to be one element per path in the following
233
format: class:format:raw_location
235
format: class:format:raw_location
234
236
237
run() returns 0 if there was an error (can't open a file, etc,) and 1 if there
238
were no errors.
239
235
=over 4
240
=over 4
236
241
237
=item class
242
=item class
Lines 265-271 Link Here
265
  my ($self, @targets) = @_;
270
  my ($self, @targets) = @_;
266
271
267
  if (!defined $self->{wanted_sub}) {
272
  if (!defined $self->{wanted_sub}) {
268
    die "archive-iterator: set_functions never called";
273
    warn "archive-iterator: set_functions never called";
274
    return 0;
269
  }
275
  }
270
276
271
  # non-forking model (generally sa-learn), everything in a single process
277
  # non-forking model (generally sa-learn), everything in a single process
Lines 424-429 Link Here
424
    # close tempfile so it will be unlinked
430
    # close tempfile so it will be unlinked
425
    close($self->{messageh});
431
    close($self->{messageh});
426
  }
432
  }
433
434
  return ! $self->{access_problem};
427
}
435
}
428
436
429
############################################################################
437
############################################################################
Lines 449-455 Link Here
449
sub run_file {
457
sub run_file {
450
  my ($self, $class, $format, $where, $date) = @_;
458
  my ($self, $class, $format, $where, $date) = @_;
451
459
452
  mail_open($where) or return;
460
  if (!mail_open($where)) {
461
    $self->{access_problem} = 1;
462
    return;
463
  }
464
453
  # skip too-big mails
465
  # skip too-big mails
454
  if (! $self->{opt_all} && -s INPUT > BIG_BYTES) {
466
  if (! $self->{opt_all} && -s INPUT > BIG_BYTES) {
455
    info("archive-iterator: skipping large message\n");
467
    info("archive-iterator: skipping large message\n");
Lines 480-486 Link Here
480
  my ($file, $offset) = ($where =~ m/(.*)\.(\d+)$/);
492
  my ($file, $offset) = ($where =~ m/(.*)\.(\d+)$/);
481
  my @msg;
493
  my @msg;
482
  my $header = '';
494
  my $header = '';
483
  mail_open($file) or return;
495
  if (!mail_open($file)) {
496
    $self->{access_problem} = 1;
497
    return;
498
  }
484
  seek(INPUT,$offset,0);
499
  seek(INPUT,$offset,0);
485
  my $past = 0;
500
  my $past = 0;
486
  while (<INPUT>) {
501
  while (<INPUT>) {
Lines 520-526 Link Here
520
  my @msg;
535
  my @msg;
521
  my $header = '';
536
  my $header = '';
522
537
523
  mail_open($file) or return;
538
  if (!mail_open($file)) {
539
    $self->{access_problem} = 1;
540
    return;
541
  }
524
  seek(INPUT, $offset, 0);
542
  seek(INPUT, $offset, 0);
525
    
543
    
526
  while (<INPUT>) {
544
  while (<INPUT>) {
Lines 898-904 Link Here
898
    return;
916
    return;
899
  }
917
  }
900
  my $header;
918
  my $header;
901
  mail_open($mail) or return;
919
  if (!mail_open($mail)) {
920
    $self->{access_problem} = 1;
921
    return;
922
  }
902
  while (<INPUT>) {
923
  while (<INPUT>) {
903
    last if /^\s*$/;
924
    last if /^\s*$/;
904
    $header .= $_;
925
    $header .= $_;
Lines 916-922 Link Here
916
  if ($folder ne '-' && -d $folder) {
937
  if ($folder ne '-' && -d $folder) {
917
    # passed a directory of mboxes
938
    # passed a directory of mboxes
918
    $folder =~ s/\/\s*$//; #Remove trailing slash, if there
939
    $folder =~ s/\/\s*$//; #Remove trailing slash, if there
919
    opendir(DIR, $folder) || die "archive-iterator: can't open '$folder' dir: $!\n";
940
    if (!opendir(DIR, $folder)) {
941
      warn "archive-iterator: can't open '$folder' dir: $!\n";
942
      $self->{access_problem} = 1;
943
      return;
944
    }
920
    while ($_ = readdir(DIR)) {
945
    while ($_ = readdir(DIR)) {
921
      if(/^[^\.]\S*$/ && ! -d "$folder/$_") {
946
      if(/^[^\.]\S*$/ && ! -d "$folder/$_") {
922
	push(@files, "$folder/$_");
947
	push(@files, "$folder/$_");
Lines 930-939 Link Here
930
955
931
  foreach my $file (@files) {
956
  foreach my $file (@files) {
932
    if ($file =~ /\.(?:gz|bz2)$/) {
957
    if ($file =~ /\.(?:gz|bz2)$/) {
933
      die "archive-iterator: compressed mbox folders are not supported at this time\n";
958
      warn "archive-iterator: compressed mbox folders are not supported at this time\n";
959
      $self->{access_problem} = 1;
960
      next;
934
    }
961
    }
935
962
936
    mail_open($file) or return;
963
    if (!mail_open($file)) {
964
      $self->{access_problem} = 1;
965
      next;
966
    }
937
    
967
    
938
    my $start = 0;		# start of a message
968
    my $start = 0;		# start of a message
939
    my $where = 0;		# current byte offset
969
    my $where = 0;		# current byte offset
Lines 982-988 Link Here
982
  if ($folder ne '-' && -d $folder) {
1012
  if ($folder ne '-' && -d $folder) {
983
    # got passed a directory full of mbx folders.
1013
    # got passed a directory full of mbx folders.
984
    $folder =~ s/\/\s*$//; # remove trailing slash, if there is one
1014
    $folder =~ s/\/\s*$//; # remove trailing slash, if there is one
985
    opendir(DIR, $folder) || die "archive-iterator: can't open '$folder' dir: $!\n";
1015
    if (!opendir(DIR, $folder)) {
1016
      warn "archive-iterator: can't open '$folder' dir: $!\n";
1017
      $self->{access_problem} = 1;
1018
      return;
1019
    }
986
    while ($_ = readdir(DIR)) {
1020
    while ($_ = readdir(DIR)) {
987
      if(/^[^\.]\S*$/ && ! -d "$folder/$_") {
1021
      if(/^[^\.]\S*$/ && ! -d "$folder/$_") {
988
	push(@files, "$folder/$_");
1022
	push(@files, "$folder/$_");
Lines 996-1004 Link Here
996
1030
997
  foreach my $file (@files) {
1031
  foreach my $file (@files) {
998
    if ($folder =~ /\.(?:gz|bz2)$/) {
1032
    if ($folder =~ /\.(?:gz|bz2)$/) {
999
      die "archive-iterator: compressed mbx folders are not supported at this time\n";
1033
      warn "archive-iterator: compressed mbx folders are not supported at this time\n";
1034
      $self->{access_problem} = 1;
1035
      next;
1000
    }
1036
    }
1001
    mail_open($file) or return;
1037
    if (!mail_open($file)) {
1038
      $self->{access_problem} = 1;
1039
      next;
1040
    }
1002
1041
1003
    # check the mailbox is in mbx format
1042
    # check the mailbox is in mbx format
1004
    $fp = <INPUT>;
1043
    $fp = <INPUT>;
(-)spamassassin.raw (-1 / +1 lines)
Lines 336-342 Link Here
336
}
336
}
337
337
338
# Go run the messages!
338
# Go run the messages!
339
eval { $iter->run(@targets); };
339
eval { $exitvalue ||= !$iter->run(@targets); };
340
340
341
$progress->final() if ($opt{progress} && $progress);
341
$progress->final() if ($opt{progress} && $progress);
342
342

Return to bug 3754