Bug#528364: POSIX locker fails to detect existing lock

Rainer Schöpf ftpmaint at dante.de
Tue May 12 12:32:47 UTC 2009


Package: libmail-box-perl
Version: 2.089-1
Severity: important
Tags: patch

Mail::Box::Locker::POSIX contains two errors, so that is it unable to detect an
existing lock.

1. fnctl returns the string "0 but true" on success and an undefined value
   on failure. The current code in sub _try_lock

   $? = fcntl($file, F_SETLK, pack('s @256', F_WRLCK)) || 0;
   $?==0;

means that the subroutine returns true regardless of the outcome of the fcntl
syscall.

2. In subroutine lock, the variable $? is compared to EAGAIN.  However, it is
   the variable $! that contains the errno.

A Patch is appended.

 Rainer Schöpf

------------------------------------------------------------------
*** /usr/share/perl5/Mail/Box/Locker/POSIX.pm.orig	2009-05-12 14:26:12.548526088 +0200
--- /usr/share/perl5/Mail/Box/Locker/POSIX.pm	2009-05-12 14:30:24.292905561 +0200
***************
*** 26,32 ****
  
  sub _try_lock($)
  {   my ($self, $file) = @_;
!     $? = fcntl($file, F_SETLK, pack('s @256', F_WRLCK)) || 0;
      $?==0;
  }
  
--- 26,32 ----
  
  sub _try_lock($)
  {   my ($self, $file) = @_;
!     $? = fcntl($file, F_SETLK, pack('s @256', F_WRLCK)) || (0 + $!);
      $?==0;
  }
  
***************
*** 66,72 ****
              return 1;
          }
  
!         if($? != EAGAIN)
          {   $self->log(ERROR =>
              "Will never get a POSIX lock on $filename for $self->{MBL_folder}: $!");
              last;
--- 66,72 ----
              return 1;
          }
  
!         if($! != EAGAIN)
          {   $self->log(ERROR =>
              "Will never get a POSIX lock on $filename for $self->{MBL_folder}: $!");
              last;
------------------------------------------------------------------

-- System Information:
Debian Release: squeeze/sid
  APT prefers oldstable
  APT policy: (500, 'oldstable'), (500, 'testing'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-1-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages libmail-box-perl depends on:
ii  libdigest-hmac-perl          1.01-7      create standard message integrity 
ii  libfile-remove-perl          1.42-1      remove files and directories, acce
ii  libio-stringy-perl           2.110-4     Perl modules for IO from scalars a
ii  libmailtools-perl            2.04-1      Manipulate email in perl programs
ii  libmime-types-perl           1.27-1      Perl extension for determining MIM
ii  libobject-realize-later-perl 0.18-1      Delayed creation of objects
ii  libtimedate-perl             1.1600-9    Time and date functions for Perl
ii  liburi-perl                  1.37+dfsg-1 Manipulates and accesses URI strin
ii  libuser-identity-perl        0.92-2      manages different identities/roles
ii  perl                         5.10.0-19   Larry Wall's Practical Extraction 

libmail-box-perl recommends no packages.

Versions of packages libmail-box-perl suggests:
ii  libhtml-format-perl           2.04-2     format HTML syntax trees into text
ii  libhtml-tree-perl             3.23-1     represent and create HTML syntax t
pn  libmail-imapclient-perl       <none>     (no description available)
ii  libmime-tools-perl            5.427-2    Perl5 modules for MIME-compliant m
ii  spamassassin                  3.2.5-4    Perl-based spam filter using text 

-- no debconf information





More information about the pkg-perl-maintainers mailing list