summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sendmail/mail.local/mail.local.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/sendmail/mail.local/mail.local.c')
-rw-r--r--usr.sbin/sendmail/mail.local/mail.local.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/usr.sbin/sendmail/mail.local/mail.local.c b/usr.sbin/sendmail/mail.local/mail.local.c
index e7f1211..ee2c6422 100644
--- a/usr.sbin/sendmail/mail.local/mail.local.c
+++ b/usr.sbin/sendmail/mail.local/mail.local.c
@@ -29,6 +29,8 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $Id: mail.local.c,v 1.9 1997/06/27 15:17:01 peter Exp $
*/
#ifndef lint
@@ -183,9 +185,9 @@ extern FILE *fdopen __P((int, const char *));
int eval = EX_OK; /* sysexits.h error value. */
-void deliver __P((int, char *));
+void deliver __P((int, char *, int, int));
void e_to_sys __P((int));
-__dead void err __P((const char *, ...));
+void err __P((const char *, ...)) __dead2;
void notifybiff __P((char *));
int store __P((char *));
void usage __P((void));
@@ -200,7 +202,7 @@ main(argc, argv)
char *argv[];
{
struct passwd *pw;
- int ch, fd;
+ int ch, fd, nobiff, nofsync;
uid_t uid;
char *from;
extern char *optarg;
@@ -220,8 +222,13 @@ main(argc, argv)
#endif
from = NULL;
- while ((ch = getopt(argc, argv, "df:r:")) != EOF)
+ nobiff = 0;
+ nofsync = 0;
+ while ((ch = getopt(argc, argv, "bdf:r:s")) != -1)
switch(ch) {
+ case 'b':
+ nobiff++;
+ break;
case 'd': /* Backward compatible. */
break;
case 'f':
@@ -232,6 +239,9 @@ main(argc, argv)
}
from = optarg;
break;
+ case 's':
+ nofsync++;
+ break;
case '?':
default:
usage();
@@ -262,7 +272,7 @@ main(argc, argv)
* at the expense of repeated failures and multiple deliveries.
*/
for (fd = store(from); *argv; ++argv)
- deliver(fd, *argv);
+ deliver(fd, *argv, nobiff, nofsync);
exit(eval);
}
@@ -317,8 +327,8 @@ store(from)
}
void
-deliver(fd, name)
- int fd;
+deliver(fd, name, nobiff, nofsync)
+ int fd, nobiff, nofsync;
char *name;
{
struct stat fsb, sb;
@@ -440,11 +450,13 @@ tryagain:
goto err1;
}
- /* Get the starting offset of the new message for biff. */
- curoff = lseek(mbfd, (off_t)0, SEEK_END);
- (void)snprintf(biffmsg, sizeof(biffmsg),
- sizeof curoff > sizeof(long) ? "%s@%qd\n" : "%s@%ld\n",
- name, curoff);
+ if (!nobiff) {
+ /* Get the starting offset of the new message for biff. */
+ curoff = lseek(mbfd, (off_t)0, SEEK_END);
+ (void)snprintf(biffmsg, sizeof(biffmsg),
+ sizeof curoff > sizeof(long) ? "%s@%qd\n" : "%s@%ld\n",
+ name, curoff);
+ }
/* Copy the message into the file. */
if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
@@ -475,7 +487,7 @@ tryagain:
}
/* Flush to disk, don't wait for update. */
- if (fsync(mbfd)) {
+ if (!nofsync && fsync(mbfd)) {
e_to_sys(errno);
warn("%s: %s", path, strerror(errno));
err3:
@@ -497,7 +509,7 @@ err0: unlockmbox();
e_to_sys(errno);
warn("%s: %s", path, strerror(errno));
truncate(path, curoff);
- } else
+ } else if (!nobiff)
notifybiff(biffmsg);
if (setreuid(0, 0) < 0) {
@@ -600,7 +612,7 @@ void
usage()
{
eval = EX_USAGE;
- err("usage: mail.local [-f from] user ...");
+ err("usage: mail.local [-b] [-f from] [-s] user ...");
}
#if __STDC__
OpenPOWER on IntegriCloud