/*
* Copyright (c) 1998-2004 Proofpoint, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
*/
"@(#) Copyright (c) 1998-2004 Proofpoint, Inc. and its suppliers.\n\
All rights reserved.\n\
Copyright (c) 1990, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n")
#include <stdlib.h>
#include <sm/errstring.h>
# include <unistd.h>
# ifdef EX_OK
# endif /* EX_OK */
# define LOCKFILE_PMODE 0
#include <sm/sysexits.h>
#ifndef HASHSPOOL
# define HASHSPOOL 0
#endif /* ! HASHSPOOL */
#ifndef HASHSPOOLMD5
# define HASHSPOOLMD5 0
#endif /* ! HASHSPOOLMD5 */
/*
** This is not intended to work on System V derived systems
** such as Solaris or HP-UX, since they use a totally different
** approach to mailboxes (essentially, they have a set-group-ID program
** rather than set-user-ID, and they rely on the ability to "give away"
** files to do their work). IT IS NOT A BUG that this doesn't
** work on such architectures.
*/
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <stdlib.h>
# include <netdb.h>
# include <pwd.h>
#include <syslog.h>
#include <ctype.h>
#include <sendmail/pathnames.h>
#if HASHSPOOL
# define HASH_NONE 0
# if HASHSPOOLMD5
# endif /* HASHSPOOLMD5 */
#endif /* HASHSPOOL */
#if _FFR_SPOOL_PATH
/*
** Override path to mail store at run time (using -p).
** From: Eugene Grosbein of Svyaz Service JSC
** NOTE: Update man page before adding this to a release.
*/
#endif /* _FFR_SPOOL_PATH */
#ifndef LOCKTO_RM
#endif /* ! LOCKTO_RM */
#ifndef LOCKTO_GLOB
#endif /* ! LOCKTO_GLOB */
/* define a realloc() which works for NULL pointers */
/*
** If you don't have flock, you could try using lockf instead.
*/
#ifdef LDA_USE_LOCKF
# ifdef LOCK_EX
# endif /* LOCK_EX */
#endif /* LDA_USE_LOCKF */
#ifndef LOCK_EX
#endif /* ! LOCK_EX */
/*
** If you don't have setreuid, and you have saved uids, and you have
** a seteuid() call that doesn't try to emulate using setuid(), then
** you can try defining LDA_USE_SETEUID.
*/
#ifdef LDA_USE_SETEUID
#endif /* LDA_USE_SETEUID */
#ifdef LDA_CONTENTLENGTH
#endif /* LDA_CONTENTLENGTH */
#ifndef INADDRSZ
#endif /* ! INADDRSZ */
#ifdef MAILLOCK
# include <maillock.h>
#endif /* MAILLOCK */
#ifndef MAILER_DAEMON
#endif /* ! MAILER_DAEMON */
#ifdef CONTENTLENGTH
#endif /* CONTENTLENGTH */
bool LMTPMode = false;
bool CloseMBDB = false;
#if HASHSPOOL
int HashDepth = 0;
bool StripRcptDomain = true;
#else /* HASHSPOOL */
# define StripRcptDomain true
#endif /* HASHSPOOL */
char *process_recipient __P((char *));
void notifybiff __P((char *));
void unlockmbox __P((void));
void flush_error __P((void));
#if HASHSPOOL
#endif /* HASHSPOOL */
static void
int status;
{
if (CloseMBDB)
{
CloseMBDB = false; /* not really necessary, but ... */
}
}
int
int argc;
char *argv[];
{
char *from;
int err;
extern char *optarg;
extern int optind;
/* make sure we have some open file descriptors */
/* use a reasonable umask */
(void) umask(0077);
# ifdef LOG_MAIL
# else /* LOG_MAIL */
openlog("mail.local", 0);
# endif /* LOG_MAIL */
/* XXX can this be converted to a compile time check? */
sizeof(SpoolPath))
{
}
#if HASHSPOOL
#else /* HASHSPOOL */
# if _FFR_SPOOL_PATH
# else /* _FFR_SPOOL_PATH */
# endif /* _FFR_SPOOL_PATH */
#endif /* HASHSPOOL */
{
switch(ch)
{
case '7': /* Do not advertise 8BITMIME */
EightBitMime = false;
break;
case 'b': /* bounce mail when over quota. */
BounceQuota = true;
break;
case 'd': /* Backward compatible. */
break;
case 'D': /* mailbox database type */
break;
case 'f':
case 'r': /* Backward compatible. */
{
usage();
}
break;
case 'h':
else
{
usage();
}
break;
case 'l':
LMTPMode = true;
break;
#if HASHSPOOL
case 'H':
{
usage();
}
switch(optarg[0])
{
case 'u':
break;
# if HASHSPOOLMD5
case 'm':
break;
# endif /* HASHSPOOLMD5 */
default:
usage();
}
{
usage();
}
{
usage();
}
break;
case 'n':
StripRcptDomain = false;
break;
#endif /* HASHSPOOL */
#if HASHSPOOL || _FFR_SPOOL_PATH
case 'p':
{
usage();
}
sizeof(SpoolPath))
{
usage();
}
break;
#endif /* HASHSPOOL || _FFR_SPOOL_PATH */
case '?':
default:
usage();
}
}
/* initialize biff structures */
{
if (err == EX_TEMPFAIL)
errcode = "421";
}
CloseMBDB = true;
if (LMTPMode)
{
if (argc > 0)
{
}
dolmtp();
/* NOTREACHED */
}
/* Non-LMTP from here on out */
if (*argv == '\0')
usage();
/*
** If from not specified, use the name from getlogin() if the
** uid matches, otherwise, use the name from the password file
** corresponding to the uid.
*/
/*
** There is no way to distinguish the error status of one delivery
** from the rest of the deliveries. So, if we failed hard on one
** or more deliveries, but had no failures on any of the others, we
** return a hard failure. If we failed temporarily on one or more
** deliveries, we return a temporary failure regardless of the other
** failures. This results in the delivery being reattempted later
** at the expense of repeated failures and multiple deliveries.
*/
HoldErrs = true;
HoldErrs = false;
if (fd < 0)
{
flush_error();
}
/* NOTREACHED */
return ExitVal;
}
char *
char *s;
bool rcpt;
{
char *p;
int l;
if (*s++ != '<')
return NULL;
p = s;
/* at-domain-list */
while (*p == '@')
{
p++;
while (*p != ',' && *p != ':' && *p != '\0')
p++;
if (*p == '\0')
return NULL;
/* Skip over , or : */
p++;
}
s = p;
/* local-part */
while (*p != '\0' && *p != '@' && *p != '>')
{
if (*p == '\\')
{
if (*++p == '\0')
return NULL;
}
else if (*p == '\"')
{
p++;
while (*p != '\0' && *p != '\"')
{
if (*p == '\\')
{
if (*++p == '\0')
return NULL;
}
p++;
}
if (*p == '\0' || *(p + 1) == '\0')
return NULL;
}
/* +detail ? */
if (*p == '+' && rcpt)
*p = '\0';
p++;
}
/* @domain */
if (*p == '@')
{
if (rcpt)
*p++ = '\0';
while (*p != '\0' && *p != '>')
p++;
}
if (*p != '>')
return NULL;
else
*p = '\0';
p++;
if (*p != '\0' && *p != ' ')
return NULL;
if (*s == '\0')
s = MAILER_DAEMON;
l = strlen(s) + 1;
if (l < 0)
return NULL;
p = malloc(l);
if (p == NULL)
{
}
(void) sm_strlcpy(p, s, l);
return p;
}
char *
char *addr;
{
{
case EX_OK:
return NULL;
case EX_NOUSER:
return "550 5.1.1 User unknown";
case EX_TEMPFAIL:
return "451 4.3.0 User database failure; retry later";
default:
return "550 5.3.0 User database failure";
}
}
void
dolmtp()
{
int rcpt_num = 0;
int rcpt_alloc = 0;
bool gotlhlo = false;
char *err;
int msgfd;
char *p;
int i;
if (myhostname[0] == '\0')
for (;;)
{
if (p >= buf && *p == '\n')
*p-- = '\0';
if (p >= buf && *p == '\r')
*p-- = '\0';
switch (buf[0])
{
case 'd':
case 'D':
{
bool inbody = false;
if (rcpt_num == 0)
{
continue;
}
HoldErrs = true;
HoldErrs = false;
{
flush_error();
continue;
}
for (i = 0; i < rcpt_num; i++)
{
if (msgfd < 0)
{
/* print error for rcpt */
flush_error();
continue;
}
if (p != NULL)
*p = '\0';
}
if (msgfd >= 0)
goto rset;
}
goto syntaxerr;
/* NOTREACHED */
break;
case 'l':
case 'L':
{
/* check for duplicate per RFC 1651 4.2 */
if (gotlhlo)
{
continue;
}
gotlhlo = true;
if (EightBitMime)
printf("250-8BITMIME\r\n");
printf("250-ENHANCEDSTATUSCODES\r\n");
printf("250 PIPELINING\r\n");
continue;
}
goto syntaxerr;
/* NOTREACHED */
break;
case 'm':
case 'M':
{
if (return_path != NULL)
{
mailerr("503 5.5.1",
"Nested MAIL command");
continue;
}
false)) == NULL))
{
mailerr("501 5.5.4",
"Syntax error in parameters");
continue;
}
printf("250 2.5.0 Ok\r\n");
continue;
}
goto syntaxerr;
/* NOTREACHED */
break;
case 'n':
case 'N':
{
printf("250 2.0.0 Ok\r\n");
continue;
}
goto syntaxerr;
/* NOTREACHED */
break;
case 'q':
case 'Q':
{
printf("221 2.0.0 Bye\r\n");
}
goto syntaxerr;
/* NOTREACHED */
break;
case 'r':
case 'R':
{
if (return_path == NULL)
{
mailerr("503 5.5.1",
"Need MAIL command");
continue;
}
if (rcpt_num >= rcpt_alloc)
{
rcpt_alloc += RCPT_GROW;
rcpt_addr = (char **)
sizeof(char **));
{
mailerr("421 4.3.0",
"Memory exhausted");
}
}
StripRcptDomain)) == NULL))
{
mailerr("501 5.5.4",
"Syntax error in parameters");
continue;
}
{
continue;
}
rcpt_num++;
printf("250 2.1.5 Ok\r\n");
continue;
}
{
printf("250 2.0.0 Ok\r\n");
rset:
while (rcpt_num > 0)
if (return_path != NULL)
return_path = NULL;
continue;
}
goto syntaxerr;
/* NOTREACHED */
break;
case 'v':
case 'V':
{
printf("252 2.3.3 Try RCPT to attempt delivery\r\n");
continue;
}
goto syntaxerr;
/* NOTREACHED */
break;
default:
continue;
/* NOTREACHED */
break;
}
}
}
int
char *from;
bool *inbody;
{
int fd;
*inbody = false;
(void) umask(0077);
{
if (fd >= 0)
return -1;
}
if (LMTPMode)
{
printf("354 Go ahead\r\n");
}
*inbody = true;
#ifdef CONTENTLENGTH
HeaderLength = 0;
BodyLength = -1;
#endif /* CONTENTLENGTH */
line[0] = '\0';
eline = true;
{
int peek;
line_len++;
line_len++;
/* Check for dot-stuffing */
{
goto lmtpdot;
line_len--;
}
/* Check to see if we have the full line from fgets() */
fullline = false;
if (line_len > 0)
{
{
if (line_len >= 2 &&
{
line_len--;
}
fullline = true;
}
{
/* Did we just miss the CRLF? */
if (peek == '\n')
{
fullline = true;
}
else
}
}
else
fullline = true;
#ifdef CONTENTLENGTH
{
eline = false;
if (HeaderLength <= 0)
{
/*
** shouldn't happen, unless ftell() is
** badly broken
*/
HeaderLength = -1;
}
}
#else /* CONTENTLENGTH */
eline = true;
#endif /* CONTENTLENGTH */
else
{
eline = false;
#ifdef CONTENTLENGTH
/* discard existing "Content-Length:" headers */
if (prevfl && HeaderLength == 0 &&
{
/*
** be paranoid: clear the line
** so no "wrong matches" may occur later
*/
line[0] = '\0';
continue;
}
#endif /* CONTENTLENGTH */
}
{
{
mailerr("451 4.3.0",
"Temporary file write error");
continue;
}
}
}
/* check if an error occurred */
return -1;
if (LMTPMode)
{
/* Got a premature EOF -- toss message and exit */
}
/* If message not newline terminated, need an extra. */
#ifdef CONTENTLENGTH
{
BodyLength = 0;
}
else
if (HeaderLength > 0 && BodyLength >= 0)
{
(LONGLONG_T) BodyLength);
sizeof(ContentHdr) - 16);
}
else
#endif /* CONTENTLENGTH */
/* Output a newline; note, empty messages are allowed. */
{
return -1;
}
return fd;
}
void
int fd;
char *name;
{
int exitval;
char *p;
char *errcode;
#ifdef CONTENTLENGTH
int readamount;
#endif /* CONTENTLENGTH */
/*
** Disallow delivery to unknown names -- special mailboxes can be
** handled in the sendmail aliases file.
*/
switch (exitval)
{
case EX_OK:
break;
case EX_NOUSER:
break;
case EX_TEMPFAIL:
name);
break;
default:
break;
}
{
if (ExitVal != EX_TEMPFAIL)
return;
}
endpwent();
/*
** Keep name reasonably short to avoid buffer overruns.
** This isn't necessary on BSD because of the proper
** definition of snprintf(), but it can cause problems
** on other systems.
** Also, clear out any bogus characters.
*/
#if !HASHSPOOL
for (p = name; *p != '\0'; p++)
{
if (!isascii(*p))
*p &= 0x7f;
else if (!isprint(*p))
*p = '.';
}
#endif /* !HASHSPOOL */
if (HomeMailFile == NULL)
{
#if HASHSPOOL
4,
#else /* HASHSPOOL */
3,
#endif /* HASHSPOOL */
SpoolPath, "/",
#if HASHSPOOL
#endif /* HASHSPOOL */
{
return;
}
}
{
return;
}
{
return;
}
/*
** If the mailbox is linked or a symlink, fail. There's an obvious
** race here, that the file was replaced with a symbolic link after
** the lstat returned, but before the open. We attempt to detect
** this by comparing the original stat information and information
** returned by an fstat of the file descriptor returned by the open.
**
** NB: this is a symptom of a larger problem, that the mail spooling
** directory is writeable by the wrong users. If that directory is
** writeable, system security is compromised for other reasons, and
** it cannot be fixed here.
**
** just return. Another process may have already opened it, so we
** each mail delivery. We no longer do this, assuming that if the
** ownership or permissions were changed there was a reason.
**
** XXX
** open(2) should support flock'ing the file.
*/
#ifdef MAILLOCK
p = name;
#else /* MAILLOCK */
p = path;
#endif /* MAILLOCK */
{
{
errcode = "451 4.3.0";
}
else
errcode = "551 5.3.0";
return;
}
{
int save_errno;
#ifdef MAILGID
(void) umask(0007);
#endif /* MAILGID */
mode);
save_errno = errno;
{
mailerr("550 5.2.0",
"%s: lstat: file changed after open", path);
goto err1;
}
if (mbfd < 0)
{
if (save_errno == EEXIST)
goto tryagain;
/* open failed, don't try again */
goto err0;
}
{
goto err1;
}
else
{
/*
** open() was successful, now close it so can
** be opened as the right owner again.
** Paranoia: reset mbdf since the file descriptor
** is no longer valid; better safe than sorry.
*/
mbfd = -1;
}
}
{
goto err0;
}
{
goto err0;
}
{
goto err0;
}
/* change UID for quota checks */
{
goto err1;
}
#ifdef DEBUG
#endif /* DEBUG */
if (mbfd < 0)
{
goto err0;
}
# if HAS_ST_GEN && 0 /* AFS returns random values for st_gen */
# endif /* HAS_ST_GEN && 0 */
{
path);
goto err1;
}
#if 0
/*
** This code could be reused if we decide to add a
** per-user quota field to the sm_mbdb interface.
*/
/*
** Fail if the user has a quota specified, and delivery of this
** message would exceed that quota. We bounce such failures using
** EX_UNAVAILABLE, unless there were internal problems, since
** storing immense messages for later retries can cause queueing
** issues.
*/
{
{
mailerr("451 4.3.0",
"%s: fstat: can't stat temporary storage: %s",
goto err1;
}
{
mailerr("551 5.2.2",
"%s: Mailbox full or quota exceeded",
goto err1;
}
}
#endif /* 0 */
/* Wait until we can get a lock on the file. */
{
goto err1;
}
/* Get the starting offset of the new message */
/* Copy the message into the file. */
{
goto err1;
}
#ifdef DEBUG
#endif /* DEBUG */
#ifdef CONTENTLENGTH
for (;;)
{
if (headerbytes == 0)
{
headerbytes = -1;
readamount = 0;
}
readamount = sizeof(buf);
else
if (readamount != 0)
if (nr <= 0)
break;
if (headerbytes > 0)
headerbytes -= nr ;
#else /* CONTENTLENGTH */
{
#endif /* CONTENTLENGTH */
{
{
errcode = "450 4.2.0";
#ifdef EDQUOT
errcode = "552 5.2.2";
#endif /* EDQUOT */
goto err3;
}
}
}
if (nr < 0)
{
goto err3;
}
/* Flush to disk, don't wait for update. */
{
err3:
#ifdef DEBUG
#endif /* DEBUG */
if (mbfd >= 0)
unlockmbox();
return;
}
/*
** Save the current size so if the close() fails below
** we can make sure no other process has changed the mailbox
** between the failed close and the re-open()/re-lock().
** If something else has changed the size, we shouldn't
** try to truncate it as we may do more harm then good
** (e.g., truncate a later message delivery).
*/
cursize = 0;
else
/* Close and check -- NFS doesn't write until the close. */
{
errcode = "450 4.2.0";
#ifdef EDQUOT
errcode = "552 5.2.2";
#endif /* EDQUOT */
if (mbfd < 0 ||
cursize == 0
# if HAS_ST_GEN && 0 /* AFS returns random values for st_gen */
# endif /* HAS_ST_GEN && 0 */
)
{
/* Don't use a bogus file */
if (mbfd >= 0)
{
mbfd = -1;
}
}
/* Attempt to truncate back to pre-write size */
goto err3;
}
else
if (setreuid(0, 0) < 0)
{
goto err0;
}
#ifdef DEBUG
#endif /* DEBUG */
unlockmbox();
if (LMTPMode)
}
/*
** user.lock files are necessary for compatibility with other
** systems, e.g., when the mail spool file is NFS exported.
** Alas, mailbox locking is more than just a local matter.
** EPA 11/94.
*/
bool Locked = false;
#ifdef MAILLOCK
int
char *name;
{
int r = 0;
if (Locked)
return 0;
{
Locked = true;
return 0;
}
switch (r)
{
case L_TMPLOCK: /* Can't create tmp file */
case L_TMPWRITE: /* Can't write pid into lockfile */
case L_MAXTRYS: /* Failed after retrycnt attempts */
errno = 0;
r = EX_TEMPFAIL;
break;
case L_ERROR: /* Check errno for reason */
r = errno;
break;
default: /* other permanent errors */
errno = 0;
r = EX_UNAVAILABLE;
break;
}
return r;
}
void
{
if (Locked)
mailunlock();
Locked = false;
}
#else /* MAILLOCK */
int
char *path;
{
int statfailed = 0;
if (Locked)
return 0;
return EX_SOFTWARE;
for (; ; sleep(5))
{
int fd;
/* global timeout */
{
errno = 0;
return EX_TEMPFAIL;
}
if (fd >= 0)
{
/* defeat lock checking programs which test pid */
Locked = true;
return 0;
}
{
if (statfailed++ > 5)
{
errno = 0;
return EX_TEMPFAIL;
}
continue;
}
statfailed = 0;
continue;
/* try to remove stale lockfile */
return errno;
}
}
void
{
if (!Locked)
return;
Locked = false;
}
#endif /* MAILLOCK */
void
char *msg;
{
static bool initialized = false;
static int f = -1;
int len;
if (!initialized)
{
initialized = true;
/* Be silent if biff service not available. */
return;
}
/* No message, just return */
return;
/* Couldn't initialize addr struct */
return;
return;
}
void
usage()
{
# if _FFR_SPOOL_PATH
mailerr(NULL, "usage: mail.local [-7] [-b] [-d] [-l] [-f from|-r from] [-h filename] [-p path] user ...");
# else /* _FFR_SPOOL_PATH */
# endif /* _FFR_SPOOL_PATH */
}
void
/*VARARGS2*/
#ifdef __STDC__
#else /* __STDC__ */
const char *hdr;
const char *fmt;
#endif /* __STDC__ */
{
{
}
if (!HoldErrs)
flush_error();
/* Log the message to syslog. */
if (!LMTPMode)
}
void
{
if (LMTPMode)
else
{
}
}
#if HASHSPOOL
const char *
char *name;
{
static char p[MAXPATHLEN];
int i;
int len;
char *str;
# if HASHSPOOLMD5
# if MAXPATHLEN <= 24
# endif /* MAXPATHLEN <= 24 */
char b64[24];
int j;
# endif /* HASHSPOOLMD5 */
{
p[0] = '\0';
return p;
}
switch(HashType)
{
case HASH_USER:
break;
# if HASHSPOOLMD5
case HASH_MD5:
md5[16] = 0;
md5[17] = 0;
for (i = 0; i < 6; i++)
{
for (j = 3; j >= 0; j--)
{
bits >>= 6;
}
}
break;
# endif /* HASHSPOOLMD5 */
}
for (i = 0; i < HashDepth; i++)
{
if (i < len)
p[i * 2] = str[i];
else
p[i * 2] = '_';
p[(i * 2) + 1] = '/';
}
return p;
}
#endif /* HASHSPOOL */
/*
* e_to_sys --
* Guess which errno's are temporary. Gag me.
*/
int
int num;
{
/* Temporary failures override hard errors. */
if (ExitVal == EX_TEMPFAIL)
return ExitVal;
switch (num) /* Hopefully temporary errors. */
{
#ifdef EDQUOT
case EDQUOT: /* Disc quota exceeded */
if (BounceQuota)
{
break;
}
/* FALLTHROUGH */
#endif /* EDQUOT */
#ifdef EAGAIN
case EAGAIN: /* Resource temporarily unavailable */
#endif /* EAGAIN */
#ifdef EBUSY
case EBUSY: /* Device busy */
#endif /* EBUSY */
#ifdef EPROCLIM
case EPROCLIM: /* Too many processes */
#endif /* EPROCLIM */
#ifdef EUSERS
case EUSERS: /* Too many users */
#endif /* EUSERS */
#ifdef ECONNABORTED
case ECONNABORTED: /* Software caused connection abort */
#endif /* ECONNABORTED */
#ifdef ECONNREFUSED
case ECONNREFUSED: /* Connection refused */
#endif /* ECONNREFUSED */
#ifdef ECONNRESET
case ECONNRESET: /* Connection reset by peer */
#endif /* ECONNRESET */
#ifdef EDEADLK
case EDEADLK: /* Resource deadlock avoided */
#endif /* EDEADLK */
#ifdef EFBIG
case EFBIG: /* File too large */
#endif /* EFBIG */
#ifdef EHOSTDOWN
case EHOSTDOWN: /* Host is down */
#endif /* EHOSTDOWN */
#ifdef EHOSTUNREACH
case EHOSTUNREACH: /* No route to host */
#endif /* EHOSTUNREACH */
#ifdef EMFILE
case EMFILE: /* Too many open files */
#endif /* EMFILE */
#ifdef ENETDOWN
case ENETDOWN: /* Network is down */
#endif /* ENETDOWN */
#ifdef ENETRESET
case ENETRESET: /* Network dropped connection on reset */
#endif /* ENETRESET */
#ifdef ENETUNREACH
case ENETUNREACH: /* Network is unreachable */
#endif /* ENETUNREACH */
#ifdef ENFILE
case ENFILE: /* Too many open files in system */
#endif /* ENFILE */
#ifdef ENOBUFS
case ENOBUFS: /* No buffer space available */
#endif /* ENOBUFS */
#ifdef ENOMEM
case ENOMEM: /* Cannot allocate memory */
#endif /* ENOMEM */
#ifdef ENOSPC
case ENOSPC: /* No space left on device */
#endif /* ENOSPC */
#ifdef EROFS
case EROFS: /* Read-only file system */
#endif /* EROFS */
#ifdef ESTALE
case ESTALE: /* Stale NFS file handle */
#endif /* ESTALE */
#ifdef ETIMEDOUT
case ETIMEDOUT: /* Connection timed out */
#endif /* ETIMEDOUT */
case EWOULDBLOCK: /* Operation would block. */
#endif /* defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN && EWOULDBLOCK != EDEADLK */
break;
default:
break;
}
return ExitVal;
}
/*
* Copyright (c) 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* 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.
*/
# endif /* defined(LIBC_SCCS) && !defined(lint) */
# include <fcntl.h>
# include <errno.h>
# include <stdio.h>
# include <ctype.h>
static int _gettemp();
char *path;
{
int fd;
}
static
char *path;
register int *doopen;
{
extern int errno;
unsigned int pid;
while (*--trv == 'X')
{
pid /= 10;
}
/*
* check the target directory; if you have six X's and it
* doesn't exist this runs for a *very* long time.
*/
{
break;
if (*trv == '/')
{
*trv = '\0';
return(0);
{
return(0);
}
*trv = '/';
break;
}
}
for (;;)
{
if (doopen)
{
0600)) >= 0)
return(1);
return(0);
}
/* tricky little algorithm for backward compatibility */
{
if (!*trv)
return(0);
if (*trv == 'z')
*trv++ = 'a';
else
{
*trv = 'a';
else
++*trv;
break;
}
}
}
/* NOTREACHED */
}
#endif /* defined(ultrix) || defined(_CRAY) */