lede-packages-rs

git clone git://archive.git.mtrnord.blog/MTRNord/lede-packages-rs.git
Log | Files | Refs | README | LICENSE

004-remove_dead-letter.patch (2318B)


      1 --- a/ssmtp.c
      2 +++ b/ssmtp.c
      3 @@ -138,71 +138,7 @@ int smtp_read_all(int fd, char *response
      4  int smtp_okay(int fd, char *response);
      5  
      6  /*
      7 -dead_letter() -- Save stdin to ~/dead.letter if possible
      8 -*/
      9 -void dead_letter(void)
     10 -{
     11 -	char *path;
     12 -	char buf[(BUF_SZ + 1)];
     13 -	struct passwd *pw;
     14 -	uid_t uid;
     15 -	FILE *fp;
     16 -
     17 -	uid = getuid();
     18 -	pw = getpwuid(uid);
     19 -
     20 -	if(isatty(fileno(stdin))) {
     21 -		if(log_level > 0) {
     22 -			log_event(LOG_ERR,
     23 -				"stdin is a TTY - not saving to %s/dead.letter", pw->pw_dir);
     24 -		}
     25 -		return;
     26 -	}
     27 -
     28 -	if(pw == (struct passwd *)NULL) {
     29 -		/* Far to early to save things */
     30 -		if(log_level > 0) {
     31 -			log_event(LOG_ERR, "No sender failing horribly!");
     32 -		}
     33 -		return;
     34 -	}
     35 -
     36 -#define DEAD_LETTER "/dead.letter"
     37 -	path = malloc (strlen (pw->pw_dir) + sizeof (DEAD_LETTER));
     38 -	if (!path) {
     39 -		/* Can't use die() here since dead_letter() is called from die() */
     40 -		exit(1);
     41 -	}
     42 -	memcpy (path, pw->pw_dir, strlen (pw->pw_dir));
     43 -	memcpy (path + strlen (pw->pw_dir), DEAD_LETTER, sizeof (DEAD_LETTER));
     44 -	
     45 -	if((fp = fopen(path, "a")) == (FILE *)NULL) {
     46 -		/* Perhaps the person doesn't have a homedir... */
     47 -		if(log_level > 0) {
     48 -			log_event(LOG_ERR, "Can't open %s failing horribly!", path);
     49 -		}
     50 -		free(path);
     51 -		return;
     52 -	}
     53 -
     54 -	/* We start on a new line with a blank line separating messages */
     55 -	(void)fprintf(fp, "\n\n");
     56 -
     57 -	while(fgets(buf, sizeof(buf), stdin)) {
     58 -		(void)fputs(buf, fp);
     59 -	}
     60 -
     61 -	if(fclose(fp) == -1) {
     62 -		if(log_level > 0) {
     63 -			log_event(LOG_ERR,
     64 -				"Can't close %s/dead.letter, possibly truncated", pw->pw_dir);
     65 -		}
     66 -	}
     67 -	free(path);
     68 -}
     69 -
     70 -/*
     71 -die() -- Write error message, dead.letter and exit
     72 +die() -- Write error message and exit
     73  */
     74  void die(char *format, ...)
     75  {
     76 @@ -216,9 +152,6 @@ void die(char *format, ...)
     77  	(void)fprintf(stderr, "%s: %s\n", prog, buf);
     78  	log_event(LOG_ERR, "%s", buf);
     79  
     80 -	/* Send message to dead.letter */
     81 -	(void)dead_letter();
     82 -
     83  	exit(1);
     84  }
     85  
     86 @@ -1640,7 +1573,7 @@ int ssmtp(char *argv[])
     87  			sleep(1);
     88  			/* don't hang forever when reading from stdin */
     89  			if (++timeout >= MEDWAIT) {
     90 -				log_event(LOG_ERR, "killed: timeout on stdin while reading body -- message saved to dead.letter.");
     91 +				log_event(LOG_ERR, "killed: timeout on stdin while reading body.");
     92  				die("Timeout on stdin while reading body");
     93  			}
     94  			continue;