From: Eric Allman Date: Sun, 12 Dec 1993 05:53:57 +0000 (-0800) Subject: avoid problems if a tf file already exists; improve logging X-Git-Tag: BSD-4_4_Lite1-Snapshot-Development~1281 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/e8f51a65799dfbd2f8f77175f9cf968b715a2527 avoid problems if a tf file already exists; improve logging SCCS-vsn: usr.sbin/sendmail/src/queue.c 8.30 --- diff --git a/usr/src/usr.sbin/sendmail/src/queue.c b/usr/src/usr.sbin/sendmail/src/queue.c index ccd477e809..c37c110ea7 100644 --- a/usr/src/usr.sbin/sendmail/src/queue.c +++ b/usr/src/usr.sbin/sendmail/src/queue.c @@ -10,9 +10,9 @@ #ifndef lint #ifdef QUEUE -static char sccsid[] = "@(#)queue.c 8.29 (Berkeley) %G% (with queueing)"; +static char sccsid[] = "@(#)queue.c 8.30 (Berkeley) %G% (with queueing)"; #else -static char sccsid[] = "@(#)queue.c 8.29 (Berkeley) %G% (without queueing)"; +static char sccsid[] = "@(#)queue.c 8.30 (Berkeley) %G% (without queueing)"; #endif #endif /* not lint */ @@ -95,21 +95,21 @@ queueup(e, queueall, announce) break; #ifdef LOG if (LogLevel > 0 && (i % 32) == 0) - syslog(LOG_ALERT, "queueup: cannot create %s: %s", - tf, errstring(errno)); + syslog(LOG_ALERT, "queueup: cannot create %s, uid=%d: %s", + tf, geteuid(), errstring(errno)); #endif - continue; } - - if (lockfile(fd, tf, NULL, LOCK_EX|LOCK_NB)) - break; + else + { + if (lockfile(fd, tf, NULL, LOCK_EX|LOCK_NB)) + break; #ifdef LOG - else if (LogLevel > 0 && (i % 32) == 0) - syslog(LOG_ALERT, "queueup: cannot lock %s: %s", - tf, errstring(errno)); + else if (LogLevel > 0 && (i % 32) == 0) + syslog(LOG_ALERT, "queueup: cannot lock %s: %s", + tf, errstring(errno)); #endif - - close(fd); + close(fd); + } if ((i % 32) == 31) { @@ -122,7 +122,8 @@ queueup(e, queueall, announce) if (fd < 0 || (tfp = fdopen(fd, "w")) == NULL) { printopenfds(TRUE); - syserr("!queueup: cannot create queue temp file %s", tf); + syserr("!queueup: cannot create queue temp file %s, uid=%d", + tf, geteuid()); } } @@ -153,8 +154,8 @@ queueup(e, queueall, announce) e->e_df = newstr(e->e_df); fd = open(e->e_df, O_WRONLY|O_CREAT, FileMode); if (fd < 0 || (dfp = fdopen(fd, "w")) == NULL) - syserr("!queueup: cannot create data temp file %s", - e->e_df); + syserr("!queueup: cannot create data temp file %s, uid=%d", + e->e_df, geteuid()); (*e->e_putbody)(dfp, FileMailer, e, NULL); (void) xfclose(dfp, "queueup dfp", e->e_id); e->e_putbody = putbody; @@ -322,7 +323,8 @@ queueup(e, queueall, announce) /* rename (locked) tf to be (locked) qf */ qf = queuename(e, 'q'); if (rename(tf, qf) < 0) - syserr("cannot rename(%s, %s), df=%s", tf, qf, e->e_df); + syserr("cannot rename(%s, %s), df=%s, uid=%d", + tf, qf, e->e_df, geteuid()); /* close and unlock old (locked) qf */ if (e->e_lockfp != NULL)