From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.139]) by sourceware.org (Postfix) with ESMTPS id 7C81E3850407 for ; Mon, 13 Jul 2020 13:10:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7C81E3850407 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=SystematicSW.ab.ca Authentication-Results: sourceware.org; spf=none smtp.mailfrom=brian.inglis@systematicsw.ab.ca Received: from BWINGLISD.cg.shawcable.net ([24.64.172.44]) by shaw.ca with ESMTP id uyETjHWHHFXePuyEUjc3OK; Mon, 13 Jul 2020 07:10:58 -0600 X-Authority-Analysis: v=2.3 cv=ePaIcEh1 c=1 sm=1 tr=0 a=kiZT5GMN3KAWqtYcXc+/4Q==:117 a=kiZT5GMN3KAWqtYcXc+/4Q==:17 a=VAVI7avi-4p2PNOo0hMA:9 From: Brian Inglis To: cygwin-apps@cygwin.com Subject: [PATCH] cygport announce SMTP HELO fails without smtp server FQDN Date: Mon, 13 Jul 2020 07:10:02 -0600 Message-Id: <20200713131001.18288-1-Brian.Inglis@SystematicSW.ab.ca> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfLUUgRnMeBZQZGL9/ZnIaG4f4/rzbM9GPInARWoxRSAUbP1HKeg1QTaYQd2OTJ3kG81NjJbyKptoeTixogac63Q4GH75EECutoAGcx8OoF+LwiXMVPx7 H12wLUPJH2qm7bjza3KZ74p6M9iJss0nbPVTnO5E+sRfTclPkevQBe+rRc2tzlR5HYVnRdQGRm1L6/HlbwcrnTho0Tz6O4F9GNXgmZ876O7Ne55mh5luXlSd B3ZcdnXyZD+54ODxmbav9g== X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin-apps@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin package maintainer discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jul 2020 13:11:01 -0000 pkg_upload.cygpart(__pkg_announce): added perl code to embedded perl script for email domain FQDN copied from git send-email with minor hooks --- lib/pkg_upload.cygpart | 51 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/lib/pkg_upload.cygpart b/lib/pkg_upload.cygpart index f88525d..06024b4 100644 --- a/lib/pkg_upload.cygpart +++ b/lib/pkg_upload.cygpart @@ -168,6 +168,7 @@ EOF echo "Upload complete." } + __pkg_announce() { local msg=$(mktemp -t cygwin-announce-${PF}.XXXXXX) local msgat=$(date +@%s) @@ -198,7 +199,52 @@ _EOF ${EDITOR:-vi} $msg || error "Editor exited abormally, aborting annoucement" +# FQDN from git send-email +# Returns the local Fully Qualified Domain Name (FQDN) if available. +# +# Tightly configured MTAa require that a caller sends a real DNS +# domain name that corresponds the IP address in the HELO/EHLO +# handshake. This is used to verify the connection and prevent +# spammers from trying to hide their identity. If the DNS and IP don't +# match, the receiving MTA may deny the connection. +# +# Here is a deny example of Net::SMTP with the default "localhost.localdomain" +# +# Net::SMTP=GLOB(0x267ec28)>>> EHLO localhost.localdomain +# Net::SMTP=GLOB(0x267ec28)<<< 550 EHLO argument does not match calling host +# +# This maildomain*() code is based on ideas in Perl library Test::Reporter +# /usr/share/perl5/Test/Reporter/Mail/Util.pm ==> sub _maildomain () + perl <(cat <new(\$host); + if (defined \$smtp) { + my \$domain = \$smtp->domain; + \$smtp->quit; + \$maildomain = \$domain if valid_fqdn(\$domain); + last if \$maildomain; + } + } + return \$maildomain; +} +sub maildomain { + return maildomain_net() || maildomain_mta() || 'localhost.localdomain'; +} + use strict; use MIME::Parser; use Net::SMTP; @@ -214,7 +260,9 @@ my \$entity = \$parser->parse_open("$msg"); print "Sending announcement of ${NAME}-${PVR} via \$smtp_server\n"; +my \$smtp_domain ||= maildomain(); # get FQDN and add Hello below my \$smtp = new Net::SMTP(\$smtp_server, + Hello => \$smtp_domain, ${SMTP_SERVER_PORT+Port => ${SMTP_SERVER_PORT},} SSL => \$smtp_encryption eq 'ssl') or die "No mailserver at ".\$smtp_server; @@ -224,7 +272,8 @@ if (\$smtp_encryption eq 'tls') { \$smtp->response(); \$smtp->code == 220 or die "$server does not support STARTTLS"; \$smtp = Net::SMTP::SSL->start_SSL(\$smtp) or die "STARTTLS failed"; - \$smtp->hello(\$smtp_server); + # Send EHLO again to receive fresh supported commands + \$smtp->hello(\$smtp_domain); } if (defined \$smtp_user) { use Authen::SASL qw(Perl); -- 2.27.0