Commit 474d441e authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

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.
parent e0d01ef3
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))
......
......@@ -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)
;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment