Subject: Re: bug#22795: 25.0.91; Can't write read only file on w32

From: "Ota, Takaaki" <[email-masked]>
Date: Tue, 7 Jun 2016 16:02:38 -0700

I changed the ownership of the home directory.  Then performed the
next test.  Does this tell you anything?

(user-uid)
1001

;; I manually deleted ~/memo~ before this test

(file-attributes "~/memo" 'integer)
(nil 1 1001 513 (22359 18939 0 0) (22359 18939 0 0) (20624 9296 0 0) 289738 "-r--r--r--" t (1536 1 . 32777) (50396 . 34426))

;; Find the file, perform read-only-mode and then save it - the save succeed.

(file-attributes "~/memo~" 'integer)
(nil 1 1001 513 (22359 18939 0 0) (22359 18939 0 0) (20624 9296 0 0) 289738 "-r--r--r--" t (1536 1 . 32777) (50396 . 34426))

(file-attributes "~/memo" 'integer)
(nil 1 1001 513 (22359 20386 0 0) (22359 20386 0 0) (20624 9296 0 0) 289738 "-r--r--r--" t (16128 10 . 5242) (50396 . 34426))

;; close the file
;; Find the file, perform read-only-mode and then try to save again - the save fails by error "Cannot write backup file ..." "Removing old name: Permission denied ..."
;; And now

(file-attributes "~/memo~" 'integer)
(nil 1 1001 513 (22359 18939 0 0) (22359 18939 0 0) (20624 9296 0 0) 289738 "-r--r--r--" t (1536 1 . 32777) (50396 . 34426))

(file-attributes "~/memo" 'integer)
(nil 1 1001 513 (22359 20386 0 0) (22359 20386 0 0) (20624 9296 0 0) 289738 "-r--r--r--" t (16128 10 . 5242) (50396 . 34426))

(file-attributes "~/.emacs.d/%backup%~" 'integer)
(nil 1 1001 513 (20624 4722 0 0) (22359 18939 0 0) (20624 4722 0 0) 289738 "-r--r--r--" t (256 3 . 42744) (50396 . 34426))

-Tak

Tue, 7 Jun 2016 05:42:52 +0300: Eli Zaretskii <[email-masked]> wrote:

> > Date: Mon, 6 Jun 2016 13:46:32 -0700
> > CC: <[email-masked]>
> > From: "Ota, Takaaki" <[email-masked]>
> > 
> > Mon, 6 Jun 2016 22:10:29 +0300: Eli Zaretskii <[email-masked]> wrote:
> > 
> > > > Date: Mon, 6 Jun 2016 09:24:23 -0700
> > > > CC: <[email-masked]>
> > > > From: "Ota, Takaaki" <[email-masked]>
> > > > 
> > > > After opening a read only file, execute read-only-mode, modify the
> > > > file and try to save the file under emacs 25.0.94 on Linux and Windows
> > > > file-ownership-preserved-p returns non nil value on Linux and nil on
> > > > Windows.
> > > 
> > > What does (file-attributes FILENAME 'integer) return for that file?
> > > And what does (user-uid) return?
> > 
> > On Linux
> > 
> > (file-attributes "~/memo" 'integer)
> > (nil 1 1000 1000 (22351 8780 403703 908000) (22351 6556 219830 864000) (22351 6556 223830 864000) 1827 "-r--r--r--" t 131312 2049)
> > (user-uid)
> > 1000
> > 
> > On Windows (both 24.5 and 25.0.94)
> > 
> > (file-attributes "~/memo" 'integer)
> > (nil 1 544 513 (21821 905 0 0) (22357 41339 0 0) (20624 9296 0 0) 289738 "-r--r--r--" t (1024 1 . 32777) (50396 . 34426))
> > (user-uid)
> > 1001
> 
> This may be part of the problem: your home directory is not owned by
> your user, it is owned by the Administrators group.  That is
> definitely why file-ownership-preserved-p returns nil in your case,
> but it can also be part of the larger problem we are investigating.
> (On my machines, I always take ownership of the home directory and all
> of its subdirectories, recursively, to avoid any ownership issues.)
>