home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / wizards / 3873 < prev    next >
Encoding:
Text File  |  1992-09-10  |  9.0 KB  |  297 lines

  1. Path: sparky!uunet!sun-barr!cs.utexas.edu!rutgers!cmcl2!adm!news
  2. From: Eduard.Vopicka@vse.cs (Eduard Vopicka)
  3. Newsgroups: comp.unix.wizards
  4. Subject: (none)
  5. Message-ID: <32505@adm.brl.mil>
  6. Date: 10 Sep 92 13:00:18 GMT
  7. Sender: news@adm.brl.mil
  8. Lines: 287
  9.  
  10. ~s Sendmail/IDA and frozen config files
  11.  
  12. Hi all you UNIX wizards!
  13.  
  14. I am (hopefully) done with sendmail-6.67a8/IDA-1.5 port to SCO 3.2.2.
  15. I have had no significant problems while doing this. Now I am trying
  16. to get the same program working under Interactive UNIX. And here is my
  17. problem - I cannot get easily over it:
  18.  
  19. The sendmail/IDA frozen configuration files are known not to work
  20. under various UNIX implementations, in my case under Interactive UNIX.
  21. This fact is evidently known - quick scan through source files shows
  22. the frozen config file option being carefully automatically excluded
  23. while compiling sendmail/IDA under Interactive UNIX.
  24.  
  25. This is normally not a problem but if the mail load on the machine is
  26. heavy things are getting unacceptably slow. I have heard some rumors that
  27. both the source of the problem and the solution are known, but I failed to
  28. find the answer. (Of course the solution must be known, the sendmail binary
  29. supplied with the Interactive operating system supports the frozen config
  30. files.)
  31.  
  32. So I have tried to forcibly enable the frozen config files option. But
  33. no fun. I have observed that sendmail fails on the malloc() after the
  34. frozen config file is read. malloc() returns NULL and sendmail then
  35. complains with "Out of memory!!" and exits.
  36.  
  37. Please does any of you UNIX wizards know the solution and can you kick me
  38. in the right direction. Any help will be highly appreciated - my goal is
  39. to have the same sendmail/IDA running on all our UNIXes here at Prague
  40. School of Economics. And the frozen configuration files seem to be
  41. essential in our environment.
  42.  
  43. Please can you send any answers to this list or directly to eda@vse.cs.
  44.  
  45. Thanks in advance,
  46.  
  47. Ed
  48.  
  49. ============================================================================
  50. = Eduard Vopicka                             e-mail: Eduard.Vopicka@vse.cs =
  51. = Computing Centre                              fax: +42 2 235 85 09       =
  52. = Prague School of Economics                                               =
  53. = W. Churchill square 4                                                    =
  54. = CS 130 67 Prague 3                      ("There is always one more bug") =
  55. ============================================================================
  56.  
  57. Attached are two excerpts from the sendmail's main.c, the freeze() and
  58. thaw() procedures.
  59.  
  60. /*
  61.  * Copyright (c) 1983 Eric P. Allman
  62.  * Copyright (c) 1988 Regents of the University of California.
  63.  * All rights reserved.
  64.  *
  65.  * Redistribution and use in source and binary forms, with or without
  66.  * modification, are permitted provided that the following conditions
  67.  * are met:
  68.  * 1. Redistributions of source code must retain the above copyright
  69.  *    notice, this list of conditions and the following disclaimer.
  70.  * 2. Redistributions in binary form must reproduce the above copyright
  71.  *    notice, this list of conditions and the following disclaimer in the
  72.  *    documentation and/or other materials provided with the distribution.
  73.  * 3. All advertising materials mentioning features or use of this software
  74.  *    must display the following acknowledgement:
  75.  *    This product includes software developed by the University of
  76.  *    California, Berkeley and its contributors.
  77.  * 4. Neither the name of the University nor the names of its contributors
  78.  *    may be used to endorse or promote products derived from this software
  79.  *    without specific prior written permission.
  80.  *
  81.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  82.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  83.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  84.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  85.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  86.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  87.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  88.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  89.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  90.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  91.  * SUCH DAMAGE.
  92.  */
  93.  
  94. static void freeze __P((char *));
  95. static thaw __P((char *));
  96.  
  97. #ifdef _PATH_SENDMAILFC
  98. /*
  99. **  FREEZE -- freeze BSS & allocated memory
  100. **
  101. **    This will be used to efficiently load the configuration file.
  102. **
  103. **    Parameters:
  104. **        freezefile -- the name of the file to freeze to.
  105. **
  106. **    Returns:
  107. **        none.
  108. **
  109. **    Side Effects:
  110. **        Writes BSS and malloc'ed memory to freezefile
  111. */
  112.  
  113. union frz
  114. {
  115.     char        frzpad[BUFSIZ];    /* insure we are on a BUFSIZ boundary */
  116.     struct
  117.     {
  118.         TIME_TYPE frzstamp;    /* timestamp on this freeze */
  119.         char    *frzbrk;    /* the current break */
  120.         char    *frzedata;    /* address of edata */
  121.         char    *frzend;    /* address of end */
  122.         char    frzver[252];    /* sendmail version */
  123.         char    frzdatecompiled[64];    /* sendmail compilation date */
  124.     } frzinfo;
  125. };
  126.  
  127. static void
  128. freeze(freezefile)
  129.     char *freezefile;
  130. {
  131.     int f;
  132.     union frz fhdr;
  133.     extern int edata, end;
  134. # if defined(__hpux)
  135.     extern void *sbrk __P((int));
  136. # else /* !__hpux */
  137.     extern char *sbrk __P((int));
  138. # endif /* __hpux */
  139.     extern char Version[];
  140.     extern char datecompiled[];
  141.  
  142.     if (freezefile == NULL)
  143.         return;
  144. # ifdef notdef
  145.     {
  146.         /*
  147.         ** NIS (nee YP) state is saved in the freeze, the readback
  148.         ** of the freeze file destroys similar information.  This
  149.         ** causes strange results later due to the unexpected closing
  150.         ** of a file descriptor using a stale copy.
  151.         */
  152.  
  153.         char *domain;
  154.         if (yp_get_default_domain(&domain) == 0)
  155.             yp_unbind(domain);
  156.     }
  157. # endif /* YP */
  158.  
  159.     /* try to open the freeze file */
  160.     if ((f = open(freezefile, O_WRONLY|O_CREAT|O_TRUNC, FileMode)) < 0)
  161.     {
  162.         syserr("Cannot freeze %s", freezefile);
  163.         errno = 0;
  164.         return;
  165.     }
  166.  
  167.     /* build the freeze header */
  168.     fhdr.frzinfo.frzstamp = curtime();
  169.     fhdr.frzinfo.frzbrk = sbrk(0);
  170.     fhdr.frzinfo.frzedata = (char *) &edata;
  171.     fhdr.frzinfo.frzend = (char *) &end;
  172.     (void) strcpy(fhdr.frzinfo.frzver, Version);
  173.     (void) strcpy(fhdr.frzinfo.frzdatecompiled, datecompiled);
  174.  
  175.     /* write out the freeze header */
  176.     if (write(f, (char *) &fhdr, sizeof fhdr) != sizeof fhdr ||
  177.         write(f, (char *) &edata, (int) (fhdr.frzinfo.frzbrk - (char *) &edata)) !=
  178.                     (int) (fhdr.frzinfo.frzbrk - (char *) &edata))
  179.     {
  180.         syserr("Cannot freeze %s", freezefile);
  181.     }
  182.  
  183.     /* fine, clean up */
  184.     (void) close(f);
  185. }
  186.  
  187. /*
  188. **  THAW -- read in the frozen configuration file.
  189. **
  190. **    Parameters:
  191. **        freezefile -- the name of the file to thaw from.
  192. **
  193. **    Returns:
  194. **        TRUE if it successfully read the freeze file.
  195. **        FALSE otherwise.
  196. **
  197. **    Side Effects:
  198. **        reads freezefile in to BSS area.
  199. */
  200.  
  201. static int
  202. thaw(freezefile)
  203.     char *freezefile;
  204. {
  205.     int f;
  206.     union frz fhdr;
  207.     extern int edata, end;
  208.     extern char Version[];
  209.     extern char datecompiled[];
  210. # if defined(__hpux)
  211.     extern int brk __P((const void *));
  212. # else /* !__hpux */
  213.     extern char *brk __P((const char *));
  214. # endif /* __hpux */
  215.  
  216.     if (freezefile == NULL)
  217.         return (FALSE);
  218.  
  219.     /* open the freeze file */
  220.     if ((f = open(freezefile, O_RDONLY, 0)) < 0)
  221.     {
  222. # ifdef LOG
  223.         if (OpMode == MD_DAEMON)
  224.             syslog(LOG_WARNING, "Cannot open frozen config file %s: %m", freezefile);
  225. # endif /* LOG */
  226.         errno = 0;
  227.         return (FALSE);
  228.     }
  229. # ifdef notdef
  230.     {
  231.         /*
  232.         ** NIS (nee YP) state is saved in the freeze, the readback
  233.         ** of the freeze file destroys similar information.  This
  234.         ** causes strange results later due to the unexpected closing
  235.         ** of a file descriptor using a stale copy.
  236.         */
  237.  
  238.         char *domain;
  239.         if (yp_get_default_domain(&domain) == 0)
  240.             yp_unbind(domain);
  241.     }
  242. # endif /* YP */
  243.  
  244.     /* read in the header */
  245.     if (read(f, (char *) &fhdr, sizeof fhdr) < sizeof fhdr)
  246.     {
  247.         syserr("Cannot read frozen config file");
  248.         (void) close(f);
  249.         return (FALSE);
  250.     }
  251.     {
  252.         char why[40];
  253.  
  254.         *why = '\0';
  255.         if (fhdr.frzinfo.frzedata != (char *) &edata)
  256.             (void) strcat(why, "Edata");
  257.         if (fhdr.frzinfo.frzend != (char *) &end)
  258.             (void) strcat(why, "End");
  259.         if (strcmp(fhdr.frzinfo.frzver, Version))
  260.             (void) strcat(why, "Version");
  261.         if (strcmp(fhdr.frzinfo.frzdatecompiled, datecompiled))
  262.             (void) strcat(why, "Datecompiled");
  263.         if (*why)
  264.         {
  265.             if (tTd(0, 1))
  266.                 printf("Wrong version of frozen config file (%s mismatch)\n", why);
  267. # ifdef LOG
  268.             syslog(LOG_WARNING, "Wrong version of frozen config file (%s mismatch)", why);
  269. # endif /* LOG */
  270.             (void) close(f);
  271.             return (FALSE);
  272.         }
  273.     }
  274.  
  275.     /* arrange to have enough space */
  276.     if ((int)brk(fhdr.frzinfo.frzbrk) == -1)
  277.     {
  278.         syserr("Cannot break to %x", fhdr.frzinfo.frzbrk);
  279.         (void) close(f);
  280.         return (FALSE);
  281.     }
  282.  
  283.     /* now read in the freeze file */
  284.     if (read(f, (char *) &edata, (int) (fhdr.frzinfo.frzbrk - (char *) &edata)) !=
  285.                     (int) (fhdr.frzinfo.frzbrk - (char *) &edata))
  286.     {
  287.         syserr("Cannot read frozen config file");
  288.         /* oops!  we have trashed memory..... */
  289.         (void) write(2, "Cannot read freeze file\n", 24);
  290.         _exit(EX_SOFTWARE);
  291.     }
  292.  
  293.     (void) close(f);
  294.     return (TRUE);
  295. }
  296. #endif /* _PATH_SENDMAILFC */
  297.