From: Eli Zaretskii Date: Tue, 18 Dec 2012 19:05:56 +0000 (+0200) Subject: Follow symlinks in MS-Windows emulations of ACL functions. X-Git-Tag: emacs-24.3.90~173^2~7^2~557 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=474d441e121b783a81e226042518b1c68e90fc2a;p=emacs.git 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. --- diff --git a/src/ChangeLog b/src/ChangeLog index 7d85beace0c..4328fda1f40 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2012-12-18 Eli Zaretskii + + * 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. + 2012-12-17 Juanma Barranquero * 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) errno = EINVAL; else { - /* Copy the link target name, in wide characters, fro + /* Copy the link target name, in wide characters, from reparse_data, then convert it to multibyte encoding in the current locale's codepage. */ WCHAR *lwname; @@ -4766,6 +4766,7 @@ acl_t acl_get_file (const char *fname, acl_type_t type) { PSECURITY_DESCRIPTOR psd = NULL; + const char *filename; if (type == ACL_TYPE_ACCESS) { @@ -4776,6 +4777,12 @@ acl_get_file (const char *fname, acl_type_t type) DACL_SECURITY_INFORMATION ; int e = errno; + filename = map_w32_filename (fname, NULL); + if ((volume_info.flags & FILE_SUPPORTS_REPARSE_POINTS) != 0) + fname = chase_symlinks (filename); + else + fname = filename; + errno = 0; if (!get_file_security (fname, si, psd, 0, &sd_len) && errno != ENOTSUP) @@ -4819,6 +4826,7 @@ acl_set_file (const char *fname, acl_type_t type, acl_t acl) BOOL dflt; BOOL dacl_present; int e; + const char *filename; if (acl_valid (acl) != 0 || (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) return -1; } + filename = map_w32_filename (fname, NULL); + if ((volume_info.flags & FILE_SUPPORTS_REPARSE_POINTS) != 0) + fname = chase_symlinks (filename); + else + fname = filename; + if (get_security_descriptor_owner ((PSECURITY_DESCRIPTOR)acl, &psid, &dflt) && psid) flags |= OWNER_SECURITY_INFORMATION; @@ -4866,10 +4880,13 @@ acl_set_file (const char *fname, acl_type_t type, acl_t acl) errno = 0; set_file_security ((char *)fname, flags, (PSECURITY_DESCRIPTOR)acl); err = GetLastError (); - if (st >= 2) - restore_privilege (&old2); - if (st >= 1) - restore_privilege (&old1); + if (st) + { + if (st >= 2) + restore_privilege (&old2); + restore_privilege (&old1); + revert_to_self (); + } if (errno == ENOTSUP) ;