From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf0-f181.google.com ([209.85.192.181]) by ur; Tue Mar 21 20:02:38 EDT 2017 Received: by mail-pf0-f181.google.com with SMTP id o126so86214522pfb.3 for <9front@9front.org>; Tue, 21 Mar 2017 17:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:from:to:subject:mime-version :content-transfer-encoding; bh=55RY7IsxxmGUytRUwfgnvzNsChY1kB7sN7A//KiVX38=; b=pZf11TgnkKDqW0lX9HMI3T6ot7nhFB1I7NNrVxOF4rfAWwkWZsAmVmdoAXrmDIZBz9 7OGFU2NG75N6bIke+WqrW323Ua9iW6CPE5EytQbXzOGr1SSMv1y9Ej6k2j1jpxfrrBPi T6rhC6Q4tn3rkmvX0qAP+rL4qRTeSi2sBG3eMSu2JdkASZx6gSKTaiEPiAYm81cN9HCX dGNLsjm/LCsuwzzzTwUfzu48l0euKUwKPVgd4pjfNZLUJ5G4Ok2jYT7iWkOZeZal5uSh Az889H+GgDFUbIuNLAuvYSwEqR9eTdqVwHA8U6H/hRxqcDlXCkpP8n/xZT2TkFg5D8MV 7+hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:from:to:subject:mime-version :content-transfer-encoding; bh=55RY7IsxxmGUytRUwfgnvzNsChY1kB7sN7A//KiVX38=; b=WaqSg9ibXFKDey8vRSr7ocPi10I6mDmpHEgIy05+WwwXub2jiV4IRS08jNr9IPs6VV trWwxb1cl7jt/R3gZvnFvEfI2+Ev3MqMXg8OrDrJnMjjuqwBoa+cmBWcjFFSmQiQPFZo lvzOG2VGfyWYXsObhHIe2FFqRfi4jb4h7q0d7FT/1Ry3fgTCIxe0L3Q+VLCu+ki2RRi+ zEfOskQA8LD/TceEgirHdJZdSFyt/dLvsl9G7B3B1cPoTcnhQmEH3WT/00a0CNvHERPu Zw09QTwUqtSNWVYwsu6xxMBXCnHQEA1/NVHg06fESjc+gOPOOF4Gnfp2kt3/CgbU63Cq WSMw== X-Gm-Message-State: AFeK/H1gkq+K8hHnxRNy58xgnOikUZNDYaI+H1hOjhSz1rzFLEU9sXNChBpQT1khSqsAGA== X-Received: by 10.84.231.198 with SMTP id g6mr52069418pln.20.1490140954922; Tue, 21 Mar 2017 17:02:34 -0700 (PDT) Return-Path: Received: from youmu.sam-d.org (108-90-40-156.lightspeed.sntcca.sbcglobal.net. [108.90.40.156]) by smtp.gmail.com with ESMTPSA id s4sm41611280pfi.74.2017.03.21.17.02.34 for <9front@9front.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Mar 2017 17:02:34 -0700 (PDT) Message-ID: <197eef1bfc064ad154d32b26d2c10001@youmu.sam-d.org> Date: Wed, 22 Mar 2017 00:02:23 +0000 From: inkswinc@gmail.com To: 9front@9front.org Subject: nupas auth: incompatibility and error messaging MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: lossless structured realtime-java GPU interface-oriented locator Nupas' smtp.c file uses a different var in the 'server=' part of the string it queries from factotum than upas did: where upas used 'server=smtp.gmail.com' (from the dialstring passed on the commandline), nupas uses 'server=gmail-smtp-msa.l.google.com' (result of some lookup, I presume) Not only does this break backwards compatibility, but it also feels a little more brittle to me; the latter name seems likely to change. Not sure where else this difference occurs; it doesn't seem to in imaps, which I also use, but it does seem to in /sys/lib/tls/smtp (though with gmail that needs to change all the time anyways, so...) It also doesn't do a good job of error messaging when auth fails; it just shows up as an error in the 'hello' phase, which sucks. Following patch is an attempt at resolving those issues; it works for me. This is the first time I've ever given anyone else any C code I've written, so feel free to be ruthless if you see anything suboptimal. diff -r a01d0802d023 sys/src/cmd/upas/smtp/smtp.c --- a/sys/src/cmd/upas/smtp/smtp.c Mon Mar 20 19:15:40 2017 +0100 +++ b/sys/src/cmd/upas/smtp/smtp.c Tue Mar 21 23:49:01 2017 +0000 @@ -493,20 +493,27 @@ static char * doauth(char *methods) { - char *buf, *err; + char *buf, *err, *factstring; UserPasswd *p; int n; DS ds; - dialstringparse(ddomain, &ds); + dialstringparse(farend, &ds); if(strstr(methods, "CRAM-MD5")) return smtpcram(&ds); - p = auth_getuserpasswd(nil, - user?"proto=pass service=smtp server=%q user=%q":"proto=pass service=smtp server=%q", + factstring = smprint(user? + "proto=pass service=smtp server=%q user=%q": + "proto=pass service=smtp server=%q", ds.host, user); - if (p == nil) + + p = auth_getuserpasswd(nil,factstring); + if (p == nil) { + syslog(0, "smtp.fail", "failed to get userpasswd for %s", factstring); + free(factstring); return Giveup; + } + free(factstring); err = Retry; if (strstr(methods, "LOGIN")){ Thanks, sam-d