#! /bin/sh /usr/share/dpatch/dpatch-run # Subject: Avoid losing mail when close() fails. # Origin: http://debathena.mit.edu/trac/changeset/14162 # Forwarded: no # Author: Robert Basch # Reviewed-by: Mitchell Berger # Reveiwed-by: Geoffrey Thomas @DPATCH@ diff -ur nmh-1.3.orig/uip/dropsbr.c nmh-1.3/uip/dropsbr.c --- nmh-1.3.orig/uip/dropsbr.c 2008-04-05 14:41:38.000000000 -0400 +++ nmh-1.3/uip/dropsbr.c 2010-02-08 04:38:54.000000000 -0500 @@ -469,8 +469,7 @@ int mbx_close (char *mailbox, int md) { - lkclose (md, mailbox); - return OK; + return (lkclose (md, mailbox) == 0 ? OK : NOTOK); } @@ -643,7 +642,8 @@ return NOTOK; } - mbx_close (file, fd); + if (mbx_close (file, fd) == NOTOK) + return NOTOK; return OK; } diff -ur nmh-1.3.orig/uip/inc.c nmh-1.3/uip/inc.c --- nmh-1.3.orig/uip/inc.c 2007-11-04 06:54:34.000000000 -0500 +++ nmh-1.3/uip/inc.c 2010-02-08 04:38:54.000000000 -0500 @@ -781,7 +781,8 @@ if (pop_quit () == NOTOK) adios (NULL, "%s", response); if (packfile) { - mbx_close (packfile, pd); + if (mbx_close (packfile, pd) == NOTOK) + adios (packfile, "error writing to file"); pd = NOTOK; } } diff -ur nmh-1.3.orig/uip/packf.c nmh-1.3/uip/packf.c --- nmh-1.3.orig/uip/packf.c 2007-11-04 06:54:35.000000000 -0500 +++ nmh-1.3/uip/packf.c 2010-02-08 04:38:54.000000000 -0500 @@ -171,7 +171,8 @@ } /* close and unlock maildrop file */ - mbx_close (file, md); + if (mbx_close (file, md) == NOTOK) + adios (file, "error writing to file"); context_replace (pfolder, folder); /* update current folder */ if (mp->hghsel != mp->curmsg) diff -ur nmh-1.3.orig/uip/slocal.c nmh-1.3/uip/slocal.c --- nmh-1.3.orig/uip/slocal.c 2008-04-11 10:12:55.000000000 -0400 +++ nmh-1.3/uip/slocal.c 2010-02-08 04:38:54.000000000 -0500 @@ -1067,7 +1067,11 @@ } /* close and unlock file */ - mbx_close (mailbox, md); + if (mbx_close (mailbox, md) == NOTOK) { + if (verbose) + adorn ("", "error writing to:"); + return -1; + } if (verbose) verbose_printf (", success.\n");