From 51edf695f58aa7a390625645d5a3d9fe036a602d Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Sun, 9 Feb 2014 11:39:18 +0200 Subject: main/busybox: align sendmail patches with upstream --- ...tomatically-determine-sender-if-not-speci.patch | 57 ---------- ...ake-f-optional-document-its-default-value.patch | 119 +++++++++++++++++++++ ...dmail-use-FQDN-in-default-envelope-sender.patch | 42 ++++++++ main/busybox/APKBUILD | 16 ++- 4 files changed, 172 insertions(+), 62 deletions(-) delete mode 100644 main/busybox/0001-sendmail-automatically-determine-sender-if-not-speci.patch create mode 100644 main/busybox/0001-sendmail-make-f-optional-document-its-default-value.patch create mode 100644 main/busybox/0002-sendmail-use-FQDN-in-default-envelope-sender.patch (limited to 'main/busybox') diff --git a/main/busybox/0001-sendmail-automatically-determine-sender-if-not-speci.patch b/main/busybox/0001-sendmail-automatically-determine-sender-if-not-speci.patch deleted file mode 100644 index 8b6df8ad96..0000000000 --- a/main/busybox/0001-sendmail-automatically-determine-sender-if-not-speci.patch +++ /dev/null @@ -1,57 +0,0 @@ -From a2a978538c82999dc7d4018827e0f96188a135de Mon Sep 17 00:00:00 2001 -From: Kaarle Ritvanen -Date: Wed, 22 Jan 2014 00:41:49 +0200 -Subject: [PATCH] sendmail: automatically determine sender if not specified - -Make the -f option optional. If not given, construct the sender -address from the username and fully qualified hostname. - -This is required to interoperate with the cron applet. ---- - mailutils/sendmail.c | 16 +++++++--------- - 1 file changed, 7 insertions(+), 9 deletions(-) - -diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c -index b5aa1d1..b99c42f 100644 ---- a/mailutils/sendmail.c -+++ b/mailutils/sendmail.c -@@ -199,8 +199,8 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) - G.fp0 = xfdopen_for_read(3); - - // parse options -- // -v is a counter, -f is required. -H and -S are mutually exclusive, -a is a list -- opt_complementary = "vv:f:w+:H--S:S--H:a::"; -+ // -v is a counter, -H and -S are mutually exclusive, -a is a list -+ opt_complementary = "vv:w+:H--S:S--H:a::"; - // N.B. since -H and -S are mutually exclusive they do not interfere in opt_connect - // -a is for ssmtp (http://downloads.openwrt.org/people/nico/man/man8/ssmtp.8.html) compatibility, - // it is still under development. -@@ -279,7 +279,6 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) - // we should start with modern EHLO - if (250 != smtp_checkp("EHLO %s", host, -1)) - smtp_checkp("HELO %s", host, 250); -- free(host); - - // perform authentication - if (opts & OPT_a) { -@@ -305,12 +304,11 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) - // file descriptor (e.g. 4), or again from a secured file. - - // got no sender address? -> use system username as a resort -- // N.B. we marked -f as required option! -- //if (!G.user) { -- // // N.B. IMHO getenv("USER") can be way easily spoofed! -- // G.user = xuid2uname(getuid()); -- // opt_from = xasprintf("%s@%s", G.user, domain); -- //} -+ if (!G.user) G.user = xuid2uname(getuid()); -+ if (!opt_from) -+ opt_from = xasprintf("%s@%s", G.user, xgethostbyname(host)->h_name); -+ free(host); -+ - smtp_checkp("MAIL FROM:<%s>", opt_from, 250); - - // process message --- -1.8.3.1 - diff --git a/main/busybox/0001-sendmail-make-f-optional-document-its-default-value.patch b/main/busybox/0001-sendmail-make-f-optional-document-its-default-value.patch new file mode 100644 index 0000000000..d30ed4a2bf --- /dev/null +++ b/main/busybox/0001-sendmail-make-f-optional-document-its-default-value.patch @@ -0,0 +1,119 @@ +From 0bf0f3dee27f3d0ec953a43f800245abbe43aa6f Mon Sep 17 00:00:00 2001 +From: Denys Vlasenko +Date: Wed, 5 Feb 2014 15:01:39 +0100 +Subject: [PATCH 1/2] sendmail: make -f optional, document its default value + +Signed-off-by: Denys Vlasenko +--- + mailutils/sendmail.c | 67 +++++++++++++++++++++++++++++++++++++++++++--------- + 1 file changed, 56 insertions(+), 11 deletions(-) + +diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c +index b5aa1d1..824109d 100644 +--- a/mailutils/sendmail.c ++++ b/mailutils/sendmail.c +@@ -15,7 +15,8 @@ + //usage: "Read email from stdin and send it\n" + //usage: "\nStandard options:" + //usage: "\n -t Read additional recipients from message body" +-//usage: "\n -f SENDER Sender (required)" ++//usage: "\n -f SENDER For use in MAIL FROM:. Can be empty string" ++//usage: "\n Default: -auUSER, or username of current UID" + //usage: "\n -o OPTIONS Various options. -oi implied, others are ignored" + //usage: "\n -i -oi synonym. implied and ignored" + //usage: "\n" +@@ -40,6 +41,52 @@ + //usage: "\nUse makemime to create emails with attachments" + //usage: ) + ++/* Currently we don't sanitize or escape user-supplied SENDER and RECIPIENT_EMAILs. ++ * We may need to do so. For one, '.' in usernames seems to require escaping! ++ * ++ * From http://cr.yp.to/smtp/address.html: ++ * ++ * SMTP offers three ways to encode a character inside an address: ++ * ++ * "safe": the character, if it is not <>()[].,;:@, backslash, ++ * double-quote, space, or an ASCII control character; ++ * "quoted": the character, if it is not \012, \015, backslash, ++ * or double-quote; or ++ * "slashed": backslash followed by the character. ++ * ++ * An encoded box part is either (1) a sequence of one or more slashed ++ * or safe characters or (2) a double quote, a sequence of zero or more ++ * slashed or quoted characters, and a double quote. It represents ++ * the concatenation of the characters encoded inside it. ++ * ++ * For example, the encoded box parts ++ * angels ++ * \a\n\g\e\l\s ++ * "\a\n\g\e\l\s" ++ * "angels" ++ * "ang\els" ++ * all represent the 6-byte string "angels", and the encoded box parts ++ * a\,comma ++ * \a\,\c\o\m\m\a ++ * "a,comma" ++ * all represent the 7-byte string "a,comma". ++ * ++ * An encoded address contains ++ * the byte <; ++ * optionally, a route followed by a colon; ++ * an encoded box part, the byte @, and a domain; and ++ * the byte >. ++ * ++ * It represents an Internet mail address, given by concatenating ++ * the string represented by the encoded box part, the byte @, ++ * and the domain. For example, the encoded addresses ++ * ++ * <\God@heaven.af.mil> ++ * <"God"@heaven.af.mil> ++ * <@gateway.af.mil,@uucp.local:"\G\o\d"@heaven.af.mil> ++ * all represent the Internet mail address "God@heaven.af.mil". ++ */ ++ + #include "libbb.h" + #include "mail.h" + +@@ -163,7 +210,7 @@ int sendmail_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; + int sendmail_main(int argc UNUSED_PARAM, char **argv) + { + char *opt_connect = opt_connect; +- char *opt_from; ++ char *opt_from = NULL; + char *s; + llist_t *list = NULL; + char *host = sane_address(safe_gethostname()); +@@ -199,8 +246,8 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) + G.fp0 = xfdopen_for_read(3); + + // parse options +- // -v is a counter, -f is required. -H and -S are mutually exclusive, -a is a list +- opt_complementary = "vv:f:w+:H--S:S--H:a::"; ++ // -v is a counter, -H and -S are mutually exclusive, -a is a list ++ opt_complementary = "vv:w+:H--S:S--H:a::"; + // N.B. since -H and -S are mutually exclusive they do not interfere in opt_connect + // -a is for ssmtp (http://downloads.openwrt.org/people/nico/man/man8/ssmtp.8.html) compatibility, + // it is still under development. +@@ -304,13 +351,11 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) + // Since reading from console may defeat usability, the solution is either to read from a predefined + // file descriptor (e.g. 4), or again from a secured file. + +- // got no sender address? -> use system username as a resort +- // N.B. we marked -f as required option! +- //if (!G.user) { +- // // N.B. IMHO getenv("USER") can be way easily spoofed! +- // G.user = xuid2uname(getuid()); +- // opt_from = xasprintf("%s@%s", G.user, domain); +- //} ++ // got no sender address? use auth name, then UID username as a last resort ++ if (!opt_from) { ++ opt_from = G.user ? G.user : xuid2uname(getuid()); ++ } ++ + smtp_checkp("MAIL FROM:<%s>", opt_from, 250); + + // process message +-- +1.8.3.1 + diff --git a/main/busybox/0002-sendmail-use-FQDN-in-default-envelope-sender.patch b/main/busybox/0002-sendmail-use-FQDN-in-default-envelope-sender.patch new file mode 100644 index 0000000000..0c0f3dc78b --- /dev/null +++ b/main/busybox/0002-sendmail-use-FQDN-in-default-envelope-sender.patch @@ -0,0 +1,42 @@ +From 545f970465584ccab628f1528951541f5984aa0c Mon Sep 17 00:00:00 2001 +From: Kaarle Ritvanen +Date: Sun, 9 Feb 2014 09:49:36 +0100 +Subject: [PATCH 2/2] sendmail: use FQDN in default envelope sender + +RFC 5321 requires the return path to be supplied with a proper domain +name. + +Signed-off-by: Kaarle Ritvanen +Signed-off-by: Denys Vlasenko +--- + mailutils/sendmail.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c +index 824109d..9455b4e 100644 +--- a/mailutils/sendmail.c ++++ b/mailutils/sendmail.c +@@ -326,7 +326,6 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) + // we should start with modern EHLO + if (250 != smtp_checkp("EHLO %s", host, -1)) + smtp_checkp("HELO %s", host, 250); +- free(host); + + // perform authentication + if (opts & OPT_a) { +@@ -353,8 +352,11 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) + + // got no sender address? use auth name, then UID username as a last resort + if (!opt_from) { +- opt_from = G.user ? G.user : xuid2uname(getuid()); ++ opt_from = xasprintf("%s@%s", ++ G.user ? G.user : xuid2uname(getuid()), ++ xgethostbyname(host)->h_name); + } ++ free(host); + + smtp_checkp("MAIL FROM:<%s>", opt_from, 250); + +-- +1.8.3.1 + diff --git a/main/busybox/APKBUILD b/main/busybox/APKBUILD index cf5562b841..394f0e76a2 100644 --- a/main/busybox/APKBUILD +++ b/main/busybox/APKBUILD @@ -1,7 +1,7 @@ # Maintainer: Natanael Copa pkgname=busybox pkgver=1.22.1 -pkgrel=2 +pkgrel=3 pkgdesc="Size optimized toolbox of many common UNIX utilities" url=http://busybox.net arch="all" @@ -25,7 +25,10 @@ source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2 0001-ifupdown-pass-interface-device-name-for-ipv6-route-c.patch 0001-ifupdown-use-x-hostname-NAME-with-udhcpc.patch 0001-ifupdown-support-link-address-family.patch - 0001-sendmail-automatically-determine-sender-if-not-speci.patch + + 0001-sendmail-make-f-optional-document-its-default-value.patch + 0002-sendmail-use-FQDN-in-default-envelope-sender.patch + busyboxconfig glibc.patch" @@ -116,7 +119,8 @@ bc381f9ceb3824141c968f5bc4353943 busybox-1.22.1-date.patch 04eeda8c49d4688e6dec02451f8b6aae 0001-ifupdown-pass-interface-device-name-for-ipv6-route-c.patch e1c183cbe1ca18a0fa0d9597314076c9 0001-ifupdown-use-x-hostname-NAME-with-udhcpc.patch b15c67be5ccb3e523f540d8e218d5c85 0001-ifupdown-support-link-address-family.patch -75662f95668ecb349760d88ac547d1e2 0001-sendmail-automatically-determine-sender-if-not-speci.patch +d372d376820957fd5f2aee158af9867e 0001-sendmail-make-f-optional-document-its-default-value.patch +9d83db6173fe5b0fb8ee6ce741d5bb18 0002-sendmail-use-FQDN-in-default-envelope-sender.patch 59ead78a0bb2f01afff4147a37c8bd3b busyboxconfig befaac2c59c380e36a452b3f1c1d4a3a glibc.patch" sha256sums="ae0b029d0a9e4dd71a077a790840e496dd838998e4571b87b60fed7462b6678b busybox-1.22.1.tar.bz2 @@ -131,7 +135,8 @@ a31ce8bcb8b81b20e80ffa407600a530d085806c6471f4e4249fcb3a491b79ef busybox-uname- 2e9d56335ca39e944b9abd9ecc91d0e47a3fe3434f8b7ec3f526bc8fa0895ada 0001-ifupdown-pass-interface-device-name-for-ipv6-route-c.patch 53563c6dc4db13004d0b37f7bf1748e861b5a5c4244c1d34f102c23b689420c5 0001-ifupdown-use-x-hostname-NAME-with-udhcpc.patch 9a41b920dd7ee4746866f9dd4ae42899198cd9b10bfa433f2f5ead8083957da2 0001-ifupdown-support-link-address-family.patch -801c463ec51b60106a6879c913e198db31a4c3d587409c0072e3d105949ab0fc 0001-sendmail-automatically-determine-sender-if-not-speci.patch +422ce68917dadf1a49085df2a00ffab670e2d0866dcdb7209ee49318ad195fca 0001-sendmail-make-f-optional-document-its-default-value.patch +7c88ef1d837ec8efb7c21e5b1b16e4ac3060ccde7ad5f698e9e6ef630d412593 0002-sendmail-use-FQDN-in-default-envelope-sender.patch 8f7cd9baf35ed96ab8d2a7528c6e56dc88407c21676f8d50ec3946390fd53aee busyboxconfig c604ef791c31d35a8c5ee4558d21428a46f37a6d762c4a7e29864f4037fc44a0 glibc.patch" sha512sums="3e99fe373d638f714c3a61e1b02493d85ca532f472df038f7557db518ded38347072882ed568852941be7aac46fc34007257b4287375335ff5a09b60b295ce80 busybox-1.22.1.tar.bz2 @@ -146,6 +151,7 @@ eb7cce973bfd53ce3350713437b9e2751becfb8dfb10b14f27c4f812297c403b90f80dc2906179d4 f2ed7bf994766a20ceecb28bea8c66307b6b66cdd7099408b1f29a529786ce07e55824b21256321708663e00d6fe9428480b0d3e121b67d6ebd8a8a87b1486d1 0001-ifupdown-pass-interface-device-name-for-ipv6-route-c.patch b1a1cc2ada657a3d3364c8c96853575d73784e769cd8768c170c27a3e59abd2beace75dff6d5047c4391725e961d93149f9c3f45ed75fb1c582bf18b818282c9 0001-ifupdown-use-x-hostname-NAME-with-udhcpc.patch 2dcda497ba3b7c0a7dc9d85e08efa71e51c57e84967fa1a5f06d48f29c9ee9f14a1931c1c2854e9632a5db785c8e72df10bdfb0735a9ecad7a8d390fff74abd1 0001-ifupdown-support-link-address-family.patch -a41a73f3d8996097cb6ba726bd7b7b4a5fe1dc7c6810269b3e523442383c3432bf7b7d5581d7fd629f1f3cd3c72528c726dffc23b47e1c21dd8d61dec381690c 0001-sendmail-automatically-determine-sender-if-not-speci.patch +7fde27b1742f641ad1da376d5cf7a96e1f60fef70fb9d382ca47b062df76d1c35d7a7f08cba5350484f818383eb897c772d5469fd515e648023d0a85d0ed640e 0001-sendmail-make-f-optional-document-its-default-value.patch +d466676cd2779ff33f288bb073aa2baa4f3606cf8b96ec514e624a7acb46442a2839ef18c47e19cc18a8234a485de39596773b44e4be2eff39617d7cf677dd38 0002-sendmail-use-FQDN-in-default-envelope-sender.patch a7f7d6c5ee710a71313d79490707e1337c7c97c1fbf8a3c5cfa6fd82950ebb0376bfcfd444b65faa32d837e2bac00c67b101555b582a18fabb5ce7f7be7729e7 busyboxconfig 1d2739379dab1deb3eae7cffd4845300eb7d30f7343b4a1209b21a5680860d55080ad45fdefe098b249ce3040c01951fa7f0a79cd447b2d7b260eb000099d9dc glibc.patch" -- cgit v1.2.3