diff options
| author | Stephen Gildea | 2019-12-20 09:15:13 -0800 |
|---|---|---|
| committer | Stephen Gildea | 2019-12-21 10:51:10 -0800 |
| commit | 678a71ea2d044f19f75e3f45c930c5e3b707e3dc (patch) | |
| tree | e62c41f8970ff093717954d300f7176b8be2058c | |
| parent | 59ce7609cb383893ac55921589051993c388c6cc (diff) | |
| download | emacs-678a71ea2d044f19f75e3f45c930c5e3b707e3dc.tar.gz emacs-678a71ea2d044f19f75e3f45c930c5e3b707e3dc.zip | |
backup-by-copying-when-privileged-mismatch applies to file gid, too.
* lisp/files.el (backup-by-copying-when-privileged-mismatch): In addition
to checking the file uid, a second test is added: if the file gid is not
greater than backup-by-copying-when-privileged-mismatch,
backup-by-copying-when-mismatch will also be forced on.
* doc/emacs/files.texi, doc/lispref/backups.texi: Updated documentation.
Also fixed a typo in the Emacs reference manual, changing "higher" to
"no greater" so that the limit is no longer documented reversed.
| -rw-r--r-- | doc/emacs/files.texi | 5 | ||||
| -rw-r--r-- | doc/lispref/backups.texi | 6 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/files.el | 15 |
4 files changed, 20 insertions, 11 deletions
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 7221edcc1b2..f5dd408cc9f 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi | |||
| @@ -690,8 +690,9 @@ non-@code{nil} (the default is @code{t}), and renaming would change | |||
| 690 | the file's owner or group, use copying. | 690 | the file's owner or group, use copying. |
| 691 | 691 | ||
| 692 | If you change @code{backup-by-copying-when-mismatch} to @code{nil}, | 692 | If you change @code{backup-by-copying-when-mismatch} to @code{nil}, |
| 693 | Emacs checks the numeric user-id of the file's owner. If this is | 693 | Emacs checks the numeric user-id of the file's owner and the numeric |
| 694 | higher than @code{backup-by-copying-when-privileged-mismatch}, then it | 694 | group-id of the file's group. If either is |
| 695 | no greater than @code{backup-by-copying-when-privileged-mismatch}, then it | ||
| 695 | behaves as though @code{backup-by-copying-when-mismatch} is | 696 | behaves as though @code{backup-by-copying-when-mismatch} is |
| 696 | non-@code{nil} anyway. | 697 | non-@code{nil} anyway. |
| 697 | 698 | ||
diff --git a/doc/lispref/backups.texi b/doc/lispref/backups.texi index 6a5b6d1661d..c17d98eb190 100644 --- a/doc/lispref/backups.texi +++ b/doc/lispref/backups.texi | |||
| @@ -232,11 +232,11 @@ non-@code{nil}. | |||
| 232 | @defopt backup-by-copying-when-privileged-mismatch | 232 | @defopt backup-by-copying-when-privileged-mismatch |
| 233 | This variable, if non-@code{nil}, specifies the same behavior as | 233 | This variable, if non-@code{nil}, specifies the same behavior as |
| 234 | @code{backup-by-copying-when-mismatch}, but only for certain user-id | 234 | @code{backup-by-copying-when-mismatch}, but only for certain user-id |
| 235 | values: namely, those less than or equal to a certain number. You set | 235 | and group-id values: namely, those less than or equal to a certain number. |
| 236 | this variable to that number. | 236 | You set this variable to that number. |
| 237 | 237 | ||
| 238 | Thus, if you set @code{backup-by-copying-when-privileged-mismatch} | 238 | Thus, if you set @code{backup-by-copying-when-privileged-mismatch} |
| 239 | to 0, backup by copying is done for the superuser only, | 239 | to 0, backup by copying is done for the superuser and group 0 only, |
| 240 | when necessary to prevent a change in the owner of the file. | 240 | when necessary to prevent a change in the owner of the file. |
| 241 | 241 | ||
| 242 | The default is 200. | 242 | The default is 200. |
| @@ -533,6 +533,11 @@ The HIST argument of 'read-from-minibuffer' now works correctly with | |||
| 533 | buffer-local variables. This means that different buffers can have | 533 | buffer-local variables. This means that different buffers can have |
| 534 | their own separated input history list if desired. | 534 | their own separated input history list if desired. |
| 535 | 535 | ||
| 536 | ** 'backup-by-copying-when-privileged-mismatch' applies to file gid, too. | ||
| 537 | In addition to checking the file owner uid, Emacs also checks that the | ||
| 538 | group gid is not greater than backup-by-copying-when-privileged-mismatch; | ||
| 539 | if so, backup-by-copying-when-mismatch will be forced on. | ||
| 540 | |||
| 536 | 541 | ||
| 537 | * Editing Changes in Emacs 27.1 | 542 | * Editing Changes in Emacs 27.1 |
| 538 | 543 | ||
diff --git a/lisp/files.el b/lisp/files.el index a384e7136e8..96f1e8d47e7 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -134,10 +134,11 @@ This variable is relevant only if `backup-by-copying' is nil." | |||
| 134 | (defcustom backup-by-copying-when-privileged-mismatch 200 | 134 | (defcustom backup-by-copying-when-privileged-mismatch 200 |
| 135 | "Non-nil means create backups by copying to preserve a privileged owner. | 135 | "Non-nil means create backups by copying to preserve a privileged owner. |
| 136 | Renaming may still be used (subject to control of other variables) | 136 | Renaming may still be used (subject to control of other variables) |
| 137 | when it would not result in changing the owner of the file or if the owner | 137 | when it would not result in changing the owner of the file or if the |
| 138 | has a user id greater than the value of this variable. This is useful | 138 | user id and group id of the file are both greater than the value of |
| 139 | when low-numbered uid's are used for special system users (such as root) | 139 | this variable. This is useful when low-numbered uid's and gid's are |
| 140 | that must maintain ownership of certain files. | 140 | used for special system users (such as root) that must maintain |
| 141 | ownership of certain files. | ||
| 141 | This variable is relevant only if `backup-by-copying' and | 142 | This variable is relevant only if `backup-by-copying' and |
| 142 | `backup-by-copying-when-mismatch' are nil." | 143 | `backup-by-copying-when-mismatch' are nil." |
| 143 | :type '(choice (const nil) integer) | 144 | :type '(choice (const nil) integer) |
| @@ -4634,8 +4635,10 @@ BACKUPNAME is the backup file name, which is the old file renamed." | |||
| 4634 | (let ((attr (file-attributes | 4635 | (let ((attr (file-attributes |
| 4635 | real-file-name | 4636 | real-file-name |
| 4636 | 'integer))) | 4637 | 'integer))) |
| 4637 | (<= (file-attribute-user-id attr) | 4638 | (or (<= (file-attribute-user-id attr) |
| 4638 | copy-when-priv-mismatch)))) | 4639 | copy-when-priv-mismatch) |
| 4640 | (<= (file-attribute-group-id attr) | ||
| 4641 | copy-when-priv-mismatch))))) | ||
| 4639 | (not (file-ownership-preserved-p real-file-name | 4642 | (not (file-ownership-preserved-p real-file-name |
| 4640 | t))))) | 4643 | t))))) |
| 4641 | setmodes) | 4644 | setmodes) |