fix bug in file modes when mailing to files that didn't exist before;
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Thu, 24 Sep 1981 00:52:26 +0000 (16:52 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Thu, 24 Sep 1981 00:52:26 +0000 (16:52 -0800)
add an 'F' line to the .cf file that will read class entries from
another file, given a scanf string to do the parsing.

SCCS-vsn: usr.sbin/sendmail/src/deliver.c 3.43
SCCS-vsn: usr.sbin/sendmail/src/version.c 3.38
SCCS-vsn: usr.sbin/sendmail/src/readcf.c 3.14

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

index 639e104..ab79d94 100644 (file)
@@ -7,7 +7,7 @@
 # include <syslog.h>
 # endif LOG
 
 # include <syslog.h>
 # endif LOG
 
-static char SccsId[] = "@(#)deliver.c  3.42    %G%";
+static char SccsId[] = "@(#)deliver.c  3.43    %G%";
 
 /*
 **  DELIVER -- Deliver a message to a list of addresses.
 
 /*
 **  DELIVER -- Deliver a message to a list of addresses.
@@ -721,7 +721,7 @@ mailfile(filename, ctladdr)
                (void) signal(SIGTERM, SIG_DFL);
                umask(OldUmask);
                if (stat(filename, &stb) < 0)
                (void) signal(SIGTERM, SIG_DFL);
                umask(OldUmask);
                if (stat(filename, &stb) < 0)
-                       stb.st_mode = 0;
+                       stb.st_mode = 0666;
                if (bitset(0111, stb.st_mode))
                        exit(EX_CANTCREAT);
                if (ctladdr == NULL)
                if (bitset(0111, stb.st_mode))
                        exit(EX_CANTCREAT);
                if (ctladdr == NULL)
index 982f32e..72de016 100644 (file)
@@ -1,6 +1,6 @@
 # include "sendmail.h"
 
 # include "sendmail.h"
 
-static char SccsId[] = "@(#)readcf.c   3.13    %G%";
+static char SccsId[] = "@(#)readcf.c   3.14    %G%";
 
 /*
 **  READCF -- read control file.
 
 /*
 **  READCF -- read control file.
@@ -8,6 +8,26 @@ static char SccsId[] = "@(#)readcf.c   3.13    %G%";
 **     This routine reads the control file and builds the internal
 **     form.
 **
 **     This routine reads the control file and builds the internal
 **     form.
 **
+**     The file is formatted as a sequence of lines, each taken
+**     atomically.  The first character of each line describes how
+**     the line is to be interpreted.  The lines are:
+**             Dxval           Define macro x to have value val.
+**             Cxword          Put word into class x.
+**             Fxfile [fmt]    Read file for lines to put into
+**                             class x.  Use scanf string 'fmt'
+**                             or "%s" if not present.  Fmt should
+**                             only produce one string-valued result.
+**             Hname: value    Define header with field-name 'name'
+**                             and value as specified; this will be
+**                             macro expanded immediately before
+**                             use.
+**             Sn              Use rewriting set n.
+**             Rlhs rhs        Rewrite addresses that match lhs to
+**                             be rhs.
+**             Mn p f r a      Define mailer.  n - internal name,
+**                             p - pathname, f - flags, r - rewriting
+**                             rule for sender, a - argument vector.
+**
 **     Parameters:
 **             cfname -- control file name.
 **             safe -- set if this is a system configuration file.
 **     Parameters:
 **             cfname -- control file name.
 **             safe -- set if this is a system configuration file.
@@ -105,6 +125,7 @@ readcf(cfname, safe)
                        break;
 
                  case 'C':             /* word class */
                        break;
 
                  case 'C':             /* word class */
+                 case 'F':             /* word class from file */
                        class = buf[1];
                        if (!isalpha(class))
                                goto badline;
                        class = buf[1];
                        if (!isalpha(class))
                                goto badline;
@@ -112,8 +133,26 @@ readcf(cfname, safe)
                                class -= 'A';
                        else
                                class -= 'a';
                                class -= 'A';
                        else
                                class -= 'a';
+                       
+                       /* read list of words from argument or file */
+                       if (buf[0] == 'F')
+                       {
+                               /* read from file */
+                               for (p = &buf[2]; *p != '\0' && !isspace(*p); p++)
+                                       continue;
+                               if (*p == '\0')
+                                       p = "%s";
+                               else
+                               {
+                                       *p = '\0';
+                                       while (isspace(*++p))
+                                               continue;
+                               }
+                               fileclass(class, &buf[2], p);
+                               break;
+                       }
 
 
-                       /* scan the list of words and set class 'i' for all */
+                       /* scan the list of words and set class for all */
                        for (p = &buf[2]; *p != '\0'; )
                        {
                                register char *wd;
                        for (p = &buf[2]; *p != '\0'; )
                        {
                                register char *wd;
@@ -147,6 +186,51 @@ readcf(cfname, safe)
        }
 }
 \f/*
        }
 }
 \f/*
+**  FILECLASS -- read members of a class from a file
+**
+**     Parameters:
+**             class -- class to define.
+**             filename -- name of file to read.
+**             fmt -- scanf string to use for match.
+**
+**     Returns:
+**             none
+**
+**     Side Effects:
+**
+**             puts all lines in filename that match a scanf into
+**                     the named class.
+*/
+
+fileclass(class, filename, fmt)
+       int class;
+       char *filename;
+       char *fmt;
+{
+       register FILE *f;
+       char buf[MAXLINE];
+
+       f = fopen(filename, "r");
+       if (f == NULL)
+       {
+               syserr("cannot open %s", filename);
+               return;
+       }
+
+       while (fgets(buf, sizeof buf, f) != NULL)
+       {
+               register STAB *s;
+               char wordbuf[MAXNAME+1];
+
+               if (sscanf(buf, fmt, wordbuf) != 1)
+                       continue;
+               s = stab(wordbuf, ST_CLASS, ST_ENTER);
+               s->s_class |= 1 << class;
+       }
+
+       fclose(f);
+}
+\f/*
 **  MAKEMAILER -- define a new mailer.
 **
 **     Parameters:
 **  MAKEMAILER -- define a new mailer.
 **
 **     Parameters:
index 155df5e..3d64db2 100644 (file)
@@ -1,3 +1,3 @@
-static char    SccsId[] = "@(#)SendMail version 3.37 of %G%";
+static char    SccsId[] = "@(#)SendMail version 3.38 of %G%";
 
 
-char   Version[] = "3.37 [%G%]";
+char   Version[] = "3.38 [%G%]";