diff options
Diffstat (limited to 'pullimap')
-rwxr-xr-x | pullimap | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -32,6 +32,10 @@ use Socket qw/PF_INET PF_INET6 SOCK_STREAM/; use Net::IMAP::InterIMAP qw/read_config compact_set/; +# Clean up PATH +$ENV{PATH} = join ':', qw{/usr/bin /bin}; +delete @ENV{qw/IFS CDPATH ENV BASH_ENV/}; + my %CONFIG; sub usage(;$) { my $rv = shift // 0; @@ -61,7 +65,7 @@ my $CONF = read_config( delete $CONFIG{config} // $NAME, , 'deliver-method' => qr/\A([ls]mtp:\[.*\]:\d+)\z/ , 'deliver-ehlo' => qr/\A(\P{Control}+)\z/ , 'deliver-rcpt' => qr/\A(\P{Control}+)\z/ - , 'purge-after' => qr/\A(\d+)\z/ + , 'purge-after' => qr/\A(\d*)\z/ )->{$ARGV[0]}; my ($MAILBOX, $STATE); @@ -82,7 +86,9 @@ do { } sysopen($STATE, $statefile, O_CREAT|O_RDWR|O_DSYNC, 0600) or die "Can't open $statefile: $!"; - fcntl($STATE, F_SETLK, pack('sslll', F_WRLCK, SEEK_SET, 0, 0, $$)) or die "Can't lock $statefile: $!"; + # XXX we need to pack the struct flock manually: not portable! + my $struct_flock = pack('s!s!l!l!i!', F_WRLCK, SEEK_SET, 0, 0, 0); + fcntl($STATE, F_SETLK, $struct_flock) or die "Can't lock $statefile: $!"; my $flags = fcntl($STATE, F_GETFD, 0) or die "fcntl F_GETFD: $!"; fcntl($STATE, F_SETFD, $flags | FD_CLOEXEC) or die "fcntl F_SETFD: $!"; }; @@ -231,7 +237,7 @@ my $LAST_PURGED; sub purge() { my $days = $CONF->{'purge-after'} // return; my ($uidnext) = $IMAP->get_cache('UIDNEXT'); - return unless 1<$uidnext; + return unless $days ne '' and 1<$uidnext; my $set = "1:".($uidnext-1); unless ($days == 0) { |