length back to munmap(). Evaluate intersection between given
area and mapped area and return it, if any.
(mmap64): On regular files, don't allow mappings beginning beyond
EOF. Return with errno set to ENXIO instead.
(munmap): Rewrite SUSv3 conformant. Check if given memory area is
valid. Unmap all maps inside given memory area. Don't return error
if no mapping has been unmapped.
return socket connection state.
* fhandler_socket.cc (dup): Copy socket connect state to new file
handle.
* net.cc (cygwin_rcmd): Mark file handles of sockets returned by
rcmd() as CONNECTED state.
(cygwin_rexec): Similarly for rexec().
(socketpair): Mark both ends of a new socket pair as CONNECTED.
(fhandler_base::get_encoded): New function.
(fhandler_base::set_encoded): Ditto.
* fhandler_disk_file.cc (fhandler_disk_file::opendir): Set encoded flag in
fhandler, as appropriate.
(fhandler_disk_file::readdir): Unmunge filename as appropriate based on new
encoding flag.
* path.cc (normalize_posix_path): Don't punt on files with colons.
(special_char): New function.
(mount_item::fnmunge): Ditto.
(fnunmunge): Ditto.
(special_name): Ditto.
(mount_item::build_win32): Avoid drive considerations when file is encoded.
(mount_info::conv_to_win32_path): Handle encoded filenames.
(mount_info::conv_to_posix_path): Ditto.
(fillout_mntent): Add posix string when directory is encoded.
* path.h (fnunmunge): Declare.
(path_conv::is_encoded): Declare.
If a non-zero addr is given, align it to the next lower 64K boundary.
(fhandler_disk_file::mmap): If a non-zero address is given, try
mapping using the given address first. If it fails and flags is not
MAP_FIXED, try again with NULL address.
(cygheap_user::token): Delete.
(cygheap_user::impersonated): Delete.
(cygheap_user::external_token): New member.
(cygheap_user::internal_token): New member.
(cygheap_user::impersonation_state): New member.
(cygheap_user::issetuid): Modify.
(cygheap_user::token): New method.
(cygheap_user::deimpersonate): New method.
(cygheap_user::reimpersonate): New method.
(cygheap_user::has_impersonation_tokens): New method.
(cygheap_user::close_impersonation_tokens): New method.
* dtable.cc (dtable::vfork_child_dup): Use new cygheap_user methods.
* fhandler_socket.cc (fhandler_socket::dup): Ditto.
* fork.cc (fork_child): Ditto.
(fork_parent): Ditto.
* grp.cc (internal_getgroups): Ditto.
* security.cc (verify_token): Ditto.
(check_file_access): Ditto.
(cygwin_set_impersonation_token): Detect conflicts. Set
user.external_token.
* spawn.cc (spawn_guts): Use new cygheap_user methods.
* syscalls.cc (seteuid32): Rearrange to use the two tokens
in cygheap_user.
(setegid32): Use new cygheap_user methods.
* uinfo.cc: (internal_getlogin): Ditto.
(pthread::threads): Instantiate.
(pthread::pthread): Initialize running and suspendend.
Initialize next with NULL.
Add thread to thread list if it is not the null_pthread.
(pthread::~pthread): Remove thread from thread list if it is not the null_pthread.
(pthread::postcreate): Set running flag.
(pthread::exit): Reset running flag.
(pthread::cancel): Try to cancel thread only if still running.
(pthread::_fixup_after_fork): Implement.
(pthread::detach): Check if thread is still running before detach.
* thread.h (pthread::running): New member.
(pthread::next): Ditto.
(pthread::fixup_after_fork): New static method.
(pthread::threads): New static method.
(pthread::_fixup_after_fork): New method.
cygerrno.h.
* include/cygwin/config.h (__DYNAMIC_REENT__): Define.
* include/cygwin/version.h: Bump API minor version.
* cygwin.din: Export __getreent
* cygerrno.h: Include errno.h. Fix places where _impure_ptr is used directly
to store the errno value.
* debug.cc (__set_errno): Ditto.
* errno.cc: Remove _RRENT_ONLY define to get errno.cc compiled.
* signal.cc: Rename _reent_clib to _REENT throughout.
* thread.h (reent_clib): Remove prototype.
* thread.cc (reent_clib): Rename reent_clib to __getreent. Return _impure_ptr
until MTinterface is initialized.
(reent_winsup): Fix a possible SEGV when _r == NULL. Return NULL instead.
* MTinterface::fixup_after_fork: Switch reent back to _impure_ptr to keep
signal handling running when fork is called from a thread other than the
mainthread.
to return 0 if attribute is already initialized back to EBUSY.
(pthread_condattr_init): Ditto.
(pthread_rwlockattr_init): Ditto.
(pthread_mutexattr_init): Ditto.
Fix return code if out of memory.
(pthread_condattr_init): Ditto.
(pthread_rwlockattr_init): Ditto.
(pthread_mutexattr_init): Return 0 if attribute is already initialized.
when the real {u,g}ids and the groups are original.
Move RevertToSelf and ImpersonateLoggedOnUser to the main line.
* uinfo.cc (uinfo_init): Reorganize. If CreateProcess was called
while impersonated, preserve the uids and gids and call
ImpersonateLoggedOnUser. Preserve the uids and gids on Win9X.
* exceptions.cc (error_start_init): Quote the pgm in the command.
* fhandler.cc (fhandler_base::write): Only make file sparse if the
seeked area is >= 128K.
* syslog.cc (vsyslog): New function, overtaking functionality from
syslog.
(syslog): Just call vsyslog.
* include/cygwin/version.h: Bump API minor.
* include/sys/syslog.h: Add vsyslog declaration.
* fhandler_disk_file.cc (fhandler_disk_file::fstat): Mark the pc
as non-executable if the file cannot be opened for read. Retry query
open only if errno is EACCES. Never change the mode, even if it is 000
when query open() fails.
(accept_thread): Remove.
(fhandler_socket::connect): Remove all special blocking handling.
(fhandler_socket::accept): Ditto.
* net.cc (cygwin_connect): Make blocking sockets temporarily
non-blocking and call cygwin_select on them to be interruptible.
(cygwin_accept): Ditto.
* path.cc (path_conv::check): Set exec state based on known situations.
* path.cc (mount_item::fnmunge): New function.
(mount_item::build_win32): New function.
(mount_info::conv_to_win32_path): Use build_win32 to build windows path.
* path.h (mount_item::fnmunge): Declare new function.
(mount_item::build_win32): Ditto.
* sys/mount.h (MOUNT_ENC): Define.
revert to original account before calling fixup_before_fork_exec
and impersonate again afterwards. Change comment accordingly.
Clean up error handling and debug output.
(sock_event::load): Change to void. Check if winsock2 is available.
(socke_event::wait): Return 0 if interruptible mode is not available.
(fhandler_socket::connect): Remove checks for winsock2 availability.
(fhandler_socket::accept): Ditto.
(fhandler_base::set_did_lseek): Rename from set_check_win95_lseek_bug.
(fhandler_base::get_did_lseek): Rename from get_check_win95_lseek_bug.
(fhandler_base::set_fs_flags): New method.
(fhandler_base::get_fs_flags): Ditto.
* fhandler.cc (fhandler_base::write): Make 64 bit clean. Convert file
to a "sparse" file when writing after a long lseek (>64K) beyond EOF.
(fhandler_base::lseek): Call set_did_lseek() instead of
set_check_win95_lseek_bug().
(fhandler_base::fhandler_base): Initialize fs_flags to 0.
* fhandler_disk_file.cc (fhandler_disk_file::open): Don't create files
as "sparse" unconditionally. Set fs_flags member.
* syscalls.cc (statfs): Call full_path.root_dir() instead of
rootdir(full_path). Use GetDiskFreeSpaceEx when available and
report space available in addition to free space.
* fhandler_disk_file.cc (fhandler_disk_file::fstat_by_name):
Do not call FindFirstFile for disk root directories.
char *parameter instead of local static buffer.
(fhandler_socket::create_secret_event): Accomodate new calling
convention for secret_event_name.
(fhandler_socket::close_secret_event): Ditto.
(ENTROPY_SOURCE_NAME): Ditto.
(secret_event_name): New static function. Create shared event name
with "Global\" prefix on systems supporting terminal services.
(fhandler_socket::set_connect_secret): Fix conditional.
(fhandler_socket::create_secret_event): Create secret event using
secret_event_name().
(fhandler_socket::close_secret_event): Ditto.
* shared.cc (shared_name): Create shared object name with "Global\"
prefix on systems supporting terminal services.
* wincap.cc: Set has_terminal_services capability throughout.
(wincap_2003): New global object representing Windows 2003 Server
capabilities.
(wincapc::init): Accomodate Windows 2003 Server.
* wincap.h (struct wincaps): Add has_terminal_services capability.
(MTinterface::Init): Ditto.
* thread.cc (MTinterface::Init): Remove function parameter.
Always initialize reent_key.
(pthread::init_mainthread): Remove function parameter.
(MTinterface::fixup_after_fork): Fix pthread::init_mainthread call.
* dcrt0.cc (dll_crt_0_1) Fix calls to MTinterface::Init and
pthread::init_mainthread.
Call pthread::init_mainthread only when not forked.
* include/stdint.h: New file.
* include/cygwin/in.h: Include stdint.h instead of sys/types.h.
* include/cygwin/types.h: Include stdint.h. Remove typedefs for
intN_t and uintN_t since these are defined in stdint.h now.
(wincapc:pty_needs_alloc_console): New function.
* wincap.cc: Add pty_needs_alloc_console throughout.
* fhandler_tty.cc (fhandler_tty_slave::open): Open an "invisible" console on
first pty allocation.
(cfsetospeed): Use setspeed to set speed.
(cfsetispeed): Use setspeed to set speed.
* autoload.cc: Add load statement for UuidCreate, and UuidCreateSequential.
* cpuid.h: New file.
* cygwin.din: Export gethostid.
* fhandler_proc.cc (cpuid): Move to cpuid.h.
(can_set_flag): Move to cpuid.h.
* syscalls.cc (gethostid): New function.
* version.h: Bump DLL minor version number to 83.
* thread.h (pthread_rwlock::release): New method.
* thread.cc (pthread_rwlock::unlock): Use release to signal
waiting threads.
(pthread_rwlock::rdlock_cleanup): Signal waiting threads after a
cancelation.
(pthread_rwlock::wrlock_cleanup): Ditto.
(get_nt_attribute): Only call read_sd and get_info_from_sd.
Return void.
(get_file_attribute): Move sd error handling to get_info_from_sd.
and symlink handling to fhandler_disk_file::fstat_helper.
(get_nt_object_attribute): Only call read_sd and get_info_from_sd.
Return void.
(get_object_attribute): Remove symlink handling and simply return -1
when ntsec is off.
* fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): For
symlinks set the attribute, call get_file_attribute to get the ids
and return. In the normal case call get_file_attribute with the
addresses of the buffer ids and do not recheck if the file is a socket.
(cygthread::simplestub): Initialize stack pointer.
(cygthread::terminate_thread): Account for possibility that stack pointer has
not been set. Issue warnings for unusual conditions.
* cygthread.cc: Ditto.
(cygthread::stub): Don't initialize already initialized events.
(cygthread::freerange): Don't create thread here.
(cygthread::cygthread): Create thread here. Die if thread not created.
(cygthread::operator new): Simplify. Just grab a thread structure from the
pool. Don't try to start the thread.
(cygthread::terminate_thread): Don't close event handles. Just reuse them.
Call MEM_RELEASE rather than MEM_DECOMMIT (from Joe Buehler).
allow pasting accented characters and typing them using the "alt + numerics"
sequences.
* include/limits.h (IOV_MAX): Set to a number which is small enough to use in
an array.
functions.
* cygthread.cc (cygthread::init): Eliminate unneeded muto.
(cygthread::operator new): Don't lock. Instead change use of avail variable
into tri-state: available (1), not available (-1), uninitialized (0).
(cygthread::terminate_thread): Set avail to uninitialized.
(cygthread::detach): Eliminate local 'avail'. Always set avail to 1 unless
signalled.
* cygthread.cc (cygthread::operator new): Be more defensive when messing with
from the current effective ids.
* fhandler_socket.cc (fhandler_socket::fstat): Keep the uid and gid set
by fhandler_base::fstat.
* security.cc (get_nt_attribute): Do not test wincap.has_security ().
(get_nt_object_attribute): Ditto.
(get_file_attribute): Add test for wincap.has_security ().
(get_object_attribute): Ditto.
(login): Use mutex to secure against concurrent access to wtmp file.
(logout): Rewrite using POSIX calls.
(utmp_fd): Initialized to -1 now. Any value < 0 is treated as closed
in subsequent functions.
(utmp_readonly): New variable, indicating utmp file open for reading
only.
(internal_setutent): New function implementing setutent().
(setutent): Call internal_setutent now.
(endutent): Reset utmp_readonly.
(getutent): Return immediately if utmp file can't be opened.
(getutid): Ditto.
(getutline): Ditto.
(pututline): Ditto. Use mutex to secure against concurrent access to
utmp file.
according to the GNU coding style.
* thread.cc: Ditto.
* dcrt0.cc (dll_crt0_1): Rename pthread::initMainThread call to
pthread::init_mainthread.
* pthread.cc (pthead_getsequence_np): Rename pthread::isGoodObject
call to pthread::is_good_object.
declaration.
(List::forEach): Change callback parameter to template class
member functionpointer.
(pthread_keys::fixup_before_fork): Change to inline. Use
List::forEach to fixup keys.
(pthread_keys::fixup_after_fork): Ditto.
(pthread_keys::runAllDestructors): Ditto.
(pthread_key::saveAKey): Remove.
(pthread_key::restoreAKey): Ditto.
(pthread_key::destroyAKey): Ditto.
(pthread_key::run_destructor): Rename to runDestructor.
(pthread_mutex::fixup_after_fork): Change to inline. Use
List::forEach to fixup mutexes after a fork.
(pthread_mutex::FixupAfterFork): New method.
(pthread_mutex::mutexes): New member.
(pthread_cond::fixup_after_fork): Change to inline. Use
List::forEach to fixup conds after a fork.
(pthread_cond::FixupAfterFork): New method.
(pthread_cond::conds): New member.
(pthread_rwlock::fixup_after_fork): Change to inline. Use
List::forEach to fixup rwlocks after a fork.
(pthread_rwlock::FixupAfterFork): New method.
(pthread_rwlock::rwlocks): New member.
(semaphore::fixup_after_fork): Change to inline. Use
List::forEach to fixup mutexes after a fork.
(semaphore::FixupAfterFork): New method.
(semaphore::semaphores): New member.
(MTinterface::mutexs): Remove.
(MTinterface::conds): Ditto.
(MTinterface::rwlocks): Ditto.
(MTinterface::semaphores): Ditto.
(pthread_equal): Add extern "C".
(pthread_mutex_lock): Ditto.
* thread.cc (MTinterface::fixup_after_fork): Change
fixup_after_fork calls for pthread objects.
(semaphore::conds): Instantiate.
(pthread_cond::pthread_cond): Use List::Insert rather than
custom list code.
(pthread_cond::~pthread_cond): Use List::Remove rather than
custom list code.
(pthread_cond::fixup_after_fork): Rename to FixupAfterFork.
(pthread_rwlock::rwlocks): Instantiate.
(pthread_rwlock::pthread_crwlock): Use List::Insert rather than
custom list code.
(pthread_rwlock::~pthread_rwlock): Use List::Remove rather than
custom list code.
(pthread_rwlock::fixup_after_fork): Rename to FixupAfterFork.
(pthread_key::saveAKey): Remove.
(pthread_key::fixup_before_fork): Ditto.
(pthread_key::restoreAKey): Ditto.
(pthread_key::fixup_after_fork): Ditto.
(pthread_key::destroyAKey): Ditto.
(pthread_key::runAllDestructors): Ditto.
(pthread_key::run_destructor): Rename to runDestructor.
(pthread_mutex::mutexes): Instantiate.
(pthread_mutex::pthread_mutex): Use List::Insert rather than
custom list code.
(pthread_mutex::~pthread_mutex): Use List::Remove rather than
custom list code.
(pthread_mutex::fixup_after_fork): Rename to FixupAfterFork.
(semaphore::conds): Instantiate.
(semaphore::semaphore): Use List::Insert rather than custom list
code.
(semaphores::~semaphore): Use List::Remove rather than custom
list code.
(semaphore::fixup_after_fork): Rename to FixupAfterFork.
* exceptions.cc (signal_fixup_after_exec): Eliminate argument in definition.
Don't reset signal handlers after spawm. Just treat like fork/exec.
* dcrt0.cc (dll_crt0_1): Don't pass PROC_SPAWN argument to
signal_fixup_after_exec.
* syscalls.cc (unlink): Don't change attributes of file if not readonly/system.
Ditto for resetting of arguments.
trunc exports show up before previous bump since there has been no exported
version of the DLL with the 64 bit changes yet but 1.3.22 will have the btowc
and trunc.
* include/cygwin/version.h: Reflect new exports.
* syscalls.cc (_stat): Rename to stat to avoid newlib wrapper.
* syscalls.cc (_fstat): Ditto.
* fhandler_console.cc (fhandler_console::close): Correct check for current tty.
Add debugging output when console is freed.
(set_console_state_for_spawn): Add debugging output.
* fhandler_tty.cc (fhandler_tty_slave::open): Don't decrement console open flag
when vforking.
* sigproc.cc (sigproc_terminate): Fix debugging output.
* spawn.cc (handle): Eliminate second argument.
(spawn_guts): Reflect elimination of argument change to handle.
* syscalls.cc (setsid): Add debugging output when console is freed.
* syscalls.cc (rename): Revert assumption that DELETE_ON_CLOSE works on Win9x.
* fhandler_socket.cc (fhandler_socket::dup): On NT systems avoid
using WinSock2 socket duplication methods. Add comment.
2003-03-11 Pierre Humblet <pierre.humblet@ieee.org>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork):
Set io_handle to INVALID_SOCKET in case of failure.
(fhandler_socket::dup): Return 0 if the io_handle is valid.
* autoload.cc (GetSystemTimes): Define new autoload function.
* fhandler_proc.cc (proc_listing): Add cpuinfo and partitions entries.
(fhandler_proc::fill_filebuf): Add PROC_CPUINFO and PROC_PARTITIONS cases.
(format_proc_uptime): Use GetSystemTimes if available.
(read_value): New macro.
(print): New macro.
(cpuid): New function.
(can_set_flag): New function.
(format_proc_cpuinfo): New function.
(format_proc_partitions): New function.
delete files since this allows us to preserve the protection of hard linked
files.
(link): Generate full path for potentially recalculated .lnk target.
(path_conv::is_lnk_symlink): New function. True if path represents .lnk style
symlink.
* path.cc (check_shortcut): Set PATH_LNK in pflags when appropriate.
(symlink_info::check): Ditto. Remove PATH_LNK from pflags initially.
* syscalls.cc (unlink): Always remove readonly attribute from a symlink
regardless of type.
(link): (from Corinna Vinschen) Allow links to symlinks. Reset attributes on a
symlink after successful link creation.
(chmod): Use is_lnk_symlink where appropriate.
(rename): Ditto.
* tty.cc (create_tty_master): Call GetComputerName instead of
cygwin_gethostname. Set ut_id.
* syscalls.cc (login): Call endutent.
(setutent): Do not seek after a fresh open.
(fhandler_tty_slave::dup): Declare new function.
(fhandler_tty_slave::fixup_after_function): Declare new function.
* fhandler_tty.cc (fhandler_tty_slave_open): Only increment
fhandler_console::open_fhs when associated with a pty.
(fhandler_tty_slave::close): Define new function. Decrement
fhandler_console::open_fhs when associated with a pty.
(fhandler_tty_slave::dup): Define new function. Increment
fhandler_console::open_fhs when associated with a pty.
(fhandler_tty_slave::fixup_after_fork): Define new function. Increment
fhandler_console::open_fhs when associated with a pty.
* fhandler_socket.cc (class sock_event): New class managing Winsock
events for interruptible socket calls.
(fhandler_socket::connect): Move support for interruptible call to
class sock_event. Use class object instead.
(fhandler_socket::accept): Ditto. Remove useless casts.
2003-03-27 Thomas Pfaff <tpfaff@gmx.net>
* fhandler_socket.cc (fhandler_socket::connect): Add support for
an interruptable connect.
data on sockets to evaluate AF_LOCAL sockets correctly.
(dtable::build_fhandler): Set unit number on sockets.
* fhandler.h (fhandler_socket): Add unit number.
(fhandler_socket::get_unit): New method.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Set unit
number.
(fhandler_socket::fstat): Reorganize to return more Linux-like
values.
* net.cc: include ctype.h.
(fdsock): Set unit number when building fhandler.
* path.cc (path_conv::check): Set device type to FH_SOCKET if file
is a AF_UNIX socket.
(get_devn): Evaluate unit for virtual socket devices.
(win32_device_name): Set windows path for sockets to unix_path with
just backslashes to keep the different names.
* syscalls.cc (fstat64): Don't override st_ino, st_dev and st_rdev
for sockets.
(stat_worker): Ditto.
From Pierre Humblet:
* autoload.cc (AccessCheck): Add.
(DuplicateToken): Add.
* security.h (check_file_access): Declare.
* syscalls.cc (access): Convert path to Windows, check existence
and readonly attribute. Call check_file_access instead of acl_access.
* security.cc (check_file_access): Create.
* sec_acl (acl_access): Delete.
(fhandler_disk_file::open): Accept some filesystem specific stuff.
* sigproc.cc (wait_for_sigthread): Become slightly more thread safe.
(sig_send): Don't assume that signal thread is ready.
* include/winioctl.h (FSCTL_SET_SPARSE): Define.
cygwin:
* wincap.h (wincaps::supports_sparse_files): New flag.
(wincapc::supports_sparse_files): New method.
* wincap.cc (wincap_unknown): Define value for the new flag.
(wincap_95): Ditto.
(wincap_95osr2): Ditto.
(wincap_98): Ditto.
(wincap_98se): Ditto.
(wincap_me): Ditto.
(wincap_nt3): Ditto.
(wincap_nt4): Ditto.
(wincap_nt4sp4): Ditto.
(wincap_2000): Ditto.
(wincap_xp): Ditto.
* path.h (path_conv::fs_flags): New method.
* fhandler_disk_file.cc: Include winioctl.h for DeviceIoControl.
(fhandler_disk_file::open): Set newly created and truncated files as
sparse on platforms that support it.
parameter. Only protect pages actually unused currently. Do job
of map_map() when initializing a map.
(mmap_record::map_map): Reduce functionality for the reuse case
of private anonymous mapping.
(mmap_record::fixup_map): Format change.
(list::add_record): Add offset and length parameter to call
mmap_record::alloc_map() correctly.
(mmap64): Rename `l' variable to `map_list'. Accomodate above changes.
(munmap): Rename `l' variable to `map_list'.
(msync): Ditto.
(fhandler_disk_file::mmap): Streamline code.
(mprotect): Ditto.
(fixup_mmaps_after_fork): Rename `l' variable to `map_list'.
* exceptions.cc (try_to_debug): Set priority of current thread rather than the
main thread. Make busy waiting loop less busy. Restore priority when function
returns.
declaration of is_grp_member.
* uinfo.cc (internal_getlogin): Use UNKNOWN_GID.
* passwd.cc (pwdgrp::read_passwd): Use UNKNOWN_UID.
* grp.cc (pwdgrp::read_group): Change group name to provide better
feedback.
(getgrgid): Use gid16togid32.
* sec_helper.cc (is_grp_member): Delete.
loop. Set default rights to same values as in alloc_sd(). Set DELETE
for owner and default owner only if S_IWOTH is given.
* sec_acl.cc: Change all __aclent16_t to __aclent32_t except in
wrapper function definitions. Replace call to the aclXYZ functions by
calls aclXYZ32.
(searchace): Change type of third argument to __uid32_t and use
ILLEGAL_UID instead of -1;
(setacl): Remove some initializations. Only give STANDARD_RIGHTS_WRITE
for S_IWOTH. Replace -1 by ILLEGAL_UID.
(getacl): Change type of owner_sid, group_sid and ace_sid to cygpsid.
In last else clause, suppress second call to ace_sid.get_id and use
TRUE in first call. Replace EqualSid by ==.
(acl_access): Call internal_getgroups in USER and GROUP cases.
(acecmp: Define static.
(acl32): Create from 16 bit type.
(facl32): Ditto.
(lacl32): Ditto.
(aclcheck32): Ditto.
(aclsort32): Ditto.
(acltomode32): Ditto.
(aclfrommode32): Ditto.
(acltopbits32): Ditto.
(aclfrompbits32): Ditto.
(acltotext32): Ditto.
(aclfromtext32): Ditto, and use strechr.
(acl16to32): Create.
(acl): Make it a wrapper function.
(facl): Ditto.
(lacl): Ditto.
(aclcheck): Ditto.
(aclsort): Ditto.
(acltomode): Ditto.
(aclfrommode): Ditto.
(acltopbits): Ditto.
(aclfrompbits): Ditto.
(acltotext): Ditto.
(aclfromtext): Ditto.
* security.cc (write_sd): Call set_process_privilege and check
ownership.
(alloc_sd): Remove call to set_process_privilege and the owner check.
* security.cc (extract_nt_dom_user): Simplify with strechr.
(get_user_groups): Initialize glen to MAX_SID_LEN.
(get_user_local_groups): Ditto.
(get_attribute_from_acl): Define ace_sid as cygpsid.
(get_nt_attribute): Define owner_sid and group_sid as cygpsid.
Call get_sids_info instead of cygsid.get_{u,g}id and is_grp_member.
(get_nt_object_attribute): Ditto.
(alloc_sd): Define ace_sid as cygpsid.
(class cygsid): Use cygpsid as base. Remove members psid, get_id,
get_uid, get_gid, string, debug_printf and the == and != operators.
(cygsidlist::clear_supp): Only do work if setgroups has been called.
* sec_helper.cc: Define sid_auth NO_COPY.
(cygpsid::operator==): New operator.
(cygpsid::get_id): New function.
(cygpsid::string): New function.
(cygsid::string): Delete.
(cygsid::get_id): Delete.
* pwdgrp.h: Change arguments of internal_getpwsid,
internal_getgrsid and internal_getgroups to cygpsid.
* passwd.cc (internal_getpwsid): Change argument from cygsid to cygpsid.
* grp.cc (internal_getgrsid): Ditto.
(internal_getgroups): Ditto.
* autoload.cc: Add OpenThreadToken.
* sec_helper.cc (set_process_privilege): Add and use use_thread
argument.
* security.cc (alloc_sd): Modify call to set_process_privilege.
Remember the result in each process. If failed and file owner is not
the user, fail.
(internal_getgrsid): Only refresh if uninitialized.
(internal_getgrent): Ditto.
* passwd.cc (getpwent): Only refresh passwd entries when at beginning.
(pwdgrp::read_passwd): linebuf *cannot* be NO_COPY.
(internal_getpwsid): Only refresh if uninitialized.
(getpass): No need to refresh passwd data here.
* pwdgrp.h (refresh): Eliminate default.
* termios.cc (tcsetattr): Correctly record errno after tcsetattr call.
* fhandler_serial.cc (fhandler_serial::tcsetattr): Add error-checking so that
if any Win32 SetComm*() calls fail, errno gets set to EINVAL and tcsetattr()
returns -1. Catch invalid bitrates, mostly. If baud rate setting is B0, just
drop DTR and leave Win32 DCB bitrate as-is since 0 is not a valid Win32
setting.
(fhandler_serial::tcgetattr): If DTR is low, populate the bitrate as B0,
otherwise get it from the DCB.
Humblet).
* pwdgrp.h (pwdgrp::refresh): Avoid calling read function if we already have
lock since that means we are in the process of reading the file.
* uinfo.cc (pwdgrp::next_str): Search only for input char in string. Return
EOS on failure. Don't check for NULL since it shouldn't be possible.
(pwdgrp::add_line): Revert to replacing '\n' in input line with '\0'.
(pwdgrp::next_num): Pass explicit separator character to next_str.
* grp.cc (pwdgrp::parse_group): Ditto.
* passwd.cc (pwdgrp::parse_passwd): Ditto. Revamp test for garbage input.
* pwdgrp.h (pwdgrp::next_str): Don't use default parameter.
output.
* pwdgrp.h (pwdgrp::next_num): Rename from next_int. Returns true/false if
parse operation succeeded.
(pwdgrp::reparse): Remove.
(pwdgrp::raw_ptr): New function. Returns pointer in line.
(pwdgrp::next_num): New functions for parsing other than unsigned long.
* grp.cc (pwdgrp::parse_group): Reinstate previous parsing behavior. Don't
fill in fields with NULL and assign empty gr_mem to known pointer rather than
doing a pointless calloc. Streamline gr_mem parsing. Don't increment
curr_lines here.
* passwd.cc (pwdgrp::parse_passwd): Use new behavior of next_num. Don't
increment curr_lines here.
* uinfo.cc (pwdgrp::next_str): Keep returning EOL if out of data.
(pwdgrp::reparse): Remove.
(pwdgrp::next_num): Rename from next_int. Return bool indicating success of
parse, argument returns value parsed.
(pwdgrp::add_line): Increment curr_lines here on successful parse.
(pwdgrp::load): (from Pierre Humblet) Don't return status. Just report it
here.
update the euid and call cygheap->user.set_name. Remove special
handling of ILLEGAL_UID.
(setgid32): Add a debug_printf. On Win95, always set the egid.
Remove special handling of ILLEGAL_GID. Do not compare gid and gr_gid.
* child_info.h (class cygheap_exec_info): Remove uid.
* spawn.cc (spawn_guts): Do not set ciresrv.moreinfo->uid.
* dcrto.cc (dll_crt0_1): Always call uinfo_init.
* uinfo.cc (uinfo_init): Reorganize and close handle if needed.
(cygheap_user::ontherange): Do not call internal_getpwnam if pw is NULL.
* signal.cc (nanosleep): New function.
(sleep): Move old functionality to nanosleep(). Call nanosleep().
(usleep): Remove old functionality. Call nanosleep().
* include/cygwin/version.h: Bump API minor number.
(gr): Use constructor (sigh).
(pwdgrp::parse_group): Rename from parse_grp.
(pwdgrp::read_group): Rename from read_etc_group. Just call gr.load with a
single argument.
* passwd.cc: Call pr.refresh() rather than doing isunitialized tests
throughout.
(pr): Use constructor (sigh).
(pwdgrp::parse_passwd): Rename from "parse_pwd".
(pwdgrp::read_passwd): Rename from read_etc_passwd. Just call pr.load with a
single argument.
* pwdgrp.h (pwdgrp_state): Eliminate.
(pwdgrp): Reflect above renamings.
(pwdgrp::etc_ix): Rename from pwd_ix.
(pwdgrp::read): New element.
(pwdgrp::lock): New element.
(pwdgrp::refresh): New function.
(pwdgrp::load): Eliminate variations which take buffer arguments.
(pwdgrp::pwdgrp): New constructors. Initialize mutex here.
* uinfo.cc (pwdgrp::load): Accommodate pwd_ix -> etc_ix renaming.
(pwdgrp::load): Set initialized state to true rather than setting state to
loaded.
(etc::set_last_modified): Remove obsolete function.
* path.cc (etc::change_possible): Revert type to bool.
(etc::test_file_change): Do not test for negative values of change_possible and
do not set it to -res.
(etc::dir_changed): When the handle is NULL, call memset instead of
test_file_changed. When the handle is invalid, return true.
(etc::file_changed): Remove unneeded check for !fn[n].
(pwdgrp::max_lines): New field.
(pwdgrp::curr_lines): New field.
(pwdgrp::pwdgrp_buf): Ditto.
(pwdgrp_buf_elem_size): Ditto.
(pwdgrp_parse): Ditto.
(pwdgrp::gets): Just declare here.
(pwdgrp::load): Ditto. Just take one argument.
(pwdgrp::load): Define overloaded function accepting passwd buf.
(pwdgrp::load): Define overloaded function accepting group buf.
* grp.cc: Use pwdgrp elements rather than standalone static variables
throughout.
(curr_lines): Eliminate.
(max_lines): Ditto.
(add_grp_line): Ditto.
(parse_grp): Define as returning boolean. Accept void * arg and line count.
Coerce first argument into __group32 buf reference. Increment curr_line as
appropriate.
(read_etc_group): Pass pwdgrp buffer to gr.load.
* passwd.cc: Use pwdgrp elements rather than standalone static variables
throughout.
(curr_lines): Eliminate.
(max_lines): Ditto.
(add_grp_line): Ditto.
(parse_passwd): Define as returning boolean. Accept void * arg and line count.
Coerce first argument into passwd buf reference. Increment curr_line as
appropriate.
(read_etc_group): Pass pwdgrp buffer to pr.load.
* path.cc (etc::fn): Extend buffer size to allow index by 1 rather than zero.
(etc::last_modified): Ditto.
(etc::change_possible): Ditto. Renamed from sawchange. Change to signed char
since elements are now tri-state.
(etc::init): Assume "handle" is 1 based rather than 0.
(etc::test_file_change): New function. Sets change_possible based on file date
comparison.
(etc::dir_changed): Check file states immediately after changed_h is
initialized to avoid a race.
(etc::file_changed): Use test_file_change to detect if file needs to be
updated.
* path.h (etc): Move class here from pwdgrp.h.
* uinfo.cc: Move etc:: functions to path.cc. Move pwdgrp functions here.
(pwdgrp::gets): Eliminate buf checks. Just check eptr and set lptr.
(pwdgrp::add_line): New function.
(pwdgrp::load): Call generic add_line function which will call correct parser.
"unknown" to "mkgroup".
(internal_getgrgid): Do not return default in nontsec case.
(internal_getgroups): Add argument srchsid and look for it in groups if not
NULL.
* passwd.cc (read_etc_passwd): On NT, add a line for uid = -1. Use same
default uid for Win95 and NT. Call cygheap_user::ontherange to initialize
HOME.
* cygheap.cc (init_cygheap::etc_changed): Move to uinfo.cc.
* cygheap.h (init_cygheap::etc_changed_h): Remove.
(init_cygheap::etc_changed): Ditto.
* grp.cc (group_state): Remove. Use gr instead throughout.
(gr): Define as class pwdgrp.
(read_etc_group): Remove gr definition. Remove calls to set_last_modified and
close. Pass add_grp to gr.load to load file.
* passwd.cc (passwd_state): Remove. Use pr instead, throughout.
(pr): Define as class pwdgrp.
(read_etc_passwd): Remove pr definition. Remove calls to set_last_modified and
close. Pass add_pwd_line to pr.load to load file.
* pwdgrp.h (etc): New helper class for pwdgrp.
(pwdgrp): Combine pwdgrp_check and pwdgrp_read into one class. Remove file_w32
and last_modified fields.
(pwdgrp::set_last_modified): Remove.
(pwdgrp::isinitializing): Remove FindFirstFile stuff. Move to
etc::file_changed.
(pwdgrp::load): Rename from 'open'. Call etc::init to initialize etc scanning.
Close file handle after reading buffer into memory. Parse buffer by calling
second argument.
(pwdgrp::gets): Reorganize slightly to rely on eptr starting at beginning of
buffer. Free buffer when memory exhausted.
(pwdgrp::close): Remove.
* uinfo.cc (etc::dir_changed): New function.
(etc::init): Ditto.
(etc::file_changed): Ditto.
(etc::set_last_modified): Ditto.
for strictness.
(mprotect): Protect against calling VirtualProtect() for shared
pages on 9x/Me.
(fixup_mmaps_after_fork): If ReadProcessMemory() fails, try to
change protection of parent page to PAGE_READONLY, then try again.
Revert protection afterwards.
(setacl): Start the search for a matching default at the next entry.
Invalidate the type of merged entries instead of clearing it.
Use well_known_creator for default owner and owning group and do
not try to merge non-default and default entries in these cases.
(getacl): Recognize well_known_creator for default owner and group.
(acl_worker): Improve errno settings and streamline the nontsec case.
* security.cc (write_sd): Remove the call to set_process_privilege.
(alloc_sd): If the owner changes, call set_process_privilege and return
immediately on failure. Change inheritance rules: on new directories add
inherit only allow ACEs for creator_owner, creator_group and everyone.
Preserve all inheritances through chmod and chown calls. Introduce
isownergroup to implement the uid == gid case, to keep the inheritance
code simple. Do not initialize owner_sid and group_sid and stop using
the variable psd.
* path.cc (iscygdrive): Disallow /cygdrive\x.
(normalize_posix_path): "Normalize" a windows path, if detected, rather than
converting to posix.
* fhandler_serial.cc (fhandler_serial::tcsetattr): Add support and capability
checking for B230400 bitrate.
(fhandler_serial::tcgetattr): Add support for B230400 bitrate.
* include/sys/termios.h: Add B230400 definition for Posix support of 230.4Kbps.
needed.
* dtable.cc (dtable::vfork_parent_restore): Remove assertion.
* pipe.cc (fhandler_pipe::close): Don't close read_state during fork_fixup
since it wasn't inherited.
passed-in termios struct.
* fhandler_console.cc (fhandler_console::read): Prior to loop, make a copy of
current termios for passing to line_edit prior so that all characters are
processed consistently.
* fhandler_tty.cc (fhandler_pty_master::write): Ditto.
(process_input): Make a copy of curent termios prior to read for use in
subsequent line_edit.
* fhandler_termios.cc (fhandler_termios::line_edit): Replace third parameter
with passed-in termios struct and use it throughout rather than the data from
the current fhandler_termios class.
via signal.
(signal_exit): Enter critical section early to avoid exit races with main
thread.
* dcrt0.cc (do_exit): Use exit_lock critical section to avoid races.
can be < or >.
* fhandler_tty.cc (fhandler_pty_master::write): Don't return after sending a
signal.
* fhandler_termios.cc (fhandler_termios::line_edit): Trivial change to use
built-in bool types.
* fhandler_termios.cc (fhandler_termios::line_edit): After accept_input, handle
both potential error condition and pipe full conditions.
* fhandler_tty.cc (fhandler_pty_master::accept_input): Return -1 on error.
(fhandler_pty_master::write): Handle pipe full condition.
remove last char from readahead buffer if accept_input() fails.
* fhandler_tty.cc (fhandler_pty_master::accept_input): Return 0 and restore
readahead buffer when tty slave pipe is full.
where thread termination may cause data loss.
(fhandler_base::read): Always return at end of function. Just set len to
copied_chars when len is zero. Return immediately after raw_read if len <= 0.
Remove in_len setting and just check end instead. Fix CRLF handling at end of
buffer.
* dcrt0.cc (dll_crt0_1): Call well known SID initializer function.
* security.h (cygsid::init): Declare new static method.
* sec_helper.cc (cygsid::init): New method for initializing well
known SIDs.
2002-12-14 Pierre Humblet <pierre.humblet@ieee.org>
* security.h: Declare well_known_creator_group_sid.
* sec_helper.cc: Define and initialize well_known_creator_group_sid.
whose second arguments are both the lenght and the return value.
* fhandler.cc (fhandler_base::read): Rework slightly to use second argument as
input/output. Tweak CRLF stuff.
(fhandler_base::readv): Accommodate fhandler_*::read changes.
* cygthread.h (cygthread::detach): Declare as taking optional handle argument.
(cygthread::detach): When given a handle argument, wait for the handle to be
signalled before waiting for thread to detach. Return true when signal
detected.
* configure.in: Reorder SUBDIRS to have mingw before cygwin.
* configure: Regenerate from configure.in.
* cygwin/Makefile.in: Add MINGW_LDFLAGS when linking cygrun.exe.
(cygthread::detach): Accept a "wait_for_signal" argument.
(cygthread::terminate_thread): New function.
* cygthread.cc (cygthread::stub): Set stack pointer argument.
(cygthread::terminate_thread): New function. Forcibly terminate thread.
(cygthread::detach): Optionally wait for signals and kill thread when signal
arrives.
* exceptions.cc (signal_exit): Set signal_arrived prior to exiting to wake up
anything blocking on signals.
* fhandler.h (fhandler_base::set_r_no_interrupt): Change to accept bool
argument.
(fhandler_pipe::ready_for_read): Declare.
* pipe.cc (pipeargs): New structure.
(read_pipe): New thread stub wrapper for normal pipe read.
(fhandler_pipe::read): Modify to call reader in a cygthread, terminating on
signal, as appropriate.
* select.cc (fhandler_pipe::ready_for_read): Define new function.
* pwdgrp.h (pwdgrp_check::pwdgrp_state): Replace by
pwdgrp_check::isinitializing ().
(pwdgrp_check::isinitializing): Create.
* passwd.cc (grab_int): Change type to unsigned, use strtoul and
set the pointer content to 0 if the field is invalid.
(parse_pwd): Move validity test after getting pw_gid.
(read_etc_passwd): Replace "passwd_state <= " by
passwd_state::isinitializing ().
(internal_getpwuid): Ditto.
(internal_getpwnam): Ditto.
(getpwent): Ditto.
(getpass): Ditto.
* grp.cc (parse_grp): Use strtoul for gr_gid and verify the validity.
(read_etc_group): Replace "group_state <= " by
group_state::isinitializing ().
(internal_getgrgid): Ditto.
(getgrent32): Ditto.
(internal_getgrent): Ditto.
2002-12-10 Pierre Humblet <pierre.humblet@ieee.org>
* security.h: Move declarations of internal_getgrent,
internal_getpwsid and internal_getgrsid to pwdgrp.h.
* pwdgrp.h: Declare internal_getpwsid, internal_getpwnam,
internal_getpwuid, internal_getgrsid, internal_getgrgid,
internal_getgrnam, internal_getgrent and internal_getgroups.
Delete "emulated" from enum pwdgrp_state.
(pwdgrp_check::isuninitialized): Create.
(pwdgrp_check::pwdgrp_state): Change state to initializing
rather than to uninitialized.
(pwdgrp_read::gets): Remove trailing CRs.
* passwd.cc (grab_string): Don't look for NLs.
(grab_int): Ditto.
(parse_pwd): Don't look for CRs. Return 0 if entry is too short.
(search_for): Delete.
(read_etc_passwd): Simplify tests to actually read the file.
Set state to loaded before making internal_getpwXX calls.
Replace search_for calls by equivalent internal_pwgetXX calls.
(internal_getpwsid): Use passwd_state.isuninitialized to decide
to call read_etc_passwd.
(internal_getpwuid): Create.
(internal_getpwnam): Create.
(getpwuid32): Simply call internal_getpwuid.
(getpwuid_r32): Call internal_getpwuid.
(getpwnam): Simply call internal_getpwnam.
(getpwnam_r): Call internal_getpwnam.
* grp.cc (parse_grp): Don't look for CRs. Adjust blank space.
(add_grp_line): Adjust blank space.
(class group_lock): Ditto.
(read_etc_group): Simplify tests to actually read the file.
Set state to loaded before making internal_getgrXX calls.
Replace getgrXX calls by equivalent internal calls.
(internal_getgrsid): Use group_state.isuninitialized to decide
to call read_etc_group.
(internal_getgrgid): Create.
(internal_getgrnam): Create.
(getgroups32): Simply call internal_getgrgid.
(getgrnam32): Simply call internal_getgrnam.
(internal_getgrent): Call group_state.isuninitialized.
(internal_getgroups): Create from the former getgroups32, using
two of the four arguments. Set gid to myself->gid and username
to cygheap->user.name ().
(getgroups32): Simply call internal_getgroup.
(getgroups): Call internal_getgroup instead of getgroups32.
(setgroups32): Call internal versions of get{pw,gr}XX.
* sec_helper.cc: Include pwdgrp.h.
(is_grp_member): Call internal versions of get{pw,gr}XX.
* security.cc: Include pwdgrp.h.
(alloc_sd): Call internal versions of get{pw,gr}XX.
* syscalls.cc: Include pwdgrp.h.
(seteuid32): Call internal versions of get{pw,gr}XX.
(setegid32): Ditto.
* uinfo.cc: Include pwdgrp.h.
(internal_getlogin): Call internal versions of get{pw,gr}XX.
(cygheap_user::ontherange): Ditto.
* sec_acl.cc: Include pwdgrp.h.
(setacl): Call internal versions of get{pw,gr}XX.
(acl_access): Ditto and simplify logic.
(aclfromtext): Ditto.
enum to allow the function to return an error.
* fhandler_console.cc (fhandler_console::read): Update the line_edit call to
use the new enum.
* fhandler_termios.cc (fhandler_termios::line_edit): Change return from an int
to an enum to allow the function to return an error. Put put_readahead call
before doecho for future patch.
* fhandler_tty.cc (fhandler_pty_master::write): Change to call line_edit one
character at a time, and stop if an error occurs.
* Makeile.in (DLL_OFILES): Add reference to the new netdb.cc file.
* cygwin.din : Add new aliased exports for service and protocol enumerations in
netdb.cc.
(winpids::init): New declaration.
(winpids::cs): Ditto.
(winpids::winpids): Use set rather than init.
* external.cc (fillout_pinfo): Ditto.
* dcrt0.cc (dll_crt0_1): Call winpids::init.
* pinfo.cc (winpids::set): Renamed from init. Wrap calls in critical section.
(winpids::init): New function.
(winpids::cs): Define.
* sec_acl.cc: Fix some formatting. Only set and check `other' bits in
a_perm throughout. Use ILLEGAL_GID id for all entries having no id.
(setacl): Fix inheritance condition.
(getacl): Set all permission bits in CLASS_OBJ and DEF_CLASS_OBJ
entries. Remove DENY bits before returning to calling function.
(acltomode): Fix usage of searchace(). If available, use CLASS_OBJ
to mask GROUP_OBJ permissions.
(aclfrommode): Fix usage of searchace(). If available, set CLASS_OBJ
permissions to same value as GROUP_OBJ permissions.
2002-11-24 Pierre Humblet <pierre.humblet@ieee.org>
* sec_acl.cc (getace): Fix the behavior when allow and
deny entries are present in arbitrary order.
(getacl): Report the actual number of entries when
aclbufp is NULL, even if nentries is zero. Fix the mask
reporting, handle the case where the owner and group sids
are equal and streamline the code.
(acl_worker): Take allow_ntsec into account.
* dcrt0.cc (dll_crt0_1): Add call to pthread::initMainThread to
initialize mainthread when it is safe to call new.
* init.cc (dll_entry): Change call to store reents in tls key.
* thread.cc (_reent_clib) : Change call to get reents from tls
key.
(_reent_winsup): Ditto.
(MTinterface::Init): Key handling changed. Remove initialization
of member variables.
(MTinterface::fixup_after_fork): Reinitialize mainthread object
after fork. Reset threadount to 1.
(pthread::initMainThread): Create mainthread object dynamically.
and initialize with valid handles.
(pthread::self): Remove calls to create thread objects.
(pthread::setTlsSelfPointer): Change call to store thread self
handle in tls key.
(pthread::getTlsSelfPointer): New static method.
(pthread::exit): Remove setTlsSelfPointer call.
(pthread::initCurrentThread): New method.
(pthread::thread_init_wrapper): Change call to store thread self
handle in tls key.
(pthread::join): Check for a valid joiner.
(pthreadNull::pthreadNull): Mark Null object as detached.
(pthreadNull::exit): Terminate thread via ExitThread.
* thread.h (pthread::initMainThread): Change parameter in function
call.
(pthread::getTlsSelfPointer): New static method.
(pthread::initCurrentThread): New method.
(MTinterface::reent_key): Remove.
(MTinterface::thread_self_dwTlsIndex): Ditto..
(MTinterface::indexallocated): Ditto.
(MTinterface::mainthread): Ditto.
(MTinterface::reent_key): New member.
(MTinterface::thread_self_key): Ditto.
(MTinterface::MTinterface): Initialize all members.