Subject: bug#29455: backup-by-copying ACL Operation not permitted with Windows 7 and Samba

From: Eli Zaretskii <[email-masked]>
Date: Tue, 28 Nov 2017 19:28:19 +0200

> From: Shuguang Sun <[email-masked]>
> Date: Tue, 28 Nov 2017 18:43:53 +0800
> Cc: [email-masked]
> 
>  Thanks, but that's not what I asked.  I asked you to create a local
>  file (which I call "SOME-FILE" below, replace that with the actual
>  name of the file), and then type this inside Emacs:
> 
>    M-: (set-file-acl "SOME-FILE" "O:S-1-22-1-79077G:S-1-22-2-108D:P(A;;0x1e01ff;;;S-1-22-1-79077)
>  (A;;FR;;;S-1-22-2-108)(A;;FR;;;WD)") RET
> 
> It raises the same error message:
> (file-error "Setting ACL" "Operation not permitted" "c:/Users/username/Documents/base/subtitle.txt")
> 
> or
> eval: Setting ACL: Operation not permitted, c:/Users/username/HOME/.emacs.d/autosave/.bashrc.~1~

OK, I think I understand what causes this: the problem is with setting
the owner of the file to a user whose SID the local system doesn't
recognize, because it's not a local user.  If you omit the
O:S-1-22-1-79077G:S-1-22-2-108 part from the argument, the
set-file-acl call will most probably succeed.

I think that Emacs works correctly in this case: it tries to preserve
the ACLs of the original file in the backup file, and when that fails,
falls back to preserving only the read-write mode bits.  Your original
problem was caused by debug-on-error being non-nil, which shouldn't be
done except when debugging something.

I don't see how we could avoid showing the error message, because
Emacs cannot possibly know which user SID values are known to the
local system.  When you configure your backups of files from networked
drives to be stored on a local disk, you should realize that you run
the risk of having these problems with preserving extended
permissions.

So I think we see Emacs working as designed, and this bug should be
closed.