aboutsummaryrefslogtreecommitdiffstats
path: root/pullimap
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2016-06-12 22:27:32 +0200
committerGuilhem Moulin <guilhem@fripost.org>2016-06-12 22:27:32 +0200
commit5eb218879ba9ba7daa5e49ba4e3c0a690dc01e3b (patch)
treec90e9ccddc914e1df8dbc49338cb27d300abdb50 /pullimap
parent862d890b59e80997b84bca3f32099dadcd9d6622 (diff)
parent320a4da020952e3a8b926535d03d49a28dea20d0 (diff)
Merge branch 'master' into debian
Diffstat (limited to 'pullimap')
-rwxr-xr-xpullimap12
1 files changed, 9 insertions, 3 deletions
diff --git a/pullimap b/pullimap
index 49fc837..1324228 100755
--- a/pullimap
+++ b/pullimap
@@ -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) {