Serious misfeature in smail2.2 under SVr3

Eric S. Raymond eric at snark.uu.net
Mon May 8 01:49:59 AEST 1989


THE SYMPTOM:
   On SVr3.0 and later UNIXes installation of smail2.3 may cause /etc/profile
processing to hang, preventing users (including root!) from logging in. This
behavior was first observed on a Toshiba 5100 running T/PIX.

THE PROBLEM:
   These systems call mail -e to check mail. The svbinmail supplied with 2.3
and earlier versions of smail interprets -e as a directive to go into reader
mode, waiting for input. Because /etc/profile typically traps and eats
interrupts, this can result in a hang and serious lossage.

THE FIX:
   Teach svbinmail how to do `mail -e' properly. This fix should be portable
to BSD systems, but has been tested unly on SV. It is not complicated.
To apply, simply pipe this article through patch -d <smaildir>/src where
<smaildir> is your toplevel smail source directory.

SMAIL 3.0 DEVELOPERS:
   Please incorporate this code or equivalent. The last thing we need is
for this bug to survive in your stuff...

*** svbinmail.c.old	Sat May  6 09:04:11 1989
--- svbinmail.c	Sat May  6 10:03:07 1989
***************
*** 11,21 ****
--- 11,26 ----
  /*  */
  
  #include <stdio.h>
+ #include <pwd.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
  #include "defs.h"
  #ifdef BSD
  #include <strings.h>
+ #define MAILDIR	"/usr/spool/mail/%s"
  #else
  #include <string.h>
+ #define MAILDIR	"/usr/mail/%s"
  #endif
  
  #ifdef SENDMAIL
***************
*** 32,37 ****
--- 37,43 ----
  char prog[128];
  
  void	perror(), exit(), usage();
+ struct passwd	*getpwuid();
  
  main(argc, argv)
  int argc;
***************
*** 53,58 ****
--- 59,79 ----
  		while((c = getopt(argc, argv, "epqrtf:")) != EOF) {
  			switch(c) {
  			case 'e':
+ 				{
+ 					char	mailfile[BUFSIZ];
+ 					struct stat stbuf;
+ 					struct passwd *pw;
+ 
+ 					if ((pw = getpwuid(getuid())) == 0)
+ 						return(2);
+ 					(void) sprintf(mailfile,
+ 						MAILDIR, pw->pw_name);
+ 					if (stat(mailfile, &stbuf) == -1)
+ 						return(1);
+ 					else
+ 						return(stbuf.st_size == 0);
+ 				}
+ 				break;
  			case 'p':
  			case 'q':
  			case 'r':
-- 
      Eric S. Raymond                       (the mad mastermind of TMN-Netnews)
      uunet!snark!eric | eric at snark.uu.net  Phone: (215)-296-5718



More information about the Comp.bugs.sys5 mailing list