unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29225: Tramp backup-by-copying in a Converting ACL Invalid argument error on Windows 7
@ 2017-11-09  8:24 Shuguang Sun
  2017-11-09 17:18 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Shuguang Sun @ 2017-11-09  8:24 UTC (permalink / raw)
  To: 29225

[-- Attachment #1: Type: text/plain, Size: 1479 bytes --]

Hi,

Windows 7
GNU Emacs 26.0.50 (build 1, x86_64-w64-mingw32) of 2017-08-27
(backup-by-copying t)

When I tramp to a host (linux) and edit a file, and save it, I get an error
about the backup as below. The ACL is in different format on Linus and on
Windows. It is "user::..." on linux, however, it looks like "O:S-1-5-21-"
on windows.

Could we allow the user to set whether to copy ACl for certain type of
files?

Debugger entered--Lisp error: (file-error "Converting ACL" "Invalid
argument"
"c:/Users/user/HOME/.emacs.d/autosave/Rfiles/!drive_c!plink!!user@host
!!!path!user!Ava!_mortality.R.~1~")

set-file-acl("c:/Users/user/HOME/.emacs.d/autosave/Rfiles/!drive_c!plink!!user@host!!!path!user!Ava!_mortality.R.~1~"
"user::rw-\ngroup::rw-\nother::r--\n")

set-file-extended-attributes("c:/Users/user/HOME/.emacs.d/autosave/Rfiles/!drive_c!plink!!user@host!!!path!user!Ava!_mortality.R.~1~"
((acl . "user::rw-\ngroup::rw-\nother::r--\n") (selinux-context nil nil nil
nil)))
  backup-buffer-copy("/plink:user@host:/path/user/Ava/_mortality.R"
"c:/Users/user/HOME/.emacs.d/autosave/Rfiles/!drive_c!plink!!user@host!!!path!user!Ava!_mortality.R.~1~"
436 ((acl . "user::rw-\ngroup::rw-\nother::r--\n") (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)

Best Regards,
Shuguang

[-- Attachment #2: Type: text/html, Size: 1852 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#29225: Tramp backup-by-copying in a Converting ACL Invalid argument error on Windows 7
  2017-11-09  8:24 bug#29225: Tramp backup-by-copying in a Converting ACL Invalid argument error on Windows 7 Shuguang Sun
@ 2017-11-09 17:18 ` Eli Zaretskii
  2017-11-10 12:41   ` Michael Albinus
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2017-11-09 17:18 UTC (permalink / raw)
  To: Shuguang Sun, Michael Albinus; +Cc: 29225

> From: Shuguang Sun <shuguang@gmail.com>
> Date: Thu, 9 Nov 2017 16:24:39 +0800
> 
> Could we allow the user to set whether to copy ACl for certain type of files?

That should work automatically.

> Debugger entered--Lisp error: (file-error "Converting ACL" "Invalid argument"
> "c:/Users/user/HOME/.emacs.d/autosave/Rfiles/!drive_c!plink!!user@host!!!path!user!Ava!_mortality.R.~1~")
> 
>   set-file-acl
> ("c:/Users/user/HOME/.emacs.d/autosave/Rfiles/!drive_c!plink!!user@host!!!path!user!Ava!_mortality.R.~1~"
> "user::rw-\ngroup::rw-\nother::r--\n")
>   set-file-extended-attributes
> ("c:/Users/user/HOME/.emacs.d/autosave/Rfiles/!drive_c!plink!!user@host!!!path!user!Ava!_mortality.R.~1~"
> ((acl . "user::rw-\ngroup::rw-\nother::r--\n") (selinux-context nil nil nil nil)))
>   backup-buffer-copy("/plink:user@host:/path/user/Ava/_mortality.R"
> "c:/Users/user/HOME/.emacs.d/autosave/Rfiles/!drive_c!plink!!user@host!!!path!user!Ava!_mortality.R.~1~"
> 436 ((acl . "user::rw-\ngroup::rw-\nother::r--\n") (selinux-context nil nil nil nil)))

This seems to indicate that Unix-style ACLs are passed to native
Windows ACL functions, which won't work.  Michael, could you please
look into this?  I'd expect ACLs derived from remote files never to be
used on local files.

Thanks.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#29225: Tramp backup-by-copying in a Converting ACL Invalid argument error on Windows 7
  2017-11-09 17:18 ` Eli Zaretskii
@ 2017-11-10 12:41   ` Michael Albinus
  2017-11-10 13:06     ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Albinus @ 2017-11-10 12:41 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Shuguang Sun, 29225

Eli Zaretskii <eliz@gnu.org> writes:

Hi Eli,

>> Debugger entered--Lisp error: (file-error "Converting ACL" "Invalid argument"
>> "c:/Users/user/HOME/.emacs.d/autosave/Rfiles/!drive_c!plink!!user@host!!!path!user!Ava!_mortality.R.~1~")
>> 
>>   set-file-acl
>> ("c:/Users/user/HOME/.emacs.d/autosave/Rfiles/!drive_c!plink!!user@host!!!path!user!Ava!_mortality.R.~1~"
>> "user::rw-\ngroup::rw-\nother::r--\n")
>>   set-file-extended-attributes
>> ("c:/Users/user/HOME/.emacs.d/autosave/Rfiles/!drive_c!plink!!user@host!!!path!user!Ava!_mortality.R.~1~"
>> ((acl . "user::rw-\ngroup::rw-\nother::r--\n") (selinux-context nil nil nil nil)))
>>   backup-buffer-copy("/plink:user@host:/path/user/Ava/_mortality.R"
>> "c:/Users/user/HOME/.emacs.d/autosave/Rfiles/!drive_c!plink!!user@host!!!path!user!Ava!_mortality.R.~1~"
>> 436 ((acl . "user::rw-\ngroup::rw-\nother::r--\n") (selinux-context nil nil nil nil)))
>
> This seems to indicate that Unix-style ACLs are passed to native
> Windows ACL functions, which won't work.  Michael, could you please
> look into this?  I'd expect ACLs derived from remote files never to be
> used on local files.

And vice versa.

However, Tramp has no chance to do something here. It offers own
implementations of `file-acl' and `set-file-acl'; both functions don't
know where the returned ACL shall be used (´file-acl'), or where the ACL
comes from (`set-file-acl'). Therefore, the docstring of `set-file-acl'
says

"Value is t if setting of ACL was successful, nil otherwise."

The error message "Converting ACL" "Invalid argument" comes from
Ffile_acl of fileio.c. It *raises* an error instead of silently
returning Qnil, as advertised by the docstring. A similar wrong
behaviour I've found in `tramp-smb-handle-set-file-acl'.

I would convert both functions to return nil instead of raising an
error, in the emacs-26 branch. Any objection?

> Thanks.

Best regards, Michael.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#29225: Tramp backup-by-copying in a Converting ACL Invalid argument error on Windows 7
  2017-11-10 12:41   ` Michael Albinus
@ 2017-11-10 13:06     ` Eli Zaretskii
  2017-11-10 14:39       ` Michael Albinus
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2017-11-10 13:06 UTC (permalink / raw)
  To: Michael Albinus; +Cc: shuguang, 29225

> From: Michael Albinus <michael.albinus@gmx.de>
> Cc: Shuguang Sun <shuguang@gmail.com>,  29225@debbugs.gnu.org
> Date: Fri, 10 Nov 2017 13:41:04 +0100
> 
> "Value is t if setting of ACL was successful, nil otherwise."
> 
> The error message "Converting ACL" "Invalid argument" comes from
> Ffile_acl of fileio.c. It *raises* an error instead of silently
> returning Qnil, as advertised by the docstring. A similar wrong
> behaviour I've found in `tramp-smb-handle-set-file-acl'.
> 
> I would convert both functions to return nil instead of raising an
> error, in the emacs-26 branch. Any objection?

I think it should return nil when acl_errno_valid returns false, and
otherwise signal an error.  It currently calls acl_errno_valid in one
of the two places where error could happen, but not in the other.  And
the doc string should be amended to say that.  WDYT?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#29225: Tramp backup-by-copying in a Converting ACL Invalid argument error on Windows 7
  2017-11-10 13:06     ` Eli Zaretskii
@ 2017-11-10 14:39       ` Michael Albinus
  2017-11-10 15:13         ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Albinus @ 2017-11-10 14:39 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: shuguang, 29225

[-- Attachment #1: Type: text/plain, Size: 1166 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

Hi Eli,

> I think it should return nil when acl_errno_valid returns false, and
> otherwise signal an error.  It currently calls acl_errno_valid in one
> of the two places where error could happen, but not in the other.  And
> the doc string should be amended to say that.  WDYT?

Seems to work, yes. acl_from_text returns EINVAL for wrong ACLs, so the
error would be suppressed, because acl_errno_valid returns false this case.

I've tested successfully the appended patch on GNU/Linux.

(set-file-acl "/tmp/123" "dummy")

returns nil with the applied patch, and (file-error "Converting ACL"
"Invalid argument" "/tmp/123") w/o the patch.

I cannot test on MS Windows.

I don't know whether we must extend the docstring. Summarizing probable
errors is not the default in Emacs docstrings. And the docstring does
not promise, that no error at all will happen.

If you don't object, I'll commit the patch to emacs-26. Plus minor
changes in Tramp. Maybe I'll find also the time next days, to add the
missing tests for file-acl and set-file-acl in tramp-tests.el. See the
TODO list at the end of that file.

Best regards, Michael.


[-- Attachment #2: Type: text/plain, Size: 384 bytes --]

diff --git a/src/fileio.c b/src/fileio.c
index cc1399e1bd..f538f12f9b 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3047,7 +3047,7 @@ support.  */)
   if (STRINGP (acl_string))
     {
       acl = acl_from_text (SSDATA (acl_string));
-      if (acl == NULL)
+      if (acl == NULL && acl_errno_valid (errno))
 	{
 	  report_file_error ("Converting ACL", absname);
 	  return Qnil;

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#29225: Tramp backup-by-copying in a Converting ACL Invalid argument error on Windows 7
  2017-11-10 14:39       ` Michael Albinus
@ 2017-11-10 15:13         ` Eli Zaretskii
  2017-11-12 13:21           ` Michael Albinus
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2017-11-10 15:13 UTC (permalink / raw)
  To: Michael Albinus; +Cc: shuguang, 29225

> From: Michael Albinus <michael.albinus@gmx.de>
> Cc: shuguang@gmail.com,  29225@debbugs.gnu.org
> Date: Fri, 10 Nov 2017 15:39:39 +0100
> 
> > I think it should return nil when acl_errno_valid returns false, and
> > otherwise signal an error.  It currently calls acl_errno_valid in one
> > of the two places where error could happen, but not in the other.  And
> > the doc string should be amended to say that.  WDYT?
> 
> Seems to work, yes. acl_from_text returns EINVAL for wrong ACLs, so the
> error would be suppressed, because acl_errno_valid returns false this case.
> 
> I've tested successfully the appended patch on GNU/Linux.
> 
> (set-file-acl "/tmp/123" "dummy")
> 
> returns nil with the applied patch, and (file-error "Converting ACL"
> "Invalid argument" "/tmp/123") w/o the patch.
> 
> I cannot test on MS Windows.

I don't see why it wouldn't work on Windows as well.

> I don't know whether we must extend the docstring. Summarizing probable
> errors is not the default in Emacs docstrings. And the docstring does
> not promise, that no error at all will happen.

That's okay, I can always amend the doc string later.

> If you don't object, I'll commit the patch to emacs-26. Plus minor
> changes in Tramp.

No objection, but please only condition the call to 'error' on
acl_errno_valid.  I see no reason to proceed with calling acl_set_file
if acl_from_text fails.

> Maybe I'll find also the time next days, to add the missing tests
> for file-acl and set-file-acl in tramp-tests.el.

Sounds good, thanks.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#29225: Tramp backup-by-copying in a Converting ACL Invalid argument error on Windows 7
  2017-11-10 15:13         ` Eli Zaretskii
@ 2017-11-12 13:21           ` Michael Albinus
  2018-01-17 10:05             ` Michael Albinus
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Albinus @ 2017-11-12 13:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: shuguang, 29225

Eli Zaretskii <eliz@gnu.org> writes:

> No objection, but please only condition the call to 'error' on
> acl_errno_valid.  I see no reason to proceed with calling acl_set_file
> if acl_from_text fails.

Done.

>> Maybe I'll find also the time next days, to add the missing tests
>> for file-acl and set-file-acl in tramp-tests.el.
>
> Sounds good, thanks.

Also done.

I've committed the patch to the emacs-26 branch. Shuguang, do you have a
chance to check this?

Best regards, Michael.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#29225: Tramp backup-by-copying in a Converting ACL Invalid argument error on Windows 7
  2017-11-12 13:21           ` Michael Albinus
@ 2018-01-17 10:05             ` Michael Albinus
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Albinus @ 2018-01-17 10:05 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 29225-done, shuguang

Version: 26.1

Michael Albinus <michael.albinus@gmx.de> writes:

> I've committed the patch to the emacs-26 branch. Shuguang, do you have a
> chance to check this?

No News Are Good News. I'm closing the bug.

Best regards, Michael.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-01-17 10:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-09  8:24 bug#29225: Tramp backup-by-copying in a Converting ACL Invalid argument error on Windows 7 Shuguang Sun
2017-11-09 17:18 ` Eli Zaretskii
2017-11-10 12:41   ` Michael Albinus
2017-11-10 13:06     ` Eli Zaretskii
2017-11-10 14:39       ` Michael Albinus
2017-11-10 15:13         ` Eli Zaretskii
2017-11-12 13:21           ` Michael Albinus
2018-01-17 10:05             ` Michael Albinus

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).