diff options
| author | Eli Zaretskii | 2012-12-23 19:16:33 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2012-12-23 19:16:33 +0200 |
| commit | 40ff07a5a0ce6c3bdff8a86d4161bfd1ca25f651 (patch) | |
| tree | ac9feb49b75baacf6203290afa717243b7a6ec60 /src | |
| parent | 299614f3bcac13be9a17d038f247856e384d9dbd (diff) | |
| download | emacs-40ff07a5a0ce6c3bdff8a86d4161bfd1ca25f651.tar.gz emacs-40ff07a5a0ce6c3bdff8a86d4161bfd1ca25f651.zip | |
Don't fail in acl_set_file on MS-Windows if the operation is a no-op.
src/w32.c (acl_set_file): If setting the file security descriptor
fails, and the new DACL is identical to the existing one, silently
return success. This fixes problems for users backing up their
own files without having the necessary privileges for setting
security descriptors.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/w32.c | 27 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index c7502104ddf..648f14a61e4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2012-12-23 Eli Zaretskii <eliz@gnu.org> | 1 | 2012-12-23 Eli Zaretskii <eliz@gnu.org> |
| 2 | 2 | ||
| 3 | * w32.c (acl_set_file): If setting the file security descriptor | ||
| 4 | fails, and the new DACL is identical to the existing one, silently | ||
| 5 | return success. This fixes problems for users backing up their | ||
| 6 | own files without having the necessary privileges for setting | ||
| 7 | security descriptors. | ||
| 8 | |||
| 3 | * w32proc.c (reader_thread): Do not index fd_info[] with negative | 9 | * w32proc.c (reader_thread): Do not index fd_info[] with negative |
| 4 | values. | 10 | values. |
| 5 | (reader_thread): Exit when cp->status becomes STATUS_READ_ERROR | 11 | (reader_thread): Exit when cp->status becomes STATUS_READ_ERROR |
| @@ -4876,8 +4876,31 @@ acl_set_file (const char *fname, acl_type_t type, acl_t acl) | |||
| 4876 | retval = 0; | 4876 | retval = 0; |
| 4877 | errno = e; | 4877 | errno = e; |
| 4878 | } | 4878 | } |
| 4879 | else if (err == ERROR_INVALID_OWNER) | 4879 | else if (err == ERROR_INVALID_OWNER || err == ERROR_NOT_ALL_ASSIGNED) |
| 4880 | errno = EPERM; | 4880 | { |
| 4881 | /* Maybe the requested ACL and the one the file already has are | ||
| 4882 | identical, in which case we can silently ignore the | ||
| 4883 | failure. (And no, Windows doesn't.) */ | ||
| 4884 | acl_t current_acl = acl_get_file (fname, ACL_TYPE_ACCESS); | ||
| 4885 | |||
| 4886 | errno = EPERM; | ||
| 4887 | if (current_acl) | ||
| 4888 | { | ||
| 4889 | char *acl_from = acl_to_text (current_acl, NULL); | ||
| 4890 | char *acl_to = acl_to_text (acl, NULL); | ||
| 4891 | |||
| 4892 | if (acl_from && acl_to && xstrcasecmp (acl_from, acl_to) == 0) | ||
| 4893 | { | ||
| 4894 | retval = 0; | ||
| 4895 | errno = e; | ||
| 4896 | } | ||
| 4897 | if (acl_from) | ||
| 4898 | acl_free (acl_from); | ||
| 4899 | if (acl_to) | ||
| 4900 | acl_free (acl_to); | ||
| 4901 | acl_free (current_acl); | ||
| 4902 | } | ||
| 4903 | } | ||
| 4881 | else if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND) | 4904 | else if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND) |
| 4882 | errno = ENOENT; | 4905 | errno = ENOENT; |
| 4883 | 4906 | ||