unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Change in backup-buffer: how to interpret?
@ 2002-12-30 20:53 Kai Großjohann
  2002-12-30 20:58 ` Kai Großjohann
  2003-01-01 16:46 ` Richard Stallman
  0 siblings, 2 replies; 3+ messages in thread
From: Kai Großjohann @ 2002-12-30 20:53 UTC (permalink / raw)
  Cc: Michael.Albinus

Between Emacs 21.2.93 and the current CVS, I see the following change
in backup-buffer.  (Actually, more stuff has changed.)

@@ -2147,13 +2356,17 @@
 (defun backup-buffer ()
   "Make a backup of the disk file visited by the current buffer, if appropriate.
 This is normally done before saving the buffer the first time.
-If the value is non-nil, it is the result of `file-modes' on the original
-file; this means that the caller, after saving the buffer, should change
-the modes of the new file to agree with the old modes.
 
 A backup may be done by renaming or by copying; see documentation of
 variable `make-backup-files'.  If it's done by renaming, then the file is
-no longer accessible under its old name."
+no longer accessible under its old name.
+
+The value is non-nil after a backup was made by renaming.
+It has the form (MODES . BACKUPNAME).
+MODES is the result of `file-modes' on the original
+file; this means that the caller, after saving the buffer, should change
+the modes of the new file to agree with the old modes.
+BACKUPNAME is the backup file name, which is the old file renamed."
   (if (and make-backup-files (not backup-inhibited)
 	   (not buffer-backed-up)
 	   (file-exists-p buffer-file-name)
@@ -2179,12 +2392,15 @@
 			    (or (eq delete-old-versions t) (eq delete-old-versions nil))
 			    (or delete-old-versions
 				(y-or-n-p (format "Delete excess backup versions of %s? "
-						  real-file-name))))))
+						  real-file-name)))))
+		      (modes (file-modes buffer-file-name)))
 		  ;; Actually write the back up file.
 		  (condition-case ()
 		      (if (or file-precious-flag
     ;			      (file-symlink-p buffer-file-name)
 			      backup-by-copying
+			      ;; Don't rename a suid or sgid file.
+			      (< 0 (logand modes #o6000))
 			      (and backup-by-copying-when-linked
 				   (> (file-nlinks real-file-name) 1))
 			      (and (or backup-by-copying-when-mismatch


As you can see, `modes' is the result of (file-modes
buffer-file-name), and later on (logand modes #o6000) is then
invoked.

I think that file-modes can return nil.  (Ange-FTP always returns
nil.)  Then the logand will fail.

So is it a bug in the current code (which should deal with a nil
return value of file-modes), or is it a bug in Ange-FTP (which
returns nil)?
-- 
Ambibibentists unite!

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

* Re: Change in backup-buffer: how to interpret?
  2002-12-30 20:53 Change in backup-buffer: how to interpret? Kai Großjohann
@ 2002-12-30 20:58 ` Kai Großjohann
  2003-01-01 16:46 ` Richard Stallman
  1 sibling, 0 replies; 3+ messages in thread
From: Kai Großjohann @ 2002-12-30 20:58 UTC (permalink / raw)


kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:

> So is it a bug in the current code (which should deal with a nil
> return value of file-modes), or is it a bug in Ange-FTP (which
> returns nil)?

I think it would be a good idea to augment the documentation for
filename handlers.  Each operation should say what a filename handler
should do when it doesn't know.

Eg, I think that file-attributes is supposed to return -1 as a
don't-know value for uid and gid, and (0 0) as a don't-know value for
access, modification, and status change time.  But maybe I'm wrong --
that's even more of a reason for documentation ;-)
-- 
Ambibibentists unite!

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

* Re: Change in backup-buffer: how to interpret?
  2002-12-30 20:53 Change in backup-buffer: how to interpret? Kai Großjohann
  2002-12-30 20:58 ` Kai Großjohann
@ 2003-01-01 16:46 ` Richard Stallman
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Stallman @ 2003-01-01 16:46 UTC (permalink / raw)
  Cc: emacs-devel

    I think that file-modes can return nil.  (Ange-FTP always returns
    nil.)  Then the logand will fail.

    So is it a bug in the current code (which should deal with a nil
    return value of file-modes), or is it a bug in Ange-FTP (which
    returns nil)?

It's a bug in my change.  Thanks for reporting it--I will fix it.

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

end of thread, other threads:[~2003-01-01 16:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-30 20:53 Change in backup-buffer: how to interpret? Kai Großjohann
2002-12-30 20:58 ` Kai Großjohann
2003-01-01 16:46 ` Richard Stallman

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