diff options
| author | Richard M. Stallman | 1999-09-08 07:37:56 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1999-09-08 07:37:56 +0000 |
| commit | 2cb28a6046084caa7d9e21d717b555f71b4c1a88 (patch) | |
| tree | 2c92b99e36e8ece78006765865cbcc061582263d | |
| parent | bb53e1ee9a9b8898dd3d49ecc53804ca79294398 (diff) | |
| download | emacs-2cb28a6046084caa7d9e21d717b555f71b4c1a88.tar.gz emacs-2cb28a6046084caa7d9e21d717b555f71b4c1a88.zip | |
(backup-by-copying-when-privileged-mismatch): New variable.
(backup-buffer): Use it.
| -rw-r--r-- | lisp/files.el | 30 |
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. | |||
| 84 | The file's owner and group are unchanged. | 84 | The file's owner and group are unchanged. |
| 85 | 85 | ||
| 86 | The choice of renaming or copying is controlled by the variables | 86 | The 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. | ||
| 126 | Renaming may still be used (subject to control of other variables) | ||
| 127 | when it would not result in changing the owner of the file or if the owner | ||
| 128 | has a user id greater than the value of this variable. This is useful | ||
| 129 | when low-numbered uid's are used for special system users (such as root) | ||
| 130 | that must maintain ownership of certain files. | ||
| 131 | This 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 |