# <meyering@redhat.com> and Ward Vandewege <ward@gnu.org> with internal
# timestamp 2013/01/23 20:26:29 was merged into this main script.
-\f
-#
-# - Message reporting
-#
-
-sub ftp_syslog {
- my $priority = shift;
- my $message = shift;
-
- # Remove a trailing newline
- $message =~ s/[\r\n]+$//;
- # Collapse the message to a single line for syslog
- $message =~ s/[\r\n]+/ \/ /g;
-
- # The syslog function is pretty picky, and (sometimes) dies silently
- # when using non-valid syslog priorities.
- # That's why we run it inside an eval, and print out any errors to STDERR.
- eval {
- syslog($priority, $message);
- };
- if ($@) {
- print STDERR "$@\n";
- }
-}
-
-sub ftp_warn($) {
- ftp_syslog('warning', "($log_style) " . $_[0]);
- warn $_[0];
-}
-
-sub ftp_die($;$) {
- my $msg = shift;
- my $exitcode = shift;
- $exitcode ||= 1;
- ftp_syslog('err', "($log_style) " . $msg);
- exit $exitcode;
-}
-
-\f
-#
-# - Initialization and preliminaries
-#
-
use strict;
use warnings;
use POSIX qw(strftime);
use Cwd;
use Email::MessageID;
+
+\f
+#
+# - Initialization and preliminaries
+#
+
umask (022);
BEGIN {
my %info; # package being processed; a global so fatal and mail can use it
+\f
+#
+# - Logging
+#
+
+sub ftp_syslog {
+ my $priority = shift;
+ my $message = shift;
+
+ # Remove a trailing newline
+ $message =~ s/[\r\n]+$//;
+ # Collapse the message to a single line for syslog
+ $message =~ s/[\r\n]+/ \/ /g;
+
+ # The syslog function is pretty picky, and (sometimes) dies silently
+ # when using non-valid syslog priorities.
+ # That's why we run it inside an eval, and print out any errors to STDERR.
+ eval {
+ syslog($priority, $message);
+ };
+ if ($@) {
+ print STDERR "$@\n";
+ }
+}
+
+sub ftp_warn($) {
+ ftp_syslog('warning', "($log_style) " . $_[0]);
+ warn $_[0];
+}
+
+sub ftp_die($;$) {
+ my $msg = shift;
+ my $exitcode = shift;
+ $exitcode ||= 1;
+ ftp_syslog('err', "($log_style) " . $msg);
+ exit $exitcode;
+}
+
# Initialize our syslogging
if (IN_TEST_MODE) {
$ENV{TEST_SYSLOG_SOCKET} =~ m/^([[:alnum:]\/]+)$/
openlog(SYSLOG_APP_IDENT, 'pid', SYSLOG_FACILITY);
ftp_syslog('info', "($log_style) Beginning upload processing run.");
+#
+# -- Configuration sanity check
+#
+
# make sure our directories all exist, or it's hopeless.
# Use die instead of fatal - this error should "never" happen.
for my $dir ($package_config_base, $incoming_dir, $incoming_tmp,