ソースを参照

ssmtp: maintenance update

remove needless dead.letter function (at least on embedded devices)
backport debian fixes (slightly modified)

compile tested. Please apply to upstream - thank you!

Signed-off-by: Dirk Brenken <dirk@brenken.org>
Dirk Brenken 9 年 前
コミット
1a62d46b3a

+ 20
- 19
mail/ssmtp/Makefile ファイルの表示

@@ -1,5 +1,5 @@
1 1
 #
2
-# Copyright (C) 2007-2014 OpenWrt.org
2
+# Copyright (C) 2007-2015 OpenWrt.org
3 3
 #
4 4
 # This is free software, licensed under the GNU General Public License v2.
5 5
 # See /LICENSE for more information.
@@ -9,8 +9,8 @@ include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=ssmtp
11 11
 PKG_VERSION:=2.64
12
-PKG_RELEASE:=1.1
13
-PKG_MAINTAINER:=Dirk Brenken <dibdot@gmail.com>
12
+PKG_RELEASE:=1
13
+PKG_MAINTAINER:=Dirk Brenken <dirk@brenken.org>
14 14
 PKG_LICENSE:=GPL-2.0+
15 15
 
16 16
 PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.bz2
@@ -21,23 +21,24 @@ include $(INCLUDE_DIR)/package.mk
21 21
 
22 22
 TARGET_CFLAGS += $(TARGET_CPPFLAGS)
23 23
 
24
-define Package/ssmtp
25
-  SECTION:=mail
26
-  CATEGORY:=Mail
27
-  DEPENDS:=+libopenssl
28
-  TITLE:=A minimal and secure mail sender with ssl support
29
-  URL:=http://packages.debian.org/ssmtp
24
+define Package/$(PKG_NAME)
25
+	SECTION:=mail
26
+	CATEGORY:=Mail
27
+	DEPENDS:=+libopenssl
28
+	TITLE:=A minimal and secure mail sender with ssl support
29
+	URL:=http://packages.debian.org/ssmtp
30 30
 endef
31 31
 
32
-define Package/ssmtp/description
33
- A secure, effective and simple way of getting mail off a system to your
34
- mail hub. It contains no suid-binaries or other dangerous things - no
35
- mail spool to poke around in, and no daemons running in the background.
36
- Mail is simply forwarded to the configured mailhost. Extremely easy
37
- configuration.
32
+define Package/$(PKG_NAME)/description
33
+A secure, effective and simple way of getting mail off a system to your
34
+mail hub. It contains no suid-binaries or other dangerous things - no
35
+mail spool to poke around in, and no daemons running in the background.
36
+Mail is simply forwarded to the configured mailhost. Extremely easy
37
+configuration.
38
+
38 39
 endef
39 40
 
40
-define Package/ssmtp/conffiles
41
+define Package/$(PKG_NAME)/conffiles
41 42
 /etc/ssmtp/ssmtp.conf
42 43
 /etc/ssmtp/revaliases
43 44
 endef
@@ -48,7 +49,7 @@ CONFIGURE_VARS += \
48 49
 CONFIGURE_ARGS += \
49 50
 	--enable-ssl
50 51
 
51
-define Package/ssmtp/install
52
+define Package/$(PKG_NAME)/install
52 53
 	$(INSTALL_DIR) $(1)/etc/ssmtp
53 54
 	$(INSTALL_CONF) $(PKG_BUILD_DIR)/ssmtp.conf $(1)/etc/ssmtp/
54 55
 	$(INSTALL_DATA) $(PKG_BUILD_DIR)/revaliases $(1)/etc/ssmtp/
@@ -56,9 +57,9 @@ define Package/ssmtp/install
56 57
 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/ssmtp $(1)/usr/sbin/
57 58
 endef
58 59
 
59
-define Package/ssmtp/postinst
60
+define Package/$(PKG_NAME)/postinst
60 61
 #!/bin/sh
61 62
 ln -sf ssmtp $${IPKG_INSTROOT}/usr/sbin/sendmail
62 63
 endef
63 64
 
64
-$(eval $(call BuildPackage,ssmtp))
65
+$(eval $(call BuildPackage,$(PKG_NAME)))

+ 94
- 0
mail/ssmtp/patches/004-remove_dead-letter.patch ファイルの表示

@@ -0,0 +1,94 @@
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;

+ 21
- 0
mail/ssmtp/patches/006-add_ip-header.patch ファイルの表示

@@ -0,0 +1,21 @@
1
+--- a/ssmtp.c
2
++++ b/ssmtp.c
3
+@@ -1338,6 +1338,7 @@ ssmtp() -- send the message (exactly one
4
+ int ssmtp(char *argv[])
5
+ {
6
+ 	char b[(BUF_SZ + 2)], *buf = b+1, *p, *q;
7
++	char *remote_addr;
8
+ #ifdef MD5AUTH
9
+ 	char challenge[(BUF_SZ + 1)];
10
+ #endif
11
+@@ -1541,6 +1542,10 @@ int ssmtp(char *argv[])
12
+ 		outbytes += smtp_write(sock, "From: %s", from);
13
+ 	}
14
+ 
15
++	if(remote_addr=getenv("REMOTE_ADDR")) {
16
++		outbytes += smtp_write(sock, "X-Originating-IP: %s", remote_addr);
17
++	}
18
++
19
+ 	if(have_date == False) {
20
+ 		outbytes += smtp_write(sock, "Date: %s", arpadate);
21
+ 	}

+ 18
- 0
mail/ssmtp/patches/008-remove_garbage.patch ファイルの表示

@@ -0,0 +1,18 @@
1
+--- a/ssmtp.c
2
++++ b/ssmtp.c
3
+@@ -1591,12 +1591,12 @@ int ssmtp(char *argv[])
4
+ 			outbytes += smtp_write(sock, "%s", leadingdot ? b : buf);
5
+ 		} else {
6
+ 			if (log_level > 0) {
7
+-				log_event(LOG_INFO, "Sent a very long line in chunks");
8
++				log_event(LOG_INFO, "Sending a partial line");
9
+ 			}
10
+ 			if (leadingdot) {
11
+-				outbytes += fd_puts(sock, b, sizeof(b));
12
++				outbytes += fd_puts(sock, b, strlen(b));
13
+ 			} else {
14
+-				outbytes += fd_puts(sock, buf, bufsize);
15
++				outbytes += fd_puts(sock, buf, strlen(buf));
16
+ 			}
17
+ 		}
18
+ 		(void)alarm((unsigned) MEDWAIT);

+ 92
- 0
mail/ssmtp/patches/010-fix_message-header.patch ファイルの表示

@@ -0,0 +1,92 @@
1
+--- a/ssmtp.c
2
++++ b/ssmtp.c
3
+@@ -282,6 +282,7 @@ standardise() -- Trim off '\n's and doub
4
+ */
5
+ bool_t standardise(char *str, bool_t *linestart)
6
+ {
7
++	size_t sl;
8
+ 	char *p;
9
+ 	bool_t leadingdot = False;
10
+ 
11
+@@ -297,6 +298,12 @@ bool_t standardise(char *str, bool_t *li
12
+ 	if((p = strchr(str, '\n'))) {
13
+ 		*p = '\0';
14
+ 		*linestart = True;
15
++
16
++		/* If the line ended in "\r\n", then drop the '\r' too */
17
++		sl = strlen(str);
18
++		if(sl >= 1 && str[sl - 1] == '\r') {
19
++			str[sl - 1] = '\0';
20
++		}
21
+ 	}
22
+ 	return(leadingdot);
23
+ }
24
+@@ -690,6 +697,14 @@ void header_parse(FILE *stream)
25
+ 		}
26
+ 		len++;
27
+ 
28
++		if(l == '\r' && c == '\n') {
29
++			/* Properly handle input that already has "\r\n"
30
++			   line endings; see https://bugs.debian.org/584162 */
31
++			l = (len >= 2 ? *(q - 2) : '\n');
32
++			q--;
33
++			len--;
34
++		}
35
++
36
+ 		if(l == '\n') {
37
+ 			switch(c) {
38
+ 				case ' ':
39
+@@ -712,8 +727,9 @@ void header_parse(FILE *stream)
40
+ 						if((q = strrchr(p, '\n'))) {
41
+ 							*q = '\0';
42
+ 						}
43
+-						header_save(p);
44
+-
45
++						if(len > 0) {
46
++							header_save(p);
47
++						}
48
+ 						q = p;
49
+ 						len = 0;
50
+ 			}
51
+@@ -722,35 +738,12 @@ void header_parse(FILE *stream)
52
+ 
53
+ 		l = c;
54
+ 	}
55
+-	if(in_header) {
56
+-		if(l == '\n') {
57
+-			switch(c) {
58
+-				case ' ':
59
+-				case '\t':
60
+-						/* Must insert '\r' before '\n's embedded in header
61
+-						   fields otherwise qmail won't accept our mail
62
+-						   because a bare '\n' violates some RFC */
63
+-						
64
+-						*(q - 1) = '\r';	/* Replace previous \n with \r */
65
+-						*q++ = '\n';		/* Insert \n */
66
+-						len++;
67
+-						
68
+-						break;
69
+-
70
+-				case '\n':
71
+-						in_header = False;
72
+-
73
+-				default:
74
+-						*q = '\0';
75
+-						if((q = strrchr(p, '\n'))) {
76
+-							*q = '\0';
77
+-						}
78
+-						header_save(p);
79
+-
80
+-						q = p;
81
+-						len = 0;
82
+-			}
83
+-		}
84
++	if(in_header && l == '\n') {
85
++		/* Got EOF while reading the header */
86
++		if((q = strrchr(p, '\n'))) {
87
++			*q = '\0';
88
++ 		}
89
++		header_save(p);
90
+ 	}
91
+ 	(void)free(p);
92
+ }