From 21c28500c0afea85a4acc9cd2e6c816522394431 Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Fri, 10 Feb 2006 16:29:20 +0000 Subject: [PATCH] Give error if overflow in quota setting in appendfile on a 32-bit system; make Exim output off_t size for -bV so tests can be appropriate. --- doc/doc-txt/ChangeLog | 11 ++++- src/src/exim.c | 4 +- src/src/globals.c | 4 +- src/src/transports/appendfile.c | 19 ++++++++- test/README | 9 ++++- test/confs/5007 | 49 +++++++++++++++++++++++ test/log/5007 | 3 ++ test/mail/5005.nofile/maildirsize | 2 +- test/mail/5005.userx/maildirsize | 2 +- test/mail/5006.userx/maildirsize | 2 +- test/mail/5007.userx/maildirsize | 3 ++ test/mail/5007.userx/new/1.myhost.test.ex | 9 +++++ test/runtest | 36 ++++++++++++----- test/scripts/5000-maildir/5005 | 2 +- test/scripts/5000-maildir/5007 | 7 ++++ 15 files changed, 142 insertions(+), 20 deletions(-) create mode 100644 test/confs/5007 create mode 100644 test/log/5007 create mode 100644 test/mail/5007.userx/maildirsize create mode 100644 test/mail/5007.userx/new/1.myhost.test.ex create mode 100644 test/scripts/5000-maildir/5007 diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index a9f562bce..c66ec6a12 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.290 2006/02/10 14:25:43 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.291 2006/02/10 16:29:20 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -120,6 +120,15 @@ PH/20 Added $auth1, $auth2, $auth3 to contain authentication data (as well as $1, $2, $3) because the numerical variables can be reset during some expansion items (e.g. "match"), thereby losing the authentication data. +PH/21 Make -bV show the size of off_t variables so that the test suite can + decide whether to run tests for quotas > 2G. + +PH/22 Test the values given for quota, quota_filecount, quota_warn_threshold, + mailbox_size, and mailbox_filecount in the appendfile transport. If a + filecount value is greater than 2G or if a quota value is greater than 2G + on a system where the size of off_t is not greater than 4, a panic error + is given. + Exim version 4.60 diff --git a/src/src/exim.c b/src/src/exim.c index 87239c569..5b0eb0335 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/exim.c,v 1.31 2006/02/07 11:19:00 ph10 Exp $ */ +/* $Cambridge: exim/src/src/exim.c,v 1.32 2006/02/10 16:29:20 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -1012,6 +1012,8 @@ if (fixed_never_users[0] > 0) fprintf(f, "%d:", (unsigned int)fixed_never_users[i]); fprintf(f, "%d\n", (unsigned int)fixed_never_users[i]); } + +fprintf(f, "Size of off_t: %d\n", sizeof(off_t)); } diff --git a/src/src/globals.c b/src/src/globals.c index e609f3020..275b7c8f0 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/globals.c,v 1.46 2006/02/10 14:25:43 ph10 Exp $ */ +/* $Cambridge: exim/src/src/globals.c,v 1.47 2006/02/10 16:29:20 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -1224,7 +1224,7 @@ uschar *warnmsg_delay = NULL; uschar *warnmsg_recipients = NULL; BOOL write_rejectlog = TRUE; -uschar *version_copyright = US"Copyright (c) University of Cambridge 2005"; +uschar *version_copyright = US"Copyright (c) University of Cambridge 2006"; uschar *version_date = US"?"; uschar *version_cnumber = US"????"; uschar *version_string = US"?"; diff --git a/src/src/transports/appendfile.c b/src/src/transports/appendfile.c index d336ada04..bb5d90bcb 100644 --- a/src/src/transports/appendfile.c +++ b/src/src/transports/appendfile.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/transports/appendfile.c,v 1.11 2006/02/07 11:19:02 ph10 Exp $ */ +/* $Cambridge: exim/src/src/transports/appendfile.c,v 1.12 2006/02/10 16:29:20 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -271,6 +271,7 @@ mailbox_filecount */ for (i = 0; i < 5; i++) { double d; + uschar *which = NULL; if (q == NULL) d = default_value; else { @@ -316,33 +317,49 @@ for (i = 0; i < 5; i++) } } + /* Set each value, checking for possible overflow. */ + switch (i) { case 0: + if (d >= 2.0*1024.0*1024.0*1024.0 && sizeof(off_t) <= 4) which = US"quota"; ob->quota_value = (off_t)d; q = ob->quota_filecount; break; case 1: + if (d >= 2.0*1024.0*1024.0*1024.0) which = US"quota_filecount"; ob->quota_filecount_value = (int)d; q = ob->quota_warn_threshold; break; case 2: + if (d >= 2.0*1024.0*1024.0*1024.0 && sizeof(off_t) <= 4) + which = US"quota_warn_threshold"; ob->quota_warn_threshold_value = (off_t)d; q = ob->mailbox_size_string; default_value = -1.0; break; case 3: + if (d >= 2.0*1024.0*1024.0*1024.0 && sizeof(off_t) <= 4) + which = US"mailbox_size";; ob->mailbox_size_value = (off_t)d; q = ob->mailbox_filecount_string; break; case 4: + if (d >= 2.0*1024.0*1024.0*1024.0) which = US"mailbox_filecount"; ob->mailbox_filecount_value = (int)d; break; } + + if (which != NULL) + { + *errmsg = string_sprintf("%s value %.10g is too large (overflow) in " + "%s transport", which, d, tblock->name); + return FAIL; + } } return OK; diff --git a/test/README b/test/README index f32478817..13284ab2c 100644 --- a/test/README +++ b/test/README @@ -1,4 +1,4 @@ -$Cambridge: exim/test/README,v 1.1 2006/02/06 16:07:10 ph10 Exp $ +$Cambridge: exim/test/README,v 1.2 2006/02/10 16:29:20 ph10 Exp $ EXPORTABLE EXIM TEST SUITE -------------------------- @@ -643,6 +643,13 @@ This command must be at the head of a script. If no IPv6 interface has been found, the entire script is skipped, and a comment is output. + need_largefiles + +This command must be at the head of a script. If the Exim binary does not +suppport large files (off_t is <= 4), the entire script is skipped, and a +comment is output. + + need_move_frozen_messages This command must be at the head of a script. If the Exim binary does not have diff --git a/test/confs/5007 b/test/confs/5007 new file mode 100644 index 000000000..a1ac93e55 --- /dev/null +++ b/test/confs/5007 @@ -0,0 +1,49 @@ +# Exim test configuration 5007 + +QUOTA=500 + +exim_path = EXIM_PATH +host_lookup_order = bydns +primary_hostname = myhost.test.ex +rfc1413_query_timeout = 0s +spool_directory = DIR/spool +log_file_path = DIR/spool/log/%slog +gecos_pattern = "" +gecos_name = CALLER_NAME + + +# ----- Main settings ----- + +delay_warning = +qualify_domain = test.ex + + +# ----- Routers ----- + +begin routers + +r1: + driver = accept + transport = t1 + +# ----- Transports ----- + +begin transports + +t1: + driver = appendfile + directory = DIR/test-mail/$local_part + user = CALLER + maildir_format + maildir_use_size_file + quota = QUOTA + + +# ----- Retry ----- + +begin retry + +* * F,1d,1d + + +# End diff --git a/test/log/5007 b/test/log/5007 new file mode 100644 index 000000000..16e2bd446 --- /dev/null +++ b/test/log/5007 @@ -0,0 +1,3 @@ +1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@test.ex U=CALLER P=local S=sss +1999-03-02 09:44:33 10HmaX-0005vi-00 => userx R=r1 T=t1 +1999-03-02 09:44:33 10HmaX-0005vi-00 Completed diff --git a/test/mail/5005.nofile/maildirsize b/test/mail/5005.nofile/maildirsize index 29b5511a6..068a4d924 100644 --- a/test/mail/5005.nofile/maildirsize +++ b/test/mail/5005.nofile/maildirsize @@ -1,3 +1,3 @@ -dddS,dC +500S,0C ddd d ddd d diff --git a/test/mail/5005.userx/maildirsize b/test/mail/5005.userx/maildirsize index 04dcb85d1..9ae181a23 100644 --- a/test/mail/5005.userx/maildirsize +++ b/test/mail/5005.userx/maildirsize @@ -1,2 +1,2 @@ -dddS,dC +500S,0C ddd d diff --git a/test/mail/5006.userx/maildirsize b/test/mail/5006.userx/maildirsize index 29b5511a6..1f3670618 100644 --- a/test/mail/5006.userx/maildirsize +++ b/test/mail/5006.userx/maildirsize @@ -1,3 +1,3 @@ -dddS,dC +0S,0C ddd d ddd d diff --git a/test/mail/5007.userx/maildirsize b/test/mail/5007.userx/maildirsize new file mode 100644 index 000000000..496f0f6cd --- /dev/null +++ b/test/mail/5007.userx/maildirsize @@ -0,0 +1,3 @@ +3221225472S,0C +ddd d +ddd d diff --git a/test/mail/5007.userx/new/1.myhost.test.ex b/test/mail/5007.userx/new/1.myhost.test.ex new file mode 100644 index 000000000..c077e2b7e --- /dev/null +++ b/test/mail/5007.userx/new/1.myhost.test.ex @@ -0,0 +1,9 @@ +Received: from CALLER by myhost.test.ex with local (Exim x.yz) + (envelope-from ) + id 10HmaX-0005vi-00 + for userx@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +Test message diff --git a/test/runtest b/test/runtest index 2210cba3b..d5a161234 100755 --- a/test/runtest +++ b/test/runtest @@ -1,6 +1,6 @@ #! /usr/bin/perl -w -# $Cambridge: exim/test/runtest,v 1.3 2006/02/09 14:50:58 ph10 Exp $ +# $Cambridge: exim/test/runtest,v 1.4 2006/02/10 16:29:20 ph10 Exp $ ############################################################################### # This is the controlling script for the "new" test suite for Exim. It should # @@ -36,6 +36,7 @@ $server_opts = ""; $have_ipv4 = 1; $have_ipv6 = 1; +$have_largefiles = 0; $test_start = 1; $test_end = $test_top = 8999; @@ -614,7 +615,7 @@ while() # Maildirsize data if (/^\d+S,\d+C\s*$/) { - print MUNGED "dddS,dC\n"; + print MUNGED; while () { last if !/^\d+ \d+\s*$/; @@ -788,7 +789,8 @@ while() /^Transports:/ || /^log selectors =/ || /^cwd=/ || - /^Fixed never_users:/ + /^Fixed never_users:/ || + /^Size of off_t:/ ); } @@ -1459,7 +1461,7 @@ if (/^sleep\s+(.*)$/) # Various Unix management commands are recognized -if (/^(ln|ls|du|mkdir|mkfifo|touch|cp)\s/ || +if (/^(ln|ls|du|mkdir|mkfifo|touch|cp|cat)\s/ || /^sudo (rmdir|rm|chown|chmod)\s/) { run_system("$_ >>test-stdout 2>>test-stderr"); @@ -1952,9 +1954,14 @@ while () { my(@temp); - if (/^Exim version/) { print; next; } + if (/^Exim version/) { print; } - if (/^Support for: (.*)/) + elsif (/^Size of off_t: (\d+)/) + { + $have_largefiles = 1 if $1 > 4; + } + + elsif (/^Support for: (.*)/) { print; @temp = split /(\s+)/, $1; @@ -1962,7 +1969,7 @@ while () %parm_support = @temp; } - if (/^Lookups: (.*)/) + elsif (/^Lookups: (.*)/) { print; @temp = split /(\s+)/, $1; @@ -1970,7 +1977,7 @@ while () %parm_lookups = @temp; } - if (/^Authenticators: (.*)/) + elsif (/^Authenticators: (.*)/) { print; @temp = split /(\s+)/, $1; @@ -1978,7 +1985,7 @@ while () %parm_authenticators = @temp; } - if (/^Routers: (.*)/) + elsif (/^Routers: (.*)/) { print; @temp = split /(\s+)/, $1; @@ -1990,7 +1997,7 @@ while () # that the basic transport name is set, and then the name with each of the # options. - if (/^Transports: (.*)/) + elsif (/^Transports: (.*)/) { print; @temp = split /(\s+)/, $1; @@ -2853,6 +2860,15 @@ foreach $test (@test_list) if (/^rmfiltertest/) { $rmfiltertest = 1; next; } if (/^sortlog/) { $sortlog = 1; next; } + if (/^need_largefiles/) + { + next if $have_largefiles; + print ">>> Large file support is needed for test $testno, but is not available: skipping\n"; + $docheck = 0; # don't check output + undef $_; # pretend EOF + last; + } + if (/^need_ipv4/) { next if $have_ipv4; diff --git a/test/scripts/5000-maildir/5005 b/test/scripts/5000-maildir/5005 index ea7ccc360..a816245ba 100644 --- a/test/scripts/5000-maildir/5005 +++ b/test/scripts/5000-maildir/5005 @@ -1,4 +1,4 @@ -# maildir with maildirsize for quota handling +# maildirsize for quota handling exim -d -odi nofile@test.ex Message for nofile **** diff --git a/test/scripts/5000-maildir/5007 b/test/scripts/5000-maildir/5007 new file mode 100644 index 000000000..e9c8ee48a --- /dev/null +++ b/test/scripts/5000-maildir/5007 @@ -0,0 +1,7 @@ +# maildirsize for quota handling quota > 2G +need_largefiles +# Set a quota that is greater than 2G +exim -DQUOTA=3G -odi userx@test.ex +Test message +**** +no_msglog_check -- 2.25.1