.\" SUCH DAMAGE.
.\"
.\" from: @(#)mail.local.8 6.8 (Berkeley) 4/27/91
-.\" $Id: mail.local.8,v 1.7 1996/12/05 15:00:40 deraadt Exp $
+.\" $Id: mail.local.8,v 1.8 1997/03/29 02:59:55 millert Exp $
.\"
.Dd April 27, 1991
.Dt MAIL.LOCAL 8
(ignoring all other arguments) attains a
.Nm username.lock
for the calling user and retains it until stdin is closed or a signal
-like SIGINT, SIGTERM, or SIGHUP is received.
+like SIGINT, SIGTERM, or SIGHUP is received. If
+.Nm mail.local
+is able to create the lock file, ``1'' is written to stdout, otherwise
+``0'' is written and an error message is written to stderr.
.El
.Pp
Individual mail messages in the mailbox are delimited by an empty
#ifndef lint
/*static char sccsid[] = "from: @(#)mail.local.c 5.6 (Berkeley) 6/19/91";*/
-static char rcsid[] = "$Id: mail.local.c,v 1.13 1997/03/28 02:16:40 millert Exp $";
+static char rcsid[] = "$Id: mail.local.c,v 1.14 1997/03/29 02:59:56 millert Exp $";
#endif /* not lint */
#include <sys/param.h>
}
holdfd = getlock(from, pw);
- if (holdfd == -1)
+ if (holdfd == -1) {
+ write(STDOUT_FILENO, "0\n", 2);
return (1);
+ }
+ write(STDOUT_FILENO, "1\n", 2);
while (read(0, &c, 1) == -1 && errno == EINTR)
;
/*
* Only root can write the spool directory.
*/
- if ((lfd = open(lpath, O_CREAT|O_WRONLY|O_EXCL,
- S_IRUSR|S_IWUSR)) < 0) {
- err(NOTFATAL, "%s: %s", lpath, strerror(errno));
- return(-1);
+ while (1) {
+ if ((lfd = open(lpath, O_CREAT|O_WRONLY|O_EXCL,
+ S_IRUSR|S_IWUSR)) != -1)
+ break;
+ if (tries > 9) {
+ err(NOTFATAL, "%s: %s", lpath, strerror(errno));
+ return(-1);
+ }
+ sleep(1 << tries);
+ tries++;
}
}
return (lfd);
}
-
-
int
deliver(fd, name, lockfile)
int fd;