]> code.delx.au - gnu-emacs/commitdiff
Follow symlinks in MS-Windows emulations of ACL functions.
authorEli Zaretskii <eliz@gnu.org>
Tue, 18 Dec 2012 19:05:56 +0000 (21:05 +0200)
committerEli Zaretskii <eliz@gnu.org>
Tue, 18 Dec 2012 19:05:56 +0000 (21:05 +0200)
 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.

src/ChangeLog
src/w32.c

index 7d85beace0c0bba6479302e707e9c87d76ef3367..4328fda1f404051a4287751235e49ccc80614d06 100644 (file)
@@ -1,3 +1,11 @@
+2012-12-18  Eli Zaretskii  <eliz@gnu.org>
+
+       * 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  <lekktu@gmail.com>
 
        * makefile.w32-in ($(BLD)/editfns.$(O), $(BLD)/fileio.$(O))
index 8ef07e6b077aae51d2f9daf2b08fa18bed76db07..0bb7a4e19c7ff01effc2e53a548f4477fd4dcbf6 100644 (file)
--- 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)
     ;