SCCS-mr: usr.sbin/sendmail/src/main.c 027
SCCS-mr: usr.sbin/sendmail/src/version.c 027
SCCS-mr: usr.sbin/sendmail/src/readcf.c 027
SCCS-vsn: usr.sbin/sendmail/src/main.c 3.126
SCCS-vsn: usr.sbin/sendmail/src/version.c 3.226
SCCS-vsn: usr.sbin/sendmail/src/readcf.c 3.38
# include "sendmail.h"
# include <sys/stat.h>
# include "sendmail.h"
# include <sys/stat.h>
-SCCSID(@(#)main.c 3.125 %G%);
+SCCSID(@(#)main.c 3.126 %G%);
/*
** SENDMAIL -- Post mail to a set of destinations.
/*
** SENDMAIL -- Post mail to a set of destinations.
** Under certain circumstances allow the user to say who
** s/he is (using -f or -r). These are:
** 1. The user's uid is zero (root).
** Under certain circumstances allow the user to say who
** s/he is (using -f or -r). These are:
** 1. The user's uid is zero (root).
-** 2. The user's login name is "network" (mail from
-** a network server).
-** 3. The user's login name is "uucp" (mail from the
-** uucp network).
-** 4. The address the user is trying to claim has a
-** "!" character in it (since #3 doesn't do it for
-** us if we are dialing out).
-** A better check to replace #3 & #4 would be if the
+** 2. The user's login name is in an approved list (typically
+** from a network server).
+** 3. The address the user is trying to claim has a
+** "!" character in it (since #2 doesn't do it for
+** us if we are dialing out for UUCP).
+** A better check to replace #3 would be if the
** effective uid is "UUCP" -- this would require me
** to rewrite getpwent to "grab" uucp as it went by,
** make getname more nasty, do another passwd file
** effective uid is "UUCP" -- this would require me
** to rewrite getpwent to "grab" uucp as it went by,
** make getname more nasty, do another passwd file
- if (strcmp(realname, "network") != 0 &&
- strcmp(realname, "uucp") != 0 &&
- strcmp(realname, "daemon") != 0 &&
+ extern bool trusteduser();
+
+ if (!trusteduser(realname) &&
# ifdef DEBUG
(!tTd(1, 9) || getuid() != geteuid()) &&
# endif DEBUG
# ifdef DEBUG
(!tTd(1, 9) || getuid() != geteuid()) &&
# endif DEBUG
+** TRUSTEDUSER -- tell us if this user is to be trusted.
+**
+** Parameters:
+** user -- the user to be checked.
+**
+** Returns:
+** TRUE if the user is in an approved list.
+** FALSE otherwise.
+**
+** Side Effects:
+** none.
+*/
+
+bool
+trusteduser(user)
+ char *user;
+{
+ register char **ulist;
+ extern char *TrustedUsers[];
+
+ for (ulist = TrustedUsers; *ulist != NULL; ulist++)
+ if (strcmp(*ulist, user) == 0)
+ return (TRUE);
+ return (FALSE);
+}
+\f/*
** FINIS -- Clean up and exit.
**
** Parameters:
** FINIS -- Clean up and exit.
**
** Parameters:
-SCCSID(@(#)readcf.c 3.37 %G%);
+SCCSID(@(#)readcf.c 3.38 %G%);
/*
** READCF -- read control file.
/*
** READCF -- read control file.
** Builds several internal tables.
*/
** Builds several internal tables.
*/
+# define MAXTRUST 10 /* maximum number of trusted users */
+
+char *TrustedUsers[MAXTRUST+1]; /* list of trusted users */
+
readcf(cfname, safe)
char *cfname;
bool safe;
{
FILE *cf;
readcf(cfname, safe)
char *cfname;
bool safe;
{
FILE *cf;
+ int class;
+ int ruleset = 0;
+ char *q;
+ char **pv;
char buf[MAXLINE];
register char *p;
struct rewrite *rwp = NULL;
extern char **prescan();
extern char **copyplist();
char buf[MAXLINE];
register char *p;
struct rewrite *rwp = NULL;
extern char **prescan();
extern char **copyplist();
- int class;
- int ruleset = 0;
cf = fopen(cfname, "r");
if (cf == NULL)
cf = fopen(cfname, "r");
if (cf == NULL)
case 'P': /* set precedence */
if (NumPriorities >= MAXPRIORITIES)
{
case 'P': /* set precedence */
if (NumPriorities >= MAXPRIORITIES)
{
- syserr("readcf: line %d: too many P lines, %d max",
- LineNumber, MAXPRIORITIES);
+ toomany('P', MAXPRIORITIES);
break;
}
for (p = &buf[1]; *p != '\0' && *p != '='; p++)
break;
}
for (p = &buf[1]; *p != '\0' && *p != '='; p++)
+ case 'T': /* trusted user(s) */
+ p = &buf[1];
+ while (*p != '\0')
+ {
+ while (isspace(*p))
+ p++;
+ q = p;
+ while (*p != '\0' && !isspace(*p))
+ p++;
+ if (*p != '\0')
+ *p++ = '\0';
+ if (*q == '\0')
+ continue;
+ for (pv = TrustedUsers; *pv != NULL; pv++)
+ continue;
+ if (pv >= &TrustedUsers[MAXTRUST])
+ {
+ toomany('T', MAXTRUST);
+ break;
+ }
+ *pv = newstr(q);
+ }
+ break;
+
default:
badline:
syserr("readcf: line %d: unknown control line \"%s\"",
default:
badline:
syserr("readcf: line %d: unknown control line \"%s\"",
+** TOOMANY -- signal too many of some option
+**
+** Parameters:
+** id -- the id of the error line
+** maxcnt -- the maximum possible values
+**
+** Returns:
+** none.
+**
+** Side Effects:
+** gives a syserr.
+*/
+
+toomany(id, maxcnt)
+ char id;
+ int maxcnt;
+{
+ syserr("readcf: line %d: too many %c lines, %d max",
+ LineNumber, id, maxcnt);
+}
+\f/*
** FILECLASS -- read members of a class from a file
**
** Parameters:
** FILECLASS -- read members of a class from a file
**
** Parameters:
-static char SccsId[] = "@(#)SendMail version 3.225 of %G%";
+static char SccsId[] = "@(#)SendMail version 3.226 of %G%";
-char Version[] = "3.225 [%G%]";
+char Version[] = "3.226 [%G%]";