From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#62952: 28.2.50; secrets.el unlocking items Date: Thu, 20 Apr 2023 13:23:34 +0200 Message-ID: <87fs8u6bm1.fsf@gmx.de> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33461"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 62952@debbugs.gnu.org To: "Philipp Uhl" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 20 13:24:15 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ppSOc-0008TS-Tp for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 20 Apr 2023 13:24:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppSOS-0001U0-Fp; Thu, 20 Apr 2023 07:24:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppSOR-0001Tr-4i for bug-gnu-emacs@gnu.org; Thu, 20 Apr 2023 07:24:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ppSOQ-0005Ok-SM for bug-gnu-emacs@gnu.org; Thu, 20 Apr 2023 07:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ppSOQ-0007QC-Fv for bug-gnu-emacs@gnu.org; Thu, 20 Apr 2023 07:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 Apr 2023 11:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62952 X-GNU-PR-Package: emacs Original-Received: via spool by 62952-submit@debbugs.gnu.org id=B62952.168198982628501 (code B ref 62952); Thu, 20 Apr 2023 11:24:02 +0000 Original-Received: (at 62952) by debbugs.gnu.org; 20 Apr 2023 11:23:46 +0000 Original-Received: from localhost ([127.0.0.1]:36718 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppSO9-0007Pd-UB for submit@debbugs.gnu.org; Thu, 20 Apr 2023 07:23:46 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]:51871) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppSO8-0007PP-42 for 62952@debbugs.gnu.org; Thu, 20 Apr 2023 07:23:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1681989815; i=michael.albinus@gmx.de; bh=SqZb8IybsPx8j0+p8iFAUCEOKTg1frSyiAfK2uf9Kh8=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=kxcAXmzLbx1I3bAVwMLaxfqbrbPYZ6tOrT4vJdZotf355wEkmPshWXOUSL6Xg36F8 KEGgRiLSlQ7K4MA12LxdrvwCcM08nLduQ5x/heTiEhiPOgEtHHqYdHD6iTKz+s4WsL aDA6yodBocGZLIyexcdBntfTDYdBxDNEioomyoJp58buTu1EDBey3sfnoMmY9FJxpp ruVm3Z6wm+pqifoVZas3Rbr8VxSUjIHFFQjQKsRLwXuzTH/cAVVOt3t19mXmQ8LVT3 2/njk3BkS5uM4A1k/mb4sPQnyQXKwBZT1dykHJw17NBoAkRg/BuFDyTDgizmwC/iHE dQiTNzZq6kF5g== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.39.0]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MJE27-1paPi13Zmt-00Kh43; Thu, 20 Apr 2023 13:23:35 +0200 In-Reply-To: (Philipp Uhl's message of "Wed, 19 Apr 2023 14:23:17 +0200") X-Provags-ID: V03:K1:gJdJKaeQar+pPXkTdkXn/XX0zk2W4Z2hyrQ03yCNMz1gWcuC6bU LiZtRKijHZk8HuS7zhwvXhFoRD54CAQPEVORqtKnwlbLBGk5/6ZlYoCrfxibOvgDFkxdwBp jysUYrmB25lPblkiC2OsX/mNGXuaNQDIb7OZKBmosZszLAbsbvzioVx9+rzwdt/ZTkfTEah NpxUA03tJ/KqwIKuWJ+YQ== UI-OutboundReport: notjunk:1;M01:P0:50SXu+pAa/A=;d7kCovSnx1794R7ObO999XXn+gl JYffY6+YBdUJQ+kzmKOQmMZ2LW/5l9WI085++zO5kfu3CB4kANuGTAopv2hIbEP/BcNk/lK4e DS8Q/RUxc8OeDBDbMRB20XiKYqF17KiEcIxk3s3Xo+pKblu+q11MCAfEc5s23U4gMyvJAdXnK 3HaKD7zk9n9WeBFMqPc3pghjW+413vAxf8RGsYaUaXXAZ9Utb5r0ToLx8ZRNFruvK3Cc3tgR0 Er25dayeurrTCbUTPauQo2/+s3yfYKbY29/LNYsG+1ug6pBeSXZQOubaigI626NMB4iqifZql YHruJkxMBVNGxLiBgKqGUWQWtPkx2neblbiKSIVx/KmE/JiZ0Ot+hkLsUjj62t0hqps3lxeJ9 31Mpv6Gx8hUf53Zuxs1TWQSVBFo5ues8dtkeGUkWyUL82yOHENRAF4FpuDBVdGq9u4JxmrsLF FyeNo8VUQPctLl/Zvmz1BjrkoCCVLvbZaRIqhqJHEoyKBooek7MnLkLtPauXegWw5wgRwhNX/ az8b2qMWhx7EWHxp0zc6yr8WAH2JJyedxYOyno6WcMgGYDLxY3SAlKaLG/ibB9YZIV9zxJ2Bd dHdgyFh1/7eu9RBueNv/80S4dltDicNvhGSXG3PgAnw/E8DxfciiILDU2JnwrNt0ohZhk/kv0 vlnAte2kISrdIPHlH45Y8xDpHA8A95jU4nFAC9Jg13lGHCp32TTRfYGVGu70uYIeei8nvwgvB 0qagdRFwVXegvNpubVSTR7hZFFNUgy3QwLJnHJ6p/t1ujhGixMBazrtYS9r70Ht8IYQqs3+s X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:260328 Archived-At: "Philipp Uhl" writes: Hi Philipp, > The secrets.el implementation lacks support for unlocking specific > items. It only unlocks collections. This does not work well with certain > password managers (e.g. in my case KeepassXC, accessed through secret > service). When receiving a secret through > > (secrets-get-secret "MyPws" "MyEntry") > > with the setting "Confirm when passwords are retrieved by clients" > turned on in KeepassXC, secrets-get-secret will just say IsLocked. Thanks for the report. > Instead, secrets-get-secret should try to unlock the entry itself before > retrieving. > > Here is a proof of concept: > > + ;; New function, analogously to secrets-unlock-collection, that > + ;; specifically unlocks the item > + (defun secrets-unlock-item (collection item) > + "Unlock item labeled ITEM from collection labeled COLLECTION. > + If successful, return the object path of the item." > + (let ((item-path (secrets-item-path collection item))) > + (unless (secrets-empty-path item-path) > + (secrets-prompt > + (cadr > + (dbus-call-method > + :session secrets-service secrets-path secrets-interface-service > + "Unlock" `(:array :object-path ,item-path))))) > + item-path)) > > (defun secrets-get-secret (collection item) > "Return the secret of item labeled ITEM in COLLECTION. > If there are several items labeled ITEM, it is undefined which > one is returned. If there is no such item, return nil. > > ITEM can also be an object path, which is used if contained in COLLECTION." > - (let ((item-path (secrets-item-path collection item))) > + (let ((item-path (secrets-unlock-item collection item))) > (unless (secrets-empty-path item-path) > (dbus-byte-array-to-string > (nth 2 > (dbus-call-method > :session secrets-service item-path secrets-interface-item > "GetSecret" :object-path secrets-session-path)))))) > > To make this function a bit more similar to how it was before, one could > concider to explicitly wait for the IsLocked event before unlocking the > item. That way, if the password manager does not support unlocking of > items, this would not be braking. LGTM. Well, I don't know how relevant it is to wait for the IsLocked event. If you have use cases where it is needed, we shall do. When we add secrets-unlock-item, we should also add secrets-lock-item as counterpart. Like we have done it with secrets-(un)?lock-collection. Would you like to add this function? Bonus points for respective tests in secrets-tests.el. All these changes exceed the limit for tiny changes in Emacs, which could be submitted w/o legal work. Would you like to sign FSF copyright papers in order to contribute to Emacs? See which explains the reasons. > Cheers, > Philipp Uhl Best regards, Michael.