Resolve conflicts from sendmail 8.12.2 import

This commit is contained in:
Gregory Neil Shapiro 2002-02-17 21:58:34 +00:00
parent 5b587aff2d
commit 12ed1c7c81
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=90795
19 changed files with 3459 additions and 5678 deletions

View File

@ -24,6 +24,10 @@ include(TEMPFILE)dnl
syscmd(rm -f TEMPFILE)dnl')', `dnl')
#####
######################################################################
#####
##### DO NOT EDIT THIS FILE! Only edit the source .mc file.
#####
######################################################################
######################################################################
divert(-1)
@ -47,8 +51,6 @@ define(`OSTYPE',
## helpful functions
define(`lower', `translit(`$1', `ABCDEFGHIJKLMNOPQRSTUVWXYZ', `abcdefghijklmnopqrstuvwx')')
define(`strcasecmp', `ifelse(lower($1), lower($2), `1', `0')')
## new FEATUREs
define(`_DNSBL_R_',`')
## access to further arguments in FEATURE/HACK
define(`_ACC_ARG_1_',`$1')
define(`_ACC_ARG_2_',`$2')
@ -102,14 +104,21 @@ dnl in MAILER.m4: _MODMF_(LMF,`LOCAL')
dnl ----------------------------------------
define(`MAILER',
`define(`_M_N_', `ifelse(`$2', `', `$1', `$2')')dnl
ifdef(_MAILER_`'_M_N_`'_, `dnl`'',
ifdef(`_MAILER_DEFINED_', `', `define(`_MAILER_DEFINED_', `1')')dnl
ifdef(_MAILER_`'_M_N_`'_,
`errprint(`*** ERROR: MAILER('_M_N_`) already included
')',
`define(_MAILER_`'_M_N_`'_, `')define(`_ARG_', `$2')define(`_ARGS_', `shift($@)')PUSHDIVERT(7)include(_CF_DIR_`'mailer/$1.m4)POPDIVERT`'')')
define(`DOMAIN', `PUSHDIVERT(-1)define(`_ARG_', `$2')include(_CF_DIR_`'domain/$1.m4)POPDIVERT`'')
define(`FEATURE', `PUSHDIVERT(-1)define(`_ARG_', `$2')define(`_ARGS_', `shift($@)')include(_CF_DIR_`'feature/$1.m4)POPDIVERT`'')
define(`FEATURE', `PUSHDIVERT(-1)ifdef(`_MAILER_DEFINED_',`errprint(`*** ERROR: FEATURE() should be before MAILER()
')')define(`_ARG_', `$2')define(`_ARGS_', `shift($@)')include(_CF_DIR_`'feature/$1.m4)POPDIVERT`'')
define(`HACK', `PUSHDIVERT(-1)define(`_ARG_', `$2')define(`_ARGS_', `shift($@)')include(_CF_DIR_`'hack/$1.m4)POPDIVERT`'')
define(`_DPO_',`')
define(`DAEMON_OPTIONS', `define(`_DPO_', defn(`_DPO_')
O DaemonPortOptions=`$1')')
define(`_CPO_',`')
define(`CLIENT_OPTIONS', `define(`_CPO_', defn(`_CPO_')
O ClientPortOptions=`$1')')
define(`_MAIL_FILTERS_', `')
define(`MAIL_FILTER', `define(`_MAIL_FILTERS_', defn(`_MAIL_FILTERS_')
X`'$1`, '`$2')')
@ -117,7 +126,10 @@ define(`INPUT_MAIL_FILTER', `MAIL_FILTER(`$1', `$2')
ifelse(defn(`confINPUT_MAIL_FILTERS')X, `X',
`define(`confINPUT_MAIL_FILTERS', $1)',
`define(`confINPUT_MAIL_FILTERS', defn(`confINPUT_MAIL_FILTERS')`, '`$1')')')
define(`CF_LEVEL', `9')dnl
define(`_QUEUE_GROUP_', `')
define(`QUEUE_GROUP', `define(`_QUEUE_GROUP_', defn(`_QUEUE_GROUP_')
Q`'$1`, '`$2')')
define(`CF_LEVEL', `10')dnl
define(`VERSIONID', ``##### $1 #####'')
define(`LOCAL_RULE_0', `divert(3)')
define(`LOCAL_RULE_1',
@ -140,6 +152,36 @@ define(`LOCAL_RULESETS',
`divert(9)
')
define(`LOCAL_SRV_FEATURES',
`define(`_LOCAL_SRV_FEATURES_')
ifdef(`_MAILER_DEFINED_',,`errprint(`*** WARNING: MAILER() should be before LOCAL_SRV_FEATURES
')')
divert(9)
SLocal_srv_features')
define(`LOCAL_TRY_TLS',
`define(`_LOCAL_TRY_TLS_')
ifdef(`_MAILER_DEFINED_',,`errprint(`*** WARNING: MAILER() should be before LOCAL_TRY_TLS
')')
divert(9)
SLocal_try_tls')
define(`LOCAL_TLS_RCPT',
`define(`_LOCAL_TLS_RCPT_')
ifdef(`_MAILER_DEFINED_',,`errprint(`*** WARNING: MAILER() should be before LOCAL_TLS_RCPT
')')
divert(9)
SLocal_tls_rcpt')
define(`LOCAL_TLS_CLIENT',
`define(`_LOCAL_TLS_CLIENT_')
ifdef(`_MAILER_DEFINED_',,`errprint(`*** WARNING: MAILER() should be before LOCAL_TLS_CLIENT
')')
divert(9)
SLocal_tls_client')
define(`LOCAL_TLS_SERVER',
`define(`_LOCAL_TLS_SERVER_')
ifdef(`_MAILER_DEFINED_',,`errprint(`*** WARNING: MAILER() should be before LOCAL_TLS_SERVER
')')
divert(9)
SLocal_tls_server')
define(`LOCAL_RULE_3', `divert(2)')
define(`LOCAL_CONFIG', `divert(6)')
define(`MAILER_DEFINITIONS', `divert(7)')
@ -150,17 +192,19 @@ define(`DOL', ``$'$1')
define(`SITECONFIG',
`CONCAT(D, $3, $2)
define(`_CLASS_$3_', `')dnl
ifelse($3, U, Cw$2 $2.UUCP, `dnl')
ifelse($3, U, C{w}$2 $2.UUCP, `dnl')
define(`SITE', `ifelse(CONCAT($'2`, $3), SU,
CONCAT(CY, $'1`),
CONCAT(C, $3, $'1`))')
sinclude(_CF_DIR_`'siteconfig/$1.m4)')
define(`EXPOSED_USER', `PUSHDIVERT(5)C{E}$1
POPDIVERT`'dnl`'')
ifdef(`_FFR_EXPOSED_USER_FILE', `define(`EXPOSED_USER_FILE', `PUSHDIVERT(5)F{E}$1
POPDIVERT`'dnl`'')', `dnl')
define(`EXPOSED_USER_FILE', `PUSHDIVERT(5)F{E}$1
POPDIVERT`'dnl`'')
define(`LOCAL_USER', `PUSHDIVERT(5)C{L}$1
POPDIVERT`'dnl`'')
define(`LOCAL_USER_FILE', `PUSHDIVERT(5)F{L}$1
POPDIVERT`'dnl`'')
define(`MASQUERADE_AS', `define(`MASQUERADE_NAME', $1)')
define(`MASQUERADE_DOMAIN', `PUSHDIVERT(5)C{M}$1
POPDIVERT`'dnl`'')
@ -168,6 +212,8 @@ define(`MASQUERADE_EXCEPTION', `PUSHDIVERT(5)C{N}$1
POPDIVERT`'dnl`'')
define(`MASQUERADE_DOMAIN_FILE', `PUSHDIVERT(5)F{M}$1
POPDIVERT`'dnl`'')
define(`MASQUERADE_EXCEPTION_FILE', `PUSHDIVERT(5)F{N}$1
POPDIVERT`'dnl`'')
define(`LOCAL_DOMAIN', `PUSHDIVERT(5)C{w}$1
POPDIVERT`'dnl`'')
define(`CANONIFY_DOMAIN', `PUSHDIVERT(5)C{Canonify}$1
@ -182,6 +228,10 @@ define(`LDAPROUTE_DOMAIN', `PUSHDIVERT(5)C{LDAPRoute}$1
POPDIVERT`'dnl`'')
define(`LDAPROUTE_DOMAIN_FILE', `PUSHDIVERT(5)F{LDAPRoute}$1
POPDIVERT`'dnl`'')
define(`LDAPROUTE_EQUIVALENT', `PUSHDIVERT(5)C{LDAPRouteEquiv}$1
POPDIVERT`'dnl`'')
define(`LDAPROUTE_EQUIVALENT_FILE', `PUSHDIVERT(5)F{LDAPRouteEquiv}$1
POPDIVERT`'dnl`'')
define(`VIRTUSER_DOMAIN', `PUSHDIVERT(5)C{VirtHost}$1
define(`_VIRTHOSTS_')
POPDIVERT`'dnl`'')
@ -192,7 +242,7 @@ define(`RELAY_DOMAIN', `PUSHDIVERT(5)C{R}$1
POPDIVERT`'dnl`'')
define(`RELAY_DOMAIN_FILE', `PUSHDIVERT(5)F{R}$1
POPDIVERT`'dnl`'')
define(`TRUST_AUTH_MECH', `PUSHDIVERT(5)C{TrustAuthMech}$1
define(`TRUST_AUTH_MECH', `_DEFIFNOT(`_USE_AUTH_',`1')PUSHDIVERT(5)C{TrustAuthMech}$1
POPDIVERT`'dnl`'')
define(`_OPTINS', `ifdef(`$1', `$2$1$3')')
@ -212,15 +262,15 @@ define(`confFROM_LINE', `From $g $d')
define(`confOPERATORS', `.:%@!^/[]+')
define(`confSMTP_LOGIN_MSG', `$j Sendmail $v/$Z; $b')
define(`_REC_AUTH_', `$.$?{auth_type}(authenticated')
define(`_REC_FULL_AUTH_', `$.$?{auth_type}(authenticated as ${auth_authen} $?{auth_author}for ${auth_author} $.with ${auth_type}')
define(`_REC_FULL_AUTH_', `$.$?{auth_type}(user=${auth_authen} $?{auth_author}author=${auth_author} $.mech=${auth_type}')
define(`_REC_HDR_', `$?sfrom $s $.$?_($?s$|from $.$_)')
define(`_REC_END_', `for $u; $|;
$.$b$?g
(envelope-from $g)$.')
define(`_REC_TLS_', `(using ${tls_version} with cipher ${cipher} (${cipher_bits} bits) verified ${verify})$.$?u')
define(`_REC_TLS_', `(version=${tls_version} cipher=${cipher} bits=${cipher_bits} verify=${verify})$.$?u')
define(`_REC_BY_', `$.by $j ($v/$Z)$?r with $r$. id $i$?{tls_version}')
define(`confRECEIVED_HEADER', `_REC_HDR_
_REC_AUTH_$?{auth_ssf} (${auth_ssf} bits)$.)
_REC_AUTH_$?{auth_ssf} bits=${auth_ssf}$.)
_REC_BY_
_REC_TLS_
_REC_END_')
@ -253,4 +303,4 @@ define(`confMILTER_MACROS_ENVRCPT', ``{rcpt_mailer}, {rcpt_host}, {rcpt_addr}'')
divert(0)dnl
VERSIONID(`$Id: cfhead.m4,v 8.76.4.16 2001/03/06 22:56:36 ca Exp $')
VERSIONID(`$Id: cfhead.m4,v 8.107 2001/07/22 03:25:37 ca Exp $')

View File

@ -1,4 +1,4 @@
.\" Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers.
.\" Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.
.\" All rights reserved.
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -8,20 +8,24 @@
.\" the sendmail distribution.
.\"
.\"
.\" $Id: mail.local.8,v 8.14.14.5 2000/12/29 18:12:16 gshapiro Exp $
.\" $Id: mail.local.8,v 8.23 2001/04/05 23:27:35 gshapiro Exp $
.\"
.\" $FreeBSD$
.\"
.TH MAIL.LOCAL 8 "$Date: 2000/12/29 18:12:16 $"
.TH MAIL.LOCAL 8 "$Date: 2001/04/05 23:27:35 $"
.SH NAME
mail.local
\- store mail in a mailbox
.SH SYNOPSIS
.B mail.local
.RB [ \-7 "] [" \-B "] [" \-b "] [" \-d "] [" \-l "] [" \-s "] [" \-f
.IR from "] "
.RB [ \-r
.IR from "] " "user ..."
.RB [ \-7 "] [" \-B "] [" \-b "] [" \-d "] [" \-D
.IR mbdb ]
.RB [ \-l "] [" \-s "] [" \-f
\fIfrom\fR|\fB\-r\fR
.IR from ]
.RB [ \-h
\fIfilename\fR ]
.I "user ..."
.SH DESCRIPTION
.B Mail.local
reads the standard input up to an end-of-file and appends it to each
@ -47,6 +51,12 @@ if a mailbox exceeds quota.
.TP
.B \-d
Specify this is a delivery (for backward compatibility).
This option has no effect.
.TP
.BI \-D " mbdb"
Specify the name of the mailbox database
which is used to look up local recipient names.
This option defaults to "pw", which means use getpwnam().
.TP
.BI \-f " from"
Specify the sender's name.
@ -63,6 +73,11 @@ status.
.TP
.BI \-r " from"
Specify the sender's name (for backward compatibility).
Same as \-f.
.TP
.BI \-h " filename"
Store incoming mail in \fIfilename\fR in the user's home directory instead
of a system mail spool directory.
.PP
Individual mail messages in the mailbox are delimited by an empty
line followed by a line beginning with the string ``From ''.
@ -100,10 +115,10 @@ Used to set the appropriate time zone on the timestamp.
temporary files
.TP
/var/mail/user
user's mailbox directory
user's default mailbox directory
.TP
/var/mail/user.lock
lock file for a user's mailbox
lock file for a user's default mailbox
.PD
.SH SEE ALSO
mail(1),

File diff suppressed because it is too large Load Diff

View File

@ -12,17 +12,15 @@
*
*/
#ifndef lint
static char copyright[] =
#include <sm/gen.h>
SM_IDSTR(copyright,
"@(#) Copyright (c) 1998-2001 Sendmail, 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";
#endif /* ! lint */
The Regents of the University of California. All rights reserved.\n")
#ifndef lint
static char id[] = "@(#)$Id: mailstats.c,v 8.53.16.13 2001/05/07 22:06:38 gshapiro Exp $";
#endif /* ! lint */
SM_IDSTR(id, "@(#)$Id: mailstats.c,v 8.95 2001/12/30 04:59:40 gshapiro Exp $")
/* $FreeBSD$ */
@ -37,6 +35,8 @@ static char id[] = "@(#)$Id: mailstats.c,v 8.53.16.13 2001/05/07 22:06:38 gshapi
#endif /* EX_OK */
#include <sysexits.h>
#include <sm/errstring.h>
#include <sm/limits.h>
#include <sendmail/sendmail.h>
#include <sendmail/mailstats.h>
#include <sendmail/pathnames.h>
@ -44,7 +44,6 @@ static char id[] = "@(#)$Id: mailstats.c,v 8.53.16.13 2001/05/07 22:06:38 gshapi
#define MNAMELEN 20 /* max length of mailer name */
int
main(argc, argv)
int argc;
@ -56,11 +55,15 @@ main(argc, argv)
int ch, fd;
char *sfile;
char *cfile;
FILE *cfp;
SM_FILE_T *cfp;
bool mnames;
bool progmode;
bool trunc;
long frmsgs = 0, frbytes = 0, tomsgs = 0, tobytes = 0, rejmsgs = 0;
long dismsgs = 0;
#if _FFR_QUARANTINE
long quarmsgs = 0;
#endif /* _FFR_QUARANTINE */
time_t now;
char mtable[MAXMAILERS][MNAMELEN + 1];
char sfilebuf[MAXLINE];
@ -70,15 +73,19 @@ main(argc, argv)
extern char *optarg;
extern int optind;
cfile = _PATH_SENDMAILCF;
cfile = getcfname(0, 0, SM_GET_SENDMAIL_CF, NULL);
sfile = NULL;
mnames = TRUE;
progmode = FALSE;
while ((ch = getopt(argc, argv, "C:f:op")) != -1)
mnames = true;
progmode = false;
trunc = false;
while ((ch = getopt(argc, argv, "cC:f:opP")) != -1)
{
switch (ch)
{
case 'c':
cfile = getcfname(0, 0, SM_GET_SUBMIT_CF, NULL);
break;
case 'C':
cfile = optarg;
break;
@ -88,18 +95,22 @@ main(argc, argv)
break;
case 'o':
mnames = FALSE;
mnames = false;
break;
case 'p':
progmode = TRUE;
trunc = true;
/* FALLTHROUGH */
case 'P':
progmode = true;
break;
case '?':
default:
usage:
(void) fputs("usage: mailstats [-C cffile] [-f stfile] [-o] [-p]\n",
stderr);
(void) sm_io_fputs(smioerr, SM_TIME_DEFAULT,
"usage: mailstats [-C cffile] [-P] [-f stfile] [-o] [-p]\n");
exit(EX_USAGE);
}
}
@ -109,21 +120,22 @@ main(argc, argv)
if (argc != 0)
goto usage;
if ((cfp = fopen(cfile, "r")) == NULL)
if ((cfp = sm_io_open(SmFtStdio, SM_TIME_DEFAULT, cfile, SM_IO_RDONLY,
NULL)) == NULL)
{
save_errno = errno;
fprintf(stderr, "mailstats: ");
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, "mailstats: ");
errno = save_errno;
perror(cfile);
sm_perror(cfile);
exit(EX_NOINPUT);
}
mno = 0;
(void) strlcpy(mtable[mno++], "prog", MNAMELEN + 1);
(void) strlcpy(mtable[mno++], "*file*", MNAMELEN + 1);
(void) strlcpy(mtable[mno++], "*include*", MNAMELEN + 1);
(void) sm_strlcpy(mtable[mno++], "prog", MNAMELEN + 1);
(void) sm_strlcpy(mtable[mno++], "*file*", MNAMELEN + 1);
(void) sm_strlcpy(mtable[mno++], "*include*", MNAMELEN + 1);
while (fgets(buf, sizeof(buf), cfp) != NULL)
while (sm_io_fgets(cfp, SM_TIME_DEFAULT, buf, sizeof(buf)) != NULL)
{
register char *b;
char *s;
@ -136,7 +148,7 @@ main(argc, argv)
break;
case 'O': /* option -- see if .st file */
if (strncasecmp(b, " StatusFile", 11) == 0 &&
if (sm_strncasecmp(b, " StatusFile", 11) == 0 &&
!(isascii(b[11]) && isalnum(b[11])))
{
/* new form -- find value */
@ -153,12 +165,12 @@ main(argc, argv)
}
/* this is the S or StatusFile option -- save it */
if (strlcpy(sfilebuf, b, sizeof sfilebuf) >=
if (sm_strlcpy(sfilebuf, b, sizeof sfilebuf) >=
sizeof sfilebuf)
{
fprintf(stderr,
"StatusFile filename too long: %.30s...\n",
b);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"StatusFile filename too long: %.30s...\n",
b);
exit(EX_CONFIG);
}
b = strchr(sfilebuf, '#');
@ -178,9 +190,9 @@ main(argc, argv)
if (mno >= MAXMAILERS)
{
fprintf(stderr,
"Too many mailers defined, %d max.\n",
MAXMAILERS);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"Too many mailers defined, %d max.\n",
MAXMAILERS);
exit(EX_SOFTWARE);
}
m = mtable[mno];
@ -197,13 +209,14 @@ main(argc, argv)
if (i == mno)
mno++;
}
(void) fclose(cfp);
(void) sm_io_close(cfp, SM_TIME_DEFAULT);
for (; mno < MAXMAILERS; mno++)
mtable[mno][0]='\0';
mtable[mno][0] = '\0';
if (sfile == NULL)
{
fprintf(stderr, "mailstats: no statistics file located\n");
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"mailstats: no statistics file located\n");
exit (EX_OSFILE);
}
@ -211,9 +224,9 @@ main(argc, argv)
if ((fd < 0) || (i = read(fd, &stats, sizeof stats)) < 0)
{
save_errno = errno;
(void) fputs("mailstats: ", stderr);
(void) sm_io_fputs(smioerr, SM_TIME_DEFAULT, "mailstats: ");
errno = save_errno;
perror(sfile);
sm_perror(sfile);
exit(EX_NOINPUT);
}
if (i == 0)
@ -222,9 +235,10 @@ main(argc, argv)
if ((i = read(fd, &stats, sizeof stats)) < 0)
{
save_errno = errno;
(void) fputs("mailstats: ", stderr);
(void) sm_io_fputs(smioerr, SM_TIME_DEFAULT,
"mailstats: ");
errno = save_errno;
perror(sfile);
sm_perror(sfile);
exit(EX_NOINPUT);
}
else if (i == 0)
@ -237,21 +251,24 @@ main(argc, argv)
{
if (stats.stat_magic != STAT_MAGIC)
{
fprintf(stderr,
"mailstats: incorrect magic number in %s\n",
sfile);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"mailstats: incorrect magic number in %s\n",
sfile);
exit(EX_OSERR);
}
else if (stats.stat_version != STAT_VERSION)
{
fprintf(stderr,
"mailstats version (%d) incompatible with %s version (%d)\n",
STAT_VERSION, sfile, stats.stat_version);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"mailstats version (%d) incompatible with %s version (%d)\n",
STAT_VERSION, sfile,
stats.stat_version);
exit(EX_OSERR);
}
else if (i != sizeof stats || stats.stat_size != sizeof(stats))
{
(void) fputs("mailstats: file size changed.\n", stderr);
(void) sm_io_fputs(smioerr, SM_TIME_DEFAULT,
"mailstats: file size changed.\n");
exit(EX_OSERR);
}
}
@ -259,17 +276,28 @@ main(argc, argv)
if (progmode)
{
(void) time(&now);
printf("%ld %ld\n", (long) stats.stat_itime, (long) now);
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "%ld %ld\n",
(long) stats.stat_itime, (long) now);
}
else
{
printf("Statistics from %s", ctime(&stats.stat_itime));
printf(" M msgsfr bytes_from msgsto bytes_to msgsrej msgsdis%s\n",
mnames ? " Mailer" : "");
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
"Statistics from %s",
ctime(&stats.stat_itime));
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
" M msgsfr bytes_from msgsto bytes_to msgsrej msgsdis");
#if _FFR_QUARANTINE
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, " msgsqur");
#endif /* _FFR_QUARANTINE */
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "%s\n",
mnames ? " Mailer" : "");
}
for (i = 0; i < MAXMAILERS; i++)
{
if (stats.stat_nf[i] || stats.stat_nt[i] ||
#if _FFR_QUARANTINE
stats.stat_nq[i] ||
#endif /* _FFR_QUARANTINE */
stats.stat_nr[i] || stats.stat_nd[i])
{
char *format;
@ -278,39 +306,78 @@ main(argc, argv)
format = "%2d %8ld %10ld %8ld %10ld %6ld %6ld";
else
format = "%2d %8ld %10ldK %8ld %10ldK %6ld %6ld";
printf(format, i,
stats.stat_nf[i], stats.stat_bf[i],
stats.stat_nt[i], stats.stat_bt[i],
stats.stat_nr[i], stats.stat_nd[i]);
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
format, i,
stats.stat_nf[i],
stats.stat_bf[i],
stats.stat_nt[i],
stats.stat_bt[i],
stats.stat_nr[i],
stats.stat_nd[i]);
#if _FFR_QUARANTINE
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
" %6ld", stats.stat_nq[i]);
#endif /* _FFR_QUARANTINE */
if (mnames)
printf(" %s", mtable[i]);
printf("\n");
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
" %s",
mtable[i]);
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "\n");
frmsgs += stats.stat_nf[i];
frbytes += stats.stat_bf[i];
tomsgs += stats.stat_nt[i];
tobytes += stats.stat_bt[i];
rejmsgs += stats.stat_nr[i];
dismsgs += stats.stat_nd[i];
#if _FFR_QUARANTINE
quarmsgs += stats.stat_nq[i];
#endif /* _FFR_QUARANTINE */
}
}
if (progmode)
{
printf(" T %8ld %10ld %8ld %10ld %6ld %6ld\n",
frmsgs, frbytes, tomsgs, tobytes, rejmsgs, dismsgs);
printf(" C %8ld %8ld %6ld\n",
stats.stat_cf, stats.stat_ct, stats.stat_cr);
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
" T %8ld %10ld %8ld %10ld %6ld %6ld",
frmsgs, frbytes, tomsgs, tobytes, rejmsgs,
dismsgs);
#if _FFR_QUARANTINE
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
" %6ld", quarmsgs);
#endif /* _FFR_QUARANTINE */
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "\n");
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
" C %8ld %8ld %6ld\n",
stats.stat_cf, stats.stat_ct,
stats.stat_cr);
(void) close(fd);
fd = open(sfile, O_RDWR | O_TRUNC);
if (fd >= 0)
(void) close(fd);
if (trunc)
{
fd = open(sfile, O_RDWR | O_TRUNC);
if (fd >= 0)
(void) close(fd);
}
}
else
{
printf("=============================================================\n");
printf(" T %8ld %10ldK %8ld %10ldK %6ld %6ld\n",
frmsgs, frbytes, tomsgs, tobytes, rejmsgs, dismsgs);
printf(" C %8ld %10s %8ld %10s %6ld\n",
stats.stat_cf, "", stats.stat_ct, "", stats.stat_cr);
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
"=============================================================");
#if _FFR_QUARANTINE
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "========");
#endif /* _FFR_QUARANTINE */
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "\n");
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
" T %8ld %10ldK %8ld %10ldK %6ld %6ld",
frmsgs, frbytes, tomsgs, tobytes, rejmsgs,
dismsgs);
#if _FFR_QUARANTINE
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
" %6ld", quarmsgs);
#endif /* _FFR_QUARANTINE */
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "\n");
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
" C %8ld %10s %8ld %10s %6ld\n",
stats.stat_cf, "", stats.stat_ct, "",
stats.stat_cr);
}
exit(EX_OK);
/* NOTREACHED */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers.
* Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1992 Eric P. Allman. All rights reserved.
* Copyright (c) 1992, 1993
@ -11,18 +11,16 @@
*
*/
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers.\n\
#include <sm/gen.h>
SM_IDSTR(copyright,
"@(#) Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.\n\
All rights reserved.\n\
Copyright (c) 1992 Eric P. Allman. All rights reserved.\n\
Copyright (c) 1992, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* ! lint */
The Regents of the University of California. All rights reserved.\n")
#ifndef lint
static char id[] = "@(#)$Id: makemap.c,v 8.135.4.13 2000/10/05 23:00:50 gshapiro Exp $";
#endif /* ! lint */
SM_IDSTR(id, "@(#)$Id: makemap.c,v 8.175 2001/12/28 22:44:01 ca Exp $")
/* $FreeBSD$ */
@ -48,31 +46,24 @@ uid_t RunAsUid;
uid_t RunAsGid;
char *RunAsUserName;
int Verbose = 2;
bool DontInitGroups = FALSE;
bool DontInitGroups = false;
uid_t TrustedUid = 0;
BITMAP256 DontBlameSendmail;
#define BUFSIZE 1024
#if _FFR_DELIM
# define ISSEP(c) ((sep == '\0' && isascii(c) && isspace(c)) || (c) == sep)
#else /* _FFR_DELIM */
# define ISSEP(c) (isascii(c) && isspace(c))
#endif /* _FFR_DELIM */
#define ISSEP(c) (sep == '\0' ? isascii(c) && isspace(c) : (c) == sep)
static void
usage(progname)
char *progname;
{
fprintf(stderr,
"Usage: %s [-C cffile] [-N] [-c cachesize] [-d] [-e] [-f] [-l] [-o] [-r] [-s] %s[-u] [-v] type mapname\n",
progname,
#if _FFR_DELIM
"[-t delimiter] "
#else /* _FFR_DELIM */
""
#endif /* _FFR_DELIM */
);
/* XXX break the usage output into multiple lines? it's too long */
sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"Usage: %s [-C cffile] [-N] [-c cachesize] [-d] [-e] [-f] [-l] [-o] [-r] [-s] [-t delimiter] [-u] [-v] type mapname\n",
progname);
#if _FFR_COMMENT_CHAR
/* add -D comment-char */
#endif /* _FFR_COMMENT_CHAR */
exit(EX_USAGE);
}
@ -83,21 +74,20 @@ main(argc, argv)
{
char *progname;
char *cfile;
bool inclnull = FALSE;
bool notrunc = FALSE;
bool allowreplace = FALSE;
bool allowempty = FALSE;
bool verbose = FALSE;
bool foldcase = TRUE;
bool unmake = FALSE;
#if _FFR_DELIM
bool inclnull = false;
bool notrunc = false;
bool allowreplace = false;
bool allowempty = false;
bool verbose = false;
bool foldcase = true;
bool unmake = false;
char sep = '\0';
#endif /* _FFR_DELIM */
char comment = '#';
int exitstat;
int opt;
char *typename = NULL;
char *mapname = NULL;
int lineno;
unsigned int lineno;
int st;
int mode;
int smode;
@ -111,7 +101,7 @@ main(argc, argv)
SMDB_USER_INFO user_info;
char ibuf[BUFSIZE];
#if HASFCHOWN
FILE *cfp;
SM_FILE_T *cfp;
char buf[MAXLINE];
#endif /* HASFCHOWN */
static char rnamebuf[MAXNAME]; /* holds RealUserName */
@ -126,25 +116,24 @@ main(argc, argv)
progname++;
else
progname = argv[0];
cfile = _PATH_SENDMAILCF;
cfile = getcfname(0, 0, SM_GET_SENDMAIL_CF, NULL);
clrbitmap(DontBlameSendmail);
RunAsUid = RealUid = getuid();
RunAsGid = RealGid = getgid();
pw = getpwuid(RealUid);
if (pw != NULL)
(void) strlcpy(rnamebuf, pw->pw_name, sizeof rnamebuf);
(void) sm_strlcpy(rnamebuf, pw->pw_name, sizeof rnamebuf);
else
(void) snprintf(rnamebuf, sizeof rnamebuf, "Unknown UID %d",
(int) RealUid);
(void) sm_snprintf(rnamebuf, sizeof rnamebuf,
"Unknown UID %d", (int) RealUid);
RunAsUserName = RealUserName = rnamebuf;
user_info.smdbu_id = RunAsUid;
user_info.smdbu_group_id = RunAsGid;
(void) strlcpy(user_info.smdbu_name, RunAsUserName,
(void) sm_strlcpy(user_info.smdbu_name, RunAsUserName,
SMDB_MAX_USER_NAME_LEN);
#define OPTIONS "C:Nc:t:deflorsuv"
#define OPTIONS "C:D:Nc:deflorst:uv"
while ((opt = getopt(argc, argv, OPTIONS)) != -1)
{
switch (opt)
@ -154,7 +143,7 @@ main(argc, argv)
break;
case 'N':
inclnull = TRUE;
inclnull = true;
break;
case 'c':
@ -162,28 +151,34 @@ main(argc, argv)
break;
case 'd':
params.smdbp_allow_dup = TRUE;
params.smdbp_allow_dup = true;
break;
case 'e':
allowempty = TRUE;
allowempty = true;
break;
case 'f':
foldcase = FALSE;
foldcase = false;
break;
#if _FFR_COMMENT_CHAR
case 'D':
comment = *optarg;
break;
#endif /* _FFR_COMMENT_CHAR */
case 'l':
smdb_print_available_types();
exit(EX_OK);
break;
case 'o':
notrunc = TRUE;
notrunc = true;
break;
case 'r':
allowreplace = TRUE;
allowreplace = true;
break;
case 's':
@ -193,23 +188,22 @@ main(argc, argv)
setbitn(DBS_LINKEDMAPINWRITABLEDIR, DontBlameSendmail);
break;
#if _FFR_DELIM
case 't':
if (optarg == NULL || *optarg == '\0')
{
fprintf(stderr, "Invalid separator\n");
sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"Invalid separator\n");
break;
}
sep = *optarg;
break;
#endif /* _FFR_DELIM */
case 'u':
unmake = TRUE;
unmake = true;
break;
case 'v':
verbose = TRUE;
verbose = true;
break;
default:
@ -240,12 +234,14 @@ main(argc, argv)
#if HASFCHOWN
/* Find TrustedUser value in sendmail.cf */
if ((cfp = fopen(cfile, "r")) == NULL)
if ((cfp = sm_io_open(SmFtStdio, SM_TIME_DEFAULT, cfile, SM_IO_RDONLY,
NULL)) == NULL)
{
fprintf(stderr, "makemap: %s: %s", cfile, errstring(errno));
sm_io_fprintf(smioerr, SM_TIME_DEFAULT, "makemap: %s: %s",
cfile, sm_errstring(errno));
exit(EX_NOINPUT);
}
while (fgets(buf, sizeof(buf), cfp) != NULL)
while (sm_io_fgets(cfp, SM_TIME_DEFAULT, buf, sizeof(buf)) != NULL)
{
register char *b;
@ -271,8 +267,9 @@ main(argc, argv)
TrustedUid = 0;
pw = getpwnam(b);
if (pw == NULL)
fprintf(stderr,
"TrustedUser: unknown user %s\n", b);
(void) sm_io_fprintf(smioerr,
SM_TIME_DEFAULT,
"TrustedUser: unknown user %s\n", b);
else
TrustedUid = pw->pw_uid;
}
@ -280,8 +277,9 @@ main(argc, argv)
# ifdef UID_MAX
if (TrustedUid > UID_MAX)
{
fprintf(stderr,
"TrustedUser: uid value (%ld) > UID_MAX (%ld)",
(void) sm_io_fprintf(smioerr,
SM_TIME_DEFAULT,
"TrustedUser: uid value (%ld) > UID_MAX (%ld)",
(long) TrustedUid,
(long) UID_MAX);
TrustedUid = 0;
@ -295,7 +293,7 @@ main(argc, argv)
continue;
}
}
(void) fclose(cfp);
(void) sm_io_close(cfp, SM_TIME_DEFAULT);
#endif /* HASFCHOWN */
if (!params.smdbp_allow_dup && !allowreplace)
@ -327,13 +325,14 @@ main(argc, argv)
if (errno == SMDBE_UNSUPPORTED_DB_TYPE &&
(hint = smdb_db_definition(typename)) != NULL)
fprintf(stderr,
"%s: Need to recompile with -D%s for %s support\n",
progname, hint, typename);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: Need to recompile with -D%s for %s support\n",
progname, hint, typename);
else
fprintf(stderr,
"%s: error opening type %s map %s: %s\n",
progname, typename, mapname, errstring(errno));
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: error opening type %s map %s: %s\n",
progname, typename, mapname,
sm_errstring(errno));
exit(EX_CANTCREAT);
}
@ -344,9 +343,9 @@ main(argc, argv)
errno = database->smdb_set_owner(database, TrustedUid, -1);
if (errno != SMDBE_OK)
{
fprintf(stderr,
"WARNING: ownership change on %s failed %s",
mapname, errstring(errno));
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"WARNING: ownership change on %s failed %s",
mapname, sm_errstring(errno));
}
}
@ -361,9 +360,9 @@ main(argc, argv)
if (errno != SMDBE_OK)
{
fprintf(stderr,
"%s: cannot make cursor for type %s map %s\n",
progname, typename, mapname);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: cannot make cursor for type %s map %s\n",
progname, typename, mapname);
exit(EX_SOFTWARE);
}
@ -377,11 +376,12 @@ main(argc, argv)
if (errno != SMDBE_OK)
break;
printf("%.*s\t%.*s\n",
(int) db_key.size,
(char *) db_key.data,
(int) db_val.size,
(char *)db_val.data);
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
"%.*s\t%.*s\n",
(int) db_key.size,
(char *) db_key.data,
(int) db_val.size,
(char *)db_val.data);
}
(void) cursor->smdbc_close(cursor);
@ -389,7 +389,8 @@ main(argc, argv)
else
{
lineno = 0;
while (fgets(ibuf, sizeof ibuf, stdin) != NULL)
while (sm_io_fgets(smioin, SM_TIME_DEFAULT, ibuf, sizeof ibuf)
!= NULL)
{
register char *p;
@ -402,26 +403,23 @@ main(argc, argv)
p = strchr(ibuf, '\n');
if (p != NULL)
*p = '\0';
else if (!feof(stdin))
else if (!sm_io_eof(smioin))
{
fprintf(stderr,
"%s: %s: line %d: line too long (%ld bytes max)\n",
progname, mapname, lineno, (long) sizeof ibuf);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: %s: line %u: line too long (%ld bytes max)\n",
progname, mapname, lineno,
(long) sizeof ibuf);
exitstat = EX_DATAERR;
continue;
}
if (ibuf[0] == '\0' || ibuf[0] == '#')
if (ibuf[0] == '\0' || ibuf[0] == comment)
continue;
if (
#if _FFR_DELIM
sep == '\0' &&
#endif /* _FFR_DELIM */
isascii(ibuf[0]) && isspace(ibuf[0]))
if (sep == '\0' && isascii(ibuf[0]) && isspace(ibuf[0]))
{
fprintf(stderr,
"%s: %s: line %d: syntax error (leading space)\n",
progname, mapname, lineno);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: %s: line %u: syntax error (leading space)\n",
progname, mapname, lineno);
exitstat = EX_DATAERR;
continue;
}
@ -441,14 +439,14 @@ main(argc, argv)
if (*p != '\0')
*p++ = '\0';
while (ISSEP(*p))
while (*p != '\0' && ISSEP(*p))
p++;
if (!allowempty && *p == '\0')
{
fprintf(stderr,
"%s: %s: line %d: no RHS for LHS %s\n",
progname, mapname, lineno,
(char *) db_key.data);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: %s: line %u: no RHS for LHS %s\n",
progname, mapname, lineno,
(char *) db_key.data);
exitstat = EX_DATAERR;
continue;
}
@ -464,9 +462,10 @@ main(argc, argv)
if (verbose)
{
printf("key=`%s', val=`%s'\n",
(char *) db_key.data,
(char *) db_val.data);
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
"key=`%s', val=`%s'\n",
(char *) db_key.data,
(char *) db_val.data);
}
errno = database->smdb_put(database, &db_key, &db_val,
@ -488,19 +487,20 @@ main(argc, argv)
if (st < 0)
{
fprintf(stderr,
"%s: %s: line %d: key %s: put error: %s\n",
progname, mapname, lineno,
(char *) db_key.data,
errstring(errno));
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: %s: line %u: key %s: put error: %s\n",
progname, mapname, lineno,
(char *) db_key.data,
sm_errstring(errno));
exitstat = EX_IOERR;
}
else if (st > 0)
{
fprintf(stderr,
"%s: %s: line %d: key %s: duplicate key\n",
progname, mapname,
lineno, (char *) db_key.data);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: %s: line %u: key %s: duplicate key\n",
progname, mapname,
lineno,
(char *) db_key.data);
exitstat = EX_DATAERR;
}
}
@ -513,61 +513,15 @@ main(argc, argv)
errno = database->smdb_close(database);
if (errno != SMDBE_OK)
{
fprintf(stderr, "%s: close(%s): %s\n",
progname, mapname, errstring(errno));
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: close(%s): %s\n",
progname, mapname, sm_errstring(errno));
exitstat = EX_IOERR;
}
smdb_free_database(database);
exit(exitstat);
/* NOTREACHED */
return exitstat;
}
/*VARARGS1*/
void
#ifdef __STDC__
message(const char *msg, ...)
#else /* __STDC__ */
message(msg, va_alist)
const char *msg;
va_dcl
#endif /* __STDC__ */
{
const char *m;
VA_LOCAL_DECL
m = msg;
if (isascii(m[0]) && isdigit(m[0]) &&
isascii(m[1]) && isdigit(m[1]) &&
isascii(m[2]) && isdigit(m[2]) && m[3] == ' ')
m += 4;
VA_START(msg);
(void) vfprintf(stderr, m, ap);
VA_END;
(void) fprintf(stderr, "\n");
}
/*VARARGS1*/
void
#ifdef __STDC__
syserr(const char *msg, ...)
#else /* __STDC__ */
syserr(msg, va_alist)
const char *msg;
va_dcl
#endif /* __STDC__ */
{
const char *m;
VA_LOCAL_DECL
m = msg;
if (isascii(m[0]) && isdigit(m[0]) &&
isascii(m[1]) && isdigit(m[1]) &&
isascii(m[2]) && isdigit(m[2]) && m[3] == ' ')
m += 4;
VA_START(msg);
(void) vfprintf(stderr, m, ap);
VA_END;
(void) fprintf(stderr, "\n");
}

View File

@ -11,18 +11,16 @@
*
*/
#ifndef lint
static char copyright[] =
#include <sm/gen.h>
SM_IDSTR(copyright,
"@(#) Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.\n\
All rights reserved.\n\
Copyright (c) 1983 Eric P. Allman. All rights reserved.\n\
Copyright (c) 1988, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* ! lint */
The Regents of the University of California. All rights reserved.\n")
#ifndef lint
static char id[] = "@(#)$Id: praliases.c,v 8.59.4.19 2001/02/28 02:37:57 ca Exp $";
#endif /* ! lint */
SM_IDSTR(id, "@(#)$Id: praliases.c,v 8.93 2001/09/11 04:05:07 gshapiro Exp $")
/* $FreeBSD$ */
@ -52,12 +50,10 @@ uid_t RunAsUid;
uid_t RunAsGid;
char *RunAsUserName;
int Verbose = 2;
bool DontInitGroups = FALSE;
bool DontInitGroups = false;
uid_t TrustedUid = 0;
BITMAP256 DontBlameSendmail;
extern void syserr __P((const char *, ...));
# define DELIMITERS " ,/"
# define PATH_SEPARATOR ':'
@ -68,7 +64,7 @@ main(argc, argv)
{
char *cfile;
char *filename = NULL;
FILE *cfp;
SM_FILE_T *cfp;
int ch;
char afilebuf[MAXLINE];
char buf[MAXLINE];
@ -77,7 +73,6 @@ main(argc, argv)
extern char *optarg;
extern int optind;
clrbitmap(DontBlameSendmail);
RunAsUid = RealUid = getuid();
RunAsGid = RealGid = getgid();
@ -86,14 +81,14 @@ main(argc, argv)
{
if (strlen(pw->pw_name) > MAXNAME - 1)
pw->pw_name[MAXNAME] = 0;
snprintf(rnamebuf, sizeof rnamebuf, "%s", pw->pw_name);
sm_snprintf(rnamebuf, sizeof rnamebuf, "%s", pw->pw_name);
}
else
(void) snprintf(rnamebuf, sizeof rnamebuf, "Unknown UID %d",
(int) RealUid);
(void) sm_snprintf(rnamebuf, sizeof rnamebuf,
"Unknown UID %d", (int) RealUid);
RunAsUserName = RealUserName = rnamebuf;
cfile = _PATH_SENDMAILCF;
cfile = getcfname(0, 0, SM_GET_SENDMAIL_CF, NULL);
while ((ch = getopt(argc, argv, "C:f:")) != -1)
{
switch ((char)ch) {
@ -105,8 +100,8 @@ main(argc, argv)
break;
case '?':
default:
(void)fprintf(stderr,
"usage: praliases [-C cffile] [-f aliasfile]\n");
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"usage: praliases [-C cffile] [-f aliasfile]\n");
exit(EX_USAGE);
}
}
@ -119,14 +114,16 @@ main(argc, argv)
exit(EX_OK);
}
if ((cfp = fopen(cfile, "r")) == NULL)
if ((cfp = sm_io_open(SmFtStdio, SM_TIME_DEFAULT, cfile, SM_IO_RDONLY,
NULL)) == NULL)
{
fprintf(stderr, "praliases: %s: %s\n",
cfile, errstring(errno));
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"praliases: %s: %s\n", cfile,
sm_errstring(errno));
exit(EX_NOINPUT);
}
while (fgets(buf, sizeof(buf), cfp) != NULL)
while (sm_io_fgets(cfp, SM_TIME_DEFAULT, buf, sizeof(buf)) != NULL)
{
register char *b, *p;
@ -138,7 +135,7 @@ main(argc, argv)
switch (*b++)
{
case 'O': /* option -- see if alias file */
if (strncasecmp(b, " AliasFile", 10) == 0 &&
if (sm_strncasecmp(b, " AliasFile", 10) == 0 &&
!(isascii(b[10]) && isalnum(b[10])))
{
/* new form -- find value */
@ -155,13 +152,13 @@ main(argc, argv)
}
/* this is the A or AliasFile option -- save it */
if (strlcpy(afilebuf, b, sizeof afilebuf) >=
if (sm_strlcpy(afilebuf, b, sizeof afilebuf) >=
sizeof afilebuf)
{
fprintf(stderr,
"praliases: AliasFile filename too long: %.30s\n",
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"praliases: AliasFile filename too long: %.30s\n",
b);
(void) fclose(cfp);
(void) sm_io_close(cfp, SM_TIME_DEFAULT);
exit(EX_CONFIG);
}
b = afilebuf;
@ -179,7 +176,7 @@ main(argc, argv)
/* find end of spec */
if (p != NULL)
{
bool quoted = FALSE;
bool quoted = false;
for (; *p != '\0'; p++)
{
@ -226,7 +223,7 @@ main(argc, argv)
continue;
}
}
(void) fclose(cfp);
(void) sm_io_close(cfp, SM_TIME_DEFAULT);
exit(EX_OK);
/* NOTREACHED */
return EX_OK;
@ -282,8 +279,8 @@ praliases(filename, argc, argv)
strcmp(db_type, "btree") != 0 &&
strcmp(db_type, "dbm") != 0)
{
fprintf(stderr,
"praliases: Skipping non-file based alias type %s\n",
sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"praliases: Skipping non-file based alias type %s\n",
db_type);
return;
}
@ -293,8 +290,8 @@ praliases(filename, argc, argv)
{
if (colon != NULL)
*colon = ':';
fprintf(stderr, "praliases: illegal alias specification: %s\n",
filename);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"praliases: illegal alias specification: %s\n", filename);
goto fatal;
}
@ -303,14 +300,16 @@ praliases(filename, argc, argv)
user_info.smdbu_id = RunAsUid;
user_info.smdbu_group_id = RunAsGid;
strlcpy(user_info.smdbu_name, RunAsUserName, SMDB_MAX_USER_NAME_LEN);
(void) sm_strlcpy(user_info.smdbu_name, RunAsUserName,
SMDB_MAX_USER_NAME_LEN);
result = smdb_open_database(&database, db_name, O_RDONLY, 0,
SFF_ROOTOK, db_type, &user_info, &params);
if (result != SMDBE_OK)
{
fprintf(stderr, "praliases: %s: open: %s\n",
db_name, errstring(result));
sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"praliases: %s: open: %s\n",
db_name, sm_errstring(result));
goto fatal;
}
@ -322,8 +321,9 @@ praliases(filename, argc, argv)
result = database->smdb_cursor(database, &cursor, 0);
if (result != SMDBE_OK)
{
fprintf(stderr, "praliases: %s: set cursor: %s\n",
db_name, errstring(result));
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"praliases: %s: set cursor: %s\n", db_name,
sm_errstring(result));
goto fatal;
}
@ -342,18 +342,19 @@ praliases(filename, argc, argv)
continue;
#endif /* 0 */
printf("%.*s:%.*s\n",
(int) db_key.size,
(char *) db_key.data,
(int) db_value.size,
(char *) db_value.data);
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
"%.*s:%.*s\n",
(int) db_key.size,
(char *) db_key.data,
(int) db_value.size,
(char *) db_value.data);
}
if (result != SMDBE_OK && result != SMDBE_LAST_ENTRY)
{
fprintf(stderr,
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"praliases: %s: get value at cursor: %s\n",
db_name, errstring(result));
db_name, sm_errstring(result));
goto fatal;
}
}
@ -374,14 +375,17 @@ praliases(filename, argc, argv)
}
if (get_res == SMDBE_OK)
{
printf("%.*s:%.*s\n",
(int) db_key.size,
(char *) db_key.data,
(int) db_value.size,
(char *) db_value.data);
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
"%.*s:%.*s\n",
(int) db_key.size,
(char *) db_key.data,
(int) db_value.size,
(char *) db_value.data);
}
else
printf("%s: No such key\n", (char *) db_key.data);
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
"%s: No such key\n",
(char *)db_key.data);
}
fatal:
@ -393,51 +397,3 @@ praliases(filename, argc, argv)
*colon = ':';
return;
}
/*VARARGS1*/
void
#ifdef __STDC__
message(const char *msg, ...)
#else /* __STDC__ */
message(msg, va_alist)
const char *msg;
va_dcl
#endif /* __STDC__ */
{
const char *m;
VA_LOCAL_DECL
m = msg;
if (isascii(m[0]) && isdigit(m[0]) &&
isascii(m[1]) && isdigit(m[1]) &&
isascii(m[2]) && isdigit(m[2]) && m[3] == ' ')
m += 4;
VA_START(msg);
(void) vfprintf(stderr, m, ap);
VA_END;
(void) fprintf(stderr, "\n");
}
/*VARARGS1*/
void
#ifdef __STDC__
syserr(const char *msg, ...)
#else /* __STDC__ */
syserr(msg, va_alist)
const char *msg;
va_dcl
#endif /* __STDC__ */
{
const char *m;
VA_LOCAL_DECL
m = msg;
if (isascii(m[0]) && isdigit(m[0]) &&
isascii(m[1]) && isdigit(m[1]) &&
isascii(m[2]) && isdigit(m[2]) && m[3] == ' ')
m += 4;
VA_START(msg);
(void) vfprintf(stderr, m, ap);
VA_END;
(void) fprintf(stderr, "\n");
}

View File

@ -10,17 +10,15 @@
*
*/
#ifndef lint
static char copyright[] =
#include <sm/gen.h>
SM_IDSTR(copyright,
"@(#) Copyright (c) 1998-2001 Sendmail, 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";
#endif /* ! lint */
The Regents of the University of California. All rights reserved.\n")
#ifndef lint
static char id[] = "@(#)$Id: rmail.c,v 8.39.4.12 2001/05/07 22:06:39 gshapiro Exp $";
#endif /* ! lint */
SM_IDSTR(id, "@(#)$Id: rmail.c,v 8.61 2001/09/18 21:45:29 gshapiro Exp $")
/* $FreeBSD$ */
@ -56,69 +54,18 @@ static char id[] = "@(#)$Id: rmail.c,v 8.39.4.12 2001/05/07 22:06:39 gshapiro Ex
#include <ctype.h>
#include <fcntl.h>
#ifdef BSD4_4
# define FORK vfork
# include <paths.h>
#else /* BSD4_4 */
# define FORK fork
# ifndef _PATH_SENDMAIL
# define _PATH_SENDMAIL "/usr/lib/sendmail"
# endif /* ! _PATH_SENDMAIL */
#endif /* BSD4_4 */
#include <stdio.h>
#include <sm/io.h>
#include <stdlib.h>
#include <string.h>
#include <sm/string.h>
#include <unistd.h>
#ifdef EX_OK
# undef EX_OK /* unistd.h may have another use for this */
#endif /* EX_OK */
#include <sysexits.h>
#ifndef MAX
# define MAX(a, b) ((a) < (b) ? (b) : (a))
#endif /* ! MAX */
#ifndef __P
# ifdef __STDC__
# define __P(protos) protos
# else /* __STDC__ */
# define __P(protos) ()
# define const
# endif /* __STDC__ */
#endif /* ! __P */
#ifndef STDIN_FILENO
# define STDIN_FILENO 0
#endif /* ! STDIN_FILENO */
#if defined(BSD4_4) || defined(linux) || SOLARIS >= 20600 || (SOLARIS < 10000 && SOLARIS >= 206) || _AIX4 >= 40300 || defined(HPUX11)
# define HASSNPRINTF 1
#endif /* defined(BSD4_4) || defined(linux) || SOLARIS >= 20600 || (SOLARIS < 10000 && SOLARIS >= 206) || _AIX4 >= 40300 || defined(HPUX11) */
#if defined(sun) && !defined(BSD) && !defined(SOLARIS) && !defined(__svr4__) && !defined(__SVR4)
# define memmove(d, s, l) (bcopy((s), (d), (l)))
#endif /* defined(sun) && !defined(BSD) && !defined(SOLARIS) && !defined(__svr4__) && !defined(__SVR4) */
#if !HASSNPRINTF && !SFIO
extern int snprintf __P((char *, size_t, const char *, ...));
#endif /* !HASSNPRINTF && !SFIO */
#if defined(BSD4_4) || defined(__osf__) || defined(__GNU_LIBRARY__) || defined(IRIX64) || defined(IRIX5) || defined(IRIX6)
# ifndef HASSTRERROR
# define HASSTRERROR 1
# endif /* ! HASSTRERROR */
#endif /* defined(BSD4_4) || defined(__osf__) || defined(__GNU_LIBRARY__) ||
defined(IRIX64) || defined(IRIX5) || defined(IRIX6) */
#if defined(SUNOS403) || defined(NeXT) || (defined(MACH) && defined(i386) && !defined(__GNU__)) || defined(oldBSD43) || defined(MORE_BSD) || defined(umipsbsd) || defined(ALTOS_SYSTEM_V) || defined(RISCOS) || defined(_AUX_SOURCE) || defined(UMAXV) || defined(titan) || defined(UNIXWARE) || defined(sony_news) || defined(luna) || defined(nec_ews_svr4) || defined(_nec_ews_svr4) || defined(__MAXION__)
# undef WIFEXITED
# undef WEXITSTATUS
# define WIFEXITED(st) (((st) & 0377) == 0)
# define WEXITSTATUS(st) (((st) >> 8) & 0377)
#endif /* defined(SUNOS403) || defined(NeXT) || (defined(MACH) && defined(i386) && !defined(__GNU__)) || defined(oldBSD43) || defined(MORE_BSD) || defined(umipsbsd) || defined(ALTOS_SYSTEM_V) || defined(RISCOS) || defined(_AUX_SOURCE) || defined(UMAXV) || defined(titan) || defined(UNIXWARE) || defined(sony_news) || defined(luna) || defined(nec_ews_svr4) || defined(_nec_ews_svr4) || defined(__MAXION__) */
#include "sendmail/errstring.h"
#include <sm/conf.h>
#include <sm/errstring.h>
#include <sendmail/pathnames.h>
static void err __P((int, const char *, ...));
static void usage __P((void));
@ -136,7 +83,7 @@ xalloc(sz)
if (sz <= 0)
sz = 1;
p = malloc((unsigned) sz);
p = malloc(sz);
if (p == NULL)
err(EX_TEMPFAIL, "out of memory");
return (p);
@ -150,7 +97,7 @@ main(argc, argv)
int ch, debug, i, pdes[2], pid, status;
size_t fplen = 0, fptlen = 0, len;
off_t offset;
FILE *fp;
SM_FILE_T *fp;
char *addrp = NULL, *domain, *p, *t;
char *from_path, *from_sys, *from_user;
char **args, buf[2048], lbuf[2048];
@ -188,8 +135,9 @@ main(argc, argv)
for (offset = 0; ; )
{
/* Get and nul-terminate the line. */
if (fgets(lbuf, sizeof(lbuf), stdin) == NULL)
exit(EX_DATAERR);
if (sm_io_fgets(smioin, SM_TIME_DEFAULT, lbuf,
sizeof(lbuf)) == NULL)
err(EX_DATAERR, "no data");
if ((p = strchr(lbuf, '\n')) == NULL)
err(EX_DATAERR, "line too long");
*p = '\0';
@ -223,7 +171,10 @@ main(argc, argv)
}
*t = '\0';
if (debug)
fprintf(stderr, "remote from: %s\n", p);
(void) sm_io_fprintf(smioerr,
SM_TIME_DEFAULT,
"remote from: %s\n",
p);
break;
}
}
@ -243,7 +194,9 @@ main(argc, argv)
err(EX_DATAERR,
"corrupted From line: %s", lbuf);
if (debug)
fprintf(stderr, "bang: %s\n", p);
(void) sm_io_fprintf(smioerr,
SM_TIME_DEFAULT,
"bang: %s\n", p);
}
}
@ -263,8 +216,10 @@ main(argc, argv)
{
from_sys = newstr(p);
if (debug)
fprintf(stderr, "from_sys: %s\n",
from_sys);
(void) sm_io_fprintf(smioerr,
SM_TIME_DEFAULT,
"from_sys: %s\n",
from_sys);
}
/* Concatenate to the path string. */
@ -273,14 +228,14 @@ main(argc, argv)
{
fplen = 0;
if ((from_path = malloc(fptlen = 256)) == NULL)
err(EX_TEMPFAIL, NULL);
err(EX_TEMPFAIL, "out of memory");
}
if (fplen + len + 2 > fptlen)
{
fptlen += MAX(fplen + len + 2, 256);
fptlen += SM_MAX(fplen + len + 2, 256);
if ((from_path = realloc(from_path,
fptlen)) == NULL)
err(EX_TEMPFAIL, NULL);
err(EX_TEMPFAIL, "out of memory");
}
memmove(from_path + fplen, p, len);
fplen += len;
@ -304,20 +259,24 @@ main(argc, argv)
if (debug)
{
if (from_path != NULL)
fprintf(stderr, "from_path: %s\n", from_path);
fprintf(stderr, "from_user: %s\n", from_user);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"from_path: %s\n",
from_path);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"from_user: %s\n", from_user);
}
if (offset != -1)
offset = (off_t)ftell(stdin);
offset = (off_t)sm_io_tell(smioin, SM_TIME_DEFAULT);
}
/* Allocate args (with room for sendmail args as well as recipients) */
/* Allocate args (with room for sendmail args as well as recipients */
args = (char **)xalloc(sizeof(*args) * (10 + argc));
i = 0;
args[i++] = _PATH_SENDMAIL; /* Build sendmail's argument list. */
args[i++] = "-G"; /* relay submission */
args[i++] = "-oee"; /* No errors, just status. */
#ifdef QUEUE_ONLY
args[i++] = "-odq"; /* Queue it, don't try to deliver. */
@ -328,16 +287,16 @@ main(argc, argv)
/* set from system and protocol used */
if (from_sys == NULL)
snprintf(buf, sizeof(buf), "-p%s", domain);
sm_snprintf(buf, sizeof(buf), "-p%s", domain);
else if (strchr(from_sys, '.') == NULL)
snprintf(buf, sizeof(buf), "-p%s:%s.%s",
sm_snprintf(buf, sizeof(buf), "-p%s:%s.%s",
domain, from_sys, domain);
else
snprintf(buf, sizeof(buf), "-p%s:%s", domain, from_sys);
sm_snprintf(buf, sizeof(buf), "-p%s:%s", domain, from_sys);
args[i++] = newstr(buf);
/* Set name of ``from'' person. */
snprintf(buf, sizeof(buf), "-f%s%s",
sm_snprintf(buf, sizeof(buf), "-f%s%s",
from_path ? from_path : "", from_user);
args[i++] = newstr(buf);
@ -360,7 +319,7 @@ main(argc, argv)
len = strlen(*argv) + 3;
if ((args[i] = malloc(len)) == NULL)
err(EX_TEMPFAIL, "Cannot malloc");
snprintf(args[i++], len, "<%s>", *argv);
sm_snprintf(args[i++], len, "<%s>", *argv);
}
argv++;
argc--;
@ -373,9 +332,11 @@ main(argc, argv)
if (debug)
{
fprintf(stderr, "Sendmail arguments:\n");
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"Sendmail arguments:\n");
for (i = 0; args[i] != NULL; i++)
fprintf(stderr, "\t%s\n", args[i]);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"\t%s\n", args[i]);
}
/*
@ -394,12 +355,12 @@ main(argc, argv)
}
if (pipe(pdes) < 0)
err(EX_OSERR, NULL);
err(EX_OSERR, "pipe failed");
switch (pid = FORK())
switch (pid = fork())
{
case -1: /* Err. */
err(EX_OSERR, NULL);
err(EX_OSERR, "fork failed");
/* NOTREACHED */
case 0: /* Child. */
@ -410,25 +371,27 @@ main(argc, argv)
}
(void) close(pdes[1]);
(void) execv(_PATH_SENDMAIL, args);
_exit(127);
err(EX_UNAVAILABLE, "%s", _PATH_SENDMAIL);
/* NOTREACHED */
}
if ((fp = fdopen(pdes[1], "w")) == NULL)
err(EX_OSERR, NULL);
if ((fp = sm_io_open(SmFtStdiofd, SM_TIME_DEFAULT, (void *) &(pdes[1]),
SM_IO_WRONLY, NULL)) == NULL)
err(EX_OSERR, "sm_io_open failed");
(void) close(pdes[0]);
/* Copy the file down the pipe. */
do
{
(void) fprintf(fp, "%s", lbuf);
} while (fgets(lbuf, sizeof(lbuf), stdin) != NULL);
(void) sm_io_fprintf(fp, SM_TIME_DEFAULT, "%s", lbuf);
} while (sm_io_fgets(smioin, SM_TIME_DEFAULT, lbuf,
sizeof(lbuf)) != NULL);
if (ferror(stdin))
err(EX_TEMPFAIL, "stdin: %s", errstring(errno));
if (sm_io_error(smioin))
err(EX_TEMPFAIL, "stdin: %s", sm_errstring(errno));
if (fclose(fp))
err(EX_OSERR, NULL);
if (sm_io_close(fp, SM_TIME_DEFAULT))
err(EX_OSERR, "sm_io_close failed");
if ((waitpid(pid, &status, 0)) == -1)
err(EX_OSERR, "%s", _PATH_SENDMAIL);
@ -447,16 +410,11 @@ main(argc, argv)
static void
usage()
{
(void) fprintf(stderr, "usage: rmail [-T] [-D domain] user ...\n");
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"usage: rmail [-T] [-D domain] user ...\n");
exit(EX_USAGE);
}
#ifdef __STDC__
# include <stdarg.h>
#else /* __STDC__ */
# include <varargs.h>
#endif /* __STDC__ */
static void
#ifdef __STDC__
err(int eval, const char *fmt, ...)
@ -467,15 +425,15 @@ err(eval, fmt, va_alist)
va_dcl
#endif /* __STDC__ */
{
va_list ap;
#ifdef __STDC__
va_start(ap, fmt);
#else /* __STDC__ */
va_start(ap);
#endif /* __STDC__ */
(void) fprintf(stderr, "rmail: ");
(void) vfprintf(stderr, fmt, ap);
va_end(ap);
(void) fprintf(stderr, "\n");
SM_VA_LOCAL_DECL
if (fmt != NULL)
{
SM_VA_START(ap, fmt);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, "rmail: ");
(void) sm_io_vfprintf(smioerr, SM_TIME_DEFAULT, fmt, ap);
SM_VA_END(ap);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, "\n");
}
exit(eval);
}

View File

@ -1,4 +1,4 @@
.\" Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers.
.\" Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.
.\" All rights reserved.
.\" Copyright (c) 1993 Eric P. Allman. All rights reserved.
.\" Copyright (c) 1993
@ -9,11 +9,11 @@
.\" the sendmail distribution.
.\"
.\"
.\" $Id: smrsh.8,v 8.11.16.2 2000/12/15 19:50:46 gshapiro Exp $
.\" $Id: smrsh.8,v 8.15 2001/01/24 00:40:47 gshapiro Exp $
.\"
.\" $FreeBSD$
.\"
.TH SMRSH 8 "$Date: 2000/12/15 19:50:46 $"
.TH SMRSH 8 "$Date: 2001/01/24 00:40:47 $"
.SH NAME
smrsh \- restricted shell for sendmail
.SH SYNOPSIS
@ -77,10 +77,10 @@ in the sm.bin directory (using the ``#!'' syntax);
it simply disallows execution of arbitrary programs.
.SH COMPILATION
Compilation should be trivial on most systems.
You may need to use \-DPATH=\e"\fIpath\fP\e"
You may need to use \-DSMRSH_PATH=\e"\fIpath\fP\e"
to adjust the default search path
(defaults to ``/bin:/usr/bin'')
and/or \-DCMDBIN=\e"\fIdir\fP\e"
and/or \-DSMRSH_CMDBIN=\e"\fIdir\fP\e"
to change the default program directory
(defaults to ``/usr/libexec/sm.bin'').
.SH FILES

View File

@ -11,18 +11,16 @@
*
*/
#ifndef lint
static char copyright[] =
#include <sm/gen.h>
SM_IDSTR(copyright,
"@(#) Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.\n\
All rights reserved.\n\
Copyright (c) 1993 Eric P. Allman. All rights reserved.\n\
Copyright (c) 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* ! lint */
The Regents of the University of California. All rights reserved.\n")
#ifndef lint
static char id[] = "@(#)$Id: smrsh.c,v 8.31.4.9 2001/04/24 04:11:51 ca Exp $";
#endif /* ! lint */
SM_IDSTR(id, "@(#)$Id: smrsh.c,v 8.55 2001/09/11 04:05:22 gshapiro Exp $")
/* $FreeBSD$ */
@ -57,7 +55,8 @@ static char id[] = "@(#)$Id: smrsh.c,v 8.31.4.9 2001/04/24 04:11:51 ca Exp $";
*/
#include <unistd.h>
#include <stdio.h>
#include <sm/io.h>
#include <sm/string.h>
#include <sys/file.h>
#include <string.h>
#include <ctype.h>
@ -69,18 +68,16 @@ static char id[] = "@(#)$Id: smrsh.c,v 8.31.4.9 2001/04/24 04:11:51 ca Exp $";
#include <syslog.h>
#include <stdlib.h>
#ifndef TRUE
# define TRUE 1
# define FALSE 0
#endif /* ! TRUE */
#include <sm/conf.h>
#include <sm/errstring.h>
/* directory in which all commands must reside */
#ifndef CMDDIR
# if defined(HPUX10) || defined(HPUX11) || SOLARIS >= 20800
# define CMDDIR "/var/adm/sm.bin"
# else /* HPUX10 || HPUX11 || SOLARIS >= 20800 */
# define CMDDIR "/usr/libexec/sm.bin"
# endif /* HPUX10 || HPUX11 || SOLARIS >= 20800 */
# ifdef SMRSH_CMDDIR
# define CMDDIR SMRSH_CMDDIR
# else /* SMRSH_CMDDIR */
# define CMDDIR "/usr/adm/sm.bin"
# endif /* SMRSH_CMDDIR */
#endif /* ! CMDDIR */
/* characters disallowed in the shell "-c" argument */
@ -88,16 +85,13 @@ static char id[] = "@(#)$Id: smrsh.c,v 8.31.4.9 2001/04/24 04:11:51 ca Exp $";
/* default search path */
#ifndef PATH
# define PATH "/bin:/usr/bin"
# ifdef SMRSH_PATH
# define PATH SMRSH_PATH
# else /* SMRSH_PATH */
# define PATH "/bin:/usr/bin:/usr/ucb"
# endif /* SMRSH_PATH */
#endif /* ! PATH */
#ifndef __P
# include "sendmail/cdefs.h"
#endif /* ! __P */
extern size_t strlcpy __P((char *, const char *, size_t));
extern size_t strlcat __P((char *, const char *, size_t));
char newcmdbuf[1000];
char *prg, *par;
@ -117,8 +111,8 @@ char *prg, *par;
void
addcmd(s, cmd, len)
char *s;
int cmd;
int len;
bool cmd;
size_t len;
{
if (s == NULL || *s == '\0')
return;
@ -126,7 +120,8 @@ addcmd(s, cmd, len)
if (sizeof newcmdbuf - strlen(newcmdbuf) <=
len + (cmd ? (strlen(CMDDIR) + 1) : 0))
{
fprintf(stderr, "%s: command too long: %s\n", prg, par);
(void)sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: command too long: %s\n", prg, par);
#ifndef DEBUG
syslog(LOG_WARNING, "command too long: %.40s", par);
#endif /* ! DEBUG */
@ -134,10 +129,10 @@ addcmd(s, cmd, len)
}
if (cmd)
{
(void) strlcat(newcmdbuf, CMDDIR, sizeof newcmdbuf);
(void) strlcat(newcmdbuf, "/", sizeof newcmdbuf);
(void) sm_strlcat(newcmdbuf, CMDDIR, sizeof newcmdbuf);
(void) sm_strlcat(newcmdbuf, "/", sizeof newcmdbuf);
}
(void) strlcat(newcmdbuf, s, sizeof newcmdbuf);
(void) sm_strlcat(newcmdbuf, s, sizeof newcmdbuf);
}
int
@ -149,7 +144,6 @@ main(argc, argv)
register char *q;
register char *r;
register char *cmd;
int i;
int isexec;
int save_errno;
char *newenv[2];
@ -165,8 +159,8 @@ main(argc, argv)
# endif /* ! LOG_MAIL */
#endif /* ! DEBUG */
(void) strlcpy(pathbuf, "PATH=", sizeof pathbuf);
(void) strlcat(pathbuf, PATH, sizeof pathbuf);
(void) sm_strlcpy(pathbuf, "PATH=", sizeof pathbuf);
(void) sm_strlcat(pathbuf, PATH, sizeof pathbuf);
newenv[0] = pathbuf;
newenv[1] = NULL;
@ -178,7 +172,8 @@ main(argc, argv)
if (argc != 3 || strcmp(argv[1], "-c") != 0)
{
fprintf(stderr, "Usage: %s -c command\n", prg);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"Usage: %s -c command\n", prg);
#ifndef DEBUG
syslog(LOG_ERR, "usage");
#endif /* ! DEBUG */
@ -201,19 +196,19 @@ main(argc, argv)
#endif /* ! DEBUG */
exit(EX_UNAVAILABLE);
}
(void) strlcpy(specialbuf, SPECIALS, sizeof specialbuf);
(void) sm_strlcpy(specialbuf, SPECIALS, sizeof specialbuf);
for (p = specialbuf; *p != '\0'; p++)
*p |= '\200';
(void) strlcat(specialbuf, SPECIALS, sizeof specialbuf);
(void) sm_strlcat(specialbuf, SPECIALS, sizeof specialbuf);
/*
** Do a quick sanity check on command line length.
*/
i = strlen(par);
if (i > (sizeof newcmdbuf - sizeof CMDDIR - 2))
if (strlen(par) > (sizeof newcmdbuf - sizeof CMDDIR - 2))
{
fprintf(stderr, "%s: command too long: %s\n", prg, par);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: command too long: %s\n", prg, par);
#ifndef DEBUG
syslog(LOG_WARNING, "command too long: %.40s", par);
#endif /* ! DEBUG */
@ -222,7 +217,7 @@ main(argc, argv)
q = par;
newcmdbuf[0] = '\0';
isexec = FALSE;
isexec = false;
while (*q)
{
@ -238,10 +233,11 @@ main(argc, argv)
{
if (isexec)
{
fprintf(stderr, "%s: missing command to exec\n",
prg);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: missing command to exec\n",
prg);
#ifndef DEBUG
syslog(LOG_CRIT, "uid %d: missing command to exec", getuid());
syslog(LOG_CRIT, "uid %d: missing command to exec", (int) getuid());
#endif /* ! DEBUG */
exit(EX_UNAVAILABLE);
}
@ -271,15 +267,15 @@ main(argc, argv)
/* allow a few shell builtins */
if (strcmp(q, "exec") == 0 && p != NULL)
{
addcmd("exec ", FALSE, strlen("exec "));
addcmd("exec ", false, strlen("exec "));
/* test _next_ arg */
q = ++p;
isexec = TRUE;
isexec = true;
continue;
}
else if (strcmp(q, "exit") == 0 || strcmp(q, "echo") == 0)
{
addcmd(cmd, FALSE, strlen(cmd));
addcmd(cmd, false, strlen(cmd));
/* test following chars */
}
else
@ -287,23 +283,24 @@ main(argc, argv)
/*
** Check to see if the command name is legal.
*/
(void) strlcpy(cmdbuf, CMDDIR, sizeof cmdbuf);
(void) strlcat(cmdbuf, "/", sizeof cmdbuf);
(void) strlcat(cmdbuf, cmd, sizeof cmdbuf);
(void) sm_strlcpy(cmdbuf, CMDDIR, sizeof cmdbuf);
(void) sm_strlcat(cmdbuf, "/", sizeof cmdbuf);
(void) sm_strlcat(cmdbuf, cmd, sizeof cmdbuf);
#ifdef DEBUG
printf("Trying %s\n", cmdbuf);
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
"Trying %s\n", cmdbuf);
#endif /* DEBUG */
if (access(cmdbuf, X_OK) < 0)
{
/* oops.... crack attack possiblity */
fprintf(stderr,
"%s: %s not available for sendmail programs\n",
prg, cmd);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: %s not available for sendmail programs\n",
prg, cmd);
if (p != NULL)
*p = ' ';
#ifndef DEBUG
syslog(LOG_CRIT, "uid %d: attempt to use %s",
getuid(), cmd);
(int) getuid(), cmd);
#endif /* ! DEBUG */
exit(EX_UNAVAILABLE);
}
@ -312,9 +309,9 @@ main(argc, argv)
** Create the actual shell input.
*/
addcmd(cmd, TRUE, strlen(cmd));
addcmd(cmd, true, strlen(cmd));
}
isexec = FALSE;
isexec = false;
if (p != NULL)
*p = ' ';
@ -322,13 +319,15 @@ main(argc, argv)
break;
r = strpbrk(p, specialbuf);
if (r == NULL) {
addcmd(p, FALSE, strlen(p));
if (r == NULL)
{
addcmd(p, false, strlen(p));
break;
}
#if ALLOWSEMI
if (*r == ';') {
addcmd(p, FALSE, r - p + 1);
if (*r == ';')
{
addcmd(p, false, r - p + 1);
q = r + 1;
continue;
}
@ -336,30 +335,34 @@ main(argc, argv)
if ((*r == '&' && *(r + 1) == '&') ||
(*r == '|' && *(r + 1) == '|'))
{
addcmd(p, FALSE, r - p + 2);
addcmd(p, false, r - p + 2);
q = r + 2;
continue;
}
fprintf(stderr, "%s: cannot use %c in command\n", prg, *r);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: cannot use %c in command\n", prg, *r);
#ifndef DEBUG
syslog(LOG_CRIT, "uid %d: attempt to use %c in command: %s",
getuid(), *r, par);
(int) getuid(), *r, par);
#endif /* ! DEBUG */
exit(EX_UNAVAILABLE);
} /* end of while *q */
if (isexec)
{
fprintf(stderr, "%s: missing command to exec\n", prg);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: missing command to exec\n", prg);
#ifndef DEBUG
syslog(LOG_CRIT, "uid %d: missing command to exec", getuid());
syslog(LOG_CRIT, "uid %d: missing command to exec",
(int) getuid());
#endif /* ! DEBUG */
exit(EX_UNAVAILABLE);
}
/* make sure we created something */
if (newcmdbuf[0] == '\0')
{
fprintf(stderr, "Usage: %s -c command\n", prg);
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"Usage: %s -c command\n", prg);
#ifndef DEBUG
syslog(LOG_ERR, "usage");
#endif /* ! DEBUG */
@ -371,15 +374,15 @@ main(argc, argv)
*/
#ifdef DEBUG
printf("%s\n", newcmdbuf);
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "%s\n", newcmdbuf);
#endif /* DEBUG */
(void) execle("/bin/sh", "/bin/sh", "-c", newcmdbuf, NULL, newenv);
save_errno = errno;
#ifndef DEBUG
syslog(LOG_CRIT, "Cannot exec /bin/sh: %m");
syslog(LOG_CRIT, "Cannot exec /bin/sh: %s", sm_errstring(errno));
#endif /* ! DEBUG */
errno = save_errno;
perror("/bin/sh");
sm_perror("/bin/sh");
exit(EX_OSFILE);
/* NOTREACHED */
return EX_OSFILE;

View File

@ -9,11 +9,11 @@
.\" the sendmail distribution.
.\"
.\"
.\" $Id: aliases.5,v 8.15.4.2 2000/12/14 23:08:15 gshapiro Exp $
.\" $Id: aliases.5,v 8.17 2000/12/14 23:09:46 gshapiro Exp $
.\"
.\" $FreeBSD$
.\"
.TH ALIASES 5 "$Date: 2000/12/14 23:08:15 $"
.TH ALIASES 5 "$Date: 2000/12/14 23:09:46 $"
.SH NAME
aliases
\- aliases file for sendmail

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.
* Copyright (c) 1998-2002 Sendmail, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993
@ -11,44 +11,99 @@
*
*/
#ifndef lint
static char id[] = "@(#)$Id: err.c,v 8.120.4.5 2001/08/17 22:09:40 ca Exp $";
#endif /* ! lint */
#include <sendmail.h>
SM_RCSID("@(#)$Id: err.c,v 8.189 2002/01/09 18:52:30 ca Exp $")
/* $FreeBSD$ */
#include <sendmail.h>
#ifdef LDAPMAP
#if LDAPMAP
# include <lber.h>
# include <ldap.h> /* for LDAP error codes */
#endif /* LDAPMAP */
static void putoutmsg __P((char *, bool, bool));
static void puterrmsg __P((char *));
static char *fmtmsg __P((char *, const char *, const char *, const char *,
int, const char *, va_list));
/*
** FATAL_ERROR -- handle a fatal exception
**
** This function is installed as the default exception handler
** in the main sendmail process, and in all child processes
** that we create. Its job is to handle exceptions that are not
** handled at a lower level.
**
** The theory is that unhandled exceptions will be 'fatal' class
** exceptions (with an "F:" prefix), such as the out-of-memory
** exception "F:sm.heap". As such, they are handled by exiting
** the process in exactly the same way that xalloc() in Sendmail 8.10
** exits the process when it fails due to lack of memory:
** we call syserr with a message beginning with "!".
**
** Parameters:
** exc -- exception which is terminating this process
**
** Returns:
** none
*/
void
fatal_error(exc)
SM_EXC_T *exc;
{
static char buf[256];
SM_FILE_T f;
/*
** This function may be called when the heap is exhausted.
** The following code writes the message for 'exc' into our
** static buffer without allocating memory or raising exceptions.
*/
sm_strio_init(&f, buf, sizeof(buf));
sm_exc_write(exc, &f);
(void) sm_io_flush(&f, SM_TIME_DEFAULT);
/*
** Terminate the process after logging an error and cleaning up.
** Problems:
** - syserr decides what class of error this is by looking at errno.
** That's no good; we should look at the exc structure.
** - The cleanup code should be moved out of syserr
** and into individual exception handlers
** that are part of the module they clean up after.
*/
errno = ENOMEM;
syserr("!%s", buf);
}
/*
** SYSERR -- Print error message.
**
** Prints an error message via printf to the diagnostic output.
** Prints an error message via sm_io_printf to the diagnostic output.
**
** If the first character of the syserr message is `!' it will
** log this as an ALERT message and exit immediately. This can
** leave queue files in an indeterminate state, so it should not
** be used lightly.
**
** If the first character of the syserr message is '!' or '@'
** then syserr knows that the process is about to be terminated,
** so the SMTP reply code defaults to 421. Otherwise, the
** reply code defaults to 451 or 554, depending on errno.
**
** Parameters:
** fmt -- the format string. If it does not begin with
** a three-digit SMTP reply code, either 554 or
** 451 is assumed depending on whether errno
** is set.
** fmt -- the format string. An optional '!' or '@',
** followed by an optional three-digit SMTP
** reply code, followed by message text.
** (others) -- parameters
**
** Returns:
** none
** Through TopFrame if QuickAbort is set.
** Raises E:mta.quickabort if QuickAbort is set.
**
** Side Effects:
** increments Errors.
@ -75,22 +130,45 @@ syserr(fmt, va_alist)
register char *p;
int save_errno = errno;
bool panic;
bool exiting;
char *user;
char *enhsc;
char *errtxt;
struct passwd *pw;
char ubuf[80];
VA_LOCAL_DECL
SM_VA_LOCAL_DECL
panic = *fmt == '!';
if (panic)
switch (*fmt)
{
fmt++;
HoldErrs = FALSE;
case '!':
++fmt;
panic = true;
exiting = true;
break;
case '@':
++fmt;
panic = false;
exiting = true;
break;
default:
panic = false;
exiting = false;
break;
}
/* format and output the error message */
if (save_errno == 0)
if (exiting)
{
/*
** Since we are terminating the process,
** we are aborting the entire SMTP session,
** rather than just the current transaction.
*/
p = "421";
enhsc = "4.0.0";
}
else if (save_errno == 0)
{
p = "554";
enhsc = "5.0.0";
@ -100,17 +178,19 @@ syserr(fmt, va_alist)
p = "451";
enhsc = "4.0.0";
}
VA_START(fmt);
SM_VA_START(ap, fmt);
errtxt = fmtmsg(MsgBuf, (char *) NULL, p, enhsc, save_errno, fmt, ap);
VA_END;
SM_VA_END(ap);
puterrmsg(MsgBuf);
/* save this message for mailq printing */
if (!panic && CurEnv != NULL)
{
if (CurEnv->e_message != NULL)
char *nmsg = sm_rpool_strdup_x(CurEnv->e_rpool, errtxt);
if (CurEnv->e_rpool == NULL && CurEnv->e_message != NULL)
sm_free(CurEnv->e_message);
CurEnv->e_message = newstr(errtxt);
CurEnv->e_message = nmsg;
}
/* determine exit status if not already set */
@ -121,7 +201,7 @@ syserr(fmt, va_alist)
else
ExitStat = EX_OSERR;
if (tTd(54, 1))
dprintf("syserr: ExitStat = %d\n", ExitStat);
sm_dprintf("syserr: ExitStat = %d\n", ExitStat);
}
pw = sm_getpwuid(RealUid);
@ -130,7 +210,7 @@ syserr(fmt, va_alist)
else
{
user = ubuf;
snprintf(ubuf, sizeof ubuf, "UID%d", (int) RealUid);
(void) sm_snprintf(ubuf, sizeof ubuf, "UID%d", (int) RealUid);
}
if (LogLevel > 0)
@ -159,13 +239,13 @@ syserr(fmt, va_alist)
#ifdef ESTALE
case ESTALE:
#endif /* ESTALE */
printopenfds(TRUE);
mci_dump_all(TRUE);
printopenfds(true);
mci_dump_all(true);
break;
}
if (panic)
{
#ifdef XLA
#if XLA
xla_all_end();
#endif /* XLA */
sync_queue_time();
@ -175,21 +255,21 @@ syserr(fmt, va_alist)
}
errno = 0;
if (QuickAbort)
longjmp(TopFrame, 2);
sm_exc_raisenew_x(&EtypeQuickAbort, 2);
}
/*
/*
** USRERR -- Signal user error.
**
** This is much like syserr except it is for user errors.
**
** Parameters:
** fmt -- the format string. If it does not begin with
** a three-digit SMTP reply code, 501 is assumed.
** (others) -- printf strings
** a three-digit SMTP reply code, 550 is assumed.
** (others) -- sm_io_printf strings
**
** Returns:
** none
** Through TopFrame if QuickAbort is set.
** Raises E:mta.quickabort if QuickAbort is set.
**
** Side Effects:
** increments Errors.
@ -207,7 +287,7 @@ usrerr(fmt, va_alist)
{
char *enhsc;
char *errtxt;
VA_LOCAL_DECL
SM_VA_LOCAL_DECL
if (fmt[0] == '5' || fmt[0] == '6')
enhsc = "5.0.0";
@ -217,9 +297,9 @@ usrerr(fmt, va_alist)
enhsc = "2.0.0";
else
enhsc = NULL;
VA_START(fmt);
errtxt = fmtmsg(MsgBuf, CurEnv->e_to, "501", enhsc, 0, fmt, ap);
VA_END;
SM_VA_START(ap, fmt);
errtxt = fmtmsg(MsgBuf, CurEnv->e_to, "550", enhsc, 0, fmt, ap);
SM_VA_END(ap);
if (SuprErrs)
return;
@ -236,32 +316,33 @@ usrerr(fmt, va_alist)
case '5':
case '6':
if (CurEnv->e_message != NULL)
if (CurEnv->e_rpool == NULL && CurEnv->e_message != NULL)
sm_free(CurEnv->e_message);
if (MsgBuf[0] == '6')
{
char buf[MAXLINE];
snprintf(buf, sizeof buf, "Postmaster warning: %.*s",
(int) sizeof buf - 22, errtxt);
CurEnv->e_message = newstr(buf);
(void) sm_snprintf(buf, sizeof buf,
"Postmaster warning: %.*s",
(int) sizeof buf - 22, errtxt);
CurEnv->e_message =
sm_rpool_strdup_x(CurEnv->e_rpool, buf);
}
else
{
CurEnv->e_message = newstr(errtxt);
CurEnv->e_message =
sm_rpool_strdup_x(CurEnv->e_rpool, errtxt);
}
break;
}
puterrmsg(MsgBuf);
if (LogLevel > 3 && LogUsrErrs)
sm_syslog(LOG_NOTICE, CurEnv->e_id, "%.900s", errtxt);
if (QuickAbort)
longjmp(TopFrame, 1);
sm_exc_raisenew_x(&EtypeQuickAbort, 1);
}
/*
/*
** USRERRENH -- Signal user error.
**
** Same as usrerr but with enhanced status code.
@ -269,12 +350,12 @@ usrerr(fmt, va_alist)
** Parameters:
** enhsc -- the enhanced status code.
** fmt -- the format string. If it does not begin with
** a three-digit SMTP reply code, 501 is assumed.
** (others) -- printf strings
** a three-digit SMTP reply code, 550 is assumed.
** (others) -- sm_io_printf strings
**
** Returns:
** none
** Through TopFrame if QuickAbort is set.
** Raises E:mta.quickabort if QuickAbort is set.
**
** Side Effects:
** increments Errors.
@ -292,7 +373,7 @@ usrerrenh(enhsc, fmt, va_alist)
#endif /* __STDC__ */
{
char *errtxt;
VA_LOCAL_DECL
SM_VA_LOCAL_DECL
if (enhsc == NULL || *enhsc == '\0')
{
@ -303,9 +384,9 @@ usrerrenh(enhsc, fmt, va_alist)
else if (fmt[0] == '2')
enhsc = "2.0.0";
}
VA_START(fmt);
errtxt = fmtmsg(MsgBuf, CurEnv->e_to, "501", enhsc, 0, fmt, ap);
VA_END;
SM_VA_START(ap, fmt);
errtxt = fmtmsg(MsgBuf, CurEnv->e_to, "550", enhsc, 0, fmt, ap);
SM_VA_END(ap);
if (SuprErrs)
return;
@ -322,38 +403,39 @@ usrerrenh(enhsc, fmt, va_alist)
case '5':
case '6':
if (CurEnv->e_message != NULL)
if (CurEnv->e_rpool == NULL && CurEnv->e_message != NULL)
sm_free(CurEnv->e_message);
if (MsgBuf[0] == '6')
{
char buf[MAXLINE];
snprintf(buf, sizeof buf, "Postmaster warning: %.*s",
(int) sizeof buf - 22, errtxt);
CurEnv->e_message = newstr(buf);
(void) sm_snprintf(buf, sizeof buf,
"Postmaster warning: %.*s",
(int) sizeof buf - 22, errtxt);
CurEnv->e_message =
sm_rpool_strdup_x(CurEnv->e_rpool, buf);
}
else
{
CurEnv->e_message = newstr(errtxt);
CurEnv->e_message =
sm_rpool_strdup_x(CurEnv->e_rpool, errtxt);
}
break;
}
puterrmsg(MsgBuf);
if (LogLevel > 3 && LogUsrErrs)
sm_syslog(LOG_NOTICE, CurEnv->e_id, "%.900s", errtxt);
if (QuickAbort)
longjmp(TopFrame, 1);
sm_exc_raisenew_x(&EtypeQuickAbort, 1);
}
/*
/*
** MESSAGE -- print message (not necessarily an error)
**
** Parameters:
** msg -- the message (printf fmt) -- it can begin with
** msg -- the message (sm_io_printf fmt) -- it can begin with
** an SMTP reply code. If not, 050 is assumed.
** (others) -- printf arguments
** (others) -- sm_io_printf arguments
**
** Returns:
** none
@ -373,13 +455,13 @@ message(msg, va_alist)
#endif /* __STDC__ */
{
char *errtxt;
VA_LOCAL_DECL
SM_VA_LOCAL_DECL
errno = 0;
VA_START(msg);
SM_VA_START(ap, msg);
errtxt = fmtmsg(MsgBuf, CurEnv->e_to, "050", (char *) NULL, 0, msg, ap);
VA_END;
putoutmsg(MsgBuf, FALSE, FALSE);
SM_VA_END(ap);
putoutmsg(MsgBuf, false, false);
/* save this message for mailq printing */
switch (MsgBuf[0])
@ -391,22 +473,23 @@ message(msg, va_alist)
/* FALLTHROUGH */
case '5':
if (CurEnv->e_message != NULL)
if (CurEnv->e_rpool == NULL && CurEnv->e_message != NULL)
sm_free(CurEnv->e_message);
CurEnv->e_message = newstr(errtxt);
CurEnv->e_message =
sm_rpool_strdup_x(CurEnv->e_rpool, errtxt);
break;
}
}
/*
/*
** NMESSAGE -- print message (not necessarily an error)
**
** Just like "message" except it never puts the to... tag on.
**
** Parameters:
** msg -- the message (printf fmt) -- if it begins
** msg -- the message (sm_io_printf fmt) -- if it begins
** with a three digit SMTP reply code, that is used,
** otherwise 050 is assumed.
** (others) -- printf arguments
** (others) -- sm_io_printf arguments
**
** Returns:
** none
@ -426,14 +509,14 @@ nmessage(msg, va_alist)
#endif /* __STDC__ */
{
char *errtxt;
VA_LOCAL_DECL
SM_VA_LOCAL_DECL
errno = 0;
VA_START(msg);
SM_VA_START(ap, msg);
errtxt = fmtmsg(MsgBuf, (char *) NULL, "050",
(char *) NULL, 0, msg, ap);
VA_END;
putoutmsg(MsgBuf, FALSE, FALSE);
SM_VA_END(ap);
putoutmsg(MsgBuf, false, false);
/* save this message for mailq printing */
switch (MsgBuf[0])
@ -445,20 +528,21 @@ nmessage(msg, va_alist)
/* FALLTHROUGH */
case '5':
if (CurEnv->e_message != NULL)
if (CurEnv->e_rpool == NULL && CurEnv->e_message != NULL)
sm_free(CurEnv->e_message);
CurEnv->e_message = newstr(errtxt);
CurEnv->e_message =
sm_rpool_strdup_x(CurEnv->e_rpool, errtxt);
break;
}
}
/*
/*
** PUTOUTMSG -- output error message to transcript and channel
**
** Parameters:
** msg -- message to output (in SMTP format).
** holdmsg -- if TRUE, don't output a copy of the message to
** holdmsg -- if true, don't output a copy of the message to
** our output channel.
** heldmsg -- if TRUE, this is a previously held message;
** heldmsg -- if true, this is a previously held message;
** don't log it to the transcript file.
**
** Returns:
@ -481,7 +565,7 @@ putoutmsg(msg, holdmsg, heldmsg)
/* display for debugging */
if (tTd(54, 8))
dprintf("--- %s%s%s\n", msg, holdmsg ? " (hold)" : "",
sm_dprintf("--- %s%s%s\n", msg, holdmsg ? " (hold)" : "",
heldmsg ? " (held)" : "");
/* map warnings to something SMTP can handle */
@ -493,12 +577,13 @@ putoutmsg(msg, holdmsg, heldmsg)
/* output to transcript if serious */
if (!heldmsg && CurEnv != NULL && CurEnv->e_xfp != NULL &&
strchr("45", msg[0]) != NULL)
fprintf(CurEnv->e_xfp, "%s\n", msg);
(void) sm_io_fprintf(CurEnv->e_xfp, SM_TIME_DEFAULT, "%s\n",
msg);
if (LogLevel >= 15 && (OpMode == MD_SMTP || OpMode == MD_DAEMON))
if (LogLevel > 14 && (OpMode == MD_SMTP || OpMode == MD_DAEMON))
sm_syslog(LOG_INFO, CurEnv->e_id,
"--> %s%s",
msg, holdmsg ? " (held)" : "");
"--- %s%s%s", msg, holdmsg ? " (hold)" : "",
heldmsg ? " (held)" : "");
if (msgcode == '8')
msg[0] = '0';
@ -512,11 +597,11 @@ putoutmsg(msg, holdmsg, heldmsg)
msg[0] = msgcode;
if (HeldMessageBuf[0] == '5' && msgcode == '4')
return;
snprintf(HeldMessageBuf, sizeof HeldMessageBuf, "%s", msg);
(void) sm_strlcpy(HeldMessageBuf, msg, sizeof HeldMessageBuf);
return;
}
(void) fflush(stdout);
(void) sm_io_flush(smioout, SM_TIME_DEFAULT);
if (OutChannel == NULL)
return;
@ -537,15 +622,21 @@ putoutmsg(msg, holdmsg, heldmsg)
/* if DisConnected, OutChannel now points to the transcript */
if (!DisConnected &&
(OpMode == MD_SMTP || OpMode == MD_DAEMON || OpMode == MD_ARPAFTP))
fprintf(OutChannel, "%s\r\n", msg);
(void) sm_io_fprintf(OutChannel, SM_TIME_DEFAULT, "%s\r\n",
msg);
else
fprintf(OutChannel, "%s\n", errtxt);
(void) sm_io_fprintf(OutChannel, SM_TIME_DEFAULT, "%s\n",
errtxt);
if (TrafficLogFile != NULL)
fprintf(TrafficLogFile, "%05d >>> %s\n", (int) getpid(),
(OpMode == MD_SMTP || OpMode == MD_DAEMON) ? msg : errtxt);
(void) sm_io_fprintf(TrafficLogFile, SM_TIME_DEFAULT,
"%05d >>> %s\n", (int) CurrentPid,
(OpMode == MD_SMTP || OpMode == MD_DAEMON)
? msg : errtxt);
#if !PIPELINING
/* XXX can't flush here for SMTP pipelining */
if (msg[3] == ' ')
(void) fflush(OutChannel);
if (!ferror(OutChannel) || DisConnected)
(void) sm_io_flush(OutChannel, SM_TIME_DEFAULT);
if (!sm_io_error(OutChannel) || DisConnected)
return;
/*
@ -554,19 +645,20 @@ putoutmsg(msg, holdmsg, heldmsg)
** rude servers don't read result.
*/
if (InChannel == NULL || feof(InChannel) || ferror(InChannel) ||
strncmp(msg, "221", 3) == 0)
if (InChannel == NULL || sm_io_eof(InChannel) ||
sm_io_error(InChannel) || strncmp(msg, "221", 3) == 0)
return;
/* can't call syserr, 'cause we are using MsgBuf */
HoldErrs = TRUE;
HoldErrs = true;
if (LogLevel > 0)
sm_syslog(LOG_CRIT, CurEnv->e_id,
"SYSERR: putoutmsg (%s): error on output channel sending \"%s\": %s",
CurHostName == NULL ? "NO-HOST" : CurHostName,
shortenstring(msg, MAXSHORTSTR), errstring(errno));
CURHOSTNAME,
shortenstring(msg, MAXSHORTSTR), sm_errstring(errno));
#endif /* !PIPELINING */
}
/*
/*
** PUTERRMSG -- like putoutmsg, but does special processing for error messages
**
** Parameters:
@ -586,11 +678,11 @@ puterrmsg(msg)
char msgcode = msg[0];
/* output the message as usual */
putoutmsg(msg, HoldErrs, FALSE);
putoutmsg(msg, HoldErrs, false);
/* be careful about multiple error messages */
if (OnlyOneError)
HoldErrs = TRUE;
HoldErrs = true;
/* signal the error */
Errors++;
@ -609,7 +701,7 @@ puterrmsg(msg)
CurEnv->e_flags |= EF_FATALERRS;
}
}
/*
/*
** ISENHSC -- check whether a string contains an enhanced status code
**
** Parameters:
@ -648,7 +740,7 @@ isenhsc(s, delim)
return 0;
return l + h;
}
/*
/*
** EXTENHSC -- check and extract an enhanced status code
**
** Parameters:
@ -665,6 +757,7 @@ isenhsc(s, delim)
** Side Effects:
** fills e with enhanced status code.
*/
int
extenhsc(s, delim, e)
const char *s;
@ -701,7 +794,7 @@ extenhsc(s, delim, e)
e[l + h] = '\0';
return l + h;
}
/*
/*
** FMTMSG -- format a message into buffer.
**
** Parameters:
@ -728,7 +821,7 @@ fmtmsg(eb, to, num, enhsc, eno, fmt, ap)
const char *enhsc;
int eno;
const char *fmt;
va_list ap;
SM_VA_LOCAL_DECL
{
char del;
int l;
@ -745,7 +838,15 @@ fmtmsg(eb, to, num, enhsc, eno, fmt, ap)
del = '-';
else
del = ' ';
(void) snprintf(eb, spaceleft, "%3.3s%c", num, del);
#if _FFR_SOFT_BOUNCE
if (SoftBounce && num[0] == '5')
{
/* replace 5 by 4 */
(void) sm_snprintf(eb, spaceleft, "4%2.2s%c", num + 1, del);
}
else
#endif /* _FFR_SOFT_BOUNCE */
(void) sm_snprintf(eb, spaceleft, "%3.3s%c", num, del);
eb += 4;
spaceleft -= 4;
@ -753,7 +854,7 @@ fmtmsg(eb, to, num, enhsc, eno, fmt, ap)
{
/* copy enh.status code including trailing blank */
l++;
(void) strlcpy(eb, fmt, l + 1);
(void) sm_strlcpy(eb, fmt, l + 1);
eb += l;
spaceleft -= l;
fmt += l;
@ -761,19 +862,26 @@ fmtmsg(eb, to, num, enhsc, eno, fmt, ap)
else if ((l = isenhsc(enhsc, '\0')) > 0 && l < spaceleft - 4)
{
/* copy enh.status code */
(void) strlcpy(eb, enhsc, l + 1);
(void) sm_strlcpy(eb, enhsc, l + 1);
eb[l] = ' ';
eb[++l] = '\0';
eb += l;
spaceleft -= l;
}
#if _FFR_SOFT_BOUNCE
if (SoftBounce && eb[-l] == '5')
{
/* replace 5 by 4 */
eb[-l] = '4';
}
#endif /* _FFR_SOFT_BOUNCE */
errtxt = eb;
/* output the file name and line number */
if (FileName != NULL)
{
(void) snprintf(eb, spaceleft, "%s: line %d: ",
shortenstring(FileName, 83), LineNumber);
(void) sm_snprintf(eb, spaceleft, "%s: line %d: ",
shortenstring(FileName, 83), LineNumber);
eb += (l = strlen(eb));
spaceleft -= l;
}
@ -800,26 +908,26 @@ fmtmsg(eb, to, num, enhsc, eno, fmt, ap)
strncmp(num, "550", 3) == 0 ||
strncmp(num, "553", 3) == 0))
{
(void) snprintf(eb, spaceleft, "%s... ",
shortenstring(to, MAXSHORTSTR));
(void) sm_strlcpyn(eb, spaceleft, 2,
shortenstring(to, MAXSHORTSTR), "... ");
spaceleft -= strlen(eb);
while (*eb != '\0')
*eb++ &= 0177;
}
/* output the message */
(void) vsnprintf(eb, spaceleft, fmt, ap);
(void) sm_vsnprintf(eb, spaceleft, fmt, ap);
spaceleft -= strlen(eb);
while (*eb != '\0')
*eb++ &= 0177;
/* output the error code, if any */
if (eno != 0)
(void) snprintf(eb, spaceleft, ": %s", errstring(eno));
(void) sm_strlcpyn(eb, spaceleft, 2, ": ", sm_errstring(eno));
return errtxt;
}
/*
/*
** BUFFER_ERRORS -- arrange to buffer future error messages
**
** Parameters:
@ -833,9 +941,9 @@ void
buffer_errors()
{
HeldMessageBuf[0] = '\0';
HoldErrs = TRUE;
HoldErrs = true;
}
/*
/*
** FLUSH_ERRORS -- flush the held error message buffer
**
** Parameters:
@ -851,12 +959,12 @@ flush_errors(print)
bool print;
{
if (print && HeldMessageBuf[0] != '\0')
putoutmsg(HeldMessageBuf, FALSE, TRUE);
putoutmsg(HeldMessageBuf, false, true);
HeldMessageBuf[0] = '\0';
HoldErrs = FALSE;
HoldErrs = false;
}
/*
** ERRSTRING -- return string description of error code
/*
** SM_ERRSTRING -- return string description of error code
**
** Parameters:
** errnum -- the error number to translate
@ -869,12 +977,16 @@ flush_errors(print)
*/
const char *
errstring(errnum)
sm_errstring(errnum)
int errnum;
{
char *dnsmsg;
char *bp;
static char buf[MAXLINE];
#if HASSTRERROR
char *err;
char errbuf[30];
#endif /* HASSTRERROR */
#if !HASSTRERROR && !defined(ERRLIST_PREDEFINED)
extern char *sys_errlist[];
extern int sys_nerr;
@ -889,58 +1001,67 @@ errstring(errnum)
dnsmsg = NULL;
switch (errnum)
{
#if defined(DAEMON) && defined(ETIMEDOUT)
case ETIMEDOUT:
case ECONNRESET:
bp = buf;
# if HASSTRERROR
snprintf(bp, SPACELEFT(buf, bp), "%s", strerror(errnum));
# else /* HASSTRERROR */
#if HASSTRERROR
err = strerror(errnum);
if (err == NULL)
{
(void) sm_snprintf(errbuf, sizeof errbuf,
"Error %d", errnum);
err = errbuf;
}
(void) sm_strlcpy(bp, err, SPACELEFT(buf, bp));
#else /* HASSTRERROR */
if (errnum >= 0 && errnum < sys_nerr)
snprintf(bp, SPACELEFT(buf, bp), "%s", sys_errlist[errnum]);
(void) sm_strlcpy(bp, sys_errlist[errnum],
SPACELEFT(buf, bp));
else
snprintf(bp, SPACELEFT(buf, bp), "Error %d", errnum);
# endif /* HASSTRERROR */
(void) sm_snprintf(bp, SPACELEFT(buf, bp),
"Error %d", errnum);
#endif /* HASSTRERROR */
bp += strlen(bp);
if (CurHostName != NULL)
{
if (errnum == ETIMEDOUT)
{
snprintf(bp, SPACELEFT(buf, bp), " with ");
(void) sm_snprintf(bp, SPACELEFT(buf, bp),
" with ");
bp += strlen(bp);
}
else
{
bp = buf;
snprintf(bp, SPACELEFT(buf, bp),
(void) sm_snprintf(bp, SPACELEFT(buf, bp),
"Connection reset by ");
bp += strlen(bp);
}
snprintf(bp, SPACELEFT(buf, bp), "%s",
shortenstring(CurHostName, MAXSHORTSTR));
(void) sm_strlcpy(bp,
shortenstring(CurHostName, MAXSHORTSTR),
SPACELEFT(buf, bp));
bp += strlen(buf);
}
if (SmtpPhase != NULL)
{
snprintf(bp, SPACELEFT(buf, bp), " during %s",
SmtpPhase);
(void) sm_snprintf(bp, SPACELEFT(buf, bp),
" during %s", SmtpPhase);
}
return buf;
case EHOSTDOWN:
if (CurHostName == NULL)
break;
(void) snprintf(buf, sizeof buf, "Host %s is down",
(void) sm_snprintf(buf, sizeof buf, "Host %s is down",
shortenstring(CurHostName, MAXSHORTSTR));
return buf;
case ECONNREFUSED:
if (CurHostName == NULL)
break;
(void) snprintf(buf, sizeof buf, "Connection refused by %s",
(void) sm_strlcpyn(buf, sizeof buf, 2, "Connection refused by ",
shortenstring(CurHostName, MAXSHORTSTR));
return buf;
#endif /* defined(DAEMON) && defined(ETIMEDOUT) */
#if NAMED_BIND
case HOST_NOT_FOUND + E_DNSBASE:
@ -1008,29 +1129,35 @@ errstring(errnum)
if (dnsmsg != NULL)
{
bp = buf;
bp += strlcpy(bp, "Name server: ", sizeof buf);
bp += sm_strlcpy(bp, "Name server: ", sizeof buf);
if (CurHostName != NULL)
{
snprintf(bp, SPACELEFT(buf, bp), "%s: ",
shortenstring(CurHostName, MAXSHORTSTR));
(void) sm_strlcpyn(bp, SPACELEFT(buf, bp), 2,
shortenstring(CurHostName, MAXSHORTSTR), ": ");
bp += strlen(bp);
}
snprintf(bp, SPACELEFT(buf, bp), "%s", dnsmsg);
(void) sm_strlcpy(bp, dnsmsg, SPACELEFT(buf, bp));
return buf;
}
#ifdef LDAPMAP
#if LDAPMAP
if (errnum >= E_LDAPBASE)
return ldap_err2string(errnum - E_LDAPBASE);
#endif /* LDAPMAP */
#if HASSTRERROR
return strerror(errnum);
err = strerror(errnum);
if (err == NULL)
{
(void) sm_snprintf(buf, sizeof buf, "Error %d", errnum);
return buf;
}
return err;
#else /* HASSTRERROR */
if (errnum > 0 && errnum < sys_nerr)
return sys_errlist[errnum];
(void) snprintf(buf, sizeof buf, "Error %d", errnum);
(void) sm_snprintf(buf, sizeof buf, "Error %d", errnum);
return buf;
#endif /* HASSTRERROR */
}

File diff suppressed because it is too large Load Diff

View File

@ -9,11 +9,11 @@
.\" the sendmail distribution.
.\"
.\"
.\" $Id: mailq.1,v 8.14.28.3 2000/12/14 23:08:15 gshapiro Exp $
.\" $Id: mailq.1,v 8.18 2000/12/23 19:37:48 ca Exp $
.\"
.\" $FreeBSD$
.\"
.TH MAILQ 1 "$Date: 2000/12/14 23:08:15 $"
.TH MAILQ 1 "$Date: 2000/12/23 19:37:48 $"
.SH NAME
mailq
\- print the mail queue
@ -60,6 +60,8 @@ indicating the ``controlling user'' information;
this shows who will own any programs that are executed
on behalf of this message
and the name of the alias this command expanded from, if any.
Moreover, status messages for each recipient are printed
if available.
.PP
The
.B mailq

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
.\" Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers.
.\" Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.
.\" All rights reserved.
.\" Copyright (c) 1983, 1997 Eric P. Allman. All rights reserved.
.\" Copyright (c) 1988, 1991, 1993
@ -9,11 +9,11 @@
.\" the sendmail distribution.
.\"
.\"
.\" $Id: sendmail.8,v 8.36.8.3 2000/12/14 23:08:15 gshapiro Exp $
.\" $Id: sendmail.8,v 8.49 2001/03/23 22:10:00 ca Exp $
.\"
.\" $FreeBSD$
.\"
.TH SENDMAIL 8 "$Date: 2000/12/14 23:08:15 $"
.TH SENDMAIL 8 "$Date: 2001/03/23 22:10:00 $"
.SH NAME
sendmail
\- an electronic mail transport agent
@ -69,6 +69,14 @@ and `group' includes `john' in the expansion,
then the letter will also be delivered to `john'.
.SS Parameters
.TP
.B \-Ac
Use submit.cf even if the operation mode does not indicate
an initial mail submission.
.TP
.B \-Am
Use sendmail.cf even if the operation mode indicates
an initial mail submission.
.TP
.BI \-B type
Set the body type to
.IR type .
@ -115,7 +123,11 @@ Initialize the alias database.
Deliver mail in the usual way (default).
.TP
.B \-bp
Print a listing of the queue.
Print a listing of the queue(s).
.TP
.B \-bP
Print number of entries in the queue(s);
only available with shared memory support.
.TP
.B \-bs
Use the
@ -239,7 +251,7 @@ This can be a simple protocol name such as ``UUCP''
or a protocol and hostname, such as ``UUCP:ucbvax''.
.TP
\fB\-q\fR[\fItime\fR]
Processed saved messages in the queue at given intervals.
Process saved messages in the queue at given intervals.
If
.I time
is omitted, process the queue once.
@ -249,7 +261,7 @@ with
`s'
being seconds,
`m'
being minutes,
being minutes (default),
`h'
being hours,
`d'
@ -262,28 +274,50 @@ For example,
or
`\-q90m'
would both set the timeout to one hour thirty minutes.
If
.I time
is specified,
By default,
.B sendmail
will run in the background.
will run in the background.
This option can be used safely with
.BR \-bd .
.TP
.BI \-qI substr
Limit processed jobs to those containing
.I substr
as a substring of the queue id.
\fB\-qp\fR[\fItime\fR]
Similar to \fB\-q\fItime\fR,
except that instead of periodically forking a child to process the queue,
sendmail forks a single persistent child for each queue
that alternates between processing the queue and sleeping.
The sleep time is given as the argument; it defaults to 1 second.
The process will always sleep at least 5 seconds if the queue was
empty in the previous queue run.
.TP
.BI \-qR substr
Limit processed jobs to those containing
.I substr
as a substring of one of the recipients.
\fB\-q\fRf
Process saved messages in the queue once and do not fork(),
but run in the foreground.
.TP
.BI \-qS substr
\fB\-q\fRG name
Process jobs in queue group called
.I name
only.
.TP
\fB\-q\fR[\fI!\fR]I substr
Limit processed jobs to those containing
.I substr
as a substring of the sender.
as a substring of the queue id or not when
.I !
is specified.
.TP
\fB\-q\fR[\fI!\fR]R substr
Limit processed jobs to those containing
.I substr
as a substring of one of the recipients or not when
.I !
is specified.
.TP
\fB\-q\fR[\fI!\fR]S substr
Limit processed jobs to those containing
.I substr
as a substring of the sender or not when
.I !
is specified.
.TP
.BI "\-R " return
Set the amount of the message to be returned
@ -307,18 +341,6 @@ Read message for recipients.
To:, Cc:, and Bcc: lines will be scanned for recipient addresses.
The Bcc: line will be deleted before transmission.
.TP
.B \-U
Initial (user) submission. This should
.I always
be set when called from a user agent such as
.B Mail
or
.B exmh
and
.I never
be set when called by a network delivery agent such as
.BR rmail .
.TP
.BI "\-V " envid
Set the original envelope id.
This is propagated across SMTP to servers that support DSNs

View File

@ -9,33 +9,36 @@
.\" the sendmail distribution.
.\"
.\"
.\" $Id: vacation.1,v 8.11.4.8 2001/07/20 04:19:38 gshapiro Exp $
.\" $Id: vacation.1,v 8.26 2001/11/21 04:21:35 gshapiro Exp $
.\"
.\" $FreeBSD$
.\"
.TH VACATION 1 "$Date: 2001/07/20 04:19:38 $"
.TH VACATION 1 "$Date: 2001/11/21 04:21:35 $"
.SH NAME
vacation
\- return ``I am not here'' indication
.SH SYNOPSIS
.B vacation
.RB [ \-i ]
.RB [ \-I ]
.RB [ \-r
.IR interval ]
.RB [ \-x ]
.RB [ \-a
.IR alias ]
.RB [ \-C
.IR cffile ]
.RB [ \-d ]
.RB [ \-f
.IR database ]
.RB [ \-i ]
.RB [ \-I ]
.RB [ \-l ]
.RB [ \-m
.IR message ]
.RB [ \-r
.IR interval ]
.RB [ \-s
.IR address ]
.RB [ \-t
.IR time ]
.RB [ \-U ]
.RB [ \-x ]
.RB [ \-z ]
.I login
.SH DESCRIPTION
@ -63,6 +66,14 @@ Handle messages for
in the same manner as those received for the user's
login name.
.TP
.BI \-C " cfpath"
Specify pathname of the sendmail configuration file.
This option is ignored if
.B \-U
is specified.
This option defaults to the standard sendmail configuration file,
located at /etc/mail/sendmail.cf on most systems.
.TP
.B \-d
Send error/debug messages to stdout instead of syslog.
Otherwise, fatal errors, such as calling
@ -76,7 +87,9 @@ syslog(8).
Use
.I filename
as name of the database instead of
.IR ~/.vacation.db .
.IR ~/.vacation.db
or
.IR ~/.vacation.{dir,pag} .
Unless the
.I filename
starts with / it is relative to ~.
@ -92,10 +105,6 @@ Same as
.B \-i
(for backwards compatibility).
.TP
.B \-l
List the content of the vacation database file including the address
and the associated time of the last auto-response to that address.
.TP
.BI \-m " filename"
Use
.I filename
@ -105,6 +114,10 @@ Unless the
.I filename
starts with / it is relative to ~.
.TP
.B \-l
List the content of the vacation database file including the address
and the associated time of the last auto-response to that address.
.TP
.BI \-r " interval"
Set the reply interval to
.I interval
@ -125,6 +138,13 @@ line as the recipient for the vacation message.
Ignored, available only for compatibility with Sun's
vacation program.
.TP
.B \-U
Do not attempt to lookup
.I login
in the password file.
The -f and -m options must be used to specify the database and message file
since there is no home directory for the default settings for these options.
.TP
.B \-x
reads an exclusion list from stdin (one address per line).
Mails coming from an address
@ -170,8 +190,12 @@ or
line is included in the mail headers.
The people who have sent you messages are maintained as a
db(3)
or
dbm(3)
database in the file
.I .vacation.db
or
.I .vacation.{dir,pag}
in your home directory.
.PP
.B Vacation
@ -201,17 +225,13 @@ Sendmail(8)
includes this
``From''
line automatically.
.PP
Fatal errors, such as calling
.B vacation
with incorrect arguments, or with non-existent
.IR login s,
are logged in the system log file, using
syslog(8).
.SH FILES
.TP 1.8i
~/.vacation.db
default database file
default database file for db(3)
.TP 1.8i
~/.vacation.{dir,pag}
default database file for dbm(3)
.TP
~/.vacation.msg
default message to send