diff options
| author | Joakim Verona | 2013-01-22 00:03:23 +0100 |
|---|---|---|
| committer | Joakim Verona | 2013-01-22 00:03:23 +0100 |
| commit | 2adf26f58a2435bcbd7f925f7e1208ceda907520 (patch) | |
| tree | c010555fabe45beeb3028cb03a64c53abae093a5 /src/w32.c | |
| parent | 9054ae6b57b275be298a919a3aed506f950409b6 (diff) | |
| parent | bb677ef7449aba3c2d5d7ede8cc4b87814f01ab3 (diff) | |
| download | emacs-2adf26f58a2435bcbd7f925f7e1208ceda907520.tar.gz emacs-2adf26f58a2435bcbd7f925f7e1208ceda907520.zip | |
auto upstream
Diffstat (limited to 'src/w32.c')
| -rw-r--r-- | src/w32.c | 80 |
1 files changed, 43 insertions, 37 deletions
| @@ -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 | } |