* fhandler.h (fhandler_base::get_stat_access): Delete.

* fhandler_disk_file.cc (fhandler_base::fstat_helper): Always check
	executable suffix to get x-bits for .exe files also in notexec case.
	Always reopen file when checking for file header.
	* ntdll.h (wait_pending): Delete.
	* path.cc (symlink_info::check_shortcut): Drop call to wait_pending
	since file is always opened for sync IO.
	(symlink_info::check_sysfile): Ditto.
	(MIN_STAT_ACCESS): Remove.
	(FULL_STAT_ACCESS): Remove.
	(symlink_info::check): Drop access flag.  Revert to open file with
	just read attributes access.  Reorder symlink check to check for
	reparse points first.  Don't check reparse points for anything else,
	even on remote drives.  Open file for GENERIC_READ when trying to
	read shortcuts or system-bit symlinks. Accommodate dropped access
	flag in call to path_conv_handle::set.
	* path.h (class path_conv_handle): Drop access flag and accommodate
	all related methods.
This commit is contained in:
Corinna Vinschen
2010-10-07 14:03:26 +00:00
parent ca11a4f34f
commit dd0821e345
6 changed files with 118 additions and 126 deletions

View File

@ -591,7 +591,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
{
buf->st_mode |= S_IFREG;
/* Check suffix for executable file. */
if (pc.exec_state () == dont_know_if_executable)
if (pc.exec_state () != is_executable)
{
PUNICODE_STRING path = pc.get_nt_native_path ();
@ -604,34 +604,28 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
shebang scripts. */
if (pc.exec_state () == dont_know_if_executable)
{
LARGE_INTEGER off = { QuadPart:0LL };
char magic[3];
OBJECT_ATTRIBUTES attr;
NTSTATUS status = 0;
IO_STATUS_BLOCK io;
bool opened = false;
if (h == get_handle ())
{
/* We have been opened via fstat. We have to re-open the
file. Either the file is not opened for reading, or the
read will change the file position. */
OBJECT_ATTRIBUTES attr;
pc.init_reopen_attr (&attr, h);
status = NtOpenFile (&h, SYNCHRONIZE | FILE_READ_DATA,
&attr, &io, FILE_SHARE_VALID_FLAGS,
FILE_OPEN_FOR_BACKUP_INTENT
| FILE_OPEN_REPARSE_POINT);
if (!NT_SUCCESS (status))
debug_printf ("%p = NtOpenFile(%S)", status,
pc.get_nt_native_path ());
else
opened = true;
}
if (NT_SUCCESS (status))
/* We have to re-open the file. Either the file is not opened
for reading, or the read will change the file position of the
original handle. */
pc.init_reopen_attr (&attr, h);
status = NtOpenFile (&h, SYNCHRONIZE | FILE_READ_DATA,
&attr, &io, FILE_SHARE_VALID_FLAGS,
FILE_OPEN_FOR_BACKUP_INTENT
| FILE_SYNCHRONOUS_IO_NONALERT);
if (!NT_SUCCESS (status))
debug_printf ("%p = NtOpenFile(%S)", status,
pc.get_nt_native_path ());
else
{
LARGE_INTEGER off = { QuadPart:0LL };
char magic[3];
status = NtReadFile (h, NULL, NULL, NULL,
&io, magic, 3, &off, NULL);
status = wait_pending (status, h, io);
if (!NT_SUCCESS (status))
debug_printf ("%p = NtReadFile(%S)", status,
pc.get_nt_native_path ());
@ -641,9 +635,8 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
pc.set_exec ();
buf->st_mode |= STD_XBITS;
}
NtClose (h);
}
if (opened)
NtClose (h);
}
}
if (pc.exec_state () == is_executable)