summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin
Commit message (Collapse)AuthorAgeFilesLines
...
* Always try to write complete incoming buffer on pipes and fifosCorinna Vinschen2017-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | This patch fixes the following problem: Commit 9636c426 refactored the pipe code especially to make sure to call WriteFile only with chunks matching the maximum atomic write count. This accidentally introduced a small change in behaviour on blocking pipes due to the success case falling through into the error case. Rather then writing atomic chunks until all bytes are written, the code immediately broke from the loop after writing the first chunk, basically the same as in case of non-blocking writes. This behaviour is not compliant to POSIX which requires "Write requests to a pipe or FIFO [...] * If the O_NONBLOCK flag is clear, a write request may cause the thread to block, but on normal completion it shall return nbyte." Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Add release message for commit 6ed4753Corinna Vinschen2017-01-121-1/+2
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* rename: Refactor "new file already exists and rename fails" caseCorinna Vinschen2017-01-121-20/+27
| | | | | | | | | | | | | | | | | | | | | | | If newfile already exists and is in use, trying to overwrite it with NtSetInformationFile(FileRenameInformation) fails exactly as if we don't have the permissions to delete it. Unfortunately the return code is the same STATUS_ACCESS_DENIED, so we have no way to distinguish these cases. What we do here so far is to start a transaction to delete newfile. If this open fails with a transactional error we stop the transaction and retry opening the file without transaction. But, here's the problem: If newfile is in use, NtOpenFile(oldfile) naturally does NOT fail with a transactional error. Rather, the subsequent call to unlink_nt(newfile) does, because there's another handle open to newfile outside a transaction. However, the code does not check if unlink_nt fails with a transactional error and so fails to retry without transaction. This patch recifies the problem and checks unlink_nt's status as well. Refactor code to get rid of goto into another code block. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* FAST_CWD: adjust the initial search scopeJohannes Schindelin2017-01-121-2/+2
| | | | | | | | | | | | A *very* recent Windows build adds more code to the preamble of RtlGetCurrentDirectory_U() so that the previous heuristic failed to find the call to the locking routine. This only affects the 64-bit version of ntdll, where the 0xe8 byte is now found at offset 40, not the 32-bit version. However, let's just double the area we search for said byte for good measure. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* Fix formatting in pinfo.ccCorinna Vinschen2017-01-101-7/+8
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Document latest Cygwin changesCorinna Vinschen2017-01-101-0/+2
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Add a /proc/<pid>/environ proc file handler, analogous to /proc/<pid>/cmdline.Erik M. Bray2017-01-101-0/+22
|
* Add a _pinfo.environ() method analogous to _pinfo.cmdline(), and others.Erik M. Bray2017-01-102-3/+84
| | | | | | | Returns the process's environment concatenated into a single block of null-terminated strings, along with the length of the environment block. Adds an associated PICOM_ENVIRON commune_process handler.
* Move the core environment parsing of environ_init into a new ↵Erik M. Bray2017-01-102-35/+51
| | | | | | | | | | win32env_to_cygenv function. win32env_to_cygwenv handles converting wchar to char and some other minor taks. Optionally it handles converting any paths in variables to posix paths. This will be useful for implementing /proc/<pid>/environ
* Return the correct value for getsockopt(SO_REUSEADDR) after setting ↵Erik M. Bray2017-01-091-0/+8
| | | | setsockopt(SO_REUSEADDR, 1).
* Don't free statically allocated sys_privsCorinna Vinschen2017-01-091-2/+2
| | | | | | | | | commit 67fd2101 introduced a bad bug. Changing sys_privs to a static area and just returning a pointer is nice... *if* the calling code doesn't call free() on it. Make sure callers check pointer for sys_privs and refrain from calling free, if so. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Export getentropy and getrandom callsCorinna Vinschen2016-12-165-6/+96
| | | | | | | | | | | | getentropy per OpenBSD http://man.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man2/getentropy.2 getrandom per Linux http://man7.org/linux/man-pages/man2/getrandom.2.html Note that GRND_NONBLOCK is not handled
* Define RtlGenRandom correctly in ntsecapi.h wrapperCorinna Vinschen2016-12-145-6/+29
| | | | | | | Include ntsecapi.h where required and just redefine RtlGenRandom correctly in the ntsecapi.h wrapper. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Rearrange RNG code slightlyCorinna Vinschen2016-12-134-34/+52
| | | | | | | | | | | | | | | In preparation of exporting getentropy/getrandom to userspace, rearrange code a bit: - Define RtlGenRandom in ntdll.h. - Drop calls to getentropy in favor of RtlGenRandom (fhandler_socket, fhandler_dev_random). - Add try/except blocks in fhandler_dev_random to return EFAULT rather than crashing if buffer pointer is invalid. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: Add release messages for last two checkinsCorinna Vinschen2016-12-131-0/+7
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix incorrect path conversion on non-existent files on network sharesCorinna Vinschen2016-12-131-0/+7
| | | | | | | | | | | | | | | | | | NtOpenFile/NtCreateFile on non-existent paths on network drives has a bug. Assuming a path Z:\dir\file. Further assuming that Z:\dir does not exist. The first NtOpenFile("Z:\dir\file") correctly returns STATUS_OBJECT_PATH_NOT_FOUND. Subsequent calls incorrectly return STATUS_OBJECT_NAME_NOT_FOUND. This appears to be some kind of caching behaviour. Waiting a while before repeating the call correctly returns STATUS_OBJECT_PATH_NOT_FOUND again. This patch works around the observed misbehaviour. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Check for .exe file in cygwin_conv_pathCorinna Vinschen2016-12-131-2/+2
| | | | | | | | So far, when converting from POSIX to Windows notation, cygwin_conv_path fails to check for .exe suffix, so /path/foo did not return /path/foo.exe even if this file exists. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin 2.6.1: Add missing release textCorinna Vinschen2016-12-061-4/+16
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* path_conv: When encountering a ".(/)+" sequence, skip *all* slashesCorinna Vinschen2016-11-281-1/+6
| | | | | | | The original code only skipped the "./", but missed to test if more trailing slashes are present. This in turn leads to invalid conversion. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* regex: Fix typo in CHaddrangeCorinna Vinschen2016-11-241-1/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* _pinfo::set_ctty: Check potential NULL pointer in debug_printf statementCorinna Vinschen2016-11-241-1/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Eliminate unused parameter from path_conv::eq_workerCorinna Vinschen2016-11-241-12/+4
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Remove redundant check for NULL pointer in cygwin_exception::dump_exceptionCorinna Vinschen2016-11-241-7/+4
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix copy/paste typo in fhandler_console::scroll_buffer_screenCorinna Vinschen2016-11-241-1/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Don't allow sending invalid signals from user spaceCorinna Vinschen2016-11-241-12/+22
| | | | | | | | Don't allow signal 0 in signal(2), sigaction(2), siginterrupt(3). Don't allow any signal in sigqueue(3) but explicitely handle signal 0 as in kill(2). Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* raise: Add missing extern "C"Corinna Vinschen2016-11-241-1/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* login_tty: Rewrite following FreeBSD's tracesCorinna Vinschen2016-11-241-15/+8
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* fcwd_access_t: Add missing breaks in f_cwd pointer computationCorinna Vinschen2016-11-241-0/+3
| | | | | | Fixes Coverity CIDs 59893/59894 Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Add comments to intentional switch fallthroughsCorinna Vinschen2016-11-243-0/+7
| | | | | | Clarify Coverity "Missing break in switch" messages. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Add length check creating domain\group stringsCorinna Vinschen2016-11-241-6/+6
| | | | | | Fix Coverity CID 153932 Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Provide <memory.h>Sebastian Huber2016-11-221-15/+0
| | | | | | | | Provide <memory.h> for all standard Newlib targets and remove Cygwin-specific header. Most POSIX like systems provide this historic header. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Move pthread types to <sys/_pthreadtypes.h>Sebastian Huber2016-11-172-46/+59
| | | | | | | | | | This makes it possible provide operating system specific types for <pthread.h>. It is in line with the FreeBSD header file structure and allows a future cleanup of <pthread.h> to not expose unrelated things via <sys/types.h> and <unistd.h>. Glibc uses the similar <bits/pthreadtypes.h> for this purpose. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Add release note for commit 8a32c24Corinna Vinschen2016-11-171-0/+3
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Use allocation granularity as the 'page_size' in /proc/<pid>/status as well, ↵Erik M. Bray2016-11-161-1/+1
| | | | for consistency with /proc/<pid>/statm
* statm should report memory as multiples of allocation_granularity instead of ↵Erik M. Bray2016-11-161-1/+5
| | | | | | page_size that ensures that values in statm mupltiplied by POSIX _SC_PAGESIZE give the correct values
* Fix ShellExecuteW commentCorinna Vinschen2016-10-241-4/+3
| | | | | | | ShellExecuteW long path behaviour is now stable: It doesn't work since Windows 8.1. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Add _PC_CASE_INSENSITIVE to [f]pathconfKen Brown2016-10-213-1/+6
| | | | | | | | Update the getconf utility to support the new flag as well as _PC_POSIX_PERMISSIONS and _PC_POSIX_SECURITY. These were previously unsupported, probably as an oversight. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix SetThreadName with gdb 7.10 on x86Jon Turney2016-10-201-1/+8
| | | | | | | | | | | Additionally to eccefd97, we need to ensure the exception handler is installed for the _ljfault used to implement _try/_except to get called. Also use the correct macro for x86 conditional compilation. Addresses https://cygwin.com/ml/cygwin/2016-09/msg00143.html Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
* Don't check directories always case-insensitive in rename(2)Corinna Vinschen2016-10-192-1/+4
| | | | | | | | | | | | | | | | | | Long-standing problem in one of the corner cases of rename(2): If we rename a directory a check is performed to see if newpath is identical to oldpath or a subdir of oldpath. This check is (accidentally? no hints anywhere in ChangeLogs or code) performed case-insensitive for as long as we use Unicode paths and NT functions. This leads to the problems described in https://cygwin.com/ml/cygwin/2016-09/msg00264.html Change this to be conditional case-sensitive as all other checks but let's take this with a grain of salt. There may be corner-cases in this corner-case which require to chek parts of the path always case-insensitive. Off the top of my head I can't construct such a case but that's no proof they don't exist :} Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Add release msg for 5a3496cCorinna Vinschen2016-10-191-0/+13
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix regression in console charset handlingCorinna Vinschen2016-10-191-0/+2
| | | | | | | | | | | | Commit d16a5630 dropped usage of cygheap's locale functions in favor of local on-the-fly usage of UTF-8 instead of ASCII. This allowed to use the current local rather than a fixed system-wide locale set at startup time. d16a5630 just missed to add the ASCII->UTF-8 conversion in the console as well. Fixes https://cygwin.com/ml/cygwin/2016-10/msg00000.html Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Bump Cygwin version to 2.6.1Corinna Vinschen2016-10-191-1/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* dlopen: on x/lib search x/bin if exe is in x/binnewlib-snapshot-20160923Michael Haubenwallner2016-09-081-1/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On 09/02/2016 11:03 AM, Corinna Vinschen wrote: > On Sep 2 10:46, Michael Haubenwallner wrote: >> On 09/01/2016 03:32 PM, Corinna Vinschen wrote: >>> You could just use the global variable program_invocation_name. If in >>> doubt, use the Windows path global_progname and convert it to full POSIX >>> via cygwin_conv_path. >> >> Patch updated, using global_progname now. > > Looks good and you're right to do it this way since I just noticed > that program_invocation_name may return a relative pathname. Yep. > Btw., in other calls which require the full POSIX path we use > mount_table->conv_to_posix_path instead of cygwin_conv_path (see > e. g. fillout_pinfo()). It's a bit faster. Maybe something for a > followup patch. No problem - attached. This renders the original patch 4/4 valid again. > Note for some later improvement: I really wonder why we don't store > the absolute POSIX path of the current executable globally yet... Same here. Thanks! /haubi/ >From f7255edd33cb4abe34f27188aab8dccdfa5dd2a0 Mon Sep 17 00:00:00 2001 From: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com> Date: Wed, 31 Aug 2016 18:05:11 +0200 Subject: [PATCH 3/4] dlopen: on x/lib search x/bin if exe is in x/bin citing https://cygwin.com/ml/cygwin-developers/2016-08/msg00020.html > Consider the file /usr/bin/cygz.dll: > - dlopen (libz.so) success > - dlopen (/usr/bin/libz.so) success > - dlopen (/usr/lib/libz.so) fails * dlfcn.c (dlopen): For dlopen("x/lib/N"), when the application executable is in "x/bin/", search for "x/bin/N" before "x/lib/N".
* dlopen (pathfinder): try each basename per dirMichael Haubenwallner2016-09-081-6/+6
| | | | | | | Rather than searching all search dirs per one basename, search for all basenames within per one search dir. pathfinder.h (check_path_access): Interchange dir- and basename-loops.
* dlopen: switch to new pathfinder classMichael Haubenwallner2016-09-083-109/+782
| | | | | | | | | | | | Instead of find_exec, without changing behaviour use new pathfinder class with new allocator_interface around tmp_pathbuf and new vstrlist class. * pathfinder.h (pathfinder): New file. * vstrlist.h (allocator_interface, allocated_type, vstrlist): New file. * dlfcn.cc (dlopen): Avoid redundant GetModuleHandleExW with RTLD_NOLOAD and RTLD_NODELETE. Switch to new pathfinder class, using (tmp_pathbuf_allocator): New class. (get_full_path_of_dll): Drop.
* Fix passwd getting error 1265 when running on newer WindowsCorinna Vinschen2016-08-311-0/+3
| | | | | | | | | | | | | On Windows 8.1 and later, the NetUserChangePassword call apparently doesn't accept the usual "\\server" string anymore, but requires to use the "domain" instead, otherwise it emits en error code 1265, ERROR_DOWNGRADE_DETECTED. Since this is accepted by pre-8.1 as well, use the domain indiscriminately when calling NetUserChangePassword from passwd(1). While at it, do some minor cleanup in passwd.c. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Add release message for commit 3d3ab82Yaakov Selkowitz2016-08-301-0/+3
| | | | Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
* Drop global __ctype_ptr__ entirely in favor of using locale_t::ctype_ptrCorinna Vinschen2016-08-251-4/+4
| | | | | | | | | | Keep __ctype_ptr__ available on Cygwin only, for backward compatibility with existing apps referencing it via the ctype macros. Otherwise initialize __global_locale.ctype_ptr and __C_locale.ctype_ptr and use them throughout. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix formattingCorinna Vinschen2016-08-251-5/+6
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix SetThreadName with current gdbJon Turney2016-08-251-1/+6
| | | | | | | | | | | Wrap SetThreadName()'s call to RaiseException() in __try/__except/__endtry, so that if the attached debugger doesn't know about MS_VC_EXCEPTION (e.g. current gdb and probably strace as well) and continues exception processing, we ignore it, rather than dying due an unhandled exception. Also remove an unnecessary cast in the RaiseException() invocation. Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>