mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-19 04:49:25 +08:00
* ntea.cc (read_ea): Change left-over return to __leave. Fix
condition to close handle. Call NtClose rather than CloseHandle. (write_ea): Fix condition to close handle. Call NtClose rather than CloseHandle. * security.cc (get_file_sd): Call pc.init_reopen_attr if a valid incoming handle was given, pc.get_object_attr otherwise. (set_file_sd): Ditto.
This commit is contained in:
parent
dc847e6b9e
commit
db1ff3b932
@ -1,3 +1,13 @@
|
||||
2014-08-27 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* ntea.cc (read_ea): Change left-over return to __leave. Fix
|
||||
condition to close handle. Call NtClose rather than CloseHandle.
|
||||
(write_ea): Fix condition to close handle. Call NtClose rather than
|
||||
CloseHandle.
|
||||
* security.cc (get_file_sd): Call pc.init_reopen_attr if a valid
|
||||
incoming handle was given, pc.get_object_attr otherwise.
|
||||
(set_file_sd): Ditto.
|
||||
|
||||
2014-08-26 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* path.h (path_conv::init_reopen_attr): Change from void to returning
|
||||
|
@ -101,7 +101,7 @@ read_ea (HANDLE hdl, path_conv &pc, const char *name, char *value, size_t size)
|
||||
if ((nlen = strlen (name)) >= MAX_EA_NAME_LEN)
|
||||
{
|
||||
set_errno (EINVAL);
|
||||
return -1;
|
||||
__leave;
|
||||
}
|
||||
glen = sizeof (FILE_GET_EA_INFORMATION) + nlen;
|
||||
gea = (PFILE_GET_EA_INFORMATION) alloca (glen);
|
||||
@ -225,8 +225,8 @@ read_ea (HANDLE hdl, path_conv &pc, const char *name, char *value, size_t size)
|
||||
}
|
||||
__except (EFAULT) {}
|
||||
__endtry
|
||||
if (!hdl)
|
||||
CloseHandle (h);
|
||||
if (!hdl && h)
|
||||
NtClose (h);
|
||||
debug_printf ("%d = read_ea(%S, %s, %p, %lu)",
|
||||
ret, attr.ObjectName, name, value, size);
|
||||
return ret;
|
||||
@ -360,8 +360,8 @@ write_ea (HANDLE hdl, path_conv &pc, const char *name, const char *value,
|
||||
}
|
||||
__except (EFAULT) {}
|
||||
__endtry
|
||||
if (!hdl)
|
||||
CloseHandle (h);
|
||||
if (!hdl && h)
|
||||
NtClose (h);
|
||||
debug_printf ("%d = write_ea(%S, %s, %p, %lu, %d)",
|
||||
ret, attr.ObjectName, name, value, size, flags);
|
||||
return ret;
|
||||
|
@ -39,7 +39,7 @@ LONG
|
||||
get_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd,
|
||||
bool justcreated)
|
||||
{
|
||||
NTSTATUS status;
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
OBJECT_ATTRIBUTES attr;
|
||||
IO_STATUS_BLOCK io;
|
||||
ULONG len = SD_MAXIMUM_SIZE, rlen;
|
||||
@ -56,20 +56,19 @@ get_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd,
|
||||
status = NtQuerySecurityObject (fh, ALL_SECURITY_INFORMATION,
|
||||
sd, len, &rlen);
|
||||
if (!NT_SUCCESS (status))
|
||||
{
|
||||
debug_printf ("NtQuerySecurityObject (%S), status %y",
|
||||
pc.get_nt_native_path (), status);
|
||||
fh = NULL;
|
||||
}
|
||||
debug_printf ("NtQuerySecurityObject (%S), status %y",
|
||||
pc.get_nt_native_path (), status);
|
||||
}
|
||||
/* If the handle was NULL, or fetching with the original handle didn't work,
|
||||
try to reopen the file with READ_CONTROL and fetch the security descriptor
|
||||
using that handle. */
|
||||
if (!fh)
|
||||
if (!fh || !NT_SUCCESS (status))
|
||||
{
|
||||
status = NtOpenFile (&fh, READ_CONTROL,
|
||||
pc.init_reopen_attr (attr, fh), &io,
|
||||
FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT);
|
||||
fh ? pc.init_reopen_attr (attr, fh)
|
||||
: pc.get_object_attr (attr, sec_none_nih),
|
||||
&io, FILE_SHARE_VALID_FLAGS,
|
||||
FILE_OPEN_FOR_BACKUP_INTENT);
|
||||
if (!NT_SUCCESS (status))
|
||||
{
|
||||
sd.free ();
|
||||
@ -216,7 +215,9 @@ set_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd, bool is_chown)
|
||||
OBJECT_ATTRIBUTES attr;
|
||||
IO_STATUS_BLOCK io;
|
||||
status = NtOpenFile (&fh, (is_chown ? WRITE_OWNER : 0) | WRITE_DAC,
|
||||
pc.init_reopen_attr (attr, fh), &io,
|
||||
fh ? pc.init_reopen_attr (attr, fh)
|
||||
: pc.get_object_attr (attr, sec_none_nih),
|
||||
&io,
|
||||
FILE_SHARE_VALID_FLAGS,
|
||||
FILE_OPEN_FOR_BACKUP_INTENT);
|
||||
if (!NT_SUCCESS (status))
|
||||
|
Loading…
x
Reference in New Issue
Block a user