aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2013-01-21 20:00:19 +0200
committerEli Zaretskii2013-01-21 20:00:19 +0200
commit84e5ed96b066fec76f81487d3a21729159ad721e (patch)
treec9127ccba82dde25cf9a5af59ed0e08255299e54 /src
parent2ef88fd45c8653fa3f175a3eb9c8e61088587a5e (diff)
downloademacs-84e5ed96b066fec76f81487d3a21729159ad721e.tar.gz
emacs-84e5ed96b066fec76f81487d3a21729159ad721e.zip
Another minor fix in acl_set_file on Windows.
src/w32.c (acl_set_file): Don't test for errors unless set_file_security returns FALSE. Avoids spurious errors when saving files.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/w32.c80
2 files changed, 49 insertions, 37 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 658febcd21c..ca37bb3ea56 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12013-01-21 Eli Zaretskii <eliz@gnu.org>
2
3 * w32.c (acl_set_file): Don't test for errors unless
4 set_file_security returns FALSE. Avoids spurious errors when
5 saving files.
6
12013-01-21 Dmitry Antipov <dmantipov@yandex.ru> 72013-01-21 Dmitry Antipov <dmantipov@yandex.ru>
2 8
3 * fileio.c (Finsert_file_contents): Revert code introduced at 9 * fileio.c (Finsert_file_contents): Revert code introduced at
diff --git a/src/w32.c b/src/w32.c
index be58dc5cd53..d014609076e 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -4868,51 +4868,57 @@ acl_set_file (const char *fname, acl_type_t type, acl_t acl)
4868 4868
4869 e = errno; 4869 e = errno;
4870 errno = 0; 4870 errno = 0;
4871 set_file_security ((char *)fname, flags, (PSECURITY_DESCRIPTOR)acl); 4871 if (!set_file_security ((char *)fname, flags, (PSECURITY_DESCRIPTOR)acl))
4872 err = GetLastError ();
4873 if (st)
4874 { 4872 {
4875 if (st >= 2) 4873 err = GetLastError ();
4876 restore_privilege (&old2);
4877 restore_privilege (&old1);
4878 revert_to_self ();
4879 }
4880
4881 if (errno == ENOTSUP)
4882 ;
4883 else if (err == ERROR_SUCCESS)
4884 {
4885 retval = 0;
4886 errno = e;
4887 }
4888 else if (err == ERROR_INVALID_OWNER || err == ERROR_NOT_ALL_ASSIGNED
4889 || err == ERROR_ACCESS_DENIED)
4890 {
4891 /* Maybe the requested ACL and the one the file already has are
4892 identical, in which case we can silently ignore the
4893 failure. (And no, Windows doesn't.) */
4894 acl_t current_acl = acl_get_file (fname, ACL_TYPE_ACCESS);
4895 4874
4896 errno = EPERM; 4875 if (errno == ENOTSUP)
4897 if (current_acl) 4876 ;
4877 else if (err == ERROR_INVALID_OWNER
4878 || err == ERROR_NOT_ALL_ASSIGNED
4879 || err == ERROR_ACCESS_DENIED)
4898 { 4880 {
4899 char *acl_from = acl_to_text (current_acl, NULL); 4881 /* Maybe the requested ACL and the one the file already has
4900 char *acl_to = acl_to_text (acl, NULL); 4882 are 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);
4901 4885
4902 if (acl_from && acl_to && xstrcasecmp (acl_from, acl_to) == 0) 4886 errno = EPERM;
4887 if (current_acl)
4903 { 4888 {
4904 retval = 0; 4889 char *acl_from = acl_to_text (current_acl, NULL);
4905 errno = e; 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);
4906 } 4902 }
4907 if (acl_from)
4908 acl_free (acl_from);
4909 if (acl_to)
4910 acl_free (acl_to);
4911 acl_free (current_acl);
4912 } 4903 }
4904 else if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND)
4905 errno = ENOENT;
4906 else
4907 errno = EACCES;
4908 }
4909 else
4910 {
4911 retval = 0;
4912 errno = e;
4913 }
4914
4915 if (st)
4916 {
4917 if (st >= 2)
4918 restore_privilege (&old2);
4919 restore_privilege (&old1);
4920 revert_to_self ();
4913 } 4921 }
4914 else if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND)
4915 errno = ENOENT;
4916 4922
4917 return retval; 4923 return retval;
4918} 4924}