my $CONF = read_config( delete $CONFIG{config} // $NAME
, [qw/_ local remote/]
, database => qr/\A(\P{Control}+)\z/
+ , logfile => qr/\A(\/\P{Control}+)\z/
, 'list-mailbox' => qr/\A([\x01-\x09\x0B\x0C\x0E-\x7F]+)\z/
, 'list-select-opts' => qr/\A([\x21\x23\x24\x26\x27\x2B-\x5B\x5E-\x7A\x7C-\x7E]+)\z/
, 'ignore-mailbox' => qr/\A([\x01-\x09\x0B\x0C\x0E-\x7F]+)\z/
command => qr/\A(\P{Control}+)\z/,
'null-stderr' => qr/\A(YES|NO)\z/i,
compress => qr/\A($RE_ATOM_CHAR+(?: $RE_ATOM_CHAR+)*)\z/,
- logfile => qr/\A(\/\P{Control}+)\z/,
SSL_protocols => qr/\A(!?$RE_SSL_PROTO(?: !?$RE_SSL_PROTO)*)\z/,
SSL_fingerprint => qr/\A((?:[A-Za-z0-9]+\$)?\p{AHex}+)\z/,
SSL_cipherlist => qr/\A(\P{Control}+)\z/,
, 'deliver-rcpt' => qr/\A(\P{Control}+)\z/
)->{$ARGV[0]};
-my ($MAILBOX, $STATE, $LOGGER_FD);
+my ($MAILBOX, $STATE);
do {
$MAILBOX = $CONF->{mailbox} // 'INBOX';
fcntl($STATE, F_SETFL, $flags | FD_CLOEXEC) or die "fcntl F_SETFL: $!";
flock($STATE, LOCK_EX) or die "Can't flock $statefile: $!";
-
-
- if (defined (my $logfile = $CONF->{logfile})) {
- require 'POSIX.pm';
- require 'Time/HiRes.pm';
- open $LOGGER_FD, '>>', $logfile or die "Can't open $logfile: $!\n";
- $LOGGER_FD->autoflush(1);
- my $flags = fcntl($LOGGER_FD, F_GETFL, 0) or die "fcntl F_GETFL: $!";
- fcntl($LOGGER_FD, F_SETFL, $flags | FD_CLOEXEC) or die "fcntl F_SETFL: $!";
- }
- elsif ($CONFIG{debug}) {
- $LOGGER_FD = \*STDERR;
- }
};
# Initialize the cache from the statefile, then pull new messages from
# the remote mailbox
#
-my $IMAP = Net::IMAP::InterIMAP::->new( %$CONF, %CONFIG{qw/quiet debug/}, 'logger-fd' => $LOGGER_FD );
+$CONF->{'logger-fd'} = \*STDERR if $CONFIG{debug};
+my $IMAP = Net::IMAP::InterIMAP::->new( %$CONF, %CONFIG{qw/quiet debug/} );
# Use BODY.PEEK[] so if something gets wrong, unpulled messages
# won't be marked as \Seen in the mailbox
-my $ATTRS = join ' ', qw/ENVELOPE INTERNALDATE BODY.PEEK[]/;
+my $ATTRS = "ENVELOPE INTERNALDATE BODY.PEEK[]";
# Pull new messages from IMAP and deliver them to SMTP, then update the
# statefile