Russell Sim | 4 Jul 2012 23:50
Picon
Gravatar

Ownership change on save.

Hi,

At the moment when I save a remote file it always seems to change the
file permissions to the user I am accessing it as.  For example if I am
editing a file as root and the file is owned by a user, on save the file
will be owned as root.  At first I thought this was a config error and I
but I was able to reproduce it using emacs23 emacs24 and emacs24.1.50.1
with -Q.

The problem is file-attrs are being stored as floats so when it comes to
deciding if the ownership needs to be changed the eq comparison fails.
I have included a patch that changes these tests to eql operations which
support floating point number comparisons.

I also did some digging about the tramp-compat-file-attributes function
which is the source of the attribute data.  It seems that the function
file-attributes can will return floats or integers, even if the
id-format is set to integer.

Thanks,
Russell

diff -c -L /home/russell/tramp-sh.el -L \#\<buffer\ tramp-sh.el\> /home/russell/tramp-sh.el /tmp/buffer-content-11983s8z
*** /home/russell/tramp-sh.el
--- #<buffer tramp-sh.el>
***************
*** 3290,3297 ****
               ;; be different from (buffer-file-name), f.e. if
               ;; `file-precious-flag' is set.
               (nth 5 file-attr))
(Continue reading)

Michael Albinus | 5 Jul 2012 08:59
Picon
Picon
Gravatar

Re: Ownership change on save.

Russell Sim <russell.sim <at> gmail.com> writes:

> Hi,

Hi Russell,

> The problem is file-attrs are being stored as floats so when it comes to
> deciding if the ownership needs to be changed the eq comparison fails.
> I have included a patch that changes these tests to eql operations which
> support floating point number comparisons.

Thanks for the patch! I've applied it slightly modified (I prefer
explicit coding, therefore I've used `=' instead of `eql').

> Thanks,
> Russell

Best regards, Michael.

Gmane