diff options
| author | Eli Zaretskii | 2012-12-29 16:32:36 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2012-12-29 16:32:36 +0200 |
| commit | ccad023bc3c70fc8368c00f7ed2f5ec947a4260d (patch) | |
| tree | c6471cecd468c61a1a81860215f731e265721a88 | |
| parent | ccb1c17e8bf1aa0d21bddd9fa37154a120657f52 (diff) | |
| download | emacs-ccad023bc3c70fc8368c00f7ed2f5ec947a4260d.tar.gz emacs-ccad023bc3c70fc8368c00f7ed2f5ec947a4260d.zip | |
Fix bug #13298 with failed backups by falling back on set-file-modes.
src/fileio.c (Fset_file_selinux_context, Fset_file_acl): Return t if
file's SELinux context or ACLs successfully set, nil otherwise.
lisp/files.el (backup-buffer-copy, basic-save-buffer-2): If
set-file-extended-attributes fails, fall back on set-file-modes
instead of signaling an error.
doc/lispref/files.texi (Changing Files): Document the return values of
set-file-selinux-context and set-file-acl.
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/files.texi | 12 | ||||
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/files.el | 20 | ||||
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/fileio.c | 10 |
6 files changed, 45 insertions, 12 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 7893424a942..b2f89024726 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-12-29 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * files.texi (Changing Files): Document the return values of | ||
| 4 | set-file-selinux-context and set-file-acl. | ||
| 5 | |||
| 1 | 2012-12-27 Glenn Morris <rgm@gnu.org> | 6 | 2012-12-27 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * files.texi (File Names): Mention Cygwin conversion functions. | 8 | * files.texi (File Names): Mention Cygwin conversion functions. |
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 3faa5f5e257..4317fe42523 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi | |||
| @@ -1703,9 +1703,11 @@ This function sets the SELinux security context of the file | |||
| 1703 | @var{filename} to @var{context}. @xref{File Attributes}, for a brief | 1703 | @var{filename} to @var{context}. @xref{File Attributes}, for a brief |
| 1704 | description of SELinux contexts. The @var{context} argument should be | 1704 | description of SELinux contexts. The @var{context} argument should be |
| 1705 | a list @code{(@var{user} @var{role} @var{type} @var{range})}, like the | 1705 | a list @code{(@var{user} @var{role} @var{type} @var{range})}, like the |
| 1706 | return value of @code{file-selinux-context}. The function does | 1706 | return value of @code{file-selinux-context}. The function returns |
| 1707 | nothing if SELinux is disabled, or if Emacs was compiled without | 1707 | @code{t} if it succeeds to set the SELinux security context of |
| 1708 | SELinux support. | 1708 | @var{filename}, @code{nil} otherwise. The function does nothing and |
| 1709 | returns @code{nil} if SELinux is disabled, or if Emacs was compiled | ||
| 1710 | without SELinux support. | ||
| 1709 | @end defun | 1711 | @end defun |
| 1710 | 1712 | ||
| 1711 | @defun set-file-acl filename acl-string | 1713 | @defun set-file-acl filename acl-string |
| @@ -1713,7 +1715,9 @@ This function sets the ACL entries of the file @var{filename} to | |||
| 1713 | @var{acl-string}. @xref{File Attributes}, for a brief description of | 1715 | @var{acl-string}. @xref{File Attributes}, for a brief description of |
| 1714 | ACLs. The @var{acl-string} argument should be a string containing the | 1716 | ACLs. The @var{acl-string} argument should be a string containing the |
| 1715 | textual representation of the desired ACL entries as returned by | 1717 | textual representation of the desired ACL entries as returned by |
| 1716 | @code{file-acl} (@pxref{File Attributes, file-acl}). | 1718 | @code{file-acl} (@pxref{File Attributes, file-acl}). The function |
| 1719 | returns @code{t} if it succeeds to set the ACL entries of | ||
| 1720 | @var{filename}, @code{nil} otherwise. | ||
| 1717 | @end defun | 1721 | @end defun |
| 1718 | 1722 | ||
| 1719 | @node File Names | 1723 | @node File Names |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b79d174d35e..0beb4a73185 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-12-29 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * files.el (backup-buffer-copy, basic-save-buffer-2): If | ||
| 4 | set-file-extended-attributes fails, fall back on set-file-modes | ||
| 5 | instead of signaling an error. (Bug#13298) | ||
| 6 | |||
| 1 | 2012-12-29 Fabián Ezequiel Gallina <fgallina@cuca> | 7 | 2012-12-29 Fabián Ezequiel Gallina <fgallina@cuca> |
| 2 | 8 | ||
| 3 | * progmodes/python.el: Support other commands triggering | 9 | * progmodes/python.el: Support other commands triggering |
diff --git a/lisp/files.el b/lisp/files.el index f076530fbc8..fb82d0dbe1f 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -4019,10 +4019,12 @@ BACKUPNAME is the backup file name, which is the old file renamed." | |||
| 4019 | nil))) | 4019 | nil))) |
| 4020 | ;; Reset the umask. | 4020 | ;; Reset the umask. |
| 4021 | (set-default-file-modes umask))) | 4021 | (set-default-file-modes umask))) |
| 4022 | (and modes | 4022 | ;; If set-file-extended-attributes fails, fall back on set-file-modes. |
| 4023 | (set-file-modes to-name (logand modes #o1777))) | 4023 | (unless (and extended-attributes |
| 4024 | (and extended-attributes | 4024 | (with-demoted-errors |
| 4025 | (set-file-extended-attributes to-name extended-attributes))) | 4025 | (set-file-extended-attributes to-name extended-attributes))) |
| 4026 | (and modes | ||
| 4027 | (set-file-modes to-name (logand modes #o1777))))) | ||
| 4026 | 4028 | ||
| 4027 | (defvar file-name-version-regexp | 4029 | (defvar file-name-version-regexp |
| 4028 | "\\(?:~\\|\\.~[-[:alnum:]:#@^._]+\\(?:~[[:digit:]]+\\)?~\\)" | 4030 | "\\(?:~\\|\\.~[-[:alnum:]:#@^._]+\\(?:~[[:digit:]]+\\)?~\\)" |
| @@ -4737,8 +4739,14 @@ Before and after saving the buffer, this function runs | |||
| 4737 | (setq setmodes (list (file-modes buffer-file-name) | 4739 | (setq setmodes (list (file-modes buffer-file-name) |
| 4738 | (file-extended-attributes buffer-file-name) | 4740 | (file-extended-attributes buffer-file-name) |
| 4739 | buffer-file-name)) | 4741 | buffer-file-name)) |
| 4740 | (set-file-modes buffer-file-name (logior (car setmodes) 128)) | 4742 | ;; If set-file-extended-attributes fails, fall back on |
| 4741 | (set-file-extended-attributes buffer-file-name (nth 1 setmodes))))) | 4743 | ;; set-file-modes. |
| 4744 | (unless | ||
| 4745 | (with-demoted-errors | ||
| 4746 | (set-file-extended-attributes buffer-file-name | ||
| 4747 | (nth 1 setmodes))) | ||
| 4748 | (set-file-modes buffer-file-name | ||
| 4749 | (logior (car setmodes) 128)))))) | ||
| 4742 | (let (success) | 4750 | (let (success) |
| 4743 | (unwind-protect | 4751 | (unwind-protect |
| 4744 | (progn | 4752 | (progn |
diff --git a/src/ChangeLog b/src/ChangeLog index 76f6865972c..f40f936d13a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2012-12-29 Eli Zaretskii <eliz@gnu.org> | 1 | 2012-12-29 Eli Zaretskii <eliz@gnu.org> |
| 2 | 2 | ||
| 3 | * fileio.c (Fset_file_selinux_context, Fset_file_acl): Return t if | ||
| 4 | file's SELinux context or ACLs successfully set, nil otherwise. | ||
| 5 | (Bug#13298) | ||
| 6 | |||
| 3 | * w32proc.c (reader_thread): Avoid passing NULL handles to | 7 | * w32proc.c (reader_thread): Avoid passing NULL handles to |
| 4 | SetEvent and WaitForSingleObject. | 8 | SetEvent and WaitForSingleObject. |
| 5 | 9 | ||
diff --git a/src/fileio.c b/src/fileio.c index 9f70c790592..e824a7abcc5 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2996,8 +2996,10 @@ DEFUN ("set-file-selinux-context", Fset_file_selinux_context, | |||
| 2996 | CONTEXT should be a list (USER ROLE TYPE RANGE), where the list | 2996 | CONTEXT should be a list (USER ROLE TYPE RANGE), where the list |
| 2997 | elements are strings naming the components of a SELinux context. | 2997 | elements are strings naming the components of a SELinux context. |
| 2998 | 2998 | ||
| 2999 | This function does nothing if SELinux is disabled, or if Emacs was not | 2999 | Value is t if setting of SELinux context was successful, nil otherwise. |
| 3000 | compiled with SELinux support. */) | 3000 | |
| 3001 | This function does nothing and returns nil if SELinux is disabled, | ||
| 3002 | or if Emacs was not compiled with SELinux support. */) | ||
| 3001 | (Lisp_Object filename, Lisp_Object context) | 3003 | (Lisp_Object filename, Lisp_Object context) |
| 3002 | { | 3004 | { |
| 3003 | Lisp_Object absname; | 3005 | Lisp_Object absname; |
| @@ -3063,6 +3065,7 @@ compiled with SELinux support. */) | |||
| 3063 | 3065 | ||
| 3064 | context_free (parsed_con); | 3066 | context_free (parsed_con); |
| 3065 | freecon (con); | 3067 | freecon (con); |
| 3068 | return Qt; | ||
| 3066 | } | 3069 | } |
| 3067 | else | 3070 | else |
| 3068 | report_file_error ("Doing lgetfilecon", Fcons (absname, Qnil)); | 3071 | report_file_error ("Doing lgetfilecon", Fcons (absname, Qnil)); |
| @@ -3127,6 +3130,8 @@ DEFUN ("set-file-acl", Fset_file_acl, Sset_file_acl, | |||
| 3127 | ACL-STRING should contain the textual representation of the ACL | 3130 | ACL-STRING should contain the textual representation of the ACL |
| 3128 | entries in a format suitable for the platform. | 3131 | entries in a format suitable for the platform. |
| 3129 | 3132 | ||
| 3133 | Value is t if setting of ACL was successful, nil otherwise. | ||
| 3134 | |||
| 3130 | Setting ACL for local files requires Emacs to be built with ACL | 3135 | Setting ACL for local files requires Emacs to be built with ACL |
| 3131 | support. */) | 3136 | support. */) |
| 3132 | (Lisp_Object filename, Lisp_Object acl_string) | 3137 | (Lisp_Object filename, Lisp_Object acl_string) |
| @@ -3166,6 +3171,7 @@ support. */) | |||
| 3166 | report_file_error ("Setting ACL", Fcons (absname, Qnil)); | 3171 | report_file_error ("Setting ACL", Fcons (absname, Qnil)); |
| 3167 | 3172 | ||
| 3168 | acl_free (acl); | 3173 | acl_free (acl); |
| 3174 | return Qt; | ||
| 3169 | } | 3175 | } |
| 3170 | #endif | 3176 | #endif |
| 3171 | 3177 | ||