/*
* Copyright (c) 1998-2001 Proofpoint, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1988, 1993
* 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-2001 Proofpoint, Inc. and its suppliers.\n\
All rights reserved.\n\
Copyright (c) 1988, 1993\n\
The Regents of the University of California. All rights reserved.\n")
/*
* RMAIL -- UUCP mail server.
*
* This program reads the >From ... remote from ... lines that UUCP is so
* fond of and turns them into something reasonable. It then execs sendmail
* with various options built from these lines.
*
* The expected syntax is:
*
* <user> := [-a-z0-9]+
* <date> := ctime format
* <site> := [-a-z0-9!]+
* <blank line> := "^\n$"
* <from> := "From" <space> <user> <space> <date>
* [<space> "remote from" <space> <site>]
* <forward> := ">" <from>
* msg := <from> <forward>* <blank-line> <body>
*
* The output of rmail(8) compresses the <forward> lines into a single
* from path.
*
* The err(3) routine is included here deliberately to make this code
* a bit more portable.
*/
#include <ctype.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef EX_OK
#endif /* EX_OK */
#include <sysexits.h>
#include <sm/errstring.h>
#include <sendmail/pathnames.h>
static char *
register int sz;
{
register char *p;
/* some systems can't handle size zero mallocs */
if (sz <= 0)
sz = 1;
if (p == NULL)
return (p);
}
int
int argc;
char *argv[];
{
extern char *optarg;
extern int optind;
debug = 0;
{
switch (ch)
{
case 'T':
debug = 1;
break;
case 'D':
break;
case '?':
default:
usage();
}
}
if (argc < 1)
usage();
for (offset = 0; ; )
{
/* Get and nul-terminate the line. */
sizeof(lbuf)) < 0)
*p = '\0';
/* Parse lines until reach a non-"From" line. */
else if (offset == 0)
"missing or empty From line: %s", lbuf);
else
{
*p = '\n';
break;
}
/* Use the "remote from" if it exists. */
{
{
for (t = p += 12; *t != '\0'; ++t)
{
break;
}
*t = '\0';
if (debug)
(void) sm_io_fprintf(smioerr,
"remote from: %s\n",
p);
break;
}
}
/* Else use the string up to the last bang. */
if (p == NULL)
{
if (*addrp == '!')
addrp);
{
*t = '\0';
p = addrp;
addrp = t + 1;
if (*addrp == '\0')
"corrupted From line: %s", lbuf);
if (debug)
(void) sm_io_fprintf(smioerr,
"bang: %s\n", p);
}
}
/* 'p' now points to any system string from this line. */
if (p != NULL)
{
/* Nul terminate it as necessary. */
for (t = p; *t != '\0'; ++t)
{
break;
}
*t = '\0';
/* If the first system, copy to the from_sys string. */
{
if (debug)
(void) sm_io_fprintf(smioerr,
"from_sys: %s\n",
from_sys);
}
/* Concatenate to the path string. */
len = t - p;
{
fplen = 0;
}
{
}
}
/* Save off from user's address; the last one wins. */
for (p = addrp; *p != '\0'; ++p)
{
break;
}
*p = '\0';
if (*addrp == '\0')
addrp = "<>";
if (debug)
{
"from_path: %s\n",
"from_user: %s\n", from_user);
}
if (offset != -1)
}
/* Allocate args (with room for sendmail args as well as recipients */
i = 0;
/* set from system and protocol used */
else
/* Set name of ``from'' person. */
/*
** Don't copy arguments beginning with - as they will be
** passed to sendmail and could be interpreted as flags.
** To prevent confusion of sendmail wrap < and > around
** the address (helps to pass addrs like @gw1,@gw2:aa@bb)
*/
{
if (**argv == '-')
else
{
}
argv++;
argc--;
/* Paranoia check, argc used for args[] bound */
if (argc < 0)
}
if (debug)
{
"Sendmail arguments:\n");
"\t%s\n", args[i]);
}
/*
** If called with a regular file as standard input, seek to the right
** position in the file and just exec sendmail. Could probably skip
** skip the stat, but it's not unreasonable to believe that a failed
** seek will cause future reads to fail.
*/
{
}
{
case -1: /* Err. */
/* NOTREACHED */
case 0: /* Child. */
if (pdes[0] != STDIN_FILENO)
{
}
/* NOTREACHED */
}
/* Copy the file down the pipe. */
do
{
sizeof(lbuf)) >= 0);
if (sm_io_error(smioin))
if (WEXITSTATUS(status))
/* NOTREACHED */
return EX_OK;
}
static void
usage()
{
"usage: rmail [-T] [-D domain] user ...\n");
}
static void
#ifdef __STDC__
#else /* __STDC__ */
int eval;
const char *fmt;
#endif /* __STDC__ */
{
{
}
}