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/w32.c | |
| 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/w32.c')
| -rw-r--r-- | src/w32.c | 27 |
1 files changed, 25 insertions, 2 deletions
| @@ -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 | ||