aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2012-12-18 21:05:56 +0200
committerEli Zaretskii2012-12-18 21:05:56 +0200
commit474d441e121b783a81e226042518b1c68e90fc2a (patch)
tree7e97a7f086d74d0adbe2854b463ba178d67623f2 /src
parente0d01ef3f862544762cf045a0524bdd062b98f6f (diff)
downloademacs-474d441e121b783a81e226042518b1c68e90fc2a.tar.gz
emacs-474d441e121b783a81e226042518b1c68e90fc2a.zip
Follow symlinks in MS-Windows emulations of ACL functions.
src/w32.c (acl_get_file, acl_set_file): Run the file name through map_w32_filename, and resolve any symlinks in the file name, like Posix platforms do. (acl_set_file): Call revert_to_self, if any privileges were enabled.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/w32.c27
2 files changed, 30 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 7d85beace0c..4328fda1f40 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12012-12-18 Eli Zaretskii <eliz@gnu.org>
2
3 * w32.c (acl_get_file, acl_set_file): Run the file name through
4 map_w32_filename, and resolve any symlinks in the file name, like
5 Posix platforms do.
6 (acl_set_file): Call revert_to_self, if any privileges were
7 enabled.
8
12012-12-17 Juanma Barranquero <lekktu@gmail.com> 92012-12-17 Juanma Barranquero <lekktu@gmail.com>
2 10
3 * makefile.w32-in ($(BLD)/editfns.$(O), $(BLD)/fileio.$(O)) 11 * makefile.w32-in ($(BLD)/editfns.$(O), $(BLD)/fileio.$(O))
diff --git a/src/w32.c b/src/w32.c
index 8ef07e6b077..0bb7a4e19c7 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -4518,7 +4518,7 @@ readlink (const char *name, char *buf, size_t buf_size)
4518 errno = EINVAL; 4518 errno = EINVAL;
4519 else 4519 else
4520 { 4520 {
4521 /* Copy the link target name, in wide characters, fro 4521 /* Copy the link target name, in wide characters, from
4522 reparse_data, then convert it to multibyte encoding in 4522 reparse_data, then convert it to multibyte encoding in
4523 the current locale's codepage. */ 4523 the current locale's codepage. */
4524 WCHAR *lwname; 4524 WCHAR *lwname;
@@ -4766,6 +4766,7 @@ acl_t
4766acl_get_file (const char *fname, acl_type_t type) 4766acl_get_file (const char *fname, acl_type_t type)
4767{ 4767{
4768 PSECURITY_DESCRIPTOR psd = NULL; 4768 PSECURITY_DESCRIPTOR psd = NULL;
4769 const char *filename;
4769 4770
4770 if (type == ACL_TYPE_ACCESS) 4771 if (type == ACL_TYPE_ACCESS)
4771 { 4772 {
@@ -4776,6 +4777,12 @@ acl_get_file (const char *fname, acl_type_t type)
4776 DACL_SECURITY_INFORMATION ; 4777 DACL_SECURITY_INFORMATION ;
4777 int e = errno; 4778 int e = errno;
4778 4779
4780 filename = map_w32_filename (fname, NULL);
4781 if ((volume_info.flags & FILE_SUPPORTS_REPARSE_POINTS) != 0)
4782 fname = chase_symlinks (filename);
4783 else
4784 fname = filename;
4785
4779 errno = 0; 4786 errno = 0;
4780 if (!get_file_security (fname, si, psd, 0, &sd_len) 4787 if (!get_file_security (fname, si, psd, 0, &sd_len)
4781 && errno != ENOTSUP) 4788 && errno != ENOTSUP)
@@ -4819,6 +4826,7 @@ acl_set_file (const char *fname, acl_type_t type, acl_t acl)
4819 BOOL dflt; 4826 BOOL dflt;
4820 BOOL dacl_present; 4827 BOOL dacl_present;
4821 int e; 4828 int e;
4829 const char *filename;
4822 4830
4823 if (acl_valid (acl) != 0 4831 if (acl_valid (acl) != 0
4824 || (type != ACL_TYPE_DEFAULT && type != ACL_TYPE_ACCESS)) 4832 || (type != ACL_TYPE_DEFAULT && type != ACL_TYPE_ACCESS))
@@ -4833,6 +4841,12 @@ acl_set_file (const char *fname, acl_type_t type, acl_t acl)
4833 return -1; 4841 return -1;
4834 } 4842 }
4835 4843
4844 filename = map_w32_filename (fname, NULL);
4845 if ((volume_info.flags & FILE_SUPPORTS_REPARSE_POINTS) != 0)
4846 fname = chase_symlinks (filename);
4847 else
4848 fname = filename;
4849
4836 if (get_security_descriptor_owner ((PSECURITY_DESCRIPTOR)acl, &psid, &dflt) 4850 if (get_security_descriptor_owner ((PSECURITY_DESCRIPTOR)acl, &psid, &dflt)
4837 && psid) 4851 && psid)
4838 flags |= OWNER_SECURITY_INFORMATION; 4852 flags |= OWNER_SECURITY_INFORMATION;
@@ -4866,10 +4880,13 @@ acl_set_file (const char *fname, acl_type_t type, acl_t acl)
4866 errno = 0; 4880 errno = 0;
4867 set_file_security ((char *)fname, flags, (PSECURITY_DESCRIPTOR)acl); 4881 set_file_security ((char *)fname, flags, (PSECURITY_DESCRIPTOR)acl);
4868 err = GetLastError (); 4882 err = GetLastError ();
4869 if (st >= 2) 4883 if (st)
4870 restore_privilege (&old2); 4884 {
4871 if (st >= 1) 4885 if (st >= 2)
4872 restore_privilege (&old1); 4886 restore_privilege (&old2);
4887 restore_privilege (&old1);
4888 revert_to_self ();
4889 }
4873 4890
4874 if (errno == ENOTSUP) 4891 if (errno == ENOTSUP)
4875 ; 4892 ;