From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#66546: 30.0.50; save-buffer to write-protected file without backup fails Date: Sat, 21 Oct 2023 22:02:26 +0300 Message-ID: <83a5sbre7x.fsf@gnu.org> References: <83h6mtq9t7.fsf@gnu.org> <8734ydx7x3.fsf@sappc2.fritz.box> <83cyxgqwjm.fsf@gnu.org> <87lec4cjqe.fsf@sappc2.fritz.box> <83ttqsp5x1.fsf@gnu.org> <87il78cdyf.fsf@sappc2.fritz.box> <83pm1gozi6.fsf@gnu.org> <87edhvd84h.fsf@sappc2.fritz.box> <838r82q0gi.fsf@gnu.org> <87wmvmfi68.fsf@sappc2.fritz.box> <83o7gxo771.fsf@gnu.org> <87ttqpgg8l.fsf@sappc2.fritz.box> <83cyxcnp2f.fsf@gnu.org> <87sf671xe3.fsf@sappc2.fritz.box> <83y1fzmdhm.fsf@gnu.org> <87zg0ez57o.fsf@sappc2.fritz.box> <835y31u8t0.fsf@gnu.org> <87edhnamg3.fsf@sappc2.fritz.box> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15467"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 66546@debbugs.gnu.org To: Jens Schmidt Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 21 21:04:03 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 1quHGT-0003gl-4U for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 21 Oct 2023 21:04:01 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1quHGF-0002Cu-C2; Sat, 21 Oct 2023 15:03:47 -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 1quHG4-0002Aj-5c for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 15:03:36 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1quHG2-0003E0-Lg for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 15:03:35 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1quHGT-0000Qp-L9 for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 15:04:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Oct 2023 19:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66546 X-GNU-PR-Package: emacs Original-Received: via spool by 66546-submit@debbugs.gnu.org id=B66546.16979149851577 (code B ref 66546); Sat, 21 Oct 2023 19:04:01 +0000 Original-Received: (at 66546) by debbugs.gnu.org; 21 Oct 2023 19:03:05 +0000 Original-Received: from localhost ([127.0.0.1]:45063 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quHFZ-0000PN-DF for submit@debbugs.gnu.org; Sat, 21 Oct 2023 15:03:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39484) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quHFW-0000Oq-5T for 66546@debbugs.gnu.org; Sat, 21 Oct 2023 15:03:04 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1quHEx-00032A-OY; Sat, 21 Oct 2023 15:02:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=eF/vwAeEPNt5ruWbo+JSJDwR67psqjf74DuQpx7JPZI=; b=Wdz2l8ajHuMT ypGc/RolFkVGnvzi1QVKyV7NN++ACGMXSwaDWVIhiJH1rBiwQr+cRcJUrw5v24/IpE07E2Dff/G6Z KOyTwCFB4ExNqLBiHJHedRkLnyE6H9L8EJbkd/ajuFw2EWZdw4CVxfPO8TvC0P5vYDf5VU08O4QEr Y+jrRCQ174dcleroHRU+A0khXTtD8QROiXTBa9gdwH5QnBC35JrNU2MbXVuTV2arccwSOWQpOCSaC iUDpQt6kmOumH8kJOzyoeFTva6MHxzDYkQjqNdLaoZgBT4LvbBac+2BIAOxMjSh4E/OIDEQjMxAHV TSGfEQ0FfxMNU6kGYEPN8Q==; In-Reply-To: <87edhnamg3.fsf@sappc2.fritz.box> (message from Jens Schmidt on Sat, 21 Oct 2023 19:56:44 +0200) 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:272932 Archived-At: > From: Jens Schmidt > Cc: 66546@debbugs.gnu.org > Date: Sat, 21 Oct 2023 19:56:44 +0200 > > >> + ;; If we get an error writing the file which we > >> + ;; previously made writable, attempt to undo the > >> + ;; write-access. > >> + ((and (eq tempsetmodes 'u+w) (not success)) > > > > Isn't it easier, safer, and more portable to compare buffer-file-name > > with (nth 2 setmodes) instead? > > I wanted to make 100% sure that we execute that first cond-branch if and > only if we previously changed the file mode. IOW, I feel I cannot > exclude that by some strange configuration > > (equal buffer-file-name (nth 2 setmodes)) > > could also be true in other cases. It doesn't matter which cases could cause this. What matters is that only when these two are identical that we need to make sure the file ends up read-only as it was before the call to set-file-modes. So please do make that change.