From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#36834: 27.0.50; [PATCH] password-cache.el: confuses key absence with nil password Date: Sun, 11 Aug 2019 19:00:21 +0300 Message-ID: <877e7jn14a.fsf@tcd.ie> References: <875znltof0.fsf@telefonica.net> <87v9vlck5a.fsf@tcd.ie> <87wog1rkte.fsf@telefonica.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="69560"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Stefan Monnier , 36834@debbugs.gnu.org To: =?UTF-8?Q?=C3=93scar?= Fuentes Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 11 18:03:04 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hwqJB-000HqI-Lk for geb-bug-gnu-emacs@m.gmane.org; Sun, 11 Aug 2019 18:03:01 +0200 Original-Received: from localhost ([::1]:40838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hwqJ9-0007EI-Vn for geb-bug-gnu-emacs@m.gmane.org; Sun, 11 Aug 2019 12:02:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50817) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hwqHH-0005zL-QN for bug-gnu-emacs@gnu.org; Sun, 11 Aug 2019 12:01:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hwqHG-00068s-Hi for bug-gnu-emacs@gnu.org; Sun, 11 Aug 2019 12:01:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36894) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hwqHG-00068d-6H for bug-gnu-emacs@gnu.org; Sun, 11 Aug 2019 12:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hwqHG-0008Oi-1O for bug-gnu-emacs@gnu.org; Sun, 11 Aug 2019 12:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 11 Aug 2019 16:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36834 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 36834-submit@debbugs.gnu.org id=B36834.156553923932245 (code B ref 36834); Sun, 11 Aug 2019 16:01:01 +0000 Original-Received: (at 36834) by debbugs.gnu.org; 11 Aug 2019 16:00:39 +0000 Original-Received: from localhost ([127.0.0.1]:45715 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hwqGt-0008O0-2T for submit@debbugs.gnu.org; Sun, 11 Aug 2019 12:00:39 -0400 Original-Received: from mail-wm1-f45.google.com ([209.85.128.45]:32965) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hwqGq-0008Nm-Mm for 36834@debbugs.gnu.org; Sun, 11 Aug 2019 12:00:37 -0400 Original-Received: by mail-wm1-f45.google.com with SMTP id p77so9300662wme.0 for <36834@debbugs.gnu.org>; Sun, 11 Aug 2019 09:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=4eWNLTpIPjUB05ELbbeTowg+XMRNOAIDofTrSq0fL5I=; b=OZ9+DF5mT3X70YWJe2nFEVMWppQuVJGF16ygHKfpmdG/r76+gNmlCf+MrSxq5knG9X PKVaPRevDwdtleSZes8T4FssjJw0Xa6zYO3ksdxtnG0KVVuMPFL7CoaHnNpe/B8rHNMW IZu0xciyBrtrRhpCAZg1flCmPE2aHMfyNyWxFA0KZtReTaB4V/h/jYbuqDt4m3Horr+4 Ow3qmJtU4GAQwaofC8VNQ/vkmPmao0kpseNSVYqRbvnL8tMq8HrpAxoaqDgiN/Vr7gzy 4VDxnbo3YTsmvQHwD7tBWkZSb/0tehXZ9LW4/NXQ1mr3KTulzkLEEnMS1k4JftJ6Avv8 WWFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=4eWNLTpIPjUB05ELbbeTowg+XMRNOAIDofTrSq0fL5I=; b=QRl9NOUbO3OtznN1TlQZN4F/mJpUikki0GJxwIuQ9+s1t2WNwm1M5O4BF/RTyEGMxs gRAqtSSBnzAZjBU83HRtwThB0ynQDwocZ3KI+ixw2cp/aGnUoC6Y7vOM/ftYJ1vLCPpW 55b1BFsxyEXC/WlGVfTvYxaoiz9ugASXIBczLD15iz5/xee94TjDUZUcoql6lOq4Rlzy yJQyqf0sXRbGXH43kkcVeLWtGWwR1NcMXcxLFzQJqAaBvPF2oR++yf45V1ke+2iXVkv7 cdPoTaPCvqZYzxV+eYFJtIvAlw1tQ6clppZ/kMThv40pRS3BLSgbq7tMDDbQDTyMD2BM RzHw== X-Gm-Message-State: APjAAAU6SDb4hlY/mkXpmEQAXfhtSM5BwGBHuxBexCAyl7xisJhSu80j vbjPRh81uDH3GEaE4OTnqukyfw== X-Google-Smtp-Source: APXvYqye9gHnv9eHxbOMP9Wj+ic7AG0jcgDSsEfbTI4RJF9pHDesBFHJ6hzwTnZFF1SD9DwchpeLjA== X-Received: by 2002:a1c:20c3:: with SMTP id g186mr22494706wmg.15.1565539230655; Sun, 11 Aug 2019 09:00:30 -0700 (PDT) Original-Received: from localhost (adsl-243.37.6.53.tellas.gr. [37.6.53.243]) by smtp.gmail.com with ESMTPSA id a26sm15598338wmg.45.2019.08.11.09.00.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 11 Aug 2019 09:00:29 -0700 (PDT) In-Reply-To: <87wog1rkte.fsf@telefonica.net> ("=?UTF-8?Q?=C3=93scar?= Fuentes"'s message of "Mon, 29 Jul 2019 16:12:45 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:164888 Archived-At: =C3=93scar Fuentes writes: > "Basil L. Contovounesios" writes: > >>> The change uses gethash instead of intern-soft, but those functions act >>> differently when the password (the value associated with the key) was >>> nil. >> >> Is it valid for the password to be nil? The logic in password-read >> suggests otherwise. > > Callers are sending nil. If it is not valid, there is a problem > elsewhere, but my understanding is that a nil password means "no > password" and it is cached in the memoization sense. If clients of password-cache.el already rely on this, IWBNI it were mentioned somewhere. >>> The effect is that every call to password-cache-add with nil as >>> password creates a new timer, >> >> Where is password-cache-add being passed a nil password? > > The caller is auth-source-remember, IIRC, which itself is called from > auth-source-search. Indeed, that's what it looks like: ;; note we remember the lack of result too, if it's applicable (when auth-source-do-cache (auth-source-remember spec found))) >>> and password-in-cache-p returns nil if >>> there exists a (key nil) entry on password-data, when previously it >>> would return non-nil. >> >> I think a nil key is also not expected. > > (key nil) means a hash table entry with `key' as key and nil as value, > not that key is nil. Ah, sorry. >> Note that password-in-cache-p is currently identical to >> password-read-from-cache. One can probably be written in terms of the >> other. > > Yes, right now they are identical, which causes a problem, because > checking for key existence shall not be the same as retrieving the value > when value can be nil. > >> Even if these "memhash" checks are TRT, I suggest either reusing or >> copying the hash table method of map-contains-key, rather than comparing >> against an interned symbol. > > Is map-contains-key available by default? I'm wary of introducing new > dependencies for saving just a few characters. That's why I said "either reusing or _copying_" what map-contains-key does, namely not using an interned symbol: (let ((v '(nil))) (not (eq v (gethash key map v)))) But as long as passwords are strings or nil it doesn't really matter. Thanks, --=20 Basil