From smail.sbay.org!smail3-maintainers-request Tue Apr 22 18:46:08 1997 Status: RO X-VM-v5-Data: ([nil nil nil t t nil nil nil nil] ["3081" "Tue" "22" "April" "1997" "22:31:05" "GMT" "Bruce Becker" "bdb@hotlips.gts.net" "" "97" "mailbox size test for appendfile transport" "^Newsgroups:" nil nil "4" nil "mailbox size test for appendfile transport" nil nil] nil) Return-Path: Received: from weird.com(really [204.92.254.5]) by most.weird.com via sendmail with esmtp id for ; Tue, 22 Apr 1997 18:46:03 -0400 (EDT) (Smail-3.2.0.94-Pre 1997-Apr-12 #27 built 1997-Apr-21) Received: from whome.planix.com (whome.planix.com [204.29.161.33]) by weird.com (8.6.5/8.6.5) with ESMTP id SAA13598 for ; Tue, 22 Apr 1997 18:45:47 -0400 Received: from zygot.ati.com(really [157.22.243.6]) by whome.planix.com via sendmail with smtp id for ; Tue, 22 Apr 1997 18:45:41 -0400 (EDT) (Smail-3.2 1996-Jul-4 #2 built 1996-Sep-5) Received: from thunder.sbay.org by zygot.ati.com with bsmtp (Smail3.1.29.1 #1) id m0wJoIv-0001KsC; Tue, 22 Apr 97 15:44 PDT Received: by thunder.sbay.org (Linux Smail3.2 #2) id m0wJoN4-000836C; Tue, 22 Apr 1997 15:49:10 -0700 (PDT) Old-Return-Path: Path: not-for-mail Message-ID: Followup-To: comp.mail.smail Organization: G.T.S., Toronto, Ontario Resent-Message-ID: <"tpk17.A.2WD.kBUXz"@thunder.sbay.org> X-Mailing-List: archive/latest/434 Precedence: list Newsgroups: comp.mail.smail,mlin.smail3.maintainers X-Newsposter: trn 4.0-test56 (2 Mar 97) X-Loop: smail3-maintainers@smail.sbay.org Resent-Date: Tue, 22 Apr 1997 18:45:47 -0400 Resent-From: smail3-maintainers@smail.sbay.org Resent-Sender: smail3-maintainers-request@smail.sbay.org From: bdb@hotlips.gts.net (Bruce Becker) Reply-To: news@gts.org To: smail3-maintainers@smail.sbay.org Date: Tue, 22 Apr 1997 22:31:05 GMT Subject: mailbox size test for appendfile transport Here's a simple addition to the appendfile transport driver's private attributes - the attribute is "size", a long integer object. The newly opened file for delivery is tested for filesize against the "size" attribute - if the filesize is > the specification, the incoming email object is bounced back to sender with a "mailbox full" message. This could no doubt be usefully enhanced in a number of ways, but it's a start... ,u, Bruce Becker Toronto, Ontario 1 416 699 1868 a /i/ Internet: bdb@gts.org Uucp: ...!gts!bdb `\o\-e O dear, where can the matter be, When converted to energy, There's _< /_ a slight loss in parity, Johnny's so long at the fair - N. Testicle --------- 8< --------- 8< --------- 8< --------- 8< --------- 8< --------- *** appendfile.h~ Mon Feb 26 13:40:44 1996 --- appendfile.h Sun Apr 20 17:40:46 1997 *************** *** 24,29 **** --- 24,30 ---- char *prefix; /* string prefixed to message */ char *suffix; /* string appended to message */ int mode; /* mode for creation */ + long size; /* file size limit */ }; /* transport flags private to pipe.c */ *** appendfile.c~ Wed Dec 11 16:10:39 1996 --- appendfile.c Mon Apr 21 04:47:22 1997 *************** *** 42,47 **** --- 42,48 ---- * suffix (string): a string to be appended after the message * in the file. * mode (integer): defines the mode to give newly created files. + * size (long): defines the maximum size of the file. * * private attribute flags: * append_as_user: if set, default uid and gid are taken from *************** *** 130,135 **** --- 131,137 ---- { "prefix", t_string, NULL, NULL, OFFSET(appendfile_private, prefix) }, { "suffix", t_string, NULL, NULL, OFFSET(appendfile_private, suffix) }, { "mode", t_mode, NULL, NULL, OFFSET(appendfile_private, mode) }, + { "size", t_long, NULL, NULL, OFFSET(appendfile_private, size) }, { "append_as_user", t_boolean, NULL, NULL, APPEND_AS_USER }, { "expand_user", t_boolean, NULL, NULL, APPEND_EXPAND_USER }, { "check_user", t_boolean, NULL, NULL, APPEND_CHECK_USER }, *************** *** 438,443 **** --- 440,467 ---- return; } + + if (priv->size > 0) { + int err; + struct stat statbuf; + + (void) fstat(fileno(f), &statbuf); + if (statbuf.st_size > priv->size) { + register struct error *er; + + er = note_error(ERR_NSOWNER|ERR_135, + xprintf("transport %s: mailbox full", tp->name)); + insert_addr_list(addr, fail, er); + (void) fclose(f); + if (priv->file) { + restore_atime(fn, atime_saved); + } + xfree(temp_fn); + xfree(fn); + return; + } + } + #ifdef HAVE_COMSAT msg_offset = lseek(fileno(f), (off_t) 0L, SEEK_END); #else *************** *** 578,583 **** --- 602,608 ---- NULL, /* prefix */ NULL, /* suffix */ 0666, /* mode */ + 0L, /* size */ }; struct appendfile_private *priv; /* new appendfile_private structure */