unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
Cc: 66546@debbugs.gnu.org
Subject: bug#66546: 30.0.50; save-buffer to write-protected file without backup fails
Date: Mon, 16 Oct 2023 14:19:09 +0300	[thread overview]
Message-ID: <838r82q0gi.fsf@gnu.org> (raw)
In-Reply-To: <87edhvd84h.fsf@sappc2.fritz.box> (message from Jens Schmidt on Sun, 15 Oct 2023 20:59:42 +0200)

> From: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
> Cc: 66546@debbugs.gnu.org
> Date: Sun, 15 Oct 2023 20:59:42 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > In that case, does the change below fix the original problem?
> 
> It does, thanks.

I've now installed that on the master branch.

> >> 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?

The only way I know of is to edit the extended attributes, which are
returned as a string, then use those edited attributes.  But the
semantics, and therefore the editing, of those strings are
platform-dependent, and editing them requires intimate knowledge of
the semantics and which edits are valid.

> > +	       ;; 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.





  reply	other threads:[~2023-10-16 11:19 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-14 19:09 bug#66546: 30.0.50; save-buffer to write-protected file without backup fails Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-14 19:32 ` Eli Zaretskii
2023-10-14 20:31   ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-15  5:33     ` Eli Zaretskii
2023-10-15  9:34       ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-15  9:54         ` Eli Zaretskii
2023-10-15 11:39           ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-15 12:12             ` Eli Zaretskii
2023-10-15 18:59               ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-16 11:19                 ` Eli Zaretskii [this message]
2023-10-16 20:04                   ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-17 10:48                     ` Eli Zaretskii
2023-10-17 20:12                       ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-18 11:32                         ` Eli Zaretskii
2023-10-18 20:36                           ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-19  4:40                             ` Eli Zaretskii
2023-10-19 21:12                               ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-20  6:06                                 ` Eli Zaretskii
2023-10-21 17:56                                   ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 19:02                                     ` Eli Zaretskii
2023-10-21 20:17                                       ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-22  4:57                                         ` Eli Zaretskii
2023-10-22  9:45                                           ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-25 12:58                                             ` Eli Zaretskii
2023-10-29 14:23                                               ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-29 14:39                                                 ` Eli Zaretskii
2023-11-01 19:06                                                   ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-02  6:47                                                     ` Eli Zaretskii
2023-11-03 21:02                                                       ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-04  8:58                                                         ` Eli Zaretskii
2023-11-04 12:30                                                           ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-04 12:59                                                             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=838r82q0gi.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=66546@debbugs.gnu.org \
    --cc=jschmidt4gnu@vodafonemail.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).