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: Sun, 15 Oct 2023 20:59:42 +0200 Message-ID: <87edhvd84h.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> 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="4708"; 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 Sun Oct 15 21:01:11 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 1qs6MN-0000uu-OA for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 15 Oct 2023 21:01:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qs6M6-0003LL-BK; Sun, 15 Oct 2023 15:00:50 -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 1qs6M3-0003J6-HY for bug-gnu-emacs@gnu.org; Sun, 15 Oct 2023 15:00:47 -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 1qs6Lu-0004kH-Ln for bug-gnu-emacs@gnu.org; Sun, 15 Oct 2023 15:00:47 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qs6MI-0000yS-Fg for bug-gnu-emacs@gnu.org; Sun, 15 Oct 2023 15:01: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: Sun, 15 Oct 2023 19:01: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.16973964283692 (code B ref 66546); Sun, 15 Oct 2023 19:01:02 +0000 Original-Received: (at 66546) by debbugs.gnu.org; 15 Oct 2023 19:00:28 +0000 Original-Received: from localhost ([127.0.0.1]:54127 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qs6Lk-0000xU-1W for submit@debbugs.gnu.org; Sun, 15 Oct 2023 15:00:28 -0400 Original-Received: from mr5.vodafonemail.de ([145.253.228.165]:53410) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qs6Lf-0000xA-6A for 66546@debbugs.gnu.org; Sun, 15 Oct 2023 15:00:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafonemail.de; s=vfde-mb-mr2-21dec; t=1697396393; bh=XNyMaHqD/iWdTGsrcYuSKdELFsNaXXcvekKfx1bjSd8=; h=From:To:Subject:References:Date:In-Reply-To:Message-ID:User-Agent: Content-Type:From; b=Mklbczo3Mr4wgtPFVtUNLlyRe/+fnfa94QPYv5BekllfsQ2TjgTXL604fgCR3YNT/ ekyh8dGtsQrFvLzAVf9FjsHr/ytou1oLQo7vQkpmJC1/yfv0Q/1/I8B8A+1Po9zj+/ itIqgWljhgVKWPynq1Y4I1Xj0IH/sUTmpzEpwwGE= 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 mr5.vodafonemail.de (Postfix) with ESMTPS id 4S7qLK2Wybz1y8G; Sun, 15 Oct 2023 18:59:53 +0000 (UTC) Original-Received: from sappc2 (port-92-194-212-150.dynamic.as20676.net [92.194.212.150]) (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 4S7qL95n1bzMks2; Sun, 15 Oct 2023 18:59:42 +0000 (UTC) In-Reply-To: <83pm1gozi6.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 15 Oct 2023 15:12:49 +0300") X-purgate-type: clean X-purgate: clean X-purgate-size: 1858 X-purgate-ID: 155817::1697396389-F67FAE6D-D97B0337/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:272532 Archived-At: Eli Zaretskii writes: >> From: Jens Schmidt >> Cc: 66546@debbugs.gnu.org >> Date: Sun, 15 Oct 2023 13:39:04 +0200 >> Yes! Thanks for guessing :-) >> >> And I have been asking a related question implicitly in the previous >> conversation, so here is it explicitly: > > In that case, does the change below fix the original problem? It does, thanks. >> Using *only* the extended-attribute Elisp functions and objects, is >> there currently a way to implement the equivalent of "chmod u+w FILE" in >> Elisp? > AFAIU, this question has no meaningful answer. Extended attributes > are much more fine-grained than the "traditional" file mode bits; in > particular, they are incompatible with the "user" notion to fit the > "u" part of "u+w": the same file can be writable by a specific user or > group of users, and unwritable by others. Even if you only limit > yourself to Posix extended attributes (and Emacs doesn't limit itself > to that), there's no good answer to your question. Then pls let me ask a more general question. Given a sequence (setq ext-attrs (file-extended-attributes file-name)) (setq ext-attrs (funcall func ext-attrs)) (set-file-extended-attributes file-name ext-attrs) is there any Elisp function FUNC so that the extended attributes on FILE-NAME as seen by the OS change by executing that sequence? > + ;; 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? > + (unless (file-writable-p buffer-file-name)