warn $_[0];
}
-sub ftp_die($;$) {
+sub ftp_abort($;$) {
my $msg = shift;
my $exitcode = shift;
$exitcode ||= 1;
# Use die instead of fatal - this error should "never" happen.
for my $dir ($package_config_base, $incoming_dir, $incoming_tmp,
$destfinal, $desttmp) {
- -d $dir or ftp_die("FATAL: configuration problem, $dir is not a directory");
+ ftp_abort("FATAL: configuration problem, $dir is not a directory")
+ unless -d $dir;
}
\f
} else {
$smtp = Net::SMTP->new ("127.0.0.1");
}
- ftp_die("FATAL: SMTP connection failed") unless $smtp;
+ ftp_abort("FATAL: SMTP connection failed") unless $smtp;
$smtp->mail($sender);
$smtp->bcc($email_always) if ($send_to_user);
} else {
$smtp = Net::SMTP->new ("127.0.0.1");
}
- ftp_die("FATAL: SMTP connection failed") unless $smtp;
+ ftp_abort("FATAL: SMTP connection failed") unless $smtp;
$smtp->mail ("ftp-upload-script\@gnu.org");
$smtp->recipient ($maintainer_email, { SkipBad => 1});
}
close (PWD) or ftp_warn("pwd exited $?");
} else { # child
- exec ("/bin/pwd") or ftp_die("can't exec pwd: $!");
+ exec ("/bin/pwd") or ftp_abort("can't exec pwd: $!");
}
- ftp_die("(in $cwd) $msg",$exit_code);
+ ftp_abort("(in $cwd) $msg",$exit_code);
}
\f
# Get list of all possible files from incoming dir.
#
opendir INCOMING, $directory
- or ftp_die("FATAL opendir($directory) failed: $!");
+ or ftp_abort("FATAL opendir($directory) failed: $!");
ENT: while (defined($_ = readdir INCOMING)) {
next ENT if m/^[.]{1,2}$/; # skip . and .. entries
# require acceptable filenames
$possible{$ent} = 1;
}
closedir INCOMING
- or ftp_die("FATAL: closedir($directory) failed: $!");
+ or ftp_abort("FATAL: closedir($directory) failed: $!");
# dispose of any garbage files
ftp_syslog('info', "$badname_count files with bogus names were trashcanned")
if DEBUG;
open LSOF, '-|', @lsof_args
- or ftp_die("FATAL: cannot spawn lsof: $!");;
+ or ftp_abort("FATAL: cannot spawn lsof: $!");;
while (<LSOF>) {
ftp_syslog('debug', "DEBUG: lsof output: $_") if DEBUG;
# only look at the name lines
# Directory: dirname[/subdirname]
#
open (DIRECTIVE_FILE, "<", $directive_file)
- or ftp_die("FATAL: open($directive_file) failed: $!");
+ or ftp_abort("FATAL: open($directive_file) failed: $!");
my $cnt = 0; # Keep track of the order of directives...
while (<DIRECTIVE_FILE>) {
my $line = $_;
sub cleanup_dir {
my $dir = shift;
opendir(DIR, $dir)
- or ftp_die("Can’t opendir $dir in cleanup_dir: $!");
+ or ftp_abort("Can’t opendir $dir in cleanup_dir: $!");
my @files = grep { ! /^\./ && -f "$dir/$_" } readdir(DIR);
closedir DIR;
# we've moved the files to work on to a new directory.
chdir ($incoming_tmp)
- or ftp_die("FATAL: chdir($incoming_tmp) failed: $!");
+ or ftp_abort("FATAL: chdir($incoming_tmp) failed: $!");
for my $files (@incoming) { # each list element is a hash reference.
ftp_syslog('info',"found directive: $files->{directive}\n");