* fhandler.h (fhandler_pty_slave::fch_open_handles): Add bool parameter
to declaration. * fhandler_tty.cc (fhandler_pty_slave::fch_open_handles): Add bool parameter "chown". Only request WRITE_OWNER access when opening pty synchronization objects if "chown" is set. (fhandler_pty_slave::fchmod): Call fch_open_handles with new bool parameter set to false. (fhandler_pty_slave::fchown): Call fch_open_handles with new bool parameter set to true. * kernel32.cc (CreateFileMappingW): Fix default standard rights for file mappings from READ_CONTROL to STANDARD_RIGHTS_REQUIRED to allow changing the DACL (fixes "access denied" error in pinfo::set_acl). * fhandler_disk_file.cc (fhandler_base::fstat_helper): Change debug output to print mode bits in octal. * security.cc (alloc_sd): Ditto. (set_file_attribute): Ditto.
This commit is contained in:
@@ -1102,17 +1102,18 @@ fhandler_pty_slave::fstat (struct stat *st)
|
||||
/* Helper function for fchmod and fchown, which just opens all handles
|
||||
and signals success via bool return. */
|
||||
bool
|
||||
fhandler_pty_slave::fch_open_handles ()
|
||||
fhandler_pty_slave::fch_open_handles (bool chown)
|
||||
{
|
||||
char buf[MAX_PATH];
|
||||
DWORD write_access = WRITE_DAC | (chown ? WRITE_OWNER : 0);
|
||||
|
||||
_tc = cygwin_shared->tty[get_minor ()];
|
||||
shared_name (buf, INPUT_AVAILABLE_EVENT, get_minor ());
|
||||
input_available_event = OpenEvent (READ_CONTROL | WRITE_DAC | WRITE_OWNER,
|
||||
input_available_event = OpenEvent (READ_CONTROL | write_access,
|
||||
TRUE, buf);
|
||||
output_mutex = get_ttyp ()->open_output_mutex (WRITE_DAC | WRITE_OWNER);
|
||||
input_mutex = get_ttyp ()->open_input_mutex (WRITE_DAC | WRITE_OWNER);
|
||||
inuse = get_ttyp ()->open_inuse (WRITE_DAC | WRITE_OWNER);
|
||||
output_mutex = get_ttyp ()->open_output_mutex (write_access);
|
||||
input_mutex = get_ttyp ()->open_input_mutex (write_access);
|
||||
inuse = get_ttyp ()->open_inuse (write_access);
|
||||
if (!input_available_event || !output_mutex || !input_mutex || !inuse)
|
||||
{
|
||||
__seterrno ();
|
||||
@@ -1166,7 +1167,7 @@ fhandler_pty_slave::fchmod (mode_t mode)
|
||||
if (!input_available_event)
|
||||
{
|
||||
to_close = true;
|
||||
if (!fch_open_handles ())
|
||||
if (!fch_open_handles (false))
|
||||
goto errout;
|
||||
}
|
||||
sd.malloc (sizeof (SECURITY_DESCRIPTOR));
|
||||
@@ -1195,7 +1196,7 @@ fhandler_pty_slave::fchown (uid_t uid, gid_t gid)
|
||||
if (!input_available_event)
|
||||
{
|
||||
to_close = true;
|
||||
if (!fch_open_handles ())
|
||||
if (!fch_open_handles (true))
|
||||
goto errout;
|
||||
}
|
||||
sd.malloc (sizeof (SECURITY_DESCRIPTOR));
|
||||
|
Reference in New Issue
Block a user