home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / emacs / bug / 1502 < prev    next >
Encoding:
Text File  |  1992-11-20  |  3.2 KB  |  152 lines

  1. Newsgroups: gnu.emacs.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!cam.org!marc
  3. From: marc@cam.org (Marc Boucher)
  4. Subject: SVR4-conforming mailbox locking in etc/movemail
  5. Message-ID: <199211202105.AA05422@Altitude.CAM.ORG>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Fri, 20 Nov 1992 11:05:18 GMT
  10. Approved: bug-gnu-emacs@prep.ai.mit.edu
  11. Lines: 139
  12.  
  13. Hello,
  14.  
  15. I have made movemail conformant to SVR4 mailbox locking conventions.
  16. Here are the diffs..
  17.  
  18. -- 
  19. ^@-------~~--**----/ --- - Marc Boucher
  20. marc@CAM.ORG \----?    ":
  21. /-----_--  -    ----_|| +1 514 466 8932 - &-
  22.  
  23. --- 1.1    1992/08/17 11:34:13
  24. +++ Makefile    1992/11/20 20:47:30
  25. @@ -1,4 +1,6 @@
  26. -CFLAGS= -g
  27. +CFLAGS= -O
  28. +# For SVR4.  Needed for movemail
  29. +  LOADLIBES= -lmail
  30.  # For Xenix.  Needed for movemail
  31.  #  LOADLIBES= -lx
  32.  # For Mips.  Needed for who knows what.
  33. --- 1.1    1992/11/20 20:27:56
  34. +++ movemail.c    1992/11/20 21:00:17
  35. @@ -31,6 +31,13 @@
  36.     a setuid or setgid program.  */
  37.  
  38.  /*
  39. + * SVR4 support by Marc Boucher <marc@CAM.ORG>:
  40. + *   compile with __svr4__ defined (implicit if gcc used)
  41. + *   link with -lmail
  42. + *   install setgid "mail".
  43. + */
  44. +
  45. +/*
  46.   * Modified January, 1986 by Michael R. Gretzinger (Project Athena)
  47.   *
  48.   * Added POP (Post Office Protocol) service.  When compiled -DPOP
  49. @@ -66,6 +73,12 @@
  50.  #endif
  51.  #endif /* USG */
  52.  
  53. +#ifdef __svr4__
  54. +#undef MAIL_USE_FLOCK
  55. +#include <maillock.h>
  56. +#include <string.h>
  57. +#endif
  58. +
  59.  #ifdef XENIX
  60.  #include <sys/locking.h>
  61.  #endif
  62. @@ -83,8 +96,10 @@
  63.  char *concat ();
  64.  extern int errno;
  65.  
  66. +#ifndef __svr4__
  67.  /* Nonzero means this is name of a lock file to delete on fatal error.  */
  68.  char *delete_lockname;
  69. +#endif
  70.  
  71.  main (argc, argv)
  72.       int argc;
  73. @@ -95,7 +110,7 @@
  74.    char buf[1024];
  75.    int nread;
  76.  
  77. -#ifndef MAIL_USE_FLOCK
  78. +#if !defined(MAIL_USE_FLOCK) && !defined(__svr4__)
  79.    struct stat st;
  80.    long now;
  81.    int tem;
  82. @@ -102,9 +117,7 @@
  83.    char *lockname, *p;
  84.    char tempname[40];
  85.    int desc;
  86. -#endif /* not MAIL_USE_FLOCK */
  87. -
  88. -  delete_lockname = 0;
  89. +#endif /* not MAIL_USE_FLOCK and not __svr4__ */
  90.  
  91.    if (argc < 3)
  92.      fatal ("two arguments required");
  93. @@ -153,6 +166,15 @@
  94.      pfatal_with_name (inname);
  95.  
  96.  #ifndef MAIL_USE_MMDF
  97. +#ifdef __svr4__
  98. +  {
  99. +    char *p;
  100. +
  101. +    p = strrchr(inname, '/') ? strrchr(inname, '/') + 1: inname;
  102. +    if(maillock(p, 5) != L_SUCCESS)
  103. +      fatal ("maillock(%s, 5) failed", p);
  104. +  }
  105. +#else
  106.  #ifndef MAIL_USE_FLOCK
  107.    /* Use a lock file named /usr/spool/mail/$USER.lock:
  108.       If it exists, the mail file is locked.  */
  109. @@ -213,6 +235,7 @@
  110.  
  111.    delete_lockname = lockname;
  112.  #endif /* not MAIL_USE_FLOCK */
  113. +#endif /* __svr4__ */
  114.  
  115.  #ifdef MAIL_USE_FLOCK
  116.    indesc = open (inname, O_RDWR);
  117. @@ -258,7 +281,7 @@
  118.      break;
  119.      }
  120.  
  121. -#ifdef BSD
  122. +#if defined(BSD) || defined(__svr4__)
  123.    if (fsync (outdesc) < 0)
  124.      pfatal_and_delete (outname);
  125.  #endif
  126. @@ -288,7 +311,11 @@
  127.      if (errno != ENOENT)
  128.        creat (inname, 0666);
  129.  #ifndef MAIL_USE_MMDF
  130. +#ifdef __svr4__
  131. +  mailunlock();
  132. +#else
  133.    unlink (lockname);
  134. +#endif
  135.  #endif /* not MAIL_USE_MMDF */
  136.  #endif /* not MAIL_USE_FLOCK */
  137.    exit (0);
  138. @@ -299,8 +326,12 @@
  139.  fatal (s1, s2)
  140.       char *s1, *s2;
  141.  {
  142. +#ifdef __svr4__
  143. +  mailunlock();
  144. +#else
  145.    if (delete_lockname)
  146.      unlink (delete_lockname);
  147. +#endif
  148.    error (s1, s2);
  149.    exit (1);
  150.  }
  151.  
  152.