Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / zotnet / mf / mmdfI / src / uucp / RCS / rmail.c,v
1 head    1.2;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.2
9 date    93.08.25.17.32.49;      author jromine; state Exp;
10 branches;
11 next    1.1;
12
13 1.1
14 date    93.08.25.17.32.24;      author jromine; state Exp;
15 branches;
16 next    ;
17
18
19 desc
20 @@
21
22
23 1.2
24 log
25 @off_t fixes for BSD44
26 @
27 text
28 @#define        MFDEBUG                 /* temporarily */
29 #ifndef lint
30 static char Id[] = "@@(#)$Id:$";
31 #endif
32
33 #include "util.h"
34 #include "mmdf.h"
35 #include <pwd.h>
36 #include <signal.h>
37 #include "mf.h"
38 #include "tws.h"
39
40 /*
41  *                              R M A I L . C
42  *
43  *      Developed from the Berkeley mail program of the same name
44  *      by Mike Obrien at RAND to run with the MMDF mail system.
45  *      Rewritten by Doug Kingston, US Army Ballistics Research Laboratory
46  *      Hacked a lot by Steve Bellovin (smb@@unc)
47  *
48  *      This program runs SETUID to root so that it can set effective and
49  *      real [ug]ids to mmdflogin.
50  *
51  *    27-Oct-82 Marshall T. Rose <mrose%uci@@rand-relay>
52  *              Support proper munging by using the UCI mail filtering
53  *              routines (enabled by #ifdef MF)
54  *              Also use ll_log() package (enabled by #ifdef LOG)
55  *
56  *    17-Oct-83 Marshall T. Rose <mrose%uci@@rand-relay>
57  *              New interfacing.  Remove the #ifdef:s
58  */
59
60
61 #define NAMESZ  64      /* Limit on component name size         */
62
63 #define ADDROK  0
64 #define UUCP    1
65 #define RETURN  2
66
67 int     Syscpy = 1;
68 int     Tmpmode = 0600;
69 char   *Fromtmp = "/tmp/rml.f.XXXXXX";
70 char   *Msgtmp = "/tmp/rml.m.XXXXXX";
71 char   *Errtmp = "/tmp/rml.e.XXXXXX";
72 char   *Okhosts = "/usr/mmdf/table/rmail.ok";
73 char   *Okdests = "/usr/mmdf/table/rmail.okdests";
74
75 extern  char    cmddfldir[];
76 extern  char    logdfldir[];
77 extern  char    mmdflogin[];
78 extern  char    pathsubmit[];
79 extern  char    sitesignature[];
80 extern  char    supportaddr[];
81 extern  struct ll_struct chanlog;
82
83 char   *dupfpath (), *index(), *rindex();
84 struct  passwd *getpwnam(), *getpwuid();
85 FILE   *popen();
86
87 /* \f */
88
89 struct ll_struct *logptr = &chanlog;
90
91 FILE *fromf;            /* temporary out for colon-less UUCP "From" lines */
92 FILE *msgf;             /* temporary out for message text */
93 FILE *mmdf;             /* filtered mail file */
94 FILE *pipef;            /* output to "submit" or "uux" */
95 char date[LINESIZE];    /* date of origination from uucp header */
96 char from[LINESIZE];    /* accumulated path of sender */
97 char origsys[NAMESZ];   /* originating system */
98 char origpath[LINESIZE];/* path from us to originating system */
99 char usrfrm[LINESIZE];
100 char Mailsys[LINESIZE];
101 int pbroke;             /* broken-pipe flag */
102 int rtnflag;            /* note was sent back */
103
104 int     brpipe();
105
106 /* \f */
107
108 main(argc, argv)
109 char **argv;
110 {
111         char fromwhom[NAMESZ];          /* user on remote system */
112         char *fromptr;
113         char linebuf[LINESIZE];         /* scratchpad */
114         char sys[NAMESZ];               /* an element in the uucp path */
115         char *cp;
116         struct passwd *pw;
117         int  error;
118         int cpyback;
119
120         if (argc < 2) {
121                 fprintf(stderr, "Usage: rmail user [user ...]\n");
122                 exit(1);
123         }
124         umask (0);
125
126         ll_hdinit (logptr, "RM");
127         logptr -> ll_file = dupfpath (logptr -> ll_file, logdfldir);
128
129         if ((pw = getpwnam (mmdflogin)) == NULL) {
130                 fprintf (stderr, "Cannot find mmdflogin\n");
131                 exit (99);
132         }
133         setgid (pw->pw_gid);
134         setuid (pw->pw_uid);
135
136         sprintf (Mailsys, "%s <%s@@%s>",
137             sitesignature, mmdflogin, LocalName ());
138
139 /* \f */
140
141     {                           /* BE VERY SURE... */
142         int     i;
143     
144         for (i = fileno (stdout); i <= HIGHFD; i++)
145             close (i);
146     }
147
148         /* create file to hold stderr output.  We first open some */
149         /* null file to make sure stdout is taken.  If stdin isn't */
150         /* open either, we've got so much trouble it isn't even worth */
151         /* worrying about a little more */
152         open("/dev/null", 0);
153         mktemp(Errtmp);
154         if (freopen(Errtmp, "w", stderr) == NULL) {
155                 fprintf(stderr, "Can't create %s\n", Errtmp);
156                 ll_log (logptr, LLOGFAT, "Unable to create '%s'",
157                         Errtmp);
158                 exit(1);
159         }
160         dup2 (fileno (stderr), fileno (stdout));
161
162         /* Create temp file for rest of message */
163         mktemp (Msgtmp);
164         if ((msgf=fdopen(creat(Msgtmp, Tmpmode), "w")) == NULL) {
165                 fprintf(stderr, "Can't create %s\n", Msgtmp);
166                 ll_log (logptr, LLOGFAT, "Unable to create '%s'",
167                         Msgtmp);
168                 exit(1);
169         }
170
171         /* create temp file for colon-less UUCP "From" lines */
172         mktemp (Fromtmp);
173         if ((fromf=fdopen(creat(Fromtmp, Tmpmode), "w")) == NULL) {
174                 fprintf(stderr, "Can't create %s\n", Fromtmp);
175                 ll_log (logptr, LLOGFAT, "Unable to create '%s'",
176                         Fromtmp);
177                 exit(1);
178         }
179
180 /* \f */
181
182         for (;;) {
183                 if( fgets(linebuf, sizeof linebuf, stdin) == NULL )
184                         break;
185                 if(   strncmp(linebuf, "From ", 5)
186                    && strncmp(linebuf, ">From ", 6) )
187                         break;
188
189                 if (linebuf[0] != '>')
190                         fputs (">", fromf);
191                 fputs(linebuf, fromf);  /* Save, we may forward via UUCP */
192                 cp = index (linebuf, ' ');      /* start of name */
193                 fromptr = ++cp;
194                 cp = index (cp, ' ');           /* cp at end of name */
195                 *cp++ = 0;                      /* term. name, cp at date */
196                 strcpy (fromwhom, fromptr);
197                 strncpy (date, cp, 24);         /* Mon Nov 10 23:12:09 1981 */
198
199                 for (;;) {
200                         cp = index(cp+1, 'r');
201                         if (cp == NULL) {
202                                 cp = rindex(fromwhom, '!');
203                                 if (cp != NULL) {
204                                         char *p;
205                                         *cp = '\0';
206                                         p = rindex(fromwhom, '!');
207                                         if (p != NULL) strcpy(origsys, p+1);
208                                         else strcpy(origsys, fromwhom);
209                                         strcat(from, fromwhom);
210                                         strcat(from, "!");
211                                         strcpy(fromwhom, cp+1);
212                                         goto out;
213                                 }
214                                 strcpy (sys, SystemName ());
215                                 strcat (from, sys);
216                                 strcpy (origsys, sys);
217                                 strcat (from, "!");
218                                 goto out;
219                         }
220                         if (strncmp(cp, "remote from ", 12) == 0)
221                                 break;
222                 }
223
224                 sscanf(cp, "remote from %s", sys);
225                 strcat(from, sys);
226                 strcpy(origsys, sys);           /* Save for quick ref. */
227                 strcat(from, "!");
228 out:;
229         }
230         if( fromwhom[0] == '\0' )               /* No from line, illegal */
231                 exit(99);
232
233 /* \f */
234
235         strcpy (origpath, from);
236         strcat (from, fromwhom);
237         mf_get_addr (from, usrfrm);
238         if ((cp = rindex (usrfrm, '<')) != NULL) {
239             strcpy (usrfrm, ++cp);/* sigh */
240             if ((cp = rindex (usrfrm, '>')) != NULL)
241                 *cp = NULL;
242             }
243         if (usrfrm[0] == NULL)
244             sprintf (usrfrm, "%s!%s%%%s@@%s",
245                 SystemName (), from, UucpChan (), LocalName ());
246         ll_log (logptr, LLOGGEN, "Rmail from '%s' (%s)", from, usrfrm);
247         fputs (linebuf, msgf);
248         if (rp_isbad (txtcpy (stdin, msgf)))
249             fputs ("\n  *** Problem during receipt from UUCP ***\n", msgf);
250
251         freopen (Msgtmp, "r", msgf);
252         freopen (Fromtmp, "r", fromf);
253         unlink (Msgtmp);
254         unlink (Fromtmp);
255         mmdf = NULL;
256
257         cpyback = 0;
258         for (argv++; --argc > 0; ) {
259                 rewind (fromf);
260                 rewind (msgf);
261                 if (mmdf != NULL)
262                     rewind (mmdf);
263                 pbroke = 0;
264                 rtnflag = 0;
265                 signal(SIGPIPE, brpipe);
266                 if (rp_isbad(deliver(*argv++)) && !rtnflag)
267                         cpyback++;
268         }
269
270         /* Send back a copy if something nasty happened.  For now, we use */
271         /* a real kludge -- we see if we noted some error, or if we find */
272         /* anything written to stderr....  */
273         fflush(stderr);
274         fflush (stdout);
275
276         if (cpyback) {rcpy();zcpy();}
277
278         unlink(Errtmp);
279         ll_close (logptr);
280         exit (0);
281 }
282
283 /* \f */
284
285 /*
286  *      deliver() -- Handle all deliveries be they returns, automatic
287  *                      copies, or the real thing.  Based on the address
288  *                      the letter is accepted or returned with a copy
289  *                      to the system administrators
290  *
291  *                      main() has set up the "from" string and the
292  *                      "date" string.
293  */
294 char    rtnend[] =
295         "  --------------- End of Returned Mail ---------------\n";
296
297 deliver(to)
298 char *to;
299 {
300         int     replyval;
301         int     i;
302         char    linebuf[LINESIZE];
303         char    tmpbuf[LINESIZE];
304
305         switch (adrcheck (to)) {
306         case ADDROK:
307                 ll_log (logptr, LLOGGEN, "Rmail to '%s' via MMDF", to);
308                 if (rp_isbad (replyval = 
309                         xsubmit (NULL, usrfrm, NULL, NULL, to)))
310                     break;
311                 if (mmdf == NULL)
312                     if (mf_get_msg () == NOTOK)
313                         mmdf = msgf;
314                 replyval = txtcpy (mmdf, pipef);
315 #ifndef RUNALON
316                 i = (pclose(pipef) >> 8 ) & 0xff;
317                 if (rp_isgood(replyval)) replyval = i;
318 #endif
319                 break;
320
321         case UUCP:
322                 ll_log (logptr, LLOGGEN, "Rmail to '%s' via UUCP", to);
323                 if (rp_isbad (replyval = xuucp(from, to)))
324                         break;
325                 replyval = txtcpy(msgf, pipef);
326 #ifndef RUNALON
327                 i = (pclose(pipef) >> 8 ) & 0xff;
328                 if (rp_isgood(replyval)) replyval = (i == 0 ? RP_OK : RP_LIO);
329 #endif
330                 break;
331
332 /* \f */
333
334         case RETURN:
335                 rtnflag = 1;
336                 ll_log (logptr, LLOGGEN, "Illegal Rmail to '%s'", to);
337                 switch (adrcheck (from)) {
338                 case ADDROK:
339                 case RETURN:
340                         replyval = xsubmit (dtimenow (), Mailsys,
341                                         from, supportaddr, from);
342                         rtnmesg(to);
343                         txtcpy(fromf, pipef);
344                         txtcpy(msgf, pipef);
345                         fputs (rtnend, pipef);
346 #ifndef RUNALON
347                         i = (pclose(pipef) >> 8 ) & 0xff;
348                         if (rp_isgood(replyval)) replyval = i;
349 #endif
350                         break;
351
352                 case UUCP:
353                         replyval = xuucp (mmdflogin, from);
354                         if (rp_isbad (replyval))
355                                 break;
356                         fprintf (pipef, "To: %s\n", from);
357                         fprintf (pipef, "Cc: %s\n", supportaddr);
358                         rtnmesg(to);
359                         txtcpy(fromf, pipef);
360                         txtcpy(msgf, pipef);
361                         fputs (rtnend, pipef);
362 #ifndef RUNALON
363                         i = (pclose(pipef) >> 8 ) & 0xff;
364                         if (rp_isgood(replyval))
365                             replyval = (i == 0 ? RP_OK : RP_LIO);
366 #endif
367                         break;
368                 }
369
370                 /* And now for the mail overseer's copy */
371                 if (Syscpy) {
372                         ll_log (logptr, LLOGGEN, "Notifying %s", supportaddr);
373                         rewind (fromf);
374                         rewind (msgf);
375
376                         replyval = xsubmit (dtimenow (), Mailsys,
377                                         usrfrm, supportaddr, supportaddr);
378                         if (rp_isbad (replyval))
379                                 break;
380                         rtnmesg(to);
381                         txtcpy (fromf, pipef);
382                         txtcpy (msgf, pipef);
383                         fputs (rtnend, pipef);
384 #ifndef RUNALON
385                         i = (pclose(pipef) >> 8 ) & 0xff;
386                         if (rp_isgood(replyval)) replyval = i;
387 #endif
388                 }
389         }
390         return (replyval);
391 }
392
393 /* \f */
394
395 adrcheck (adr)                             /* Gateway to Arpanet? */
396 char *adr;
397 {
398     char   *cp,
399             err[BUFSIZ],
400             host[BUFSIZ],
401             mbox[BUFSIZ];
402     struct adrx *adrxp;
403
404     if ((adrxp = seekadrx (adr)) == NULL)
405         return RETURN;
406     strcpy (err, adrxp -> err ? adrxp -> err : "");
407     strcpy (host, adrxp -> host ? adrxp -> host : "");
408     strcpy (mbox, adrxp -> mbox ? adrxp -> mbox : "");
409     while (seekadrx (NULL))
410         continue;
411
412     if (err[0] || mbox[0] == NULL)
413         return RETURN;
414     if (index (mbox, '!') || host[0] == NULL)
415         return UUCP;
416     if (rp_isgood (lookup (origsys, Okhosts)))
417         return ADDROK;
418     if (index (host, '@@') || rp_isbad (okhost (host)))
419         return RETURN;
420
421     return ADDROK;
422 }
423
424
425 okhost(host)             /* Host permitted to use mail facilities? */
426 char *host;
427 {
428         if (rp_isgood (lookup (origsys, Okhosts)))
429                 return (RP_OK);         /* Fully privledged originator */
430         if (rp_isgood (lookup (host, Okhosts)))
431                 return (RP_OK);         /* Fully privledged dest */
432         if (rp_isgood (lookup (host, Okdests)))
433                 return (RP_OK);         /* Unrestricted Dest. Host, OK */
434         return(RP_NO);                  /* Not permitted; must be bad */
435 }
436
437 /* \f */
438
439 /*
440  *      lookup()  --    This lookup function looks for strings which
441  *                      must be the first string on a line.  Sorry Dave (dhc)
442  *                      but the MMDF channel functions are too specific
443  *                      to be easily used here without much kludging.
444  */
445
446 /*****************************************
447 ****    Can this be a call to a MMDF function??
448 ****    Remember I have the RHOSTs table and the OKHOSTS table.
449 ******************************************/
450
451 lookup (what, where)
452 char *what, *where;
453 {
454         FILE *lookf;
455         char entry[LINESIZE];
456         char *cp;
457
458         if ((lookf = fopen (where, "r")) == NULL)
459                 return (RP_NO);         /* Unknown problem */
460         while (fgets (entry, sizeof entry, lookf) != NULL) {
461                 cp = entry;
462                 while (*cp != '\n' && *cp != ' ' && *cp != '\t')
463                         cp++;
464                 *cp = 0;
465                 if (lexequ (what, entry)) {
466                         fclose (lookf);
467                         return (RP_OK);
468                 }
469         }
470         fclose (lookf);
471         return (RP_NO);
472 }
473
474
475 /* \f */
476
477 char *rtnmessage[] = {
478         "       Your message has been intercepted trying to access\n",
479         "a restricted access host (e.g. an ARPANET host).  A copy\n",
480         "of your message has been sent to the system administrators.\n",
481         "The text of your message follows.\n\n",
482         "  --------------- Returned Mail Follows --------------\n",
483         0
484 };
485
486 rtnmesg (badadr)
487 char *badadr;
488 {
489         char **cpp;
490
491         fprintf (pipef, "Subject:  Illegal Address (%s)\n\n", badadr);
492         for (cpp = rtnmessage; *cpp; cpp++)
493                 fputs (*cpp, pipef);
494 }
495
496 txtcpy (frm, to)
497 FILE *frm, *to;
498 {
499         char buffer[BUFSIZ];
500         int nread;
501
502         while (!pbroke && (nread = fread (buffer, sizeof (*buffer), BUFSIZ, frm)) > 0)
503                 fwrite (buffer, sizeof (*buffer), nread, to);
504         return (ferror (frm) ? RP_LIO : RP_OK );
505 }
506
507 /* \f */
508
509 xsubmit (date, from, to, cc, realto)
510 char *date, *from, *to, *cc, *realto;
511 {
512     char    cmdstr[LINESIZE],
513             submit[LINESIZE];
514
515     getfpath (pathsubmit, cmddfldir, submit);
516     sprintf (cmdstr, "%s '-mlti%s*'", submit, UucpChan ());
517
518 #ifndef RUNALON
519     if ((pipef = popen (cmdstr, "w")) == NULL)
520         return (RP_NO);
521 #else
522     pipef = stdout;
523     printf ("%s\n", cmdstr);
524 #endif
525
526     fprintf (pipef, "%s\n%s\n!\n", from, realto);
527
528     if (date) {
529         fprintf (pipef, "Date:     %s\n", date);
530         fprintf (pipef, "From:     %s\n", from);
531     }
532     if (to) {
533         fprintf (pipef, "To:       %s", to);
534         if (index (to, '@@'))
535             fputc ('\n', pipef);/* Explicit host specified */
536         else
537             fprintf (pipef, "@@%s\n", LocalName ());
538     }
539     if (cc) {
540         fprintf (pipef, "Cc:       %s\n", cc);
541     }
542
543     return (RP_OK);
544 }
545
546 /* \f */
547
548 xuucp (from, to)
549 char *from, *to;
550 {
551         char    cmdstr[LINESIZE];
552
553         sprintf (cmdstr, "/etc/delivermail -r%s -ep -m -s -i %s", from, to);
554
555 #ifndef RUNALON
556         if ((pipef = popen (cmdstr, "w")) == NULL)
557                 return (RP_NO);
558 #else
559         pipef = stdout;
560         printf ("%s\n", cmdstr);
561 #endif
562
563         return (RP_OK);
564 }
565
566 /* \f */
567
568 brpipe()        /* catch broken-pipe signals */
569 {
570         signal(SIGPIPE, SIG_IGN);
571         pbroke = 1;
572 }
573
574 char *oopsmessage[] = {
575     "\n\n\tThe system administrators (%s) have been informed of the\n",
576     "problem, but have not been given a copy of your message.\n",
577     NULL
578 };
579
580 /* \f */
581
582 rcpy () {
583     int     i;
584     char    buffer[BUFSIZ],
585             message[BUFSIZ];
586     FILE * fp;
587
588     ll_log (logptr, LLOGGEN, "Advising %s of failure as %s...", from, usrfrm);
589
590     sprintf (buffer, "Problems sending mail:\n\n");
591     if (ml_1adr (NO, NO, sitesignature, "Problems sending mail", usrfrm)
592             != OK)
593         goto ml_err;
594     ml_txt (buffer);
595
596     if ((fp = fopen (Errtmp, "r")) != NULL) {
597         ml_file (fp);
598         if (ftell (fp) == 0L)
599             fprintf (pipef, "\tunknown problem\n");
600         fclose (fp);
601     }
602     else
603         ml_txt ("\tunknown problem\n");
604
605     for (i = 0; oopsmessage[i]; i++) {
606         sprintf (message, oopsmessage[i], supportaddr);
607         ml_txt (message);
608     }
609     fprintf (pipef, "\n\nReturned message follows:\n\n---------------\n\n");
610     rewind (fromf);
611     ml_file (fromf);
612     rewind (msgf);
613     ml_file (msgf);
614
615     if (ml_end (OK) != OK) {
616         char   *cp;
617
618 ml_err: ;
619         if (cp = index (buffer, '\n'))
620             *cp = NULL;
621         ll_log (logptr, LLOGFAT, "Unable to post failure notice");
622         ll_log (logptr, LLOGFAT, "info: %s", buffer);
623     }
624 }
625
626 /* \f */
627
628 zcpy () {
629     char    buffer[BUFSIZ];
630     FILE * fp;
631
632     ll_log (logptr, LLOGGEN, "Advising %s of failure...", supportaddr);
633
634     sprintf (buffer, "Problems sending mail for %s (aka %s):\n\n",
635             from, usrfrm);
636     if (ml_1adr (NO, NO, sitesignature, "Problems sending mail", supportaddr)
637             != OK)
638         goto ml_err;
639     ml_txt (buffer);
640
641     if ((fp = fopen (Errtmp, "r")) != NULL) {
642         ml_file (fp);
643         if (ftell (fp) == 0L)
644             fprintf (pipef, "\tunknown problem\n");
645         fclose (fp);
646     }
647     else
648         ml_txt ("\tunable to open error file\n");
649
650     if (ml_end (OK) != OK) {
651         char   *cp;
652
653 ml_err: ;
654         if (cp = index (buffer, '\n'))
655             *cp = NULL;
656         ll_log (logptr, LLOGFAT, "Unable to post failure notice");
657         ll_log (logptr, LLOGFAT, "info: %s", buffer);
658     }
659 }
660
661 /* \f */
662
663 mf_get_msg () {
664     int     i,
665             fd,
666             md,
667             td;
668     char    buffer[BUFSIZ],
669             tmpfil[LINESIZE],
670             mmdfil[LINESIZE];
671 #ifdef  MFDEBUG
672     FILE * fp;
673 #endif  MFDEBUG
674     FILE * out;
675
676     strcpy (tmpfil, "/tmp/rmailXXXXXX");
677     unlink (mktemp (tmpfil));
678     if ((fd = creat (tmpfil, Tmpmode)) == NOTOK)
679         return NOTOK;
680     close (fd);
681     if ((fd = open (tmpfil, 2)) == NOTOK)
682         return NOTOK;
683     if ((out = fdopen (fd, "w")) == NULL) {
684         close (fd);
685         return NOTOK;
686     }
687     if ((td = dup (fd)) == NOTOK) {
688         close (fd);
689         return NOTOK;
690     }
691
692     fprintf (out, "From %s %s\n", from, date);
693     if (rp_isbad (txtcpy (msgf, out))) {
694         close (fd);
695         close (td);
696         return NOTOK;
697     }
698     fclose (out);
699     lseek (td, (off_t)0, 0);
700
701     strcpy (mmdfil, "/tmp/mmdfXXXXXX");
702     unlink (mktemp (mmdfil));
703     if ((fd = creat (mmdfil, Tmpmode)) == NOTOK) {
704         close (td);
705         unlink (tmpfil);
706         return NOTOK;
707     }
708     if ((fd = open (mmdfil, 2)) == NOTOK) {
709         close (td);
710         unlink (tmpfil);
711         return NOTOK;
712     }
713     if ((md = dup (fd)) == NOTOK) {
714         close (td);
715         unlink (tmpfil);
716         close (fd);
717         return NOTOK;
718     }
719
720 /* \f */
721
722     switch (i = uucp_to_mmdf (td, fd, TRUE)) {
723         case OK: 
724             lseek (md, (off_t)0, 0);
725             if ((mmdf = fdopen (md, "r")) != NULL)
726                 break;
727
728         default: 
729             close (md);
730
731             sprintf (buffer, "rmail(%d) filtering failed(%d)\n",
732                     getpid (), i);
733             if (ml_1adr (NO, NO, sitesignature, "MF Failure", supportaddr)
734                     != OK)
735                 goto ml_err;
736             ml_txt (buffer);
737 #ifdef  MFDEBUG
738             lseek (td, (off_t)0, 0);
739             if ((md = dup (td)) == NOTOK)
740                 ml_txt ("unable to dup() descriptor for message copy\n");
741             else
742                 if ((fp = fdopen (md, "r")) == NULL) {
743                     ml_txt ("unable to fdopen() descriptor for message copy\n");
744                     close (md);
745                 }
746                 else {
747                     ml_txt ("\n  --Message Follows--\n");
748                     ml_file (fp);
749                     fclose (fp);
750                 }
751 #endif  MFDEBUG
752             if (ml_end (OK) != OK) {
753                 char   *cp;
754
755         ml_err: ;
756                 if (cp = index (buffer, '\n'))
757                     *cp = NULL;
758                 ll_log (logptr, LLOGFAT, "Unable to post failure notice");
759                 ll_log (logptr, LLOGFAT, "info: %s", buffer);
760             }
761
762             md = NOTOK;
763             break;
764     }
765     close (td);
766     unlink (tmpfil);
767     close (fd);
768     unlink (mmdfil);
769
770     return md;
771 }
772
773 /* \f */
774
775 mf_get_addr (from, to)
776 char *from,
777      *to;
778 {
779     struct adrx *adrxp,
780                *seekadrx ();
781
782     *to = NULL;
783     if ((adrxp = seekadrx (from)) == NULL)
784         return;
785     addr_convert (adrxp, to, TRUE);
786     while (seekadrx (NULL))
787         continue;
788     return;
789 }
790 @
791
792
793 1.1
794 log
795 @Initial revision
796 @
797 text
798 @d2 3
799 d672 1
800 a672 1
801     lseek (td, 0L, 0);
802 d697 1
803 a697 1
804             lseek (md, 0L, 0);
805 d711 1
806 a711 1
807             lseek (td, 0L, 0);
808 @