msmtp-scripts: Make conn_test default nc
authorDaniel F. Dickinson <cshored@thecshore.com>
Tue, 27 Aug 2019 05:53:51 +0000 (01:53 -0400)
committerDaniel F. Dickinson <cshored@thecshore.com>
Tue, 27 Aug 2019 10:54:56 +0000 (06:54 -0400)
On OpenWrt nc (netcat) connectivity test makes more sense than
ping because a) for non-root users ping is not permitted, and
b) nc is a default binary included with OpenWrt.
We do, however, have to change the upstream default from using
`nc -vz` to `printf "<http head request>"|nc` (with openwrt
nc if text is sent then nc closes after a response and fails
if no connection is made; the response is already thrown away
(to /dev/null) by the existing code).

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
mail/msmtp-scripts/Makefile
mail/msmtp-scripts/files/msmtpq-ng-mta.rc
mail/msmtp-scripts/files/msmtpq-ng.rc

index 42ed208edc4f8e5839921d94329645c463a6e233..34242434e839bfea5dd42399a238d7ab3ff00399 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=msmtp-scripts
 PKG_VERSION:=1.2.4
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://launchpad.net/$(PKG_NAME)/1.2/$(PKG_VERSION)/+download
@@ -116,6 +116,7 @@ define Package/msmtpq-ng/install
        $(INSTALL_DATA) ./files/msmtpq-ng.rc $(1)/etc/msmtpq-ng.rc
        $(INSTALL_DIR) $(1)/usr/bin
        $(CP) $(PKG_BUILD_DIR)/src/usr/bin/msmtpq-ng $(1)/usr/bin/
+       $(SED) "s,nc -vz,printf \"HEAD / HTTP/1.1\\\\r\\\\nHost: \$$$${EMAIL_CONN_TEST_SITE}\\\\r\\\\n\\\\r\\\\n\"|nc," $(1)/usr/bin/msmtpq-ng
        $(CP) $(PKG_BUILD_DIR)/src/usr/bin/msmtpq-ng-queue $(1)/usr/bin/
 endef
 
index f4637ff42e680fc8cce31febab92a237555f24b4..bb1536adb937d6bd506d7d5193ea2d24f267491d 100644 (file)
@@ -14,9 +14,9 @@
 #MSMTPQ_NG=msmtpq-ng
 #MSMTPQ_NG_QUEUE=msmtpq-ng-queue
 #MSMTP_CONF=/etc/msmtprc
-#EMAIL_CONN_TEST=p
-EMAIL_CONN_TEST_PING=openwrt.org
+EMAIL_CONN_TEST=n
+#EMAIL_CONN_TEST_PING=openwrt.org
 #EMAIL_CONN_TEST_IP=8.8.8.8
-#EMAIL_CONN_TEST_SITE=www.debian.org
+EMAIL_CONN_TEST_SITE=openwrt.org
 #MSMTP_HOLD_SMTP_MAIL=true
 #MSMTP_HOLD_CLI_MAIL=false
index 33d721c28bdecd816d0b72ab3cf4b70364ae70b4..ef8c0f051a7903ff68f991212e6ccb4d46865c99 100644 (file)
@@ -4,10 +4,10 @@
 #LOG=~/log/.msmtp.queue.log
 #MAXLOGLEVEL=7
 #MSMTP_LOCK_DIR=~/.msmtp.lock
-EMAIL_CONN_TEST=p
-EMAIL_CONN_TEST_PING=openwrt.org
+EMAIL_CONN_TEST=n
+#EMAIL_CONN_TEST_PING=openwrt.org
 #EMAIL_CONN_TEST_IP=8.8.8.8
-#EMAIL_CONN_TEST_SITE=www.debian.org
+EMAIL_CONN_TEST_SITE=openwrt.org
 #MSMTP_UMASK=077
 #MSMTP_LOG_UMASK=077
 #MSMTP_QUEUE_QUIET=false