* path.h (path_conv::init_reopen_attr): Change from void to returning
POBJECT_ATTRIBUTES. Take OBJECT_ATTRIBUTES reference as argument, not pointer. * fhandler_disk_file.cc: Throughout accommodate above change. * syscalls.cc: Ditto. * ntea.cc (read_ea): Don't set hdl to NULL if it's already NULL. Set attr with pc.init_reopen_attr before trying to reopen file. (write_ea): Ditto. * security.cc (get_file_sd): Use pc.init_reopen_attr rather than pc.get_object_attr when trying to reopen file. (set_file_sd): Ditto.
This commit is contained in:
parent
12b244394c
commit
dc847e6b9e
|
@ -1,3 +1,17 @@
|
||||||
|
2014-08-26 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* path.h (path_conv::init_reopen_attr): Change from void to returning
|
||||||
|
POBJECT_ATTRIBUTES. Take OBJECT_ATTRIBUTES reference as argument, not
|
||||||
|
pointer.
|
||||||
|
* fhandler_disk_file.cc: Throughout accommodate above change.
|
||||||
|
* syscalls.cc: Ditto.
|
||||||
|
* ntea.cc (read_ea): Don't set hdl to NULL if it's already NULL. Set
|
||||||
|
attr with pc.init_reopen_attr before trying to reopen file.
|
||||||
|
(write_ea): Ditto.
|
||||||
|
* security.cc (get_file_sd): Use pc.init_reopen_attr rather than
|
||||||
|
pc.get_object_attr when trying to reopen file.
|
||||||
|
(set_file_sd): Ditto.
|
||||||
|
|
||||||
2014-08-25 Corinna Vinschen <corinna@vinschen.de>
|
2014-08-25 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* cygtls.cc (san::leave/x86_64): Implement.
|
* cygtls.cc (san::leave/x86_64): Implement.
|
||||||
|
|
|
@ -672,9 +672,9 @@ fhandler_base::fstat_helper (struct stat *buf, DWORD nNumberOfLinks)
|
||||||
/* We have to re-open the file. Either the file is not opened
|
/* 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
|
for reading, or the read will change the file position of the
|
||||||
original handle. */
|
original handle. */
|
||||||
pc.init_reopen_attr (&attr, h);
|
|
||||||
status = NtOpenFile (&h, SYNCHRONIZE | FILE_READ_DATA,
|
status = NtOpenFile (&h, SYNCHRONIZE | FILE_READ_DATA,
|
||||||
&attr, &io, FILE_SHARE_VALID_FLAGS,
|
pc.init_reopen_attr (attr, h), &io,
|
||||||
|
FILE_SHARE_VALID_FLAGS,
|
||||||
FILE_OPEN_FOR_BACKUP_INTENT
|
FILE_OPEN_FOR_BACKUP_INTENT
|
||||||
| FILE_SYNCHRONOUS_IO_NONALERT);
|
| FILE_SYNCHRONOUS_IO_NONALERT);
|
||||||
if (!NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
|
@ -894,9 +894,9 @@ fhandler_disk_file::fchmod (mode_t mode)
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
HANDLE fh;
|
HANDLE fh;
|
||||||
|
|
||||||
pc.init_reopen_attr (&attr, get_handle ());
|
if (NT_SUCCESS (NtOpenFile (&fh, FILE_WRITE_ATTRIBUTES,
|
||||||
if (NT_SUCCESS (NtOpenFile (&fh, FILE_WRITE_ATTRIBUTES, &attr, &io,
|
pc.init_reopen_attr (attr, get_handle ()),
|
||||||
FILE_SHARE_VALID_FLAGS,
|
&io, FILE_SHARE_VALID_FLAGS,
|
||||||
FILE_OPEN_FOR_BACKUP_INTENT)))
|
FILE_OPEN_FOR_BACKUP_INTENT)))
|
||||||
{
|
{
|
||||||
NtSetAttributesFile (fh, pc.file_attributes ());
|
NtSetAttributesFile (fh, pc.file_attributes ());
|
||||||
|
@ -1384,9 +1384,9 @@ fhandler_base::utimens_fs (const struct timespec *tvp)
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
HANDLE fh;
|
HANDLE fh;
|
||||||
|
|
||||||
pc.init_reopen_attr (&attr, get_handle ());
|
if (NT_SUCCESS (NtOpenFile (&fh, FILE_WRITE_ATTRIBUTES,
|
||||||
if (NT_SUCCESS (NtOpenFile (&fh, FILE_WRITE_ATTRIBUTES, &attr, &io,
|
pc.init_reopen_attr (attr, get_handle ()),
|
||||||
FILE_SHARE_VALID_FLAGS,
|
&io, FILE_SHARE_VALID_FLAGS,
|
||||||
FILE_OPEN_FOR_BACKUP_INTENT)))
|
FILE_OPEN_FOR_BACKUP_INTENT)))
|
||||||
{
|
{
|
||||||
NtSetInformationFile (fh, &io, &fbi, sizeof fbi,
|
NtSetInformationFile (fh, &io, &fbi, sizeof fbi,
|
||||||
|
@ -1555,8 +1555,8 @@ fhandler_disk_file::prw_open (bool write)
|
||||||
|
|
||||||
/* First try to open with the original access mask */
|
/* First try to open with the original access mask */
|
||||||
ACCESS_MASK access = get_access ();
|
ACCESS_MASK access = get_access ();
|
||||||
pc.init_reopen_attr (&attr, get_handle ());
|
status = NtOpenFile (&prw_handle, access,
|
||||||
status = NtOpenFile (&prw_handle, access, &attr, &io,
|
pc.init_reopen_attr (attr, get_handle ()), &io,
|
||||||
FILE_SHARE_VALID_FLAGS, get_options ());
|
FILE_SHARE_VALID_FLAGS, get_options ());
|
||||||
if (status == STATUS_ACCESS_DENIED)
|
if (status == STATUS_ACCESS_DENIED)
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,7 +80,6 @@ read_ea (HANDLE hdl, path_conv &pc, const char *name, char *value, size_t size)
|
||||||
__seterrno_from_nt_status (status);
|
__seterrno_from_nt_status (status);
|
||||||
__leave;
|
__leave;
|
||||||
}
|
}
|
||||||
hdl = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fea = (PFILE_FULL_EA_INFORMATION) tp.w_get ();
|
fea = (PFILE_FULL_EA_INFORMATION) tp.w_get ();
|
||||||
|
@ -120,6 +119,7 @@ read_ea (HANDLE hdl, path_conv &pc, const char *name, char *value, size_t size)
|
||||||
NULL, TRUE);
|
NULL, TRUE);
|
||||||
if (status != STATUS_ACCESS_DENIED || !hdl)
|
if (status != STATUS_ACCESS_DENIED || !hdl)
|
||||||
break;
|
break;
|
||||||
|
pc.init_reopen_attr (attr, h);
|
||||||
}
|
}
|
||||||
status = NtOpenFile (&h, READ_CONTROL | FILE_READ_EA, &attr, &io,
|
status = NtOpenFile (&h, READ_CONTROL | FILE_READ_EA, &attr, &io,
|
||||||
FILE_SHARE_VALID_FLAGS,
|
FILE_SHARE_VALID_FLAGS,
|
||||||
|
@ -265,7 +265,6 @@ write_ea (HANDLE hdl, path_conv &pc, const char *name, const char *value,
|
||||||
__seterrno_from_nt_status (status);
|
__seterrno_from_nt_status (status);
|
||||||
__leave;
|
__leave;
|
||||||
}
|
}
|
||||||
hdl = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For compatibility with Linux, we only allow user xattrs and
|
/* For compatibility with Linux, we only allow user xattrs and
|
||||||
|
@ -323,6 +322,7 @@ write_ea (HANDLE hdl, path_conv &pc, const char *name, const char *value,
|
||||||
status = NtSetEaFile (h, &io, fea, flen);
|
status = NtSetEaFile (h, &io, fea, flen);
|
||||||
if (status != STATUS_ACCESS_DENIED || !hdl)
|
if (status != STATUS_ACCESS_DENIED || !hdl)
|
||||||
break;
|
break;
|
||||||
|
pc.init_reopen_attr (attr, h);
|
||||||
}
|
}
|
||||||
status = NtOpenFile (&h, READ_CONTROL | FILE_WRITE_EA, &attr, &io,
|
status = NtOpenFile (&h, READ_CONTROL | FILE_WRITE_EA, &attr, &io,
|
||||||
FILE_SHARE_VALID_FLAGS,
|
FILE_SHARE_VALID_FLAGS,
|
||||||
|
|
|
@ -281,14 +281,15 @@ class path_conv
|
||||||
NULL, sa.lpSecurityDescriptor);
|
NULL, sa.lpSecurityDescriptor);
|
||||||
return &attr;
|
return &attr;
|
||||||
}
|
}
|
||||||
inline void init_reopen_attr (POBJECT_ATTRIBUTES attr, HANDLE h)
|
inline POBJECT_ATTRIBUTES init_reopen_attr (OBJECT_ATTRIBUTES &attr, HANDLE h)
|
||||||
{
|
{
|
||||||
if (has_buggy_reopen ())
|
if (has_buggy_reopen ())
|
||||||
InitializeObjectAttributes (attr, get_nt_native_path (),
|
InitializeObjectAttributes (&attr, get_nt_native_path (),
|
||||||
objcaseinsensitive (), NULL, NULL)
|
objcaseinsensitive (), NULL, NULL)
|
||||||
else
|
else
|
||||||
InitializeObjectAttributes (attr, &ro_u_empty, objcaseinsensitive (),
|
InitializeObjectAttributes (&attr, &ro_u_empty, objcaseinsensitive (),
|
||||||
h, NULL);
|
h, NULL);
|
||||||
|
return &attr;
|
||||||
}
|
}
|
||||||
inline size_t get_wide_win32_path_len ()
|
inline size_t get_wide_win32_path_len ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,7 +68,7 @@ get_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd,
|
||||||
if (!fh)
|
if (!fh)
|
||||||
{
|
{
|
||||||
status = NtOpenFile (&fh, READ_CONTROL,
|
status = NtOpenFile (&fh, READ_CONTROL,
|
||||||
pc.get_object_attr (attr, sec_none_nih), &io,
|
pc.init_reopen_attr (attr, fh), &io,
|
||||||
FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT);
|
FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT);
|
||||||
if (!NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
{
|
{
|
||||||
|
@ -216,8 +216,8 @@ set_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd, bool is_chown)
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
IO_STATUS_BLOCK io;
|
IO_STATUS_BLOCK io;
|
||||||
status = NtOpenFile (&fh, (is_chown ? WRITE_OWNER : 0) | WRITE_DAC,
|
status = NtOpenFile (&fh, (is_chown ? WRITE_OWNER : 0) | WRITE_DAC,
|
||||||
pc.get_object_attr (attr, sec_none_nih),
|
pc.init_reopen_attr (attr, fh), &io,
|
||||||
&io, FILE_SHARE_VALID_FLAGS,
|
FILE_SHARE_VALID_FLAGS,
|
||||||
FILE_OPEN_FOR_BACKUP_INTENT);
|
FILE_OPEN_FOR_BACKUP_INTENT);
|
||||||
if (!NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
{
|
{
|
||||||
|
|
|
@ -719,7 +719,7 @@ retry_open:
|
||||||
if (!NT_SUCCESS (status2))
|
if (!NT_SUCCESS (status2))
|
||||||
debug_printf ("Removing R/O on %S failed, status = %y",
|
debug_printf ("Removing R/O on %S failed, status = %y",
|
||||||
pc.get_nt_native_path (), status2);
|
pc.get_nt_native_path (), status2);
|
||||||
pc.init_reopen_attr (&attr, fh_ro);
|
pc.init_reopen_attr (attr, fh_ro);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -947,8 +947,8 @@ try_again:
|
||||||
pc.get_nt_native_path ());
|
pc.get_nt_native_path ());
|
||||||
/* Re-open from handle so we open the correct file no matter if it
|
/* Re-open from handle so we open the correct file no matter if it
|
||||||
has been moved to the bin or not. */
|
has been moved to the bin or not. */
|
||||||
pc.init_reopen_attr (&attr, fh);
|
status = NtOpenFile (&fh2, DELETE,
|
||||||
status = NtOpenFile (&fh2, DELETE, &attr, &io,
|
pc.init_reopen_attr (attr, fh), &io,
|
||||||
bin_stat == move_to_bin ? FILE_SHARE_VALID_FLAGS
|
bin_stat == move_to_bin ? FILE_SHARE_VALID_FLAGS
|
||||||
: FILE_SHARE_DELETE,
|
: FILE_SHARE_DELETE,
|
||||||
flags | FILE_DELETE_ON_CLOSE);
|
flags | FILE_DELETE_ON_CLOSE);
|
||||||
|
|
Loading…
Reference in New Issue