unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: kai.grossjohann@uni-duisburg.de (Kai Großjohann)
Cc: Michael.Albinus@alcatel.de
Subject: Change in backup-buffer: how to interpret?
Date: Mon, 30 Dec 2002 21:53:13 +0100	[thread overview]
Message-ID: <84znqnqldy.fsf@lucy.cs.uni-dortmund.de> (raw)

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!

             reply	other threads:[~2002-12-30 20:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-30 20:53 Kai Großjohann [this message]
2002-12-30 20:58 ` Change in backup-buffer: how to interpret? Kai Großjohann
2003-01-01 16:46 ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84znqnqldy.fsf@lucy.cs.uni-dortmund.de \
    --to=kai.grossjohann@uni-duisburg.de \
    --cc=Michael.Albinus@alcatel.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).