diff options
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/mail.local/mail.local.8 | 7 | ||||
-rw-r--r-- | libexec/mail.local/mail.local.c | 23 |
2 files changed, 20 insertions, 10 deletions
diff --git a/libexec/mail.local/mail.local.8 b/libexec/mail.local/mail.local.8 index d92dc7c2ec4..b21bca3a314 100644 --- a/libexec/mail.local/mail.local.8 +++ b/libexec/mail.local/mail.local.8 @@ -30,7 +30,7 @@ .\" 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 @@ -75,7 +75,10 @@ In this mode (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 diff --git a/libexec/mail.local/mail.local.c b/libexec/mail.local/mail.local.c index fb98d49b638..a1d38550953 100644 --- a/libexec/mail.local/mail.local.c +++ b/libexec/mail.local/mail.local.c @@ -39,7 +39,7 @@ char copyright[] = #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> @@ -166,8 +166,11 @@ dohold() } 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) ; @@ -317,17 +320,21 @@ again: /* * 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; |