* 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:
parent
37579836e3
commit
326510785e
@ -1,9 +1,23 @@
|
||||
2014-08-27 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* 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.
|
||||
|
||||
2014-08-27 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* ntea.cc (read_ea): Change left-over return to __leave. Fix
|
||||
|
@ -1506,7 +1506,7 @@ class fhandler_pty_slave: public fhandler_pty_common
|
||||
HANDLE inuse; // used to indicate that a tty is in use
|
||||
|
||||
/* Helper functions for fchmod and fchown. */
|
||||
bool fch_open_handles ();
|
||||
bool fch_open_handles (bool chown);
|
||||
int fch_set_sd (security_descriptor &sd, bool chown);
|
||||
void fch_close_handles ();
|
||||
|
||||
|
@ -714,7 +714,7 @@ fhandler_base::fstat_helper (struct stat *buf, DWORD nNumberOfLinks)
|
||||
}
|
||||
|
||||
done:
|
||||
syscall_printf ("0 = fstat (%S, %p) st_size=%D, st_mode=%y, st_ino=%D"
|
||||
syscall_printf ("0 = fstat (%S, %p) st_size=%D, st_mode=0%o, st_ino=%D"
|
||||
"st_atim=%lx.%lx st_ctim=%lx.%lx "
|
||||
"st_mtim=%lx.%lx st_birthtim=%lx.%lx",
|
||||
pc.get_nt_native_path (), buf,
|
||||
|
@ -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));
|
||||
|
@ -506,7 +506,7 @@ alloc_sd (path_conv &pc, uid_t uid, gid_t gid, int attribute,
|
||||
/* NOTE: If the high bit of attribute is set, we have just created
|
||||
a file or directory. See below for an explanation. */
|
||||
|
||||
debug_printf("uid %u, gid %u, attribute %y", uid, gid, attribute);
|
||||
debug_printf("uid %u, gid %u, attribute 0%o", uid, gid, attribute);
|
||||
|
||||
/* Get owner and group from current security descriptor. */
|
||||
PSID cur_owner_sid = NULL;
|
||||
@ -964,7 +964,7 @@ set_file_attribute (HANDLE handle, path_conv &pc,
|
||||
}
|
||||
else
|
||||
ret = 0;
|
||||
syscall_printf ("%d = set_file_attribute(%S, %d, %d, %y)",
|
||||
syscall_printf ("%d = set_file_attribute(%S, %d, %d, 0%o)",
|
||||
ret, pc.get_nt_native_path (), uid, gid, attribute);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user