unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#454: file-precious-flag overwrites symlinks
@ 2008-06-20 17:18 ` Max Mikhanosha
  2008-08-02 21:15   ` bug#454: marked as done (file-precious-flag overwrites symlinks) Emacs bug Tracking System
  0 siblings, 1 reply; 4+ messages in thread
From: Max Mikhanosha @ 2008-06-20 17:18 UTC (permalink / raw)
  To: bug-gnu-emacs


I keep my .emacs file under version control as part of overall
collection of config files, and as result ~/.emacs is a symbolic
link.

`backup-by-copying-when-linked' is set to t, so visiting ~/.emacs
and then editing and saving it correctly saves the file that
symlink is pointing too.

For a long time I was trying to track down why sometimes, my ~/.emacs
symbolic link is suddenly overwritten by the actual file.

Finally found that this happens when one uses "Save for future
session" in customize package, and farther tracked it down to a
behavior of `basic-save-buffer-2' when file-precious-flag is set.

Test case:

-rw-r--r-- 1 max users 4 Jun 20 12:57 file
lrwxrwxrwx 1 max users 4 Jun 20 12:58 link -> file

backup-by-copying-when-linked => t
file-precious-flag => nil

Visit "link" edit and save

-rw-r--r-- 1 max users 14 Jun 20 12:59 file
lrwxrwxrwx 1 max users  4 Jun 20 12:58 link -> file

Everything fine..

backup-by-copying-when-linked => t
file-precious-flag => t

Visit "link" edit and save

-rw-r--r-- 1 max users 14 Jun 20 12:59 file
-rw-r--r-- 1 max users 24 Jun 20 13:00 link

Overwrites symlink

The offending code in basic-save-buffer-2 is:
            ;; We succeeded in writing the temp file
            ;; so rename it.
            (rename-file tempname buffer-file-name t))

Above should refer to buffer-file-truename IMHO. The documentation for
file-precious-flag mentiones that it will break hardlinks, but does
not mention that it will break symlinks.

If this behavour is not a bug, then maybe its a bug for
custom-save-all to set file-precious-flag, causing an suprise
to the user as to why ~/.emacs symlink is getting overwritten.

In GNU Emacs 22.2.1 (x86_64-suse-linux-gnu, GTK+ Version 2.10.6)
 of 2008-04-09 on momoland
configured using `configure  '--with-gcc' '--with-pop' '--without-hesiod' '--with-kerberos' '--with-kerberos5' '--with-leim' '--with-xim' '--with-system-malloc' '--prefix=/usr' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--with-x' '--with-sound' '--with-xpm' '--with-jpeg' '--with-tiff' '--with-gif' '--with-png' '--with-x-toolkit=gtk' '--x-includes=/usr/include' '--x-libraries=/usr/lib64:/usr/share/X11' '--build=x86_64-suse-linux-gnu' 'build_alias=x86_64-suse-linux-gnu' 'CC=gcc' 'CFLAGS=-O2 -g -fmessage-length=0 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -std=gnu89 -pipe -fno-strict-aliasing -Wno-pointer-sign -Wno-unused-variable -Wno-unused-label -DSYSTEM_PURESIZE_EXTRA=55000 	 -DSITELOAD_PURESIZE_EXTRA=10000 ' 'L
 DFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: C
  locale-coding-system: nil
  default-enable-multibyte-characters: t

Major mode: Fundamental

Minor modes in effect:
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
C-x C-f C-g i i C-x C-f C-g C-x C-b * C-x o ESC O B 
RET ( s e t q SPC f i l e DEL DEL DEL DEL DEL DEL DEL 
DEL DEL DEL M-x - s e DEL DEL DEL s e t - v a r i TAB 
RET b a c k u p - b y - c o p TAB - TAB l TAB RET t 
RET C-x C-f l i n k RET o l a l DEL DEL DEL ESC [ 4 
~ ESC [ 4 ~ ESC O B b DEL s o m e SPC t e x t C-x C-x 
M-x s a v e - b u f DEL DEL DEL DEL TAB - b u f f e 
r RET M-x s e t - v a r i a b l e RET f i l e - p r 
e TAB RET t RET RET m o r e SPC t e x t M-x M-p M-p 
RET C-x b TAB ESC O B ESC O B M-x s u b m i t - b u 
TAB DEL DEL DEL DEL DEL DEL DEL DEL DEL r e p o r t 
- e m TAB RET

Recent messages:
exchange-point-and-mark: No mark set in this buffer
Making completion list...
Wrote /home/max/link [2 times]
Making completion list...
next-history-element: End of history; no next item
Quit
Loading emacsbug...
Loading regexp-opt...done
Loading emacsbug...done
call-interactively: Text is read-only







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

* bug#454: file-precious-flag overwrites symlinks
@ 2008-07-30 22:56 Chong Yidong
  2008-08-01  5:04 ` Max Mikhanosha
  0 siblings, 1 reply; 4+ messages in thread
From: Chong Yidong @ 2008-07-30 22:56 UTC (permalink / raw)
  To: Max Mikhanosha; +Cc: 454

> I keep my .emacs file under version control as part of overall
> collection of config files, and as result ~/.emacs is a symbolic
> link.
>
> `backup-by-copying-when-linked' is set to t, so visiting ~/.emacs
> and then editing and saving it correctly saves the file that
> symlink is pointing too.
>
> For a long time I was trying to track down why sometimes, my ~/.emacs
> symbolic link is suddenly overwritten by the actual file.
>
> Finally found that this happens when one uses "Save for future
> session" in customize package, and farther tracked it down to a
> behavior of `basic-save-buffer-2' when file-precious-flag is set.

Setting file-precious-flag to t in custom-save-all shouldn't be a
problem, because the custom file is visited using
find-file-visit-truename.  I tried to reproduce your problem, without
success:

$ touch foo
$ ln -s foo .emacs
$ emacs
  M-x customize-variable RET sentence-end-double-space RET
  [Click on Toggle]
  C-x C-s
  C-x C-c
$ ls -l foo .emacs

lrwxrwxrwx 1 cyd cyd   3 2008-07-30 18:54 .emacs -> foo
-rw-r--r-- 1 cyd cyd 528 2008-07-30 18:55 foo

Could you provide a recipe that shows this problem?






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

* bug#454: file-precious-flag overwrites symlinks
  2008-07-30 22:56 bug#454: file-precious-flag overwrites symlinks Chong Yidong
@ 2008-08-01  5:04 ` Max Mikhanosha
  0 siblings, 0 replies; 4+ messages in thread
From: Max Mikhanosha @ 2008-08-01  5:04 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 454

After playing with it for a little bit, I found that the additional
condition is to have ~/.emacs opened in the buffer, it does not matter
if its modified or not.

So updated steps to reproduce the problem are:

1. Setup ~/.emacs being symlink to real file
2. M-x set-variable backup-by-copying-when-linked to t (this step is not nessesary to reproduce, just to show that his does not fix it)
3. Make sure sure ~/.emacs is not opened in any buffer, customize a variable, and do "Save for future sessions"
4. It saves changes to where file is pointing
5. Now do C-x C-f ~/.emacs
6. Customize variable again, do "Save for future sessions", it now overwrites ~/.emacs link with real file

I can reproduce this with 22.2.1 and with latest emacs from CVS.

Regards,
  Max

At Wed, 30 Jul 2008 18:56:16 -0400,
Chong Yidong wrote:
> 
> > I keep my .emacs file under version control as part of overall
> > collection of config files, and as result ~/.emacs is a symbolic
> > link.
> >
> > `backup-by-copying-when-linked' is set to t, so visiting ~/.emacs
> > and then editing and saving it correctly saves the file that
> > symlink is pointing too.
> >
> > For a long time I was trying to track down why sometimes, my ~/.emacs
> > symbolic link is suddenly overwritten by the actual file.
> >
> > Finally found that this happens when one uses "Save for future
> > session" in customize package, and farther tracked it down to a
> > behavior of `basic-save-buffer-2' when file-precious-flag is set.
> 
> Setting file-precious-flag to t in custom-save-all shouldn't be a
> problem, because the custom file is visited using
> find-file-visit-truename.  I tried to reproduce your problem, without
> success:
> 
> $ touch foo
> $ ln -s foo .emacs
> $ emacs
>   M-x customize-variable RET sentence-end-double-space RET
>   [Click on Toggle]
>   C-x C-s
>   C-x C-c
> $ ls -l foo .emacs
> 
> lrwxrwxrwx 1 cyd cyd   3 2008-07-30 18:54 .emacs -> foo
> -rw-r--r-- 1 cyd cyd 528 2008-07-30 18:55 foo
> 
> Could you provide a recipe that shows this problem?






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

* bug#454: marked as done (file-precious-flag overwrites symlinks)
  2008-06-20 17:18 ` bug#454: file-precious-flag overwrites symlinks Max Mikhanosha
@ 2008-08-02 21:15   ` Emacs bug Tracking System
  0 siblings, 0 replies; 4+ messages in thread
From: Emacs bug Tracking System @ 2008-08-02 21:15 UTC (permalink / raw)
  To: Chong Yidong

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


Your message dated Sat, 02 Aug 2008 17:08:05 -0400
with message-id <87vdyj9lca.fsf@stupidchicken.com>
and subject line Re: file-precious-flag overwrites symlinks
has caused the Emacs bug report #454,
regarding file-precious-flag overwrites symlinks
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact don@donarmstrong.com
immediately.)


-- 
454: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=454
Emacs Bug Tracking System
Contact don@donarmstrong.com with problems

[-- Attachment #2: Type: message/rfc822, Size: 5960 bytes --]

From: Max Mikhanosha <max@openchat.com>
To: bug-gnu-emacs@gnu.org
Subject: file-precious-flag overwrites symlinks
Date: Fri, 20 Jun 2008 13:18:28 -0400 (EDT)
Message-ID: <20080620171828.4FC98F40D9C3@momoland.openchat.com>


I keep my .emacs file under version control as part of overall
collection of config files, and as result ~/.emacs is a symbolic
link.

`backup-by-copying-when-linked' is set to t, so visiting ~/.emacs
and then editing and saving it correctly saves the file that
symlink is pointing too.

For a long time I was trying to track down why sometimes, my ~/.emacs
symbolic link is suddenly overwritten by the actual file.

Finally found that this happens when one uses "Save for future
session" in customize package, and farther tracked it down to a
behavior of `basic-save-buffer-2' when file-precious-flag is set.

Test case:

-rw-r--r-- 1 max users 4 Jun 20 12:57 file
lrwxrwxrwx 1 max users 4 Jun 20 12:58 link -> file

backup-by-copying-when-linked => t
file-precious-flag => nil

Visit "link" edit and save

-rw-r--r-- 1 max users 14 Jun 20 12:59 file
lrwxrwxrwx 1 max users  4 Jun 20 12:58 link -> file

Everything fine..

backup-by-copying-when-linked => t
file-precious-flag => t

Visit "link" edit and save

-rw-r--r-- 1 max users 14 Jun 20 12:59 file
-rw-r--r-- 1 max users 24 Jun 20 13:00 link

Overwrites symlink

The offending code in basic-save-buffer-2 is:
            ;; We succeeded in writing the temp file
            ;; so rename it.
            (rename-file tempname buffer-file-name t))

Above should refer to buffer-file-truename IMHO. The documentation for
file-precious-flag mentiones that it will break hardlinks, but does
not mention that it will break symlinks.

If this behavour is not a bug, then maybe its a bug for
custom-save-all to set file-precious-flag, causing an suprise
to the user as to why ~/.emacs symlink is getting overwritten.

In GNU Emacs 22.2.1 (x86_64-suse-linux-gnu, GTK+ Version 2.10.6)
 of 2008-04-09 on momoland
configured using `configure  '--with-gcc' '--with-pop' '--without-hesiod' '--with-kerberos' '--with-kerberos5' '--with-leim' '--with-xim' '--with-system-malloc' '--prefix=/usr' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--with-x' '--with-sound' '--with-xpm' '--with-jpeg' '--with-tiff' '--with-gif' '--with-png' '--with-x-toolkit=gtk' '--x-includes=/usr/include' '--x-libraries=/usr/lib64:/usr/share/X11' '--build=x86_64-suse-linux-gnu' 'build_alias=x86_64-suse-linux-gnu' 'CC=gcc' 'CFLAGS=-O2 -g -fmessage-length=0 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -std=gnu89 -pipe -fno-strict-aliasing -Wno-pointer-sign -Wno-unused-variable -Wno-unused-label -DSYSTEM_PURESIZE_EXTRA=55000 	 -DSITELOAD_PURESIZE_EXTRA=10000 ' 'L
 DFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: C
  locale-coding-system: nil
  default-enable-multibyte-characters: t

Major mode: Fundamental

Minor modes in effect:
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
C-x C-f C-g i i C-x C-f C-g C-x C-b * C-x o ESC O B 
RET ( s e t q SPC f i l e DEL DEL DEL DEL DEL DEL DEL 
DEL DEL DEL M-x - s e DEL DEL DEL s e t - v a r i TAB 
RET b a c k u p - b y - c o p TAB - TAB l TAB RET t 
RET C-x C-f l i n k RET o l a l DEL DEL DEL ESC [ 4 
~ ESC [ 4 ~ ESC O B b DEL s o m e SPC t e x t C-x C-x 
M-x s a v e - b u f DEL DEL DEL DEL TAB - b u f f e 
r RET M-x s e t - v a r i a b l e RET f i l e - p r 
e TAB RET t RET RET m o r e SPC t e x t M-x M-p M-p 
RET C-x b TAB ESC O B ESC O B M-x s u b m i t - b u 
TAB DEL DEL DEL DEL DEL DEL DEL DEL DEL r e p o r t 
- e m TAB RET

Recent messages:
exchange-point-and-mark: No mark set in this buffer
Making completion list...
Wrote /home/max/link [2 times]
Making completion list...
next-history-element: End of history; no next item
Quit
Loading emacsbug...
Loading regexp-opt...done
Loading emacsbug...done
call-interactively: Text is read-only




[-- Attachment #3: Type: message/rfc822, Size: 1234 bytes --]

From: Chong Yidong <cyd@stupidchicken.com>
To: Max Mikhanosha <max@openchat.com>
Cc: 454-done@emacsbugs.donarmstrong.com
Subject: Re: file-precious-flag overwrites symlinks
Date: Sat, 02 Aug 2008 17:08:05 -0400
Message-ID: <87vdyj9lca.fsf@stupidchicken.com>

I see the bug now.

I've checked in a fix, thanks.


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

end of thread, other threads:[~2008-08-02 21:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <87vdyj9lca.fsf@stupidchicken.com>
2008-06-20 17:18 ` bug#454: file-precious-flag overwrites symlinks Max Mikhanosha
2008-08-02 21:15   ` bug#454: marked as done (file-precious-flag overwrites symlinks) Emacs bug Tracking System
2008-07-30 22:56 bug#454: file-precious-flag overwrites symlinks Chong Yidong
2008-08-01  5:04 ` Max Mikhanosha

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