aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1999-09-08 07:37:56 +0000
committerRichard M. Stallman1999-09-08 07:37:56 +0000
commit2cb28a6046084caa7d9e21d717b555f71b4c1a88 (patch)
tree2c92b99e36e8ece78006765865cbcc061582263d
parentbb53e1ee9a9b8898dd3d49ecc53804ca79294398 (diff)
downloademacs-2cb28a6046084caa7d9e21d717b555f71b4c1a88.tar.gz
emacs-2cb28a6046084caa7d9e21d717b555f71b4c1a88.zip
(backup-by-copying-when-privileged-mismatch): New variable.
(backup-buffer): Use it.
-rw-r--r--lisp/files.el30
1 files changed, 24 insertions, 6 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 17a9e78c7df..272c901432f 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -84,8 +84,9 @@ names that the old file had will now refer to the new (edited) file.
84The file's owner and group are unchanged. 84The file's owner and group are unchanged.
85 85
86The choice of renaming or copying is controlled by the variables 86The choice of renaming or copying is controlled by the variables
87`backup-by-copying', `backup-by-copying-when-linked' and 87`backup-by-copying', `backup-by-copying-when-linked',
88`backup-by-copying-when-mismatch'. See also `backup-inhibited'." 88`backup-by-copying-when-mismatch' and
89`backup-by-copying-when-privileged-mismatch'. See also `backup-inhibited'."
89 :type 'boolean 90 :type 'boolean
90 :group 'backup) 91 :group 'backup)
91 92
@@ -120,6 +121,18 @@ This variable is relevant only if `backup-by-copying' is nil."
120 :type 'boolean 121 :type 'boolean
121 :group 'backup) 122 :group 'backup)
122 123
124(defcustom backup-by-copying-when-privileged-mismatch 200
125 "*Non-nil means create backups by copying to preserve a privileged owner.
126Renaming may still be used (subject to control of other variables)
127when it would not result in changing the owner of the file or if the owner
128has a user id greater than the value of this variable. This is useful
129when low-numbered uid's are used for special system users (such as root)
130that must maintain ownership of certain files.
131This variable is relevant only if `backup-by-copying' and
132`backup-by-copying-when-mismatch' are nil."
133 :type '(choice (const nil) integer)
134 :group 'backup)
135
123(defvar backup-enable-predicate 136(defvar backup-enable-predicate
124 '(lambda (name) 137 '(lambda (name)
125 (or (< (length name) 5) 138 (or (< (length name) 5)
@@ -2010,14 +2023,19 @@ no longer accessible under its old name."
2010 ;; Actually write the back up file. 2023 ;; Actually write the back up file.
2011 (condition-case () 2024 (condition-case ()
2012 (if (or file-precious-flag 2025 (if (or file-precious-flag
2013 ; (file-symlink-p buffer-file-name) 2026 ; (file-symlink-p buffer-file-name)
2014 backup-by-copying 2027 backup-by-copying
2015 (and backup-by-copying-when-linked 2028 (and backup-by-copying-when-linked
2016 (> (file-nlinks real-file-name) 1)) 2029 (> (file-nlinks real-file-name) 1))
2017 (and backup-by-copying-when-mismatch 2030 (and (or backup-by-copying-when-mismatch
2031 (integerp backup-by-copying-when-privileged-mismatch))
2018 (let ((attr (file-attributes real-file-name))) 2032 (let ((attr (file-attributes real-file-name)))
2019 (or (nth 9 attr) 2033 (and (or backup-by-copying-when-mismatch
2020 (not (file-ownership-preserved-p real-file-name)))))) 2034 (and (integerp (nth 2 attr))
2035 (integerp backup-by-copying-when-privileged-mismatch)
2036 (<= (nth 2 attr) backup-by-copying-when-privileged-mismatch)))
2037 (or (nth 9 attr)
2038 (not (file-ownership-preserved-p real-file-name)))))))
2021 (condition-case () 2039 (condition-case ()
2022 (copy-file real-file-name backupname t t) 2040 (copy-file real-file-name backupname t t)
2023 (file-error 2041 (file-error