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

From: Eli Zaretskii <[email-masked]>
Date: Sun, 26 Nov 2017 19:01:06 +0200

> From: Shuguang Sun <[email-masked]>
> Date: Sun, 26 Nov 2017 22:59:33 +0800
> 
> Local: Windows 7
> GNU Emacs 27.0.50 (build 1, x86_64-w64-mingw32) of 2017-11-24
> (backup-by-copying t)
> 
> File is on a server which is mapped as network driver in Windows 7. It seems a samba according to the SID
> below.
> The SDDL from file-acl is 
> "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)"
> 
> After I edited the file and write it, the backup meets error:
> 
> Debugger entered--Lisp error: (file-error "Setting ACL" "Operation not permitted"
> "c:/Users/username/HOME/.emacs.d/autosave/Rfiles/!drive_i!test_fixed_IA_time.r.~2~")
>   set-file-acl("c:/Users/username/HOME/.emacs.d/autosave/Rfiles/!drive_i!test_fixed_IA_time.r.~2~"
> "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)")
>   set-file-extended-attributes
> ("c:/Users/username/HOME/.emacs.d/autosave/Rfiles/!drive_i!test_fixed_IA_time.r.~2~" ((acl .
> "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)")
> (selinux-context nil nil nil nil)))
>   backup-buffer-copy("i:/power/permutation_test_fixed_IA_time.r"
> "c:/Users/username/HOME/.emacs.d/autosave/Rfiles/!drive_i!test_fixed_IA_time.r.~2~" 438 ((acl .
> "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)")
> (selinux-context nil nil nil nil)))
>   backup-buffer()
>   basic-save-buffer-2()
>   basic-save-buffer-1()
>   basic-save-buffer(t)
>   save-buffer(1)
>   funcall-interactively(save-buffer 1)
>   call-interactively(save-buffer nil nil)
>   command-execute(save-buffer)

Do you have debug-on-error set to non-nil?  In backup-buffer-copy the
function set-file-extended-attributes is called inside
with-demoted-errors, so unless debug-on-error is non-nil, the error
should have been converted to a simple message, and Emacs should have
felled back to set-file-modes.  Why isn't this happening in your case?

Also, does the following fail with SOME-FILE being a local file?

  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