home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume4 / uumail3 / part2 / uumail.c < prev   
Encoding:
C/C++ Source or Header  |  1986-11-30  |  16.1 KB  |  724 lines

  1. /*
  2.  *  U U M A I L
  3.  *  This program when invoked in the form:
  4.  *  uumail host!user will consult the local usemap for
  5.  *  the proper routing.
  6.  * 
  7.  *  If it finds it, it will invoke the proper uux call
  8.  *  to send the mail.
  9.  *  Otherwise it aborts with an error 68 (host unknown)
  10. ***************************************************************************
  11. This work in its current form is Copyright 1986 Stan Barber
  12. with the exception of opath, gethostname and the original getpath which
  13. as far as I know are in the Public Domain. This software may be distributed
  14. freely as long as no profit is made from such distribution and this notice
  15. is reproducted in whole.
  16. ***************************************************************************
  17. This software is provided on an "as is" basis with no guarantee of 
  18. usefulness or correctness of operation for any purpose, intended or
  19. otherwise. The author is in no way liable for this software's performance
  20. or any damage it may cause to any data of any kind anywhere.
  21. ***************************************************************************
  22.  * $Log:    uumail.c,v $
  23.  * Revision 3.0  86/03/14  12:05:00  sob
  24.  * Release of 3/15/86 --- 3rd Release
  25.  * 
  26.  * Revision 2.20  86/03/14  11:57:46  sob
  27.  * 
  28.  * 
  29.  * Revision 2.19  86/03/11  11:29:11  sob
  30.  * Added Copyright Notice
  31.  * 
  32.  * Revision 2.18  86/03/04  18:20:40  sob
  33.  * Fixed some problems with local vs. non-local mail.
  34.  * 
  35.  * Revision 2.17  86/02/26  03:06:47  sob
  36.  * Added error checking for a null name.
  37.  * 
  38.  * Revision 2.16  86/02/23  23:49:40  sob
  39.  * 
  40.  * 
  41.  * Revision 2.15  86/02/23  23:19:09  sob
  42.  * This version will hopefully work with the new pipeoutput option from 
  43.  * aliasing.
  44.  * Stan
  45.  * 
  46.  * Revision 2.14  86/02/18  02:56:38  sob
  47.  * Correct pointer problem with linked list.
  48.  * Stan
  49.  * 
  50.  * Revision 2.13  86/02/17  18:43:37  sob
  51.  * Updated with linked list for addresses. This will allow aliasing which
  52.  * will be added next.
  53.  * Stan
  54.  * 
  55.  * Revision 2.12  86/02/17  17:33:12  sob
  56.  * This update incorporates changes to the command line flags to
  57.  * conform more with the syntax of sendmail.
  58.  * Stan
  59.  * 
  60.  * Revision 2.11  86/02/07  16:06:16  sob
  61.  * Altered the code to always unlink the temporary letter file when
  62.  * DEBUG is NOT defined.
  63.  * Stan
  64.  * 
  65.  * Revision 2.10  85/12/26  16:50:23  sob
  66.  * Added fixes to allow uupath myhostname to work correctly.
  67.  * Stan
  68.  * 
  69.  * Revision 2.9  85/12/10  20:36:01  sob
  70.  * Added new return flag from getpath EX_TEMPFAIL to signal that the
  71.  * path database is currently being updated.
  72.  * 
  73.  * Revision 2.8  85/12/02  16:51:39  sob
  74.  * Added a fix to cope with percents in addresses returned by opath.
  75.  * Thank to steve@umd-cs.UUCP for the bug report.
  76.  * 
  77.  * Revision 2.7  85/11/18  12:36:48  sob
  78.  * Added the -h option to cause uumail NOT to add a From_ line.
  79.  * 
  80.  * Revision 2.6  85/11/14  20:20:06  sob
  81.  * Added #ifdef DEBUG to allow compiliation with out DEBUG installed
  82.  * 
  83.  * Revision 2.5  85/11/14  20:14:11  sob
  84.  * Another little buggie in the log format...sheesh.
  85.  * 
  86.  * Revision 2.4  85/11/13  15:53:18  sob
  87.  * Reformated the log file a little bit.
  88.  * 
  89.  * Revision 2.3  85/11/08  03:03:51  sob
  90.  * This is the release version.
  91.  * 
  92.  * 
  93.  * Revision 2.2  85/09/30  02:51:18  sob
  94.  * This version uses opath when defined during compile time.
  95.  * With a bit of cleaning up, this is a release version.
  96.  * 
  97.  * Revision 2.1  85/09/30  02:46:06  sob
  98.  * *** empty log message ***
  99.  * 
  100.  * Revision 2.0  85/09/09  18:22:56  UUCP
  101.  * *** empty log message ***
  102.  * 
  103.  * Revision 2.0  85/09/09  18:22:56  UUCP
  104.  * Added flags to conform with sendmail. Also updated the flags it could send
  105.  * to uux to conform with 4.3 uux command.
  106.  * Will add name resolution and header checking.
  107.  * Also will allow multiple addresses per line.
  108.  * 
  109.  * Revision 1.7  85/08/03  00:49:14  UUCP
  110.  * Cleaned up with lint.
  111.  * Stan Barber
  112.  * 
  113.  * Revision 1.6  85/07/11  19:30:00  sob
  114.  * changed PATHSIZE to PATHSIZ to conform with uupath
  115.  * 
  116.  * Revision 1.5  85/07/11  18:08:13  sob
  117.  * This one works both as uumail and uupath!
  118.  * Stan
  119.  * 
  120.  * Revision 1.4  85/07/10  18:35:05  sob
  121.  * moved DBM to getpath
  122.  * Stan Barber
  123.  * 
  124.  * Revision 1.3  85/07/09  01:28:14  sob
  125.  * First attempt to integrate uupath
  126.  * Not successful. Changed PATHALIAS define
  127.  * to DBM... will ultimately alter getpath as well
  128.  * added gethostname call to fill in for local host.
  129.  * 
  130.  * Revision 1.2  85/07/08  05:29:16  sob
  131.  * This one works with pathalias database...
  132.  * need to modify to substitue for uupath.
  133.  * Stan
  134.  * 
  135.  * Revision 1.1  85/07/08  03:11:10  sob
  136.  * Initial revision
  137.  * 
  138.  */
  139. #define _DEFINE
  140.  
  141. #include "uuconf.h"
  142.  
  143.  
  144. EXTERN bool uupath;
  145. extern int      errno;
  146. extern struct passwd *getpwuid();
  147. extern FILE    *popen();
  148. extern char     *ctime();
  149. extern char    *getlogin();
  150. extern char    *index();
  151. extern char    *rindex();
  152. extern char    *malloc();
  153. extern char     *getenv();
  154. extern char     *Alias();
  155. EXTERN char    progname[12];
  156. EXTERN char  *paths;
  157. char templet[64];
  158. char * from;
  159. struct mailname addrlist;    /* list of addresses */
  160. int local;
  161. static char Version[] ="$Header: uumail.c,v 3.0 86/03/14 12:05:00 sob RELEASE_3 $";
  162.  
  163. main(argc, argv)
  164.     char **argv;
  165. {
  166.     FILE *out, *tmpf;    /* output to uux, temp file */
  167.     char lbuf[512]; /* for pipe to uux */
  168.     char sender[512];    /* accumulated path of sender */
  169.     char sys[64];    /* a system in path */
  170.     char cmd[2000];
  171.     char **av;
  172.     int i,
  173.             error = 0,
  174.             bangcnt, hopcount = 30;
  175.         
  176.     char    c,
  177.             grade = 'C',
  178.        name[20],             /* The system name (if any) */
  179.        *fname,
  180.        *path,            /* uupath to the system */
  181.            *sysname,            /* points to the system name */
  182.            *p, *q, *r,            /* tmp pointer to argv's */
  183.        *rsys,
  184.        *FullName;
  185.        bool GrabTo,safecf,NoAlias,startuux,noheader,metoo;
  186.        extern intsig();
  187.        struct mailname *lp;
  188.  
  189.     if (signal(SIGINT, SIG_IGN) != SIG_IGN)
  190.         (void) signal(SIGINT, intsig);
  191.     if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
  192.         (void) signal(SIGHUP, intsig);
  193.     (void) signal(SIGTERM, intsig);
  194.     (void) signal(SIGPIPE, SIG_IGN);
  195.     /* initialize Boolean Values */
  196.     startuux = safecf = TRUE;
  197.     metoo=GrabTo=NoAlias=noheader = FALSE;
  198.  
  199.     for (i = 3; i < 20; i++)
  200.         (void) close(i);
  201.     errno = 0;
  202.     gethostname(Myname,32);
  203.     paths=DATABASE;
  204.     logfile=LOGFILE;
  205.     argv[argc] = NULL;
  206.     av = argv;
  207.     p = rindex(*av, '/');
  208.     if (p++ == NULL)
  209.         p = *av;
  210.     strcpy(progname ,p);
  211.     if(strcmp(p,"uupath") == 0)
  212.         uupath = TRUE;
  213.     while ((p = *++av) != NULL && p[0] == '-')
  214.     {
  215.         switch (p[1])
  216.         {
  217.  
  218.           case 'C':    /* select configuration file */
  219.             ConfFile = &p[2];
  220.             safecf = FALSE;
  221.  
  222.             break;
  223.  
  224.           case 'g':   /* set grade */
  225.             grade = p[2];
  226.             break;
  227.     
  228. # ifdef DEBUG
  229.           case 'd':    /* debug */
  230.             Debug= atoi(&p[2]);
  231.             if (Debug == 0) Debug = 1;
  232.             setbuf(stdout, (char *) NULL);
  233.             printf("Version %s\n", Version);
  234.             break;
  235. # endif DEBUG
  236.  
  237.           case 'f':    /* from address */
  238.           case 'r':    /* obsolete -f flag */
  239.             p += 2;
  240.             if (*p == '\0' && ((p = *++av) == NULL || *p == '-'))
  241.             {
  242.                 p = *++av;
  243.                 if (p == NULL || *p == '-')
  244.                 {
  245.                     syserr("No \"from\" person");
  246.                     av--;
  247.                     break;
  248.                 }
  249.             }
  250.             if (from != NULL)
  251.             {
  252.                 syserr("More than one \"from\" person");
  253.                 break;
  254.             }
  255.             from = p;
  256.             break;
  257.  
  258.           case 'w':    /* just print the path */
  259.             uupath = TRUE;
  260.             break;
  261.           case 'h':    /* don't add a From line */
  262.             noheader = TRUE;
  263.             break;
  264.           case 'n':     /* don't alias any addresses */
  265.             NoAlias = TRUE;
  266.             break;
  267.           case 't':    /* read Header for addresses */
  268.             GrabTo = TRUE;
  269.                 break;
  270.           case 'o':    /* sendmail-like options flag */
  271.             switch(p[2]){
  272.                 case 'm': /* send this message to the sender*/
  273.                     metoo=TRUE;
  274.                     break;
  275.                 case 'c': /* don't connect to expensive
  276.                         mailer, or don't start uux*/
  277.                     startuux = FALSE;
  278.                     break;
  279.                 }
  280.             break;
  281.             }
  282.     
  283.         }
  284.  
  285.     if(*av==NULL && GrabTo!= TRUE)
  286.     {
  287.         fprintf(stderr,"Usage: %s [flags] address\n",progname);
  288.         exit(EX_USAGE);
  289.     }
  290.  
  291.     if (ConfFile == NULL) ConfFile = CONFIGFILE;
  292.  
  293.     if (AliasFile == NULL) AliasFile = ALIASFILE;
  294.  
  295. /* get login name of the sender... use environment variables if possible */
  296.  
  297.     if(from==NULL || strlen(from) == 0){
  298.         if (((from = getenv("LOGNAME")) == NULL) || (strlen(from) == 0))
  299.             from = getenv("USER");
  300.         if ((from == NULL) || (strlen(from) == 0))
  301.             from = getlogin();
  302.         if ((from == NULL) || (strlen(from) == 0))
  303.             from = getpwuid(geteuid())->pw_name;
  304.     }
  305.  
  306. /* If this is not uupath, then there must be a letter */
  307.  
  308. if (!uupath)
  309. {    
  310. #ifdef DEBUG
  311.     if (Debug) printf("Mail from %s\n",from);
  312. #endif
  313.     /*
  314.      * Make temporary file for letter
  315.      * (I wish ACCESS(2) would take care of this better !!)
  316.      */
  317.     if ((p=getenv("HOME"))== NULL)
  318.         p="/tmp";
  319.     sprintf(&templet[0],"%s/.uumXXXXXX",p);
  320.     mktemp(templet);
  321.     unlink(templet);
  322.     if ((i=open(templet,2)) < 0)
  323.         {
  324.             p="/tmp";
  325.     
  326.             sprintf(&templet[0],"%s/.uumXXXXXX",p);
  327.             mktemp(templet);
  328.             unlink(templet);
  329.         }
  330.     else
  331.         {
  332.             close(i);
  333.             unlink(templet);
  334.         }
  335. #ifdef DEBUG
  336.     if (Debug>2) printf("Temp file is %s\n",templet);
  337. #endif
  338.     if((tmpf = fopen(templet, "w")) == NULL){
  339.         fprintf(stderr, "%s : can't open %s for writing\n", progname,templet);
  340.         fclose(stdin);
  341.         exit(EX_CANTCREAT);
  342.  
  343.         }
  344.     while(fgets(lbuf,sizeof lbuf,stdin))
  345.         fputs(lbuf,tmpf);
  346.     fclose(tmpf);
  347.     fclose(stdin);
  348. /* file now saved */
  349.     if((tmpf = fopen(templet, "r")) == NULL){
  350.         fprintf(stderr, "%s : can't open %s for reading\n", progname,templet);
  351.         exit(EX_OSERR);
  352.     }
  353.     
  354. }    
  355.     (void) strcpy(sender, "");
  356.  
  357.     path = malloc(PATHSIZ);
  358.  
  359. /* build address list */
  360.  
  361.  
  362.     while (*av != NULL && *av != NULL)
  363.         add(*av++,&addrlist);
  364.  
  365.     if(metoo)   add(from,&addrlist); /* add me to the list too */
  366.  
  367.     if(!NoAlias) alias();        /* do aliasing if not turned off */
  368. #ifndef NOALIAS                /* process forwarding files */
  369.     for (lp = addrlist.m_next;lp;lp = lp->m_next) forward(lp->m_name);
  370. #endif
  371.  
  372.     for (lp = addrlist.m_next;lp;lp = lp->m_next) /* mail it out */
  373.     {
  374.  
  375.     if(strlen(lp->m_name) == 0) continue;
  376.  
  377.     local = bangcnt = 0;
  378.  
  379.     q = p = lp->m_name;
  380.     
  381.     sysname = &name[0];
  382.  
  383. /* this is uupath command */    
  384.     if (uupath) 
  385.  
  386.     {
  387.     (void) strcpy(sysname ,p);
  388. #ifdef OPATH
  389.     if ((error = getpath (&name[0], path,paths)) != EX_OK)
  390.         {
  391.         if (error == EX_NOHOST) fprintf (stderr, "System %s not found in network map\n", &name[0]);
  392.         if (error == EX_NOINPUT) fprintf(stderr,"Database %s could not be opened\n",paths);
  393.         if (error == EX_TEMPFAIL) fprintf(stderr,"Database %s is being updated\nTry again later.\n",paths);
  394.         exit(EX_NOHOST);
  395.         }
  396.     if (strcmp(path,"%s") == 0) local = 1;
  397.     }
  398.     else 
  399.     {
  400.     /* check for pipe to another program output here */
  401.     if (lp->m_pipe == TRUE){
  402.                 strcat(cmd,lp->m_name);
  403.                 goto pipeout;
  404.     }
  405. #ifdef RFC976
  406.     if (index(p,'@') == NULL) strcpy(path,oupath(p));
  407.            else strcpy(path,opath(p));
  408.  
  409. #else
  410.     if (index(p,'!') != NULL) strcpy(path,oupath(p)); 
  411.             else strcpy(path,opath(p));
  412. #endif
  413.  
  414. /* fix string to allow % to be untranslated by printf and 
  415.  * friends 
  416.  */
  417.        if ((r=index(path,'%')) != NULL)
  418.         {
  419.             char t[PATHSIZ];
  420.             strncpy(t,path,(r-path));
  421.             strcat(t,"%");
  422.             strcat(t,r);
  423.             path = &t[0];
  424. #ifdef DEBUG
  425.         if (Debug>3)
  426.             fprintf(stderr,"In percent fix, %s\n",t);
  427. #endif
  428.         }
  429.  
  430.  
  431.  
  432.  
  433. #ifdef DEBUG
  434.     if (Debug >1) fprintf(stderr,"Opath returns %s\n",path);
  435. #endif
  436.  
  437.     if (path[0] == '!') /* no match in pathalias database */
  438.     {
  439.         deadletter(tmpf,local);
  440.         unlink(templet);
  441.         exit(EX_NOHOST);
  442.     }
  443.    
  444.    if (strcmp(path,p) == 0 && index(path,'!') == NULL )
  445.     {
  446.     strcpy(path,Myname);
  447.     local = 1;
  448.     }
  449.     } /* end of else uupath */
  450. #else
  451.     }
  452.     else
  453. {
  454.     /* check and pipe to output if here */
  455.     do                        /* count bangs */
  456.         {
  457.             while (((c = *p++) != '!') && (c != '\0'));
  458.                 if (c == '!') bangcnt++;
  459.         }
  460.     while (c != '\0' && bangcnt == 1);
  461.         ;
  462.     if (bangcnt >= 1)                /* expand path */
  463.         {
  464.             while ((*sysname++ = *q++) != '!');
  465.                 *--sysname = '\0';
  466.  
  467.             }
  468.     /* insert code here to look at uucp neighbors & local host */
  469.     }
  470. if (bangcnt == 0) {
  471.         strcpy(sysname,Myname);
  472.         local = 1;
  473.         }
  474. #ifdef DEBUG
  475.     if (Debug>1) printf("sysname = %s\n",&name[0]);
  476. #endif
  477.     
  478.     if (local == 0 && (error = getpath (&name[0], path,paths)) != EX_OK)
  479.         {
  480.         if (error == EX_NOHOST) fprintf (stderr, "System %s not found in network map\n", &name[0]);
  481.         if (error == EX_NOINPUT) fprintf(stderr,"Database %s could not be opened\n",paths);
  482.         if (error == EX_TEMPFAIL) fprintf(stderr,"Database %s is being updated\nTry again later.\n",paths);
  483.         exit(EX_NOHOST);
  484.         }
  485.  
  486.        if (local!=0) path = "%s";
  487.        if (strcmp (path,"%s") == 0) local = 1;
  488. #endif
  489.  
  490.  
  491. #ifdef DEBUG
  492.        if(Debug>1) printf("Path = %s\n",path);
  493. #endif
  494.  
  495.     p = q;                    /* save name */
  496.     for (i = 0; i < 1 && *p != '\0'; p++)
  497.         if (*p == '/')
  498.         i++;
  499.     fname = &sender[0];
  500.  
  501.         if (uupath)
  502.         sprintf(fname,path,"username");
  503.     else
  504.         sprintf(fname,path,q);
  505.  
  506.     p = fname;
  507. #ifdef DEBUG
  508.     if (Debug> 4) printf("p = %s  local = %d\n ",p,local);
  509. #endif
  510.     rsys = &sys[0];
  511.  
  512.     if (local == 0)
  513.         {
  514.             while((*rsys++ = *p++) != '!');
  515.             *--rsys = '\0';
  516.         }
  517.         else
  518. /* local host, remove @ sign */
  519.         {
  520.             strcpy(rsys,lp->m_name);
  521.             q=rsys;
  522.             if (index(rsys,'@') != NULL)
  523.             { 
  524.                 while (*q++ !='@');
  525.                 *--q='\0';
  526.             }
  527.         /* assume that if it has a bang in it uux
  528.             will either reject it or know what to do with it */
  529.         /* this is a little gross */
  530.         if ((q = index(rsys,'!')) != NULL)
  531.             {
  532.                 local=0;
  533.                 strcpy(&sys[0],rsys);
  534.                 sys[q-rsys]='\0';
  535.                 p=q+1;
  536.             }
  537.     }
  538.         
  539.     if ((local==0 && *fname =='\0') || (local!=0 && &sys[0]=='\0')) {
  540.         fprintf(stdout, "null name\n");
  541.         exit(EX_DATAERR);
  542.     }
  543. #ifdef DEBUG
  544.     if (Debug>3)
  545.         printf("p = %s sys = %s fname = %s\n",p, &sys[0],fname);
  546. #endif
  547.  
  548.     if (uupath)
  549.         {
  550.         printf ("Path to %s:  %s\n", lp->m_name, fname);
  551.         continue;
  552.         }
  553.     else
  554.     {
  555.         if (local!= 0)
  556.             sprintf(cmd, LOCALMAIL, &sys[0]);
  557.         else {
  558.             sprintf(cmd,"%s - ",REALUUX);
  559.         if (!startuux)
  560.             strcat(cmd,"-r");
  561. #ifndef NORETURN
  562.         if (from)
  563.             {
  564.             strcat(cmd," -a");
  565.             strcat(cmd,from);
  566.             }
  567. #endif
  568. #ifndef NOGRADE
  569.         if (grade)
  570.             {
  571.             char work[10];
  572.             sprintf(work," -g%c",grade);
  573.             strcat(cmd,work);
  574.             }
  575. #endif        
  576.         if (index(p, '!'))
  577.             {
  578.                 char work[100];
  579.                 sprintf(work, " %s!rmail \\(%s\\)",  &sys[0], p);
  580.                 strcat(cmd,work);
  581.             }
  582.         else
  583.             {
  584.                 char work[100];
  585.                 sprintf(work, " %s!rmail %s", &sys[0], p);
  586.                 strcat(cmd,work);
  587.             }
  588.         }
  589. pipeout:
  590. #ifdef DEBUG
  591.     if (Debug) fprintf(stderr,"Command is %s\n",cmd);
  592. #endif
  593.         rewind(tmpf);
  594. #ifdef DEBUG
  595.         if (Debug)
  596.             out = fopen("UUMAIL.TEST","w");
  597.         else
  598. #endif
  599.             out = popen(cmd, "w");
  600. /*        fputs(lbuf, out); */
  601.         if (!noheader) Putfrom(tmpf,out);
  602.         while (fgets(lbuf, sizeof lbuf, tmpf))
  603.             fputs(lbuf, out);
  604.  
  605. /* may not be needed */
  606.         if (local!=0)
  607.             fprintf(out,"\n.\n");
  608.  
  609. #ifdef DEBUG
  610.         if (Debug)
  611.             i = fclose(out);
  612.         else
  613. #endif
  614.             i = pclose(out);
  615.         if ((i & 0377) != 0)
  616.             {
  617.                 fprintf(stderr, "pclose: status 0%o\n", i);
  618.                 deadletter(tmpf,local);
  619. #ifdef DEBUG
  620.                 if (Debug <3)
  621. #endif
  622.                          unlink(templet);
  623.                 exit(EX_OSERR);
  624.             }
  625. #ifdef LOG
  626.         maillog(cmd);
  627. #endif
  628.        }
  629.     }
  630. #ifdef DEBUG
  631.     if (Debug <3)
  632. #endif
  633.                 unlink(templet);
  634. exit(EX_OK);
  635. }
  636.  
  637. /* print an error message on stderr */
  638.  
  639. syserr(string)
  640. char * string;
  641. {
  642.     fprintf(stderr,"%s\n",string);
  643. }
  644.  
  645. /* make a unix type From line and send it out the stream */
  646.  
  647. Putfrom(into,outto)
  648. FILE *into, *outto;
  649. {
  650.     char    *asctime();
  651.     struct    tm *bp, *localtime();
  652.     char    *tp, *zp;
  653.     int    n,fromflag=0;
  654.     char buf[128];
  655.     long iop;
  656.  
  657.     /*
  658.      * Format time
  659.      */
  660.     time(&iop);
  661.     bp = localtime(&iop);
  662.     tp = asctime(bp);
  663. /*    zp = tzname[bp->tm_isdst];*/
  664. /*    sprintf(buf, "%s%s %.16s %.3s %.5s", from, tp, zp, tp+20);*/
  665.     sprintf(buf, "From %s %.16s %.4s", from, tp, tp+20);
  666.  
  667. #ifdef UGLYUUCP
  668.     if (local == 0){
  669.             strcat(buf," remote from ");
  670.             strcat(buf,Myname);
  671.            }
  672. #endif
  673.     strcat(buf,"\n");
  674.     write(outto->_file,buf,strlen(buf));
  675.     fflush(outto);
  676.  
  677.     if (fgets(buf,sizeof(buf),into) != NULL)
  678.     if((strncmp(&buf[0], "From ", 5) == 0 || strncmp(&buf[0], "From:", 5) == 0))
  679.          write(outto->_file,">",1);
  680.     
  681.     write(outto->_file,buf,strlen(buf));
  682. }
  683.  
  684.  
  685. /* attempt to return dead letter */
  686. /* we'll do better on this one next time */
  687.  
  688. deadletter(retlet, here)
  689. FILE *retlet;
  690. int here;
  691. {
  692.     if(getlogin() != NULL) syserr("Letter failed....\n");
  693. }
  694.  
  695. /* go here on a signal we want to catch */
  696. intsig()
  697. {
  698.     unlink(templet);
  699.     exit(EX_OK);
  700. }
  701.  
  702. /* put command strings in the logfile */
  703.  
  704. #ifdef LOG
  705.  
  706. maillog(command)
  707. char * command;
  708. {
  709.     FILE *f;
  710.     char atime[24];
  711.     long clock;
  712.     time (&clock);
  713.     strncpy(atime,ctime(&clock),24);
  714.  
  715.     if ((f=fopen(logfile,"a")) != NULL)
  716.         {
  717.             fprintf(f,"%s: %s - %s\n",progname,atime,command);
  718.             fclose(f);
  719.         }
  720. }
  721.  
  722. #endif
  723.  
  724.