Put list of login names able to use -f in the .cf file.
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 17 Oct 1982 07:25:05 +0000 (23:25 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 17 Oct 1982 07:25:05 +0000 (23:25 -0800)
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

usr/src/usr.sbin/sendmail/src/main.c
usr/src/usr.sbin/sendmail/src/readcf.c
usr/src/usr.sbin/sendmail/src/version.c

index 3361781..877b9c8 100644 (file)
@@ -6,7 +6,7 @@
 # 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.
@@ -652,14 +652,12 @@ main(argc, argv)
 **     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
@@ -706,9 +704,9 @@ setfrom(from, realname)
 
        if (from != NULL)
        {
 
        if (from != NULL)
        {
-               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
@@ -775,6 +773,32 @@ setfrom(from, realname)
        }
 }
 \f/*
        }
 }
 \f/*
+**  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:
index 3905049..7a150a3 100644 (file)
@@ -1,6 +1,6 @@
 # include "sendmail.h"
 
 # include "sendmail.h"
 
-SCCSID(@(#)readcf.c    3.37            %G%);
+SCCSID(@(#)readcf.c    3.38            %G%);
 
 /*
 **  READCF -- read control file.
 
 /*
 **  READCF -- read control file.
@@ -45,20 +45,25 @@ SCCSID(@(#)readcf.c 3.37            %G%);
 **             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;
        char exbuf[MAXLINE];
        char exbuf[MAXLINE];
-       char *q;
 
        cf = fopen(cfname, "r");
        if (cf == NULL)
 
        cf = fopen(cfname, "r");
        if (cf == NULL)
@@ -201,8 +206,7 @@ readcf(cfname, safe)
                  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++)
@@ -215,6 +219,30 @@ readcf(cfname, safe)
                        NumPriorities++;
                        break;
 
                        NumPriorities++;
                        break;
 
+                 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\"",
@@ -223,6 +251,27 @@ readcf(cfname, safe)
        }
 }
 \f/*
        }
 }
 \f/*
+**  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:
index 19eab07..47fa951 100644 (file)
@@ -1,5 +1,5 @@
 # ifndef lint
 # ifndef lint
-static char    SccsId[] = "@(#)SendMail version 3.225 of %G%";
+static char    SccsId[] = "@(#)SendMail version 3.226 of %G%";
 # endif lint
 
 # endif lint
 
-char   Version[] = "3.225 [%G%]";
+char   Version[] = "3.226 [%G%]";