Hi

Thanks. That is easily fixed. Not available in the correction I gave you
in the other mail, but it is added now.

--- src/functions       (revision 2439)
+++ src/functions       (arbetskopia)
@@ -20,6 +20,9 @@
 # MA 02110-1301 USA.
 #
 # Changes:
+#       2007-08-09 Ola Lundqvist <[EMAIL PROTECTED]>
+#               Avoid overflow in directory size calculation when using dash.
+#               Also remove directory if the size is too low.
 #       2007-08-02 Ola Lundqvist <[EMAIL PROTECTED]>
 #              Broke out the common functions from the cron-apt command so it
 #               can be tested separately.
@@ -33,9 +36,18 @@
 
 # Check the tmpdir size and exit if the space is too small.
 checktmpsize() {
-    if [ "$(( $(stat --file-system --format=%S $TMPDIR) * $(stat --file-system 
--format=%a $TMPDIR) / 1024 ))" -lt "$MINTMPDIRSIZE" ]; then
-       echo >&2 "Error: Not enough free space in $TMPDIR."
-       exit 1
+    # Sector size
+    SSIZE=$(stat --file-system --format=%S $TMPDIR)
+    # Number of free sectors
+    FSCOUNT=$(stat --file-system --format=%a $TMPDIR)
+    # Check to avoid overflow in calculations when using dash 2^(32-1-6)
+    # The number size above is got from 32768/512=2^6
+    if [ "$FSCOUNT" -lt 33554432 ] ; then
+       if [ "$(($SSIZE / 512 * $FSCOUNT / 2))" -lt "$MINTMPDIRSIZE" ]; then
+           echo >&2 "Error: Not enough free space in $TMPDIR."
+           rmdir --ignore-fail-on-non-empty $TMPDIR
+           exit 1
+        fi
     fi
 }
 

Regards,

// Ola


On Wed, Aug 08, 2007 at 10:09:21AM -0400, Paolo Benvenuto wrote:
> Package: cron-apt
> Version: 0.6.0
> Severity: normal
> 
> In the case that cron-apt exit with error because there isn't enogh free 
> space in /tmp directory it should delete de tmp directory it had created.
> 
> -- System Information:
> Debian Release: lenny/sid
>   APT prefers unstable
>   APT policy: (990, 'unstable'), (500, 'testing')
> Architecture: i386 (i686)
> 
> Kernel: Linux 2.6.22-1-686 (SMP w/1 CPU core)
> Locale: LANG=es_DO.UTF-8, LC_CTYPE=es_DO.UTF-8 (charmap=UTF-8)
> Shell: /bin/sh linked to /bin/dash
> 
> Versions of packages cron-apt depends on:
> ii  apt                           0.7.6      Advanced front-end for dpkg
> ii  debianutils                   2.23       Miscellaneous utilities specific 
> t
> 
> Versions of packages cron-apt recommends:
> ii  cron             3.0pl1-100              management of regular background 
> p
> ii  liblockfile1     1.06.2                  NFS-safe locking library, 
> includes
> ii  mailx            1:8.1.2-0.20070424cvs-1 A simple mail user agent
> 
> -- no debconf information
> 
> 

-- 
 --------------------- Ola Lundqvist ---------------------------
/  [EMAIL PROTECTED]                     Annebergsslingan 37      \
|  [EMAIL PROTECTED]                     654 65 KARLSTAD          |
|  http://opalsys.net/                 +46 (0)70-332 1551       |
\  gpg/f.p.: 7090 A92B 18FE 7994 0C36  4FE4 18A1 B1CF 0FE5 3DD9 /
 ---------------------------------------------------------------


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to