Subject: bug#21699: 24.5; Bug in backup-buffer-copy and/or set-file-extended-attributes etc [set-file-extended-attributes]

From: Eli Zaretskii <[email-masked]>
Date: Mon, 19 Oct 2015 12:22:10 +0300

> Date: Mon, 19 Oct 2015 05:10:58 -0400
> From: Eli Barzilay <[email-masked]>
> Cc: [email-masked]
> 
> On Mon, Oct 19, 2015 at 4:04 AM, Eli Zaretskii <[email-masked]> wrote:
> >> Date: Mon, 19 Oct 2015 03:50:04 -0400
> >> From: Eli Barzilay <[email-masked]>
> >> Cc: [email-masked]
> >>
> >> *BUT* I doubt that this is a good idea, since on a system that
> >> supports both acl and selinux-context you probably want a t result to
> >> indicate that all of the extended settings worked.
> >
> > I don't think this is true.  Many (maybe most) systems support either
> > ACLs or SELinux, and for them the function will incorrectly return
> > nil.
> >
> > A better way might be to have a test of "null" attributes, and avoid
> > calling the low-level APIs when the attributes are "null".  A separate
> > issue, I think.
> 
> Did you have a look at my `file-extended-attributes' fix?  It does just
> that: when the low-level functions return "null" (four nils in the
> selinux case), then they won't get included in the result.  This frees
> `set-file-extended-attributes' to require that all settings succeed.

Yes, I've seen that.  But I'm not sure that we want such a change,
because it loses some information: namely, that the failed interfaces
did fail, or, equivalently, that information about the other kinds of
attributes is not available.

I don't know if this is important, but it does change the semantics of
an interface that was already released.  So I preferred a fix that
didn't involve such changes.

> And I think that there's one case where things would fail with your fix:
> a linux machine that has selinux disabled will have this as the extended
> attributes:
> 
>     ((acl . nil) (selinux-context . (nil nil nil nil)))
> 
> and your version of `set-file-extended-attributes' would fail when both
> of these fail.

You mean, a GNU/Linux machine that supports neither ACLs nor SELinux,
I suppose.  Do such machines exist, and if so, are they popular?

> With my fix, `file-extended-attributes' would just return nil in
> that case, and `set-file-extended-attributes' will succeed
> trivially.

Why should set-file-extended-attributes succeed in this case?  It
didn't set any extended attributes, right?  And if neither ACLs nor
SELinux is supported, we should definitely fall back on chmod for the
backup files, shouldn't we?