From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jens Schmidt via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#66546: 30.0.50; save-buffer to write-protected file without backup fails Date: Mon, 16 Oct 2023 22:04:15 +0200 Message-ID: <87wmvmfi68.fsf@sappc2.fritz.box> 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> Reply-To: Jens Schmidt Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11961"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cc: 66546@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 16 22:06: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 1qsTqw-0002rK-UR for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 16 Oct 2023 22:06:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qsTqO-00015r-1r; Mon, 16 Oct 2023 16:05:40 -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 1qsTqL-00015e-VV for bug-gnu-emacs@gnu.org; Mon, 16 Oct 2023 16:05:38 -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 1qsTqL-0005Ra-NU for bug-gnu-emacs@gnu.org; Mon, 16 Oct 2023 16:05:37 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qsTqk-0000wa-AI for bug-gnu-emacs@gnu.org; Mon, 16 Oct 2023 16:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jens Schmidt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 16 Oct 2023 20:06:02 +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.16974867173565 (code B ref 66546); Mon, 16 Oct 2023 20:06:02 +0000 Original-Received: (at 66546) by debbugs.gnu.org; 16 Oct 2023 20:05:17 +0000 Original-Received: from localhost ([127.0.0.1]:58069 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qsTq0-0000vQ-LZ for submit@debbugs.gnu.org; Mon, 16 Oct 2023 16:05:17 -0400 Original-Received: from mr4.vodafonemail.de ([145.253.228.164]:51284) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qsTpi-0000uA-J1 for 66546@debbugs.gnu.org; Mon, 16 Oct 2023 16:05:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafonemail.de; s=vfde-mb-mr2-23sep; t=1697486666; bh=I8MI60HGutjm/hRoYJXVMNfMo167EnG9iyADGgSIPS0=; h=From:To:Subject:References:Date:In-Reply-To:Message-ID:User-Agent: Content-Type:From; b=OHrFnOX1QLzwgDb6/nTdQEpwb9qs7UlTY5weUv32Nb4iXuRI9gp+e59oTQOUExO7+ VqNDKKIf+V72YU9M8evAByxrH9gOKbcdT5wjPgOZ64XgB4MQAqYnwT7tzdB8BV0FRa cZPMawxi1YZJrNxQgBfxcrB2sT1m8mcF1ALcODo8= Original-Received: from smtp.vodafone.de (unknown [10.0.0.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by mr4.vodafonemail.de (Postfix) with ESMTPS id 4S8SkL4xwXz1xp4; Mon, 16 Oct 2023 20:04:26 +0000 (UTC) Original-Received: from sappc2 (port-92-194-182-101.dynamic.as20676.net [92.194.182.101]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.vodafone.de (Postfix) with ESMTPSA id 4S8SkC1jbmzHnHc; Mon, 16 Oct 2023 20:04:16 +0000 (UTC) In-Reply-To: <838r82q0gi.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 16 Oct 2023 14:19:09 +0300") X-purgate-type: clean X-purgate: clean X-purgate-size: 2510 X-purgate-ID: 155817::1697486662-BF7FB94E-3E45057D/0/0 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:272584 Archived-At: Eli Zaretskii writes: >> From: Jens Schmidt >> Cc: 66546@debbugs.gnu.org >> Date: Sun, 15 Oct 2023 20:59:42 +0200 >> >> Eli Zaretskii writes: >> >> > In that case, does the change below fix the original problem? >> >> It does, thanks. > > I've now installed that on the master branch. Thanks. Now that's out of the way, should I then work on what I have called issue B in the initial message and on ERT tests for both issues? Or do you still think there is more discussion required on these beforehand? >> > + ;; If set-file-extended-attributes fails to make the >> > + ;; file writable, fall back on set-file-modes. >> > + (with-demoted-errors "Error setting attributes: %s" >> > + (set-file-extended-attributes buffer-file-name >> > + (nth 1 setmodes))) >> >> How exactly could above call to `set-file-extended-attributes' *succeed* >> to make the file writable? > > I don't know, and I don't think we should care. Due to the > above-mentioned system-dependencies, Emacs generally treats extended > attributes as opaque objects, and only tries hard to preserve them > where expected. So the above is our best effort to preserve the > attributes, which is why we call set-file-modes only if absolutely > necessary, since doing that in general affects the extended > attributes. That explains (partially) what I did not understand in your solution. But still, to me it seems that the two forms (setq setmodes (list (file-modes buffer-file-name) (with-demoted-errors "Error getting extended attributes: %s" (file-extended-attributes buffer-file-name)) buffer-file-name)) (with-demoted-errors "Error setting attributes: %s" (set-file-extended-attributes buffer-file-name (nth 1 setmodes))) , if limiting them to the extended attribute calls and if ignoring outer context, could be simplified to (set-file-extended-attributes buffer-file-name (file-extended-attributes buffer-file-name)) (If not, why not?) And wouldn't that be, in this context, just a no-op? I fully understand that the extended attributes stored in `setmodes' are required later to restore the attributes of the file after it has been written to. And in that context I understand why we call `set-file-extended-attributes'. But here not really, yet.