summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Cywin: user profile: unload impersonation user profile on exitCorinna Vinschen2019-02-232-0/+6
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: seteuid: allow inheriting impersonation user profile handleCorinna Vinschen2019-02-231-1/+5
| | | | | | | The child process needs access to the handle to be able to unload it when switching user context. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: user profile: add debug output to unload_user_profileCorinna Vinschen2019-02-231-1/+4
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: user profile: Make an effort to unload unused user profilesCorinna Vinschen2019-02-236-3/+25
| | | | | | | | | Does this work? There's not much feedback given. TODO: We might want to try unloading the user profile at process exit as well, FWIW. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: cygheap: drop unnecessary code closing curr_primary_tokenCorinna Vinschen2019-02-231-4/+0
| | | | | | | curr_primary_token is either NO_IMPERSONATION or the external_token or the internal_token, so it's never required to be closed by itself. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: cygheap: better comment impersonation tokensCorinna Vinschen2019-02-231-6/+5
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: seteuid32: don't use INVALID_HANDLE_VALUECorinna Vinschen2019-02-231-2/+2
| | | | | | NULL is the natural state of an unused handle Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: user profile: fetch roaming profile path via LDAPCorinna Vinschen2019-02-233-21/+48
| | | | | | | | | | | | | | | Commit 649911fb40e45bc9a1ad8a3c28d90eec78c9cb7f avoids the calls to NetUserGetGroups and NetUserGetLocalGroups since these can take a lot of time. The same problem potentially occurs when loading the user profile. The code fetches the roaming profile path calling NetUserGetInfo, which also can be rather slow. To avoid this problem, fetch the profile patch using LDAP. Also, don't bail out early if the user's registry hive already exists. This may result in outdated information. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: get_user_groups: fetch a user's group list from identification tokenCorinna Vinschen2019-02-223-28/+67
| | | | | | | | | | | | | NetUserGetGroups and NetUserGetLocalGroups sometimes take a lot of time (up to more than 2 mins) for no apparent reason. Call s4uauth to generate an identification token for the user and fetch the group list from there. This is *much* faster. Keep the old code only for the sake of WOW64 on Vista and Windows 7, which don't implement MsV1_0S4ULogon. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: s4uauth: allow to be called for identification onlyCorinna Vinschen2019-02-224-16/+27
| | | | | | | | | | | s4uath was only callable to create an impersonation token so far. Rework the function to allow creating an identification token for informational purposes even from untrusted processes. Take domainname and username instead of a passwd pointer to be more multi-purpose. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: drop unused parameter from get_user_local_groupsCorinna Vinschen2019-02-221-3/+2
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: passwd/group: drop fetching case-correct group names from LDAPCorinna Vinschen2019-02-221-6/+1
| | | | | | | | | | | | | Commit 4e34a39b5cdf4c3f889486b7460bea063e579d10 made sure all user and group names are case-correct, but it introduced a hefty performance hit on starting the first Cygwin process. Adding an ldap call for each AD group in a user token takes its toll in bigger AD environments with lots of groups in a user token. Real-life example: 300 groups w/ roundtrip time to the LDAP server of 0.25 secs per call... Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* stdio: drop unused O_TEXT handling on non-CygwinCorinna Vinschen2019-02-221-4/+0
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: fetch local groups from local machineCorinna Vinschen2019-02-221-1/+8
| | | | | | ...even for domain accounts, otherwise local group membership is ignored. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: bump version to 3.0.2Corinna Vinschen2019-02-221-1/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: document secure_getenvcygwin-3_0_1-releaseYaakov Selkowitz2019-02-192-3/+5
| | | | Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
* Cygwin: add secure_getenvYaakov Selkowitz2019-02-195-1/+17
| | | | Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
* Cygwin: sys/mount.h: fix commentCorinna Vinschen2019-02-191-1/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Define u_register_t if __BSD_VISIBLESebastian Huber2019-02-191-0/+2
| | | | | | Add u_register_t definition for FreeBSD compatibility. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Change register_t definitionSebastian Huber2019-02-191-1/+1
| | | | | | On 64-bit targets, the register_t type must be a 64-bit integer. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Fix comment in <sys/types.h>Sebastian Huber2019-02-191-1/+1
| | | | Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Move RTEMS and XMK specific type definitionsSebastian Huber2019-02-193-16/+12
| | | | Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Cygwin: s4uauth: convert token to primary tokenCorinna Vinschen2019-02-181-0/+26
| | | | | | | | | Up to Vista CreateProcessAsUser only worked with primary tokens, so convert S4U impersonation token to primary token. MSDN still documents it that way, but actually an impersonation token is sufficient since Windows 7. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: re-enable create_token for older systemsCorinna Vinschen2019-02-185-29/+36
| | | | | | | | | Under WOW64 on 64 bit Windows 7, MsV1_0S4ULogon appears to be unimplemented, probably under Vista as well. Re-enable create_token method, to allow basic seteuid on W7 WOW64 and Vista as well. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: s4uauth: make sure to fetch correct package idCorinna Vinschen2019-02-181-9/+16
| | | | | | | | | | | | | | | | | for domain accounts we try KerbS4ULogon first, MsV1_0S4ULogon second. But we only fetch the package id for the supporting authentication package (Kerberos/MsV1_0) once at the start. Duplicate LsaLookupAuthenticationPackage call and move into the Kerb/MsV1_0 branches so that it fetches the correct package id for the method we call next. Curious enough this worked before. Apparently both methods work with the MICROSOFT_KERBEROS_NAME_A package id. However, requesting and using the right authentication package id is the prudent thing to do. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* CYgwin: bump API minor for MOUNT_BINARY -> MOUNT_TEXT changeCorinna Vinschen2019-02-181-1/+2
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: utils: MOUNT_BINARY -> MOUNT_TEXTCorinna Vinschen2019-02-182-9/+8
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Revert "Cygwin: passwd/group: allow specifying "." as local computername"Corinna Vinschen2019-02-181-9/+1
| | | | | | | | | | | | | This reverts commit 7c34811440be0bf1e749d9f075f54320c706cb4b. This potentially allows to circumvent OpenSSHs user/group name matching, unless the Admin knows to add every local user twice or to use patterns, e.g.: Match user MACHINE+user,.+user Match user *+user Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: mount: define binary mount as defaultCorinna Vinschen2019-02-184-31/+24
| | | | | | | | | | | | | | | | | | | | | | | | | Commit c1023ee353705671aa9a8e4e1179022277add2aa changed the way path_conv::binmode() works. Rather than returning three states, O_BINARY, O_TEXT, 0, it only returned 2 states, O_BINARY, O_TEXT. Since mounts are only binary if they are explicitely mounted binary by setting the MOUNT_BINARY flag, textmode is default. This introduced a new bug. When inheriting stdio HANDLEs from native Windows processes, the fhandler and its path_conv are created from a device struct only. None of the path or mount flags get set this way. So the mount flags are 0 and path_conv::binmode() returned 0. After the path_conv::binmode() change it returned O_TEXT since, as explained above, the default mount mode is textmode. Rather than just enforcing binary mode for path_conv's created from device structs, this patch changes the default mount mode to binary: Replace MOUNT_BINARY flag with MOUNT_TEXT flag with opposite meaning. Drop all explicit setting of MOUNT_BINARY. Drop local set_flags function, it doesn't add any value. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: mount: remove unused method mount_info::set_flags_from_win32_pathCorinna Vinschen2019-02-182-16/+0
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: utils: kill: revert erroneously removed optind correctionCorinna Vinschen2019-02-182-1/+7
| | | | | | | | When recognizing a negative pid, optind is off by one. The code correcting this has been erroneously removed by commit 8de660271fe75a6993f1c9888d24b824bb7f999d. Revert that. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: fork: add PROCESS_VM_OPERATION to child process permissionsCorinna Vinschen2019-02-182-1/+14
| | | | | | ...on parent process. This is required for successful mmap propagation. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: passwd/group: allow specifying "." as local computernameCorinna Vinschen2019-02-161-1/+9
| | | | | | | Convenience only. The resulting passwd/group antry is still fully qualified. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: bump version to 3.0.1Corinna Vinschen2019-02-161-1/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: passwd/group: store account name case correct, take 2cygwin-3_0_0-releaseCorinna Vinschen2019-02-131-18/+23
| | | | | | | | | | The solution from commit 9a3cc77b2afc52a2faa5e4daeb59dfd4506c0693 didn't work for foreign domain accounts. Rather than calling LookupAccountSid we now use the info when we fetch it anyway via LDAP or Net*GetInfo. Only in case of domain groups we have to add an LDAP call explicitly. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: ldap.cc: fix formattingCorinna Vinschen2019-02-131-3/+3
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: passwd/group: rename get_group_name to get_account_nameCorinna Vinschen2019-02-132-3/+2
| | | | | | The function is the same for user and grou accounts. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: passwd/group: raise local name buffer sizeCorinna Vinschen2019-02-131-1/+1
| | | | | | | | Make sure a domain+username fits into the local name buffer. The former buffer size didn't take adding a domain name to a really_really_long_user_name into account. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: passwd/group: store account name case correctCorinna Vinschen2019-02-132-0/+14
| | | | | | | | | | | | | When looking up valid accounts by name, LookupAccountName returns a SID and a case-correct domain name. However, the name was input and LookupAccountName is case-insensitive, so the name is not necessarily written the same way as in SAM or AD. Fix that by doing a reverse lookup on the just fetched SID. This fetches the account name in the correct case. Override the incoming name with the case correct name from LookupAccountSid. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: uinfo.cc: fix formattingCorinna Vinschen2019-02-131-16/+16
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: forkables: update doc, add release notesMichael Haubenwallner2019-02-113-11/+30
|
* AArch32: Fix the build for M class semihostingTamar Christina2019-02-111-1/+3
| | | | | | | | | | | | | | The M class cores don't support Semihosting v2 mixed mode, but we were accidentally using the new immediates for it. My last patch changed the immediates which broke the build because doing a full multi-lib build including M architectures now results in an assembler error instead of silently doing the wrong thing. This fixes the issue by changing the defines around such that According to the specs any M class build uses the normal semihosting instructions. Regtested on arm-none-eabi and no issues, using a build with m class multilibs too.
* Cygwin: disk device: stop using SetFilePointerCorinna Vinschen2019-02-091-3/+6
| | | | | | | This is a really old and crappy API, as the previous commit shows. Use NtQueryInformationFile(FilePositionInformation) here instead. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: execve: fix setting O_APPEND file offset for native childCorinna Vinschen2019-02-092-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | dtable::set_file_pointers_for_exec is called from child_info_spawn::worker to move the file position of O_APPEND files to EOF if the child is a native child. However, this only works correctly for the first O_APPEND file descriptor: - set_file_pointers_for_exec calls SetFilePointer. The higher 4 bytes of the desired file offset are given to SetFilePointer as pointer to a DWORD value. On return, SetFilePointer returns the higher 4 bytes of the new file position in this DWORD. - So for the second and subsequent descriptors the higher 4 byte of the file position depend on what the actual file position of the previous file has been set to: - If the file is > 2 Gigs, the high offset will not be 0 anymore. - If the desciptor points to a non-seekable file (i.e., a pipe or socket), SetFilePosition returns an error and sets the high position to -1. Fix this by calling SetFilePointerEx instead, which does not modify the incoming position value. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: change CURR_CHILD_INFO_MAGIC according to previous patchCorinna Vinschen2019-02-081-1/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: fix child getting another pid after spawnveCorinna Vinschen2019-02-084-9/+16
| | | | | | | | | | | | | | | | | | | When calling spawnve, in contrast to execve, the parent has to create the pid for the child. With the old technique this was simply the Windows pid, but now we have to inform the child about its new pid. Add a cygpid member to class child_info_spawn. Set it in child_info_spawn::worker, just prior to calling CreateProcess rather than afterwards. Overwrite cygheap->pid in child_info_spawn::handle_spawn before calling pinfo::thisproc. Make sure pinfo::thisproc knows the pid is already set by setting the handle argument to INVALID_HANDLE_VALUE. Also set procinfo->dwProcessId to myself_initial.dwProcessId instead of to myself_initial.pid for clarity. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* AArch32: Add support for HLT to Mixed Mode modelsTamar Christina2019-02-082-7/+13
| | | | | | | | | | | | | | | | | | | | | The Semihosting v2 protocol requires us to output the Armv8-a HLT instruction when in mixed mode (SEMIHOST_V2_MIXED_MODE), however it also requires this to be done for Armv7-a and earlier architectures. The HLT instruction is defined in the undefined encoding space for older architectures but simulators such as QEMU already trap on it [1] for all architectures and is a requirement for semihosting v2 [2]. Unfortunately the GAS restricts the use of HLT to Armv8-a which requires us to use the instruction encodings we want directly in crt0. This patch does this, I have not updated newlib/libc/* as that is quite out of date already. A proper sync is needed in order to get things back in sync. A different patch for this would be best. [1] https://github.com/qemu/qemu/commit/19a6e31c9d2701ef648b70ddcfc3bf64cec8c37e [2] https://developer.arm.com/docs/100863/latest/the-semihosting-interface
* forkables: hardlink without WRITE_ATTRIBUTES firstMichael Haubenwallner2019-02-071-24/+48
| | | | | | | | | | | | When the current process has renamed (to bin) a readonly dll, we get STATUS_TRANSACTION_NOT_ACTIVE for unknown reason when subsequently creating the forkable hardlink. A workaround is to open the original file with FILE_WRITE_ATTRIBUTES access, but that fails with permission denied for users not owning the original file. * forkable.cc (dll::create_forkable): Retry hardlink creation using the original file's handle opened with FILE_WRITE_ATTRIBUTES access when the first attempt fails with STATUS_TRANSACTION_NOT_ACTIVE.
* forkables: inline dll_list::forkables_supportedMichael Haubenwallner2019-02-076-12/+10
| | | | And LONG fits better for shared_info member forkable_hardlink_support.
* forkables: simplify disabling via shmMichael Haubenwallner2019-02-075-148/+65
| | | | | | | | | | | * Rename cygwin_shared->prefer_forkable_hardlinks to forkable_hardlink_support, with values 0 for Unknown, 1 for Supported, -1 for Unsupported. Upon first dll loaded ever, dll_list::forkable_ntnamesize checks the /var/run/cygfork directory to both exist and reside on NTFS, setting cygwin_shared->forkable_hardlink_support accordingly. * Replace enum forkables_needs by bool forkables_created: Set to True by request_forkables after creating forkable hardlinks.