aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32.c
diff options
context:
space:
mode:
authorEli Zaretskii2012-12-23 19:16:33 +0200
committerEli Zaretskii2012-12-23 19:16:33 +0200
commit40ff07a5a0ce6c3bdff8a86d4161bfd1ca25f651 (patch)
treeac9feb49b75baacf6203290afa717243b7a6ec60 /src/w32.c
parent299614f3bcac13be9a17d038f247856e384d9dbd (diff)
downloademacs-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.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/w32.c b/src/w32.c
index 47b950668b0..9ebc97088d0 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -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