shared_prefix depending only on terminal service capability.
* dcrt0.cc (dll_crt0_1): Don't call set_cygwin_privileges here.
* fhandler_fifo.cc (fhandler_fifo::open): Create the mutex as global
object.
* posix_ipc.cc (ipc_mutex_init): Use cygheap->shared_prefix.
(ipc_cond_init): Ditto.
* sec_helper.cc (privilege_name): Make static. Use LookupPrivilegeName
directly to be independent of the state of cygheap.
(set_privilege): Take a LUID as parameter instead of an index value.
Only print debug output in case of failure.
(set_cygwin_privileges): Add comment. Use LookupPrivilegeValue to
get privilege LUIDs.
(init_global_security): Call set_cygwin_privileges here.
* security.h (privilege_name): Drop declaration.
(set_privilege): Declare according to above change.
(set_process_privilege): Call privilege_luid to get LUID.
(_push_thread_privilege): Ditto.
* shared.cc (open_shared): Add comment. On systems supporting the
SeCreateGlobalPrivilege, try to create/open global shared memory first.
Fall back to local shared memory if that fails.
* thread.cc (semaphore::semaphore): Use cygheap->shared_prefix.
* wincap.h (wincapc::has_create_global_privilege): New element.
* wincap.cc: Implement above element throughout.
proc file content.
(format_proc_uptime): Simplify.
(format_proc_cpuinfo): Align more closely to output of Linux 2.6 kernel.
Evaluate more data, especially for AMD CPUs.
st_birthtim to useful value.
* fhandler_process.cc (fhandler_process::fstat): Ditto.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Take
additional parameter for creation time. Fill st_birthtim with it.
Accomodate additional creation time parameter throughout.
* fhandler_raw.cc (fhandler_dev_raw::fstat): Set new stat member
st_birthtim to useful value.
* fhandler.cc (fhandler_base::fstat): Ditto.
* fhandler_registry.cc (fhandler_registry::fstat): Ditto.
* include/cygwin/version.h: Bump API minor number.
* include/cygwin/stat.h (struct __stat64): Replace st_spare4 with
timestruc_t st_birthtim.
(struct stat): Ditto if __CYGWIN_USE_BIG_TYPES__ is defined.
(st_birthtime): Define if __CYGWIN_USE_BIG_TYPES__ is defined.
(cwdstuff::init): Don't call close_user_proc_parms_cwd_handle.
Call set to set cwd with all-sharing handle.
(cwdstuff::set): Fix comment. Don't close cwd handle. Set in
user parameter block instead and close old cwd handle.
* syscalls.cc (rename): Call unlink_nt instead of RemoveDirectory or
DeleteFile to allow deleting shared files/directories.
case of query_open flag set to query_read_control. Add case for
new query_read_attributes flag.
(fhandler_base::fstatvfs): New method.
* fhandler.h (enum query_state): Add query_read_attributes flag.
(class fhandler_base): Declare new virtual fstatvfs method.
(class fhandler_socket): Ditto.
(class fhandler_pipe): Ditto.
(class fhandler_fifo): Ditto.
(class fhandler_disk_file): Ditto.
(class fhandler_virtual): Ditto.
* fhandler_disk_file.cc (fhandler_base::fstat_fs): Open with
query_read_attributes instead of query_read_control.
(fhandler_disk_file::fstatvfs): New method.
(fhandler_disk_file::facl): Open with query_read_attributes instead of
query_read_control.
* fhandler_fifo.cc (fhandler_fifo::fstatvfs): New method.
* fhandler_socket.cc (fhandler_socket::fstatvfs): New method.
(fhandler_socket::fchmod): Return with EBADF in the default case.
(fhandler_socket::fchown): Ditto.
(fhandler_socket::facl): Ditto.
* fhandler_virtual.cc (fhandler_virtual::fstatvfs): Ditto.
* ntdll.h (struct _FILE_FS_ATTRIBUTE_INFORMATION): Define.
(struct _FILE_FS_FULL_SIZE_INFORMATION): Define.
* pipe.cc (fhandler_pipe::fstatvfs): New method.
* syscalls.cc (fstatvfs): Just call the fhandler's fstatvfs.
(statvfs): Ditto.
(fstatfs): Call fstatvfs.
(statfs): Drop EFAULT handling.
* mmap.cc (gen_access): Remove.
(mmap_record::gen_access): Remove.
(mmap64): Don't mention 9x any longer.
* syscalls.cc (statvfs): Drop status code consideration for 9x.
* libc/minires-os-if.c (get_registry_dns_items): Don't mention 9x any
longer.
(get_registry_dns): Drop getting registry key on 9x. Drop is9x
variable.
/dev/null, /dev/comX and /dev/ttySx.
* devices.cc: Regenerate.
* fhandler.cc (fhandler_base::open_9x): Remove.
(fhandler_base::open): Don't test for DOS device name, don't call
open_9x.
(fhandler_dev_null::open): Remove.
* fhandler.h (class fhandler_base): Drop open_9x declaration.
(class fhandler_dev_null): Drop open declaration.
* dir.cc (rmdir): Add existance check to be errno-compatible with Linux.
* fhandler_disk_file.cc (fhandler_disk_file::rmdir): Drop test for
non-existent dir on 9x share.
* syscalls.cc (unlink): Add comment.
* wincap.cc: Remove access_denied_on_delete flag throughout.
* wincap.h: Ditto.
Increase size of stack reserved and increase size before the current stack
pointer. Use pointers when doing arithmetic.
(dll_crt0_1): Initialize exception handler when we notice we're the child of a
fork from non-main thread.
* fork.cc (frok::parent): Make argument volatile.
(frok::child): Ditto.
(lock_signals): New class.
(lock_pthread): Ditto.
(hold_everhthing): Ditto.
(frok::parent): Move atforkprepare and atforkparent to lock_pthread class.
(fork): Make ischild boolean. Use hold_everything variable within limited
scope to set various mutexes in such a way as to avoid deadlocks.
* thread.h (pthread_mutex::tid): New variable, active when debugging for
tracking thread id of owner.
(pthread_mutex::set_owner): Set tid when debugging.
* thread.cc (pthread_mutex::pthread_mutex): Clear tid.
(pthread_mutex::_unlock): Ditto when unlocking.
(pthread_mutex::fixup_after_fork): Set tid to special value after forking since
owner is unknown.
the capabilities of NT4.
(wincap_95): Remove.
(wincap_95osr2): Remove.
(wincap_98): Remove.
(wincap_98se): Remove.
(wincap_me): Remove.
(wincap_nt3): Remove.
(wincapc::init): Temporarily bail out on any 9x system.
* posix_ipc.cc: Include thread.h and semaphore.h. Remove TODO
comment.
(ipc_names): Add max_len member. Set to maximum length of the path
before tacking on the prefix path. Set prefix path for named semaphors
to /dev/shm, as on Linux.
(enum ipc_type_t): Change sem to semaphore to avoid name conflicts.
(check_path): Detect empty paths. Use ipc_names's max_len member.
Use __small_sprintf to create full object path name. Special case
semaphores.
(ipc_cond_init): Drop superfluous strcpy.
(class ipc_flock): New class to simplify file locking in subsequent
code.
(struct mq_hdr): Raise size of mqh_uname to allow adding a unique
LUID to the name.
(mq_open): Fix formatting. Create unique synchronization object names
using AllocateLocallyUniqueId.
(struct sem_finfo): New structure defining named semaphore file content.
(sem_open): Move here. Rework implementation to allow kernel
persistent implementation of POSIX named semaphores.
(_sem_close): Implement sem_close.
(sem_close): Move here. Just call _sem_close with do_close parameter
set to true.
(sem_unlink): New function.
* pthread.cc (mangle_sem_name): Remove.
(sem_open): Move to posix_ipc.cc.
(sem_close): Ditto.
* syscalls.cc (close_all_files): Call semaphore::terminate here.
* thread.cc: Fix formatting. Rearrange semaphore functions so that
they are close together.
(semaphore::semaphore): Rework to play nicely with new named semaphore
implementation.
(semaphore::_terminate): Call _sem_close if semaphore is a named
semaphore.
(semaphore::destroy): Don't destroy named semaphores. Return EINVAL
instead.
(semaphore::close): Only destroy named semaphores. Return EINVAL
otherwise.
(semaphore::open): Rework to play nicely with new named semaphore
implementation. Loop through existing semaphores to be able to
return same sem_t pointer as a former call on the same named semaphore.
(semaphore::getinternal): New function called from _sem_close.
* thread.h (class List): Make mx and head public.
(class semaphore): Fix formatting. Align method declarations with
implementation in thread.cc. Add members used for named semaphores.
(semaphore::terminate): New static method.
* include/semaphore.h: Redefine SEM_FAILED. Fix formatting.
(sem_unlink): Add declaration.
* include/cygwin/version.h: Bump API minor number.
(ipc_cond_init): Ditto.
(struct mq_hdr): Add mqh_uname member to store synchronization object
name.
(mq_open): Create unique synchronization object name and store in
mq_hdr->mqh_uname. Use this name in calls to ipc_mutex_init and
ipc_cond_init.
(shm_unlink): Export.
* syscalls.cc (shm_open): New function.
(shm_unlink): New function.
* sysconf.cc (sca): Set value of _SC_SHARED_MEMORY_OBJECTS to
_POSIX_SHARED_MEMORY_OBJECTS.
* include/cygwin/version.h: Bump API minor number.
* include/sys/mman.h (shm_open): Add prototype.
(shm_unlink): Ditto.
baud rates up to 3000000 baud. Add missing 128K and 256K cases.
(fhandler_serial::tcgetattr): Ditto.
* include/sys/termios.h: Add baud rate definitions from B460800 up to
B3000000.
mapping addition.
(ga_clone): Just call ga_dup from here.
(ga_duplist): New function to duplicate list of struct addrinfo.
(ga_echeck): Don't check a_flags, it already happened in
cygwin_getaddrinfo.
(cygwin_freeaddrinfo): Always call ipv4_freeaddrinfo.
(cygwin_getaddrinfo): Use new wincap.supports_all_posix_ai_flags
flag rather than wincap.has_gaa_on_link_prefix. Always duplicate
WinSock's addrinfo list to a self-allocated list. Handle AI_V4MAPPED
for pre-Vista platforms supporting getaddrinfo.
* wincap.h (wincapc::supports_all_posix_ai_flags): New element.
* wincap.cc: Implement above element throughout.
* include/netdb.h: Note how AI_ADDRCONFIG is not supported pre-Vista.
Remove superfluous comment.
to debug output.
* syscalls.cc (try_to_bin): Enable code to move file to user specific
recycler dir to eliminate Vista problem.
(unlink_nt): Add comment that rename after opening for delete on close
only fails on XP.
on NT by calling unlink_nt. Check for directory here.
* syscalls.cc (try_to_bin): Fix buggy debug_printf statement.
(unlink_nt): Make non-static. Don't use delete-on-close semantics on
directoires. Explain why.
(SendARP): Define.
* cygwin.din: Export if_freenameindex, if_indextoname, if_nameindex and
if_nametoindex.
* fhandler_procnet.cc: Drop including wchar.h. Drop definitions of
GAA_FLAG_INCLUDE_ALL_INTERFACES, IP_ADAPTER_UNICAST_ADDRESS_VISTA.
(fhandler_procnet::exists): Check for has_gaa_prefixes. Call
get_adapters_addresses here.
(fhandler_procnet::readdir): Ditto.
(prefix): Move to net.cc.
(fhandler_procnet::fill_filebuf): Call get_adapters_addresses here.
Simplify allocation. Use AdapterName rather than FriendlyName as
interface name. Use IfIndex if available, Ipv6IfIndex otherwise.
(in6_are_prefix_equal): Move to net.cc.
* fhandler_socket.cc: Define old SIOCGxxx values.
(CONV_OLD_TO_NEW_SIO): Convert old SIOCGxxx value to new one.
(struct __old_ifreq): Define old struct ifreq.
(fhandler_socket::ioctl): Handle old SIOCGxxx values. Handle new
SIOCGIFFRNDLYNAM command. Simplify copying ifreq data to user space.
Call get_ifconf with additional SOCKET parameter.
* net.cc (IP_ADAPTER_UNICAST_ADDRESS_LH): Define.
(IP_ADAPTER_ADDRESSES_LH): Define.
(SIO_GET_INTERFACE_LIST): Define.
(sockaddr_in6_old): Define.
(sockaddr_gen): Define.
(INTERFACE_INFO): Define.
(IN_LOOPBACK): Define.
(in_are_prefix_equal): New static function.
(ip_addr_prefix): New function, replaces prefix function, add AF_INET
handling.
(GAA_FLAG_INCLUDE_ALL_INTERFACES): Define.
(get_adapters_addresses): New function.
(WS_IFF_xxx): Define Winsock interface flag values.
(convert_ifr_flags): New function to convert Winsock interface flag
values to Cygwin interface flag values.
(get_xp_ifconf): New get_ifconf implementation for XP SP1 and above.
(get_2k_ifconf): Fix interface index. Fix formatting.
(get_nt_ifconf): Fix formatting.
(get_95_ifconf): Ditto.
(get_ifconf): Take additional SOCKET parameter. Call get_xp_ifconf
on XP SP1 and above.
(if_nametoindex): New function.
(if_indextoname): New function.
(if_nameindex): New function.
(if_freenameindex): New function.
(in6_are_prefix_equal): Moved here from fhandler_procnet.cc.
* wincap.cc (wincap_xp): Define has_gaa_prefixes as true by default.
(wincapc::init): Assume has_osversioninfoex by default. Call
GetVersionEx with OSVERSIONINFOEX first. Call with OSVERSIONINFO only
if that fails. Simplify NT4 case and try to avoid strcmp. Check XP
Service Pack using version.wServicePackMajor to avoid strcmp.
* include/asm/socket.h (SIOCGIFFRNDLYNAM): Define.
* include/cygwin/if.h: Fix formatting.
(IFF_POINTTOPOINT): Define.
(IFF_NOARP): Define.
(IFF_LOWER_UP): Define.
(IFF_DORMANT): Define.
(struct if_nameindex): Define.
(IFRF_FRIENDLYNAMESIZ): Define.
(struct ifreq_frndlyname): Define.
(IFNAMSIZ): Redefine as 44.
(IF_NAMESIZE): Define.
(struct ifreq): Redefine ifru_flags as int. Define ifru_data. Pad size
to sizeof sockaddr_in6 for further extensions.
(ifr_data): Define.
(ifr_frndlyname): Define.
(if_nametoindex): Declare.
(if_indextoname): Declare.
(if_nameindex): Declare.
(if_freenameindex): Declare.
* include/cygwin/version.h: Bump API minor number.
(CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ): Define check for old vs. new
ifreq structure.
(list::get_hash): Ditto.
(list::set): Add struct stat parameter. Use that instead of calling
fstat.
(map::get_list_by_fd): Ditto.
(map::add_list): Ditto.
(mmap_is_attached_or_noreserve): Call get_list_by_fd appropriately.
(mmap_worker): Add pameters for map list and file stat information.
Propagate to called functions.
(mmap64): Use fstat on files early. Replace call to GetFileSize.
Call get_list_by_fd and mmap_worker appropriately.
(RtlOemStringToUnicodeString): Define.
* ntdll.h (struct _RTL_USER_PROCESS_PARAMETERS): Define.
(struct _PEB): Redefine with a bit of content.
(RtlAnsiStringToUnicodeString): Declare.
(RtlOemStringToUnicodeString): Declare.
* path.cc: Include ntdll.h.
(_upp): New global variable pointing to user process parameter block.
(get_user_proc_parms): New static function to retrieve user process
parameter block.
(close_user_proc_parms_cwd_handle): New function to close handle to
current working directory in user process parameter block.
(cwdstuff::init): Drop redundant declaration of dynamically_loaded.
Set current dir only on 9x. Call close_user_proc_parms_cwd_handle
on NT instead.
(cwdstuff::keep_in_sync): Only on 9x.
(cwdstuff::set): Keep behaviour on 9x. On NT write cwd path into user
process parameter block and set cwd handle to NULL. Fix comments to
reflect new behaviour.
* net.cc (get_2k_ifconf): Ditto.
(get_nt_ifconf): Fake SIOCGIFINDEX.
(get_95_ifconf): Ditto.
(get_ifconf): Handle SIOCGIFINDEX. Fake it for loopback on systems
not supporting IP Helper Lib.
* include/asm/socket.h (SIOCGIFINDEX): Define.
* include/cygwin/if.h (struct ifreq): Add member for interface index.
(ifr_ifindex): Define.
* sec_acl.cc (setacl): Ditto. Set to true if any ACE with write
permissions is created.
* fhandler_disk_file.cc (fhandler_disk_file::facl): Reset
FILE_ATTRIBUTE_READONLY if ACL contains an ACE with write permissions.
for SIOCGIFFLAGS here. Call get_ifconf instead.
* net.cc (get_2k_ifconf): Clean up code to generate interface name.
Handle SIOCGIFFLAGS here.
(get_nt_ifconf): Fake SIOCGIFFLAGS here.
(get_95_ifconf): Ditto.
(get_ifconf): Don't fake loopback on systems with IP Helper Lib.
Set MTU for loopback to a more "modern" value.
user information on NT4.
* sec_helper.cc (security_descriptor::malloc): Drop LocalAlloc
considerations.
(security_descriptor::realloc): Ditto.
(security_descriptor::free): Ditto.
* security.cc (get_reg_security): Reinstantiate.
(get_nt_object_security): Revert to using NtQuerySecurityObject.
* security.h (class security_descriptor): Drop type member.
Accommodate throughout.
(security_descriptor::size): Constify.
(security_descriptor::copy): Ditto.
impersonation token, which collides with Vista UAC.
* cygheap.h (deimpersonate): revert to self instead of impersonating
hProcImpToken.
(reimpersonate): Only impersonate if setuid.
* dcrt0.cc (dll_crt0_0): Don't initialize hProcImpToken here.
(dll_crt0_1): Set privileges on hProcToken.
* fork.cc (frok::child): Set privileges on hProcToken. Close handle to
hProcImpToken.
* grp.cc (internal_getgroups): Use hProcToken instead of hProcImpToken.
* security.cc (check_access): Create hProcImpToken on demand here.
* security.h (set_process_privilege): Set privileges on hProcToken.
(_push_thread_privilege): Use hProcToken instead of hProcImpToken.
(pop_thread_privilege): If not setuid'ed, revert to self.
* syscalls.cc (setegid32): Drop setting primary group on hProcImpToken.
Close handle to hProcImpToken.
* uinfo.cc (internal_getlogin): Ditto.
* winsup.h (clear_procimptoken): New inline function.
(SUBLIBS): Add libresolv.a.
Add rule for libresolv.a.
* autoload.cc: Fix return code handling for IP Helper API in case
of being unable to load iphlpapi.dll.
(DnsQuery_A): Define.
(DnsRecordListFree): Define.
* cygwin.din: Export resolver functions.
* include/resolv.h: New header.
* include/arpa/nameser.h: New header.
* include/arpa/nameser_compat.h: New header.
* include/cygwin/version.h: Bump API minor number.
* libc/minires-os-if.c: New file.
* libc/minires.c: New file.
* libc/minires.h: New file.
(child_info_spawn::__stdin): Ditto.
(CURR_CHILD_INFO_MAGIC): Regenerate.
* dcrt0.cc (check_sanity_and_sync): Minor cleanup.
(child_info_spawn::handle_spawn): Handle new __std* elements by calling
move_fd.
* dtable.cc (dtable::move_fd): Define new function.
* dtable.h (dtable::move_fd): Declare new function.
* fhandler.h (fhandler_pipe::popen_pid): Declare new element.
* fhandler.h (fhandler_pipe::get_popen_pid): Define new function.
* fhandler.h (fhandler_pipe::set_popen_pid): Ditto.
* pipe.cc (fhandler_pipe::fhandler_pipe): Zero popen_pid.
(fhandler_pipe::dup): Ditto.
* spawn.cc (handle): Change second argument to bool.
(spawn_guts): Accept __stdin/__stdout arguments and set them appropriately in
child_info structure and in STARTUPINFO structure.
* syscalls.cc (popen): New cygwin-specific implementation using spawn.
(pclose): Ditto.
* winsup.h (spawn_guts): Accommodate new arguments for spawn_guts.
* fhandler.cc (fhandler_base::set_no_inheritance): Make second arg a bool.
* fhandler.h (fhandler_base::set_no_inheritance): Ditto for declaration.
* child_info.h (child_info::msv_count): Rename from the now-inappropriate
"zero".
(child_info_spawn::filler): Add filler to work around Vista bug.
(child_info_fork::filler): Ditto.
* dcrt0.cc (get_cygwin_startup_info): Remove "zero" check since it is now
always filled out.
* fork.cc (frok::parent): Move ch.zero manipulation to constructor.
* spawn.cc (spawn_guts): Ditto. Remove _ch wrapper.
* sigproc.cc (child_info::child_info): Initialize starter[].
* shared.cc (shared_info::heap_slop_size): Remove noisy system_printfs.
* shared_info.h (CURR_SHARED_MAGIC): Regenerate.
* ntdll.h (struct _FILE_RENAME_INFORMATION): Define.
* path.cc (fs_info::update): Note length of rootdir prefix in
root_len.
(get_nt_native_path): New function, taking over functionality of
path_conv::get_nt_native_path.
(path_conv::get_nt_native_path): Just call get_nt_native_path.
* path.h (get_nt_native_path): Declare.
(struct fs_info): New member root_len.
(fs_info::length): New inline method returning root_len.
(path_conv::rootdir): New inline method returning rootdir prefix.
* syscalls.cc (try_to_bin): Rewrite using only system calls.
(unlink_nt): Call try_to_bin with additional handle to open file
parameter.
(statvfs): Use path_conv::rootdir method.
* wincap.h: Define has_recycle_dot_bin throughout.
* wincap.cc: Ditto.
(struct _FILE_DISPOSITION_INFORMATION): Define.
* syscalls.cc (unlink_9x): new function to delete file on 9x.
* syscalls.cc (unlink_nt): new function to delete file on NT.
(unlink): Simplify. Move OS dependent stuff into aforementioned
functions. Also handle FILE_ATTRIBUTE_HIDDEN as R/O-like flag.
* syscalls.cc (try_to_bin): New function trying to move a file to
the recycle bin.
(unlink): Fix arguments used in CreateFile for delete on close.
Before closing the handle, try to move the file to the recycle bin.
"keep_in_sync" methods.
* external.cc (cygwin_internal): Call above keep_in_sync method when
CW_SYNC_WINENV is requested.
* path.cc (cwdstuff::init): Don't change to windows_system_directory
if keep_in_sync is requested.
(cwdstuff::keep_in_sync): New method.
(cwdstuff::set): Take sync flag into account.
Expect first DWORD in child_info struct being set to non-zero if
wincap.needs_count_in_si_lpres2 is set. Add comment to explain why.
* fork.cc (frok::parent): Set ch.zero[0] to a sensible count value
if wincap.needs_count_in_si_lpres2 is set.
* spawn.cc (spawn_guts): Ditto. Add filler bytes after ch on stack
to accomodate needs_count_in_si_lpres2.
* wincap.h: Define needs_count_in_si_lpres2 throughout.
* wincap.cc: Ditto.
(rmdir): Don't check last path component for "..".
* fhandler_disk_file.cc (fhandler_disk_file::rmdir): Drop kludge
which tries to allow deleting the current working directory.
* path.cc (has_dot_last_component): Add parameter to indicate testing
for "..". Take trailing slash into account.
(symlink_info::posixify): Rely on cygheap->cwd.win32 having a
useful value.
(cwdstuff::init): Initialize cygheap->cwd with current working
directory. Change to windows_system_directory afterwards.
(cwdstuff::set): Never call SetCurrentDirectory here. Just check
if changing into target directory would be allowed. Add comment to
explain why.
* path.h (has_dot_last_component): Declare with second parameter.
* pinfo.cc (pinfo::zap_cwd): Remove.
(pinfo::exit): Drop call to zap_cwd.
* pinfo.h (class pinfo): Remove declaration of zap_cwd.
* spawn.cc (spawn_guts): Set current working directory for non-Cygwin
child applications. Drop call to zap_cwd.
* environ.cc: Disable subauth settings.
* grp.cc: Accomodate cygsidlist's count now being a method.
* sec_helper.cc (SECURITY_MANDATORY_INTEGRITY_AUTHORITY): Remove.
(mandatory_medium_integrity_sid): Remove.
(mandatory_high_integrity_sid): Remove.
(mandatory_system_integrity_sid): Remove.
(fake_logon_sid): Add.
(cygsid::get_sid): Add well_known parameter. Set well_known_sid
accordingly.
(cygsid::getfromstr): Ditto.
(cygsidlist::alloc_sids): Move here from security.cc.
(cygsidlist::free_sids): Ditto.
(cygsidlist::add): Move here from security.h. Add well_known parameter.
Set well_known_sid accordingly. Don't allow duplicate SIDs.
* security.cc: Include cyglsa.h and cygwin/version.h. Throughout
accomodate cygsidlist's count now being a method. Throughout drop
redundant "contains" tests.
(get_user_local_groups): Add local groups as well known SIDs.
(get_token_group_sidlist): Add well known groups as well known SIDs.
(get_server_groups): Ditto. Only call get_unix_group_sidlist after
get_user_local_groups to maintain "well_known_sid" attribute.
(get_initgroups_sidlist): Add well known groups as well known SIDs.
(get_setgroups_sidlist): Add usersid and struct passwd parameter to
allow calling get_server_groups from here.
(get_system_priv_list): Make static. Return size of TOKEN_PRIVILEGES
structure.
(get_priv_list): Ditto.
(create_token): Accomodate above changes. Drop misguided attempt to
add MIC SIDs to created user token. Print returned token as hex value.
(subauth): Disable.
(lsaauth): New function implementing client side of LSA authentication.
* security.h (class cygsid): Add well_known_sid attribute. Accomodate
throughout. Add *= operator to create a well known SID.
(class cygsidlist): Rename count to cnt. Make count a method.
(cygsidlist::add): Move to sec_helper.cc.
(cygsidlist::operator *=): New method to add well known SID.
(cygsidlist::non_well_known_count): New method returning number of
non well known SIDs in list.
(cygsidlist::next_non_well_known_sid): New method returning next non
well known SID by index.
(mandatory_medium_integrity_sid): Drop declaration.
(mandatory_high_integrity_sid): Drop declaration.
(mandatory_system_integrity_sid): Drop declaration.
(fake_logon_sid): Add declaration.
(subauth): Disable declaration.
(lsaauth): Add declaration.
* syscalls.cc (seteuid32): Disable subauthentication. Add LSA
authentication.
* wincap.h: Define needs_logon_sid_in_sid_list throughout.
* wincap.cc: Ditto.
Change FS_IS_SAMBA and FS_IS_SAMBA_WITH_QUOTA and their usage
accordingly. Define FS_IS_NETAPP_DATAONTAP. Recognize NetApp device
and store in is_netapp flag. Mark NetApp device as having no good
inodes.
* path.h (struct fs_info): Add is_netapp flag. Add matching accessors.
* security.cc (create_token): Drop grps_buf. Use alloca instead.
Only add the MIC SID to the TOKEN_GROUPS list for the NtCreateToken
call. If the subauthentication token exists, use its MIC SID.
Set SID Attributes for the MIC SID to 0.
(well_known_this_org_sid): New well known sid.
(SECURITY_MANDATORY_INTEGRITY_AUTHORITY): Define.
(mandatory_medium_integrity_sid): New well known sid.
(mandatory_high_integrity_sid): Ditto.
(mandatory_system_integrity_sid): Ditto.
(cygsid::get_sid): Use local SID_IDENTIFIER_AUTHORITY. Allow all
authorities fitting in a UCHAR.
* security.cc (get_token_group_sidlist): Always add the local
group to the token. Add comment. Add "This Organization" group
if available in incoming group list.
(get_server_groups): Only add world and authenticated users groups
if not already in list.
(create_token): Add matching mandatory integrity SID to group list
on systems supporting Mandatory Integrity Control.
* security.h (well_known_this_org_sid): Define.
(mandatory_medium_integrity_sid): Define.
(mandatory_high_integrity_sid): Define.
(mandatory_system_integrity_sid): Define.
* wincap.h: Define has_mandatory_integrity_control throughout.
* wincap.cc: Ditto.
paths in symlinks to POSIX.
(symlink_info::check_shortcut): Allocate buf allowing for a trailing 0.
Call posixify on the result.
(symlink_info::check_sysfile): Read from file into local buffer.
Eliminate old b16 considerations. Call posixify on the result.
(symlink_info::check_reparse_point): Don't use PrintName but
SubstituteName which is relevant for Windows' path handling.
Call posixify on the result.
* sec_helper.cc (security_descriptor::malloc): Use own free method.
Set type.
(security_descriptor::realloc): Handle the case that psd has been
allocated using LocalAlloc. Set type.
(security_descriptor::free): Ditto.
* security.cc (get_nt_attribute): Remove.
(get_reg_security): Remove.
(get_nt_object_security): Use GetSecurityInfo which handles all
securable objects.
(get_nt_object_attribute): Remove.
(get_object_attribute): Call get_nt_object_security instead of
get_nt_object_attribute.
(get_file_attribute): Ditto.
(check_registry_access): Call get_nt_object_security instead of
get_reg_security.
* security.h (cygpsid::operator PSID): Make method const, not the
result.
(class security_descriptor): Add type member. Accomodate throughout.
(security_descriptor::copy): New method.
(security_descriptor::operator PSECURITY_DESCRIPTOR *): New operator.
actually created a handle. This handles the registry root dir.
* fhandler_registry.cc (fhandler_registry::open): Set io_handle in
case of opening one of the predefined registry keys.
for registry keys/values if ntsec is on.
* security.cc (check_access): New static function derived from
check_file_access, but object type agnostic.
(check_file_access): Only do file specific stuff. Call check_access.
(check_registry_access): New access check function for registry keys/
values.
* security.h (check_registry_access): Declare.
(class fhandler_registry): Add wow64 and prefix_len members.
Declare set_name method.
* fhandler_proc.cc (PROC_REGISTRY32): Define.
(PROC_REGISTRY64): Define.
(proc_listing): Add "registry32" and "registry64" elements.
(proc_fhandlers): Add corresponding FH_REGISTRY values.
* fhandler_registry.cc (registry_len): Drop static value in favor of
class member prefix_len. Use preifx_len instead of registry_len
throughout.
(fhandler_registry::set_name): Define. Set wow64 and prefix_len
according to directory prefix.
(fhandler_registry::fhandler_registry): Set wow64 and prefix_len to
default values.
(open_key): Add wow64 argument. Handle wow64 in call to RegOpenKeyEx.
Use fhandler_registry member wow64 in this place throughout.
* glob.cc: New file. Latest glob version from FreeBSD plus Cygwin
specific changes (__stat64/__stat32, ignore_case_with_glob,
drop collate functions).
(glob3): Return GLOB_ABORTED in case directory is unreadable and
GLOB_ERR is set, as demanded by SUSv3.
* glob.h: Import latest version from FreeBSD.
(Wow64RevertWow64FsRedirection): Define.
* security.cc (cygsuba_installed): New shared variable to store result
of cygsuba.dll installation test.
(subauth): Check if cygsuba.dll has been installed and registered
before issuing the (sub)authentication.
allocated arrays. Add max_w4 member to keep track.
(thread_socket): Make timeout depending on number of sockets to wait
for. Loop WFMO over all sockets.
(start_thread_socket): Handle any number of sockets. Fix typo. Don't
close socket event in out of memory condition.
(socket_cleanup): Free ser_num and w4.
(mount_info::conv_to_win32_path): Update comment.
* fhandler_disk_file.cc (path_conv::ndisk_links): Use backslashes
to make NT kernel functions work for \\?\GLOBALROOT paths.
performance on remote shares.
(fhandler_disk_file::opendir): Move comment about Samba weirdness into
fhandler_disk_file::readdir. Don't disallow
FileIdBothDirectoryInformation on Samba.
(fhandler_disk_file::readdir): Workaround Samba problem with
FileIdBothDirectoryInformation by rereading already read entries
using FileBothDirectoryInformation. Change comment about Samba
weirdness explaining this change.
vmin_ > ulen case into account. Simplify evaluating the bytes to read.
Don't use bytes in Queue value from ClearCommError call in case vtime_
is > 0. Reformat GetOverlappedResult call. Simplify call to ReadFile.
(SetHandleInformation): Ditto.
* debug.cc (add_handle): Use SetHandleInformation to protect handle.
(close_handle): Use SetHandleInformation to unprotect handle.
* spawn.cc (spawn_guts): Move detached test outside of P_OVERLAY block.
(conv_envvars): Use env_win32_to_posix_path_list rather than
cygwin_win32_to_posix_path_list.
(posify): Translate back to win32 path if errno is EIDRM.
* environ.h: Update copyright. Define ENV_CVT.
* path.cc (conv_path_list): If converting for the environment and removed an
element set errno to ENV_CVT.
(env_win32_to_posix_path_list): New function.
with poll(2) after shutdown(SHUT_RD) has been called on the local side.
* poll.cc (poll): Use POSIX type nfds_t for second parameter. Drop
special socket handling for POLLIN. Add comment to explain why.
* include/sys/poll.h: Declare nfds_t. Use as type for second parameter
in poll(2) declaration.
potential race condition.
(fhandler_socket::recv_internal): Fix MSG_PEEK bug on blocking sockets
and simplify recv loop.
(fhandler_socket::send_internal): Only lock when changing wsock_events.
(class fhandler_socket): Make wsock_evt private again.
(fhandler_socket::wsock_event): New read accessor for wsock_evt.
(fhandler_socket::serial_number): New read accessor to get the
socket's serial number.
(fhandler_socket::ready_for_read): Just return true.
* fhandler_socket.cc (struct wsa_event): Move definition to fhandler.h.
* select.cc (struct socketinf): Add serial number vector.
(start_thread_socket): Identify duplicate sockets by their serial
number, not (wrongly) by their wsock_evt.
conditions in evaluate_events.
(search_wsa_event_slot): Move wrongly placed memset in
fhandler_socket::init_events here.
(fhandler_socket::init_events): Initially set FD_WRITE event for
connectionless sockets.
* poll.cc (poll): Don't add sockets always to except_fds since select
is now supposed to do it right.
* select.cc (set_bits): Set connection state correctly for failed
af_local_connect on local sockets. Remove socket special handling
for except_selected descriptors.
(peek_socket): Try to set the read/write/exception bits actually
correctly.
(fhandler_socket::fixup_before_fork_exec): Remove.
(fhandler_socket::fixup_after_exec): Remove.
(fhandler_socket::need_fixup_before): Remove.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Drop
initializing prot_info_ptr. Remove unused code.
(fhandler_socket::~fhandler_socket): Drop free'ing prot_info_ptr.
(struct wsa_event): Rename connect_errorcode to errorcode.
(fhandler_socket::evaluate_events): Handle FD_CLOSE error condition
as FD_CONNECT error condition, except, never reset an FD_CLOSE error
condition. Always set FD_WRITE after successfully recorded FD_CONNECT.
(fhandler_socket::fixup_before_fork_exec): Remove.
(fhandler_socket::fixup_after_fork): Revert to using handle duplication.
(fhandler_socket::fixup_after_exec): Remove.
(fhandler_socket::dup): Revert to using handle duplication.
(fhandler_socket::send_internal): Only call wait_for_events in case
of WSAEWOULDBLOCK condition.
(fhandler_socket::set_close_on_exec): Call
fhandler_base::set_close_on_exec.
* net.cc (fdsock): Just set socket to inheritable on non-NT. Don't
call inc_need_fixup_before.
* select.cc (peek_socket): Don't set except_ready on every FD_CLOSE,
just on error.
* fhandler_tape.cc (mt): Define as DLL shared area in
.cygwin_dll_common instead of as dynamically allocated area.
Change referencing throughout.
* mtinfo.h (mt_h): Remove entirely.
(mt): Remove extern declaration.
* shared.cc (cygwin_shared_area): New global cygwin_shared
variable located in .cygwin_dll_common.
(offsets): Define shared region addresses descending from
cygwin_shared_address.
(open_shared): Replace usage of SH_CYGWIN_SHARED by SH_USER_SHARED.
(memory_init): Set cygwin_shared just by pointing to cygwin_shared_area.
* shared_info.h (shared_locations): Remove SH_CYGWIN_SHARED and
SH_MTINFO.
(cygwin_shared_address): Define as DLL start address.
* tty.h (tty_min::tty_min): Remove constructor.
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
non-private mappings.
(mmap_record::unmap_pages): Only check noreserve flag which now implies
anonymous and private.
(mprotect): Ditto.
(fixup_mmaps_after_fork): Ditto.
mmap_is_attached_or_noreserve_page function in case of access violation
and allow application to retry access on noreserve pages.
* mmap.cc (mmap_is_attached_or_noreserve_page): Changed from
mmap_is_attached_page. Handle also noreserve pages now. Change
comment accordingly.
* winsup.h (mmap_is_attached_or_noreserve_page): Declare instead of
mmap_is_attached_page.
(putmem): Make static.
(get_export): Ditto.
(rvadelta): Ditto. Don't assume that a section which ends where the import_rva
begins is the import list.
* child_info.h: Update copyright.
* fork.cc: Ditto.
at this point anyway.
(get_symlink_ea): Remove.
(set_symlink_ea): Remove.
(symlink_worker): Drop writing symlink into NTFS extended attributes.
(symlink_info::check): Drop reading symlinks from NTFS extended
attributes.
(NtSetEaFile): Define.
* fhandler.cc (fhandler_base::open): Use appropriate open flags
in query case when allow_ntea is set.
* ntdll.h (struct _FILE_GET_EA_INFORMATION): Define.
(struct _FILE_FULL_EA_INFORMATION): Define.
(NtQueryEaFile): Declare.
(NtSetEaFile): Declare.
* ntea.cc (read_ea): Rename from NTReadEA and rewrite using
NtQueryEaFile.
(write_ea): Rename from NTWriteEA and rewrite using NtSetEaFile.
* path.cc (get_symlink_ea): Make static. Add handle parameter to
accomodate new read_ea call.
(set_symlink_ea): Make static. Add handle parameter to accomodate new
write_ea call.
(symlink_worker): Call set_symlink_ea while file is still open.
(symlink_info::check): Call get_symlink_ea after file has been opened.
* security.cc (get_file_attribute): Accomodate new read_ea call.
(set_file_attribute): Accomodate new write_ea call.
* security.h (read_ea): Change declaration accordingly.
(write_ea): Ditto.
current meta key mode.
* fhandler_console.cc (fhandler_console::read): Set the top bit of
the character if metabit is true.
* fhandler_console.cc (fhandler_console::ioctl): Implement
KDGKBMETA and KDSKBMETA commands.
* fhandler_tty.cc (process_ioctl): Support KDSKBMETA.
(fhandler_tty_slave::ioctl): Send KDGKBMETA and KDSKBMETA to the
master.
* include/cygwin/kd.h: New file for the meta key mode.
* include/sys/kd.h: New file.
accept and connect back to using select:
* fhandler.h (class fhandler_socket): Remove accept_mtx.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Drop
initializing accept_mtx.
(fhandler_socket::accept): Drop event handling.
(fhandler_socket.cc (fhandler_socket::connect): Ditto.
(fhandler_socket::dup): Drop accept_mtx handling.
(fhandler_socket::listen): Ditto.
(fhandler_socket::prepare): Ditto.
(fhandler_socket::release): Ditto.
(fhandler_socket::close): Ditto.
* net.cc (cygwin_accept): Revert to calling cygwin_select to
implement interuptible accept.
(cygwin_connect): Ditto for connect.
system-wide mutex to prevent a deadlock and a race.
* sync.h (lock_process): Make fhandler_fifo a friend.
* smallprint.c (__small_vsprintf): Cosmetic change.
accept_mtx.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize
accept_mtx to NULL.
(fhandler_socket::dup): Duplicate accept_mtx, if available.
(fhandler_socket::listen): Create accept_mtx before trying to listen.
(fhandler_socket::prepare): Wait for accept_mtx if available to
serialize accepts on the same socket.
(fhandler_socket::release): Release accept_mtx.
(fhandler_socket::close): Close accept_mtx on successful closesocket.
thread being terminated rather than thread doing terminating.
* fhandler.h (fhandler_pty_master::slave): Delete.
(fhandler_pty_master::get_unit): Ditto.
(fhandler_pty_master::setup): Change argument declaration to accommodate new
usage.
* fhandler_tty.cc (fhandler_tty_master::init): Remove obsolete slave
assignment. Pass argument to setup indicating that this is a tty.
(fhandler_tty_slave::open): Use dev() method rather than referencing pc.dev
directly.
(fhandler_pty_master::open): Don't create archetype based on ptym device
number. Set device number to use DEV_TTYM_MAJOR and tty number. Pass argument
to setup indicating that this is a pty.
(fhandler_pty_master::setup): Change single argument to a flag indicating
whether we're creating a pty and use appropriately. Calculate 't' variable
here rather than in caller.
* fhandler_dsp.cc (fhandler_dev_dsp::open): Use dev() method rather than
referencing pc.dev directly.
(dll_crt0_1): Reflect renaming from tty_init to tty::init_session.
(do_exit): Reflect moving of tty_terminate into tty_list.
* exceptions.cc (events_init): Move tty_mutex stuff elsewhere.
* fhandler_console.cc (set_console_title): Use lock_ttys class.
* fhandler_termios.cc (fhandler_termios::bg_check): Make debug output more
accurate.
* fhandler_tty.cc (fhandler_tty_slave::open): Reflect move of attach_tty into
tty_list class. Don't attempt to grab master end of pty if master doesn't
exist.
(fhandler_pty_master::open): Reflect move of allocate_tty into tty_list class.
Use lock_ttys::release to release mutex. Improve debugging output.
(fhandler_pty_master::setup): Remove if 0'ed block. Fix argument to
SetNamedPipeHandleState.
* pinfo.cc (_pinfo::set_ctty): Lock ttys before setting sid/pgid. Improve
debugging. Add temporary debugging.
* tty.cc (tty_list::init_session): New function.
(tty::init_session): Rename from tty_init. Reflect move of attach_tty to
tty_list class.
(tty::create_master): Rename from create_tty_master.
(tty_list::attach): Rename from attach_tty. Reflect renaming of connect_tty to
connect. Ditto for allocate_tty.
(tty_terminate): Delete.
(tty_list::terminate): Subsume tty_terminate. Use lock_ttys rather than
manipulating mutex directly.
(tty_list::allocate): Rename from allocate_tty. Use lock_ttys rather than
manipulating mutex directly. Don't set sid here since linux apparently doesn't
do this. Reflect move of create_tty_master into tty.
(lock_ttys::lock_ttys): Define new constructor.
(lock_ttys::release): New function.
* tty.h (tty::exists): Return false immediately if !master_pid.
(tty::set_master_closed): Define new function.
(tty::create_master): Ditto.
(tty::init_session): Ditto.
(tty_list::mutex): New field.
(tty_list::allocate): Define new function.
(tty_list::connect): Ditto.
(tty_list::attach): Ditto.
(tty_list::init_session): Ditto.
(lock_ttys): New class.
(tty_init): Delete declaration.
(tty_terminate): Ditto.
(attach_tty): Ditto.
(create_tty_master): Ditto.
own them.
(fhandler_pty_master::setup): Make sure that original handle is closed when
changing inheritance.
(fhandler_pty_master::fixup_after_fork): Set from_master/to_master to arch
value always.
(fhandler_pty_master::fixup_after_exec): Clear from_master/to_master when
close_on_exec.
* dcrt0.cc (child_info_spawn::handle_spawn): Signal ready after we've run
fixup_after_exec.
* dtable.cc (dtable::fixup_after_exec): Add debugging output.
* fhandler_tty.cc (fhandler_pty_master::doecho): Use class version of
to_master.
(fhandler_tty_common::close): Remove obsolete code.
(fhandler_tty_slave::fixup_after_exec): Don't close, since this is done in
dtable's fixup_after_exec. (revisit later?)
(fhandler_pty_master::fixup_after_exec): Ditto.
* fhandler.h (fhandler_base::fixup_after_exec): Make non-inline.
(fhandler_termios::fixup_after_fork): Delete declaration.
(fhandler_termios::fixup_after_exec): Ditto.
(fhandler_tty_common::inuse): Remove.
(fhandler_tty_common::dup): Delete declaration.
(fhandler_tty_common::fixup_after_fork): Ditto.
(fhandler_tty_slave::fixup_after_exec): Declare new function.
(fhandler_pty_master::dwProcessId): New variable.
(fhandler_pty_master::from_master): Ditto.
(fhandler_pty_master::to_master): Ditto.
(fhandler_pty_master::setup): New function.
(fhandler_pty_master::fixup_after_fork): Ditto.
(fhandler_pty_master::fixup_after_exec): Ditto.
* fhandler_termios.cc (fhandler_termios::fixup_after_exec): Delete definition.
(fhandler_termios::fixup_after_fork): Ditto.
* fhandler_tty.cc (fhandler_tty_master::init): Use fhandler_pty_master setup
function rather than obsolete tty::common_init. Delete obsolete inuse setting.
(fhandler_tty_slave::fhandler_tty_slave): Set inuse to NULL here.
(fhandler_tty_slave::open): Change debugging output for clarity. Check for
different things when doing a sanity check on the tty. Reflect the fact that
master_pid now is the cygwin pid rather than the windows pid. Use "arch"
rather than "archetype" for consistency.
(fhandler_tty_slave::close): Close inuse here.
(fhandler_tty_slave::dup): Remove old if 0'ed code.
(fhandler_pty_master::dup): New function. Handles pty master archetype.
(fhandler_pty_master::fhandler_pty_master): Zero pty_master specific fields.
(fhandler_pty_master::open): Implement using archetypes, similar to slave. Use
fhandler_pty_master setup function rather than obsolete tty::common_init.
Don't set inuse.
(fhandler_tty_common::close): Don't deal with inuse. Delete old if 0'ed code.
(fhandler_pty_master::close): Implement using archetypes. Close from_master
and to_master.
(fhandler_tty_common::set_close_on_exec): Just set close_on_exec flag here
since everything uses archetypes now.
(fhandler_tty_common::fixup_after_fork): Delete definition.
(fhandler_tty_slave::fixup_after_exec): Define new function.
(fhandler_pty_master::setup): New function, derived from tty::common_init.
(fhandler_pty_master::fixup_after_fork): New function.
(shared_info.h): Reset SHARED_INFO_CB to reflect new tty size.
* tty.cc (tty_list::terminate): Close individual handles from tty_master.
(tty::master_alive): Delete.
(tty::make_pipes): Ditto.
(tty::common_init): Ditto.
* tty.h (tty::from_slave): Delete.
(tty::to_slave): Ditto.
(tty::common_init): Delete declaration.
(tty::make_pipes): Ditto.
(tty::master_pid): Define as pid_t since it is now a cygwin pid.
caller do that.
* dcrt0.cc (child_info_spawn::handle_spawn): Close parent handle here to allow
fixup_after_exec functions to use it.
* cygtls.cc (_cygtls::call2): Avoid calling exit thread if called with
*crt0_1 functions.
* cygtls.h (_cygtls::isinitialized): Check that we actually have a tls before
seeing if it is initialized.
* gendef (_sigfe_maybe): Ditto.
* dcrt0.cc (dll_crt0_1): Remove static, use just one argument.
* dll_init.cc (dllcrt0_info): New structure.
(dll_dllcrt0): Change into a front-end to renamed dll_dllcrt0_1 so that we'll
always be assured of having something like a tls.
(dll_dllcrt0_1): New function, basically renamed from from dll_dllcrt0.
Unconditionally call _my_tls.init_exception_handler now that we are assured of
having a tls. Change variable name from "linking" to "linked".
* winsup.h (dll_crt0_1): Declare.
(dll_dllcrt0_1): Ditto.
finished initializing (Thanks to Gary Zablackis for noticing this problem).
Just use cygwin_finished_initializing rather than defining a separate variable.
(modify_handle): Declare new function.
* debug.cc (modify_handle): Define new function.
* fhandler.h (fhandler_base::fork_fixup): Change return value from void to
bool.
* fhandler.cc (fhandler_base::fork_fixup): Return true if fork fixup has been
done.
* pipe.cc (fhandler_pipe::set_close_on_exec): Set inheritance of protected
handle via ModifyHandle if DEBUGGING.
(fhandler_pipe::fixup_after_fork): Protect guard handle if fork fixup has been
done.