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#57856: 28.2; bookmark context strings in encrypted files Date: Tue, 20 Sep 2022 16:49:58 +0200 Message-ID: <878rmegkx5.fsf@gmx.de> References: <87bkrfh77i.fsf@gmail.com> <87mtaz8quf.fsf@gnus.org> <877d23h4df.fsf@gmail.com> <87czbv8od3.fsf@gnus.org> <87y1ujsbjp.fsf@gmx.de> <874jx56l2v.fsf@gnus.org> <87mtaxx8s7.fsf@gmx.de> <87leqfzu6j.fsf@gnus.org> <878rmfkaco.fsf@gmx.de> <87mtavvafd.fsf@gnus.org> <87zgevimog.fsf@gmx.de> <874jx3v8y7.fsf@gnus.org> <87v8pjikil.fsf@gmx.de> <8735cnryp6.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34559"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Gustavo Barros , 57856@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 20 21:50:45 2022 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 1oajGW-0008qH-MZ for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 20 Sep 2022 21:50:44 +0200 Original-Received: from localhost ([::1]:51442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oajGV-0007ju-Dh for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 20 Sep 2022 15:50:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaeaW-0003vf-46 for bug-gnu-emacs@gnu.org; Tue, 20 Sep 2022 10:51:12 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60111) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaeaU-0001g6-Lb for bug-gnu-emacs@gnu.org; Tue, 20 Sep 2022 10:51:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oaeaU-0004m5-4P for bug-gnu-emacs@gnu.org; Tue, 20 Sep 2022 10:51: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: Tue, 20 Sep 2022 14:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57856 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 57856-submit@debbugs.gnu.org id=B57856.166368541218250 (code B ref 57856); Tue, 20 Sep 2022 14:51:02 +0000 Original-Received: (at 57856) by debbugs.gnu.org; 20 Sep 2022 14:50:12 +0000 Original-Received: from localhost ([127.0.0.1]:59185 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oaeZf-0004kG-WC for submit@debbugs.gnu.org; Tue, 20 Sep 2022 10:50:12 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:40155) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oaeZd-0004k3-3s for 57856@debbugs.gnu.org; Tue, 20 Sep 2022 10:50:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1663685400; bh=A2biTIEAE9U6e4Gt3e2SL6c3h471nLIrsmNWmbD+9HM=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=AC6TbYgbjP0U/P+sX833looF+KdSmRW8qUyXGvniDJH1SZQcioLCPZHP0AOs9jf/7 Ga6OxI60kGLN89CBMipikYweB30LebyfKTa2d33SmMDlNyb1kZQs1JWV8nd+k0pSY5 o50RT1i4OJth2JcgTLwsUYZqmrxNDKqvrpBF9j0A= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from gandalf.gmx.de ([79.140.125.182]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MbzyJ-1p8tnD0Sfn-00dUs3; Tue, 20 Sep 2022 16:50:00 +0200 In-Reply-To: <8735cnryp6.fsf@gnus.org> (Lars Ingebrigtsen's message of "Mon, 19 Sep 2022 20:44:37 +0200") X-Provags-ID: V03:K1:oOalENEzOeXH0UyNWlKttllo+gm1QgeyuC4UZhC83NYbGKd3dAF utE58Ij9ui0oRq2F3TbEDXj/Basmj1t0eV4/HfdmemtciKEjht4ip79yz62JNLJlAVmMv0R WVMImdJ2L7RxAmWr/jCDTt4PNXNOhADZzKNa8aWZpMZitiwubW4CQz81aUeUFEXmF3TJS0D lKj8VQzNQCZ0bRP+o3h7g== X-UI-Out-Filterresults: notjunk:1;V03:K0:44SZEKMz6uE=:tV2RvjDV7Ds+jYOu0nwPDf 6xOpZZD7XSc8K13j8UU+B96I+ClK4x162ek098hHMS1Qg3F9bf05CwrWbyaAOMAvUQQIy3IP4 t7VIHl0kTGiLxjrkGB1V7zTV3bZKNbk+4JHZ94KpKZwL78RTeh80fUq1OpZQ3BmrFRwzywbH3 PUs6zpUXHwBRfcW6jSabOLzC409KJjfMknwo1oUe6WEKIRfWVcxZz0e5emDzqmqSMQS7IW+BS x0tvHbmvqK3OamyaakKZmQuZ/YPBoN0h12K61sWVYMnS7Ch8FBzOwU1pHzzI7ob+5H7GJ/9Cd WxdDStOsZcvfmMn6z+QO7a4RjtDPpbtMDmM4IWwujJV7xHKmqqnEXnJZ/1NTns+iHoj5eZmam 208kW/Ky1gr28otTcmrhN1laCSM+2NUIyvaSaxMRR6N6B+q3wMmUyTjnTzHfVbGlqEdHKSzer BlTPx4NG3fR2IDYQFMN8z98aRo/+FxZBTx9xQ3Glcvd1V5YU983IPat3j0xOpr6wmBGoMkzZj /cjzVCKlk9RmXkIRGTYfxvx/S4Es+BFtu6Gy+ra/6+7iafiPFstRFB45PaPFBqSrGNyjWtTlF Ph0AUh32d9b+wByJA2uG3pflN09Vo3CIVgOcu9znKpKnG8xDq3C9Xptosq6WQ7yWoCDab9R3v KPwXML70C58tJQx4IFY7W9NUv9PpxW59wvs8LTR21FZz5O1gqseRWFlAXK+Nys/zLiaDiDEgr kxAfHv/izTdhksnMAzLJMN0nXWmIAo7dKYanvBGqVbLDEQAXRvXvnWOWled9mT4lyViy9qrJ 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" Xref: news.gmane.io gmane.emacs.bugs:243214 Archived-At: --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: Hi Lars, > Michael Albinus writes: > >> But we will protect users who do in their init file >> >> (setq auth-sources '("~/.authinfo" "~/my-own-netrc-file-name")) > > Yes, that's a good point. I gave it a try. WDYT? (Documentation must be added, of course) Best regards, Michael. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Transfer-Encoding: quoted-printable diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el index 86e0b48a79..4519705e14 100644 =2D-- a/lisp/auth-source-pass.el +++ b/lisp/auth-source-pass.el @@ -319,6 +319,16 @@ auth-source-pass--name-port-user-suffixes (list (format "%s" name))))) +(defun auth-source-pass-file-name-p (file) + "Say whether FILE is used by `auth-source-pass'." + (and (stringp file) (stringp auth-source-pass-filename) + (string-equal + (expand-file-name file) (expand-file-name auth-source-pass-filena= me)))) + +(with-eval-after-load 'bookmark + (add-hook 'bookmark-inhibit-bookmark-functions + #'auth-source-pass-file-name-p)) + (provide 'auth-source-pass) ;;; auth-source-pass.el ends here diff --git a/lisp/auth-source.el b/lisp/auth-source.el index c79e5b81f7..13ebd80106 100644 =2D-- a/lisp/auth-source.el +++ b/lisp/auth-source.el @@ -522,6 +522,21 @@ auth-source-backend-parse-parameters ;; (mapcar #'auth-source-backend-parse auth-sources) +(defun auth-source-file-name-p (file) + "Say whether FILE is used by `auth-sources'." + (let* ((backends (mapcar #'auth-source-backend-parse auth-sources)) + (files + (mapcar (lambda (x) + (when (member (slot-value x 'type) '(json netrc plsto= re)) + (slot-value x 'source))) + backends))) + (member (expand-file-name file) + (mapcar #'expand-file-name (remq nil files))))) + +(with-eval-after-load 'bookmark + (add-hook 'bookmark-inhibit-bookmark-functions + #'auth-source-file-name-p)) + (cl-defun auth-source-search (&rest spec &key max require create delete &allow-other-keys) diff --git a/lisp/bookmark.el b/lisp/bookmark.el index f150a24bbf..941cf7932c 100644 =2D-- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -592,6 +592,14 @@ bookmark-make-record-function in which case a default heuristic will be used. The function can also equivalently just return ALIST without NAME.") +(defcustom bookmark-inhibit-bookmark-functions nil + "List of functions to call before make a bookmark record. +The functions take `buffer-file-name' as argument. If any of +these functions returns non-nil, the current buffer is not used +for a bookmark." + :type 'hook + :version "29.1") + (defun bookmark-make-record () "Return a new bookmark record (NAME . ALIST) for the current location." (let* ((bookmark-search-size @@ -599,10 +607,8 @@ bookmark-make-record ;; don't include any context in the bookmark file, because ;; that would leak (possibly secret) data. (if (and buffer-file-name - (or (and (fboundp 'epa-file-name-p) - (epa-file-name-p buffer-file-name)) - (and (fboundp 'tramp-crypt-file-name-p) - (tramp-crypt-file-name-p buffer-file-name)))) + (not (run-hook-with-args-until-success + 'bookmark-inhibit-bookmark-functions buffer-file= -name))) 0 bookmark-search-size)) (record (funcall bookmark-make-record-function))) diff --git a/lisp/epa-hook.el b/lisp/epa-hook.el index 70c3030881..f4616b3b91 100644 =2D-- a/lisp/epa-hook.el +++ b/lisp/epa-hook.el @@ -92,6 +92,10 @@ epa-file-name-p "Say whether FILE is handled by `epa-file'." (and auto-encryption-mode (string-match-p epa-file-name-regexp file))) +(with-eval-after-load 'bookmark + (add-hook 'bookmark-inhibit-bookmark-functions + #'epa-file-name-p)) + (define-minor-mode auto-encryption-mode "Toggle automatic file encryption/decryption (Auto Encryption mode)." :global t :init-value t :group 'epa-file :version "23.1" diff --git a/lisp/net/tramp-crypt.el b/lisp/net/tramp-crypt.el index d556c87606..60a1c37c9c 100644 =2D-- a/lisp/net/tramp-crypt.el +++ b/lisp/net/tramp-crypt.el @@ -852,6 +852,14 @@ tramp-crypt-handle-unlock-file (tramp-compat-funcall 'unlock-file (tramp-crypt-encrypt-file-name filename)))) +(with-eval-after-load 'bookmark + (add-hook 'bookmark-inhibit-bookmark-functions + #'tramp-crypt-file-name-p) + (add-hook 'tramp-crypt-unload-hook + (lambda () + (remove-hook 'bookmark-inhibit-bookmark-functions + #'tramp-crypt-file-name-p)))) + (add-hook 'tramp-unload-hook (lambda () (unload-feature 'tramp-crypt 'force))) --=-=-=--