Commit 84e5ed96 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

Another minor fix in acl_set_file on Windows.

 src/w32.c (acl_set_file): Don't test for errors unless
 set_file_security returns FALSE.  Avoids spurious errors when
 saving files.
parent 2ef88fd4
2013-01-21 Eli Zaretskii <eliz@gnu.org>
* w32.c (acl_set_file): Don't test for errors unless
set_file_security returns FALSE. Avoids spurious errors when
saving files.
2013-01-21 Dmitry Antipov <dmantipov@yandex.ru> 2013-01-21 Dmitry Antipov <dmantipov@yandex.ru>
   
* fileio.c (Finsert_file_contents): Revert code introduced at * fileio.c (Finsert_file_contents): Revert code introduced at
......
...@@ -4868,28 +4868,18 @@ acl_set_file (const char *fname, acl_type_t type, acl_t acl) ...@@ -4868,28 +4868,18 @@ acl_set_file (const char *fname, acl_type_t type, acl_t acl)
e = errno; e = errno;
errno = 0; errno = 0;
set_file_security ((char *)fname, flags, (PSECURITY_DESCRIPTOR)acl); if (!set_file_security ((char *)fname, flags, (PSECURITY_DESCRIPTOR)acl))
err = GetLastError ();
if (st)
{ {
if (st >= 2) err = GetLastError ();
restore_privilege (&old2);
restore_privilege (&old1);
revert_to_self ();
}
if (errno == ENOTSUP) if (errno == ENOTSUP)
; ;
else if (err == ERROR_SUCCESS) else if (err == ERROR_INVALID_OWNER
{ || err == ERROR_NOT_ALL_ASSIGNED
retval = 0;
errno = e;
}
else if (err == ERROR_INVALID_OWNER || err == ERROR_NOT_ALL_ASSIGNED
|| err == ERROR_ACCESS_DENIED) || err == ERROR_ACCESS_DENIED)
{ {
/* Maybe the requested ACL and the one the file already has are /* Maybe the requested ACL and the one the file already has
identical, in which case we can silently ignore the are identical, in which case we can silently ignore the
failure. (And no, Windows doesn't.) */ failure. (And no, Windows doesn't.) */
acl_t current_acl = acl_get_file (fname, ACL_TYPE_ACCESS); acl_t current_acl = acl_get_file (fname, ACL_TYPE_ACCESS);
...@@ -4913,6 +4903,22 @@ acl_set_file (const char *fname, acl_type_t type, acl_t acl) ...@@ -4913,6 +4903,22 @@ acl_set_file (const char *fname, acl_type_t type, acl_t acl)
} }
else if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND) else if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND)
errno = ENOENT; errno = ENOENT;
else
errno = EACCES;
}
else
{
retval = 0;
errno = e;
}
if (st)
{
if (st >= 2)
restore_privilege (&old2);
restore_privilege (&old1);
revert_to_self ();
}
return retval; return retval;
} }
......
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