Fix various 32/64-bit portability issues in ssp, the single-step profiler, and
also build it for 64-bit.
This didn't turn out to actually be very useful for what I wanted to use it for,
so it's only been lightly tested.
It appears that on x86_64, single-step exceptions occur for much more of the
code in system DLLs, unlike x86, so ssp may take much, much longer to profile
some programs. There is existing code to use breakpoints to mitigate this, but
that is currently disabled.
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
* sec_auth.cc (get_token_group_sidlist): Drop auth_luid and
auth_pos parameter. Remove code adding a logon SID.
(get_initgroups_sidlist): Drop auth_luid and auth_pos parameter.
Drop in call to get_token_group_sidlist. Accommodate in callers.
(get_setgroups_sidlist): Ditto.
(create_token): Explicitely set auth_luid to ANONYMOUS_LOGON_LUID
or LOCALSERVICE_LUID depending on OS. Explain why.
Remove handling of logon SID since we don't generate one anymore.
(lsaauth): Drop now unused local variable auth_luid and auth_pos.
* wincap.h (wincaps::has_broken_whoami): New element.
* wincap.cc: Implement above element throughout.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* cyglsa.c (must_create_logon_sid): Remove.
(LsaApInitializePackage): Drop checking version and setting
must_create_logon_sid accordingly.
(LsaApLogonUserEx): Drop code setting login SID only required on
Windows 2000 and earlier.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This follows up from my msg re GMP-ECM failing its 'make check' on the
main list https://cygwin.com/ml/cygwin/2016-02/msg00147.html .
There's an error that ought to be reported during dynamic linking if the
linked-to address is too far from the relocation site. However the error
is not reported if __OPTIMIZE__ was #defined when building the Cygwin DLL.
I can't see why optimization settings should affect this.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* mount.cc (mount_info::conv_to_posix_path): Account for scenarios
where the path is identical to a mount point in terms of preserving
the trailing slash in the output.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
GCC 5 adds #line directives (and hence extra newlines) for macros
expansions, which confuses cygmagic. Using the -P flag avoids
them entirely.
https://cygwin.com/ml/cygwin-patches/2016-q1/msg00016.html
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
GCC 5 switched from C89 to C11 by default. This implies a change from
GNU to C99 inline by default, which have very different meanings of
extern inline vs. static inline:
https://gcc.gnu.org/onlinedocs/gcc/Inline.html
Marking these as gnu_inline retains the previous behaviour.
winsup/cygwin/
* exceptions.cc (exception::handle): Change debugging to int to fix
an always-true boolean comparison warning.
* include/cygwin/config.h (__getreent): Mark gnu_inline.
* winbase.h (ilockcmpexch, ilockcmpexch64): Ditto.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
POSIX.1e requires that chmod changes the MASK rather than the
GROUP_OBJ value if the ACL is non-trivial.
On Windows, especially on home machines, a standard ACL often
consists of entries for the user, maybe the group, and additional
entries for SYSTEM and the Administrators group. A user calling
chmod on a file with bog standard Windows perms usually expects
that chmod changes the GROUP_OBJ perms, but given the rules from
POSIX.1e we can't do that.
However, since we already treat Admins and SYSTEM special in a
ACL (they are not used in MASK computations) we go a step in the
Windows direction to follow user expectations. If an ACL only
consists of the three POSIX permissions, plus entries for Admins
and SYSTEM *only*, then we change the permissions of the GROUP_OBJ
entry *and* the MASK entry.
* fhandler_disk_file.cc (fhandler_disk_file::chmod): Drop unused
code. Add special handling for a "standard" Windows ACL. Add
comment to explain.
* sec_acl.cc (get_posix_access): Allow to return "standard-ness"
of an ACL to the caller. Add preceeding comment to explain a bit.
* security.h (get_posix_access): Align prototype.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Handle additional ACE for primary group only as another GROUP
entry if it's an allow ACE. Deny ACEs don't qualify.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Observed running hexchat under X. For some reason the call to
LoadLibraryEx(..., LOAD_LIBRARY_SEARCH_SYSTEM32) in dll_load
hangs when trying to autoload MsgWaitForMultipleObjectsEx in
select.cc after hexchat forks to run DNS calls. Dropping the
call and just using full paths as in 2.3.1 fixes the issue.
* autoload.cc (dll_load): Drop call to LoadLibraryEx with
LOAD_LIBRARY_SEARCH_SYSTEM32 flag.
* wincap.h (wincaps::has_load_lib_search_flags): Remove.
* wincap.cc (wincaps::has_load_lib_search_flags): Drop handling
this flag.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Rename "res" to "wait_state" and change its type to
select_stuff::wait_states. Use select_stuff::wait_states
values instead of ints throughout. Rearrange a few comments.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
On Cygwin 32 running under WOW64:
When case-correcting the path fetched with -S, the underlying
Windows function fetching the normalized path returns the real
path C:\Windows\SysWOW64 instead of the path redirection
enabled C:\Windows\System32 path. This breaks using the result
of `cygpath -S' to fetch the POSIX path of the network related
files under SYSTEMROOT\drivers\etc. This path is in fact under
the *real* C:\Windows\System32 and only mapped into the 32 bit
C:\Windows\System32 (aka C:\Windows\SysWOW64) via path redirection.
Sounds messy?
This patch checks if we're running under WOW64. If so, it
changes the path returned by GetSystemDirectoryW from "system32"
to "Sysnative". This in turn is changed to "System32" by
NtQueryInformationFile, so we're back to what we need.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
If the calling process doesn't have sufficient privileges to
fetch the linked token of an admin-user token, cygwin_logon_user
fails. This patch changes that by returning the original,
unprivileged token of the admin user to allow authentication
and calling setuid for the current process.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* sec_acl.cc (get_posix_access): Fix bracketing in expression
constructing POSIX group permissions so as not leaking deny bits
into POSIX file type bits.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (wsock_init): Use MAKEWORD macro to create requested
version rather than handcrafted expression.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (dll_load): Move safe loading from std_dll_init here.
Add code to handle systems supporting LOAD_LIBRARY_SEARCH flags.
Add comments to explain what the code is doing. Fix up comment
preceeding this function.
(std_dll_init): Move safe loading code to dll_load.
* wincap.h (wincaps::has_load_lib_search_flags): New element.
* wincap.cc: Implement above element throughout.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (fhandler_base::get_plain_ino): New inline method.
Add comment to explain what it's supposed to be used for.
* fhandler_socket.cc (fhandler_socket::get_proc_fd_name): Create
filename using inode number.
(fhandler_socket::fstat): Generate inode number from filename if
ino is not set (that's the case in a stat(2) call).
* pipe.cc: Throughout, use get_plain_ino when appropriate.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This reverts commit 4b104ce070.
The DLLs always guaranteed to be loaded from the system dir are only
those in the KnownDLLs list. We're using some DLLs not in that list on
all supported OSes, thus we need to make sure to use full paths.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_base): Convert unique_id to int64_t.
(fhandler_base::set_ino): New protected inline method.
(fhandler_base::get_unique_id): Convert to int64_t.
(fhandler_base::set_unique_id): New inline method taking int64_t.
(fhandler_pipe::fstat): Declare.
(fhandler_pipe::init): Take extra parameter.
(fhandler_pipe::create): Ditto.
* fhandler_socket.cc (fhandler_socket::init_events): Set inode number
to serial number.
(fhandler_socket::fstat): Set device to DEV_TCP_MAJOR. Create st_ino
from get_ino.
* include/cygwin/signal.h (struct _sigcommune): Replace
_si_pipe_fhandler with _si_pipe_unique_id.
* pinfo.h (_pinfo::pipe_fhandler): Take unique id instead of HANDLE.
* pinfo.cc (commune_process): Accommodate change to _si_pipe_unique_id.
(_pinfo::commune_request): Ditto.
(_pinfo::pipe_fhandler): Ditto.
* pipe.cc (fhandler_pipe::init): Take unique id as argument and set
inode number and unique_id from there.
(fhandler_pipe::open): Rework to find any matching pipe from unique
id in filename.
(fhandler_pipe::get_proc_fd_name): Create filename using inode number.
(fhandler_pipe::create): Generate and return unique id from process pid
and pipe_unique_id. In outer method, call init with additional unique
id as parameter.
(fhandler_pipe::fstat): New method.
(pipe_worker): Accommodate using 64 bit inode number in filename.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* select.cc (copyfd_set): Remove.
(select): Don't copy local wait fd arrays over to returned fd arrays
since bits set there are not accounted for in return value. Zero out
returned fd arrays instead. Always call sel.poll even in case of a
timeout. Always zero out fd array when timing out. Convert while/do
to do/while for clarity. Use dedicated variable as return value to
decouple return value from artificial return code from sel.wait.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* dcrt0.cc (dll_crt0_1), environ.cc (environ_init, getwinenveq,
build_env), strfuncs.cc (sys_wcstombs, sys_wcstombs_alloc),
wchar.c (sys_wcstombs, sys_wcstombs_alloc): avoid mis-conversions
of text that does not, actually, refer to a path or file name
Detailed explanation:
Our WCS -> UTF conversion handles the private Unicode page specially
to allow for otherwise invalid file names. However, this handling makes
no sense for command-lines, nor environment variables, which we would
rather convert verbatim.
As a stop-gap solution, let's just introduce a version of the
sys_wcstombs() function that specifically excludes that file name
conversion magic.
The proper solution is to change sys_wcstombs() to assume that it is not
a path that wants to be converted, and introduce sys_wcstombs_path()
that does, but that is a bigger task which we leave for another patch.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* cygpath.cc (do_sysfolders): Drop lame workaround to fix case of
directory returned by GetSystemDirectoryW. Try to fix case of
any path returned by this function in case it has to return a
POSIX path to support case-sensitivity.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>