files in this case, instead of moving them to the recycler. Create
even more unique filename. Add comment to explain filename.
(unlink_nt): Remove code returning with EBUSY on remote shares.
Set bin_stat to move_to_bin except on NFS. Add comment to explain.
SubstituteName for volume string to recognize volume mount points.
Reuse subst when calling sys_wcstombs.
* syscalls.cc (rename): Set errno to EBUSY when trying to rename
volume mount points. Explain why.
(ro_u_sys): Ditto.
* syscalls.cc (nt_path_has_suffix): Replace with ...
(nt_path_has_executable_suffix): New function checking for explicit
executable suffixes.
(rename): Call nt_path_has_executable_suffix instead of
nt_path_has_suffix. Check oldpath for nt_path_has_executable_suffix
as well to set old_explicit_suffix.
CW_SET_EXTERNAL_TOKEN.
Add new enum CW_TOKEN_IMPERSONATION, CW_TOKEN_RESTRICTED.
* cygheap.h (cyguser): New flags ext_token_is_restricted,
curr_token_is_restricted and setuid_to_restricted.
* external.cc (cygwin_internal): Add CW_SET_EXTERNAL_TOKEN.
* sec_auth.cc (set_imp_token): New function.
(cygwin_set_impersonation_token): Call set_imp_token ().
* security.h (set_imp_token): New prototype.
* spawn.cc (spawn_guts): Use CreateProcessAsUserW if restricted token
was enabled by setuid(). Do not create new window station in this case.
* syscalls.cc (seteuid32): Add handling of restricted external tokens.
Set HANDLE_FLAG_INHERIT for primary token.
(setuid32): Set setuid_to_restricted flag.
* uinfo.cc (uinfo_init): Do not reimpersonate if restricted token was
enabled by setuid (). Initialize user.*_restricted flags.
call initial_setlocale from here.
* syscalls.cc (initial_setlocale): Set internal charset and revert
application locale to "C".
(setlocale): Don't set Cygwin's internal charset here.
* dcrt0.cc (dll_crt0_1): Call setlocale (LC_CTYPE, "") here, just
before resetting application locale to "C".
* environ.cc (environ_init): Drop code setting locale here.
* syscalls.cc (check_codepage): Break out check for required codepage
from internal_setlocale.
(internal_setlocale): Just convert CWD and $PATH from old charset to
new charset and set internal charset.
(setlocale): Change accordingly. Don't require LC_ALL or LC_CTYPE to
store old locale value. Always call internal_setlocale if charset
changed due to locale environment changes.
returning pointer to posix path.
(cwdstuff::reset_posix): Convert to non-inline method taking a wchar_t
pointer.
* path.cc (cwdstuff::set): Revert change from 2009-05-13. Set posix
to valid incoming path again.
(cwdstuff::reset_posix): New implementation setting posix path from
incoming wchar_t path. Explain usage.
(cwdstuff::get_posix): Drop implementation.
(cwdstuff::get): Drop special case to handle empty posix path.
* syscalls.cc (internal_setlocale): Store old posix cwd as wide char
path. Restore posix cwd using new charset. Explain why.
* sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig
after receiving an event that it is ready to go.
(init_sig_pipe): New function.
(wait_sig): Call init_sig_pipe to create pipes for communicating signals to
this process. Don't send sigCONT signal when initializing.
* fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change.
* fhandler.h (fhandler_*::write): Make ssize_t/__stdcall.
(fhandler_*::write_overlapped): Ditto.
(fhandler_*::raw_write): Ditto.
(fhandler_*::readv): Ditto.
(fhandler_*::writev): Ditto.
(fhandler_*::raw_read): Make __stdcall.
* fhandler: Accommodate changes to read/write functions throughout.
* fhandler_clipboard.cc: Ditto.
* fhandler_console.cc: Ditto.
* fhandler_dsp.cc: Ditto.
* fhandler_fifo.cc: Ditto.
* fhandler_mailslot.cc: Ditto.
* fhandler_mem.cc: Ditto.
* fhandler_mem.cc: Ditto.
* fhandler_random.cc: Ditto.
* fhandler_tape.cc: Ditto.
* fhandler_tty.cc: Ditto.
* fhandler_virtual.cc: Ditto.
* fhandler_windows.cc: Ditto.
* fhandler_zero.cc: Ditto.
* syscalls.cc (readv): Use ssize_t as temp variable.
* fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will
never be treated as < 0.
(fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove
duplicate debugging test. Fix error return.
* fhandler.h (fhandler_fifo::fifo_name): Declare new function.
(fhandler_fifo::close): Ditto.
(fhandler_fifo::dup): Ditto.
(fhandler_fifo::close_on_exec): Ditto.
* fhandler.cc (fhandler_fifo::fifo_name): Define new function.
(FIFO_BUF_SIZE): New define.
(cnp): Ditto.
(fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write
side as a client. Open dummy client when writing and can't connect.
(wait): Rework. Implement fifo_wait_for_next_client. Handle signals during
connect better. Add new fifo_wait_for_server code which polls
(sigh) waiting for server.
(fhandler_fifo::raw_read): Handle transition states when one client closes and
another is available.
(fhandler_fifo::close): Define.
(fhandler_fifo::dup): Ditto.
(fhandler_fifo::close_on_exec): Ditto.
* wincap.cc: Implement above element throughout.
* wchar.h (__sjis_mbtowc): Declare.
(__eucjp_mbtowc): Ditto.
(__gbk_mbtowc): Ditto.
(__kr_mbtowc): Ditto.
(__big5_mbtowc): Ditto.
* syscalls.cc (internal_setlocale): Convert to char * function.
Return parameter by default. Return NULL if request to use a
charset can't be satisfied due to missing codepage support in the
underlying OS. Fix comment.
(setlocale): Store original locale. Restore to original locale if
internal_setlocale returns NULL.
(select_record::select_record): Define do-nothing constructor for "new" to
avoid gratuitous zeroing.
(select_info): New base class.
(select_pipe_info): New class with methods for dealing with pipes.
(select_socket_info): New class with methods for dealing with sockets.
(select_serial_info): Dummy class for serial.
(select_mailslot_info): Dummy class for mailslots.
(select_stuff): Define device_specific_* as actual classes rather than void *.
* dtable.h (dtable::select_read): Accommodate return value change to 'bool' and
argument change to "select_stuff".
(dtable::select_write): Ditto.
(dtable::select_except): Ditto.
* dtable.cc (dtable::select_read): Accommodate return value change to 'bool'
and argument change to "select_stuff".
(dtable::select_write): Ditto.
(dtable::select_except): Ditto.
* fhandler.h: Excise select-related classes.
(fhandler_*::select_read): Change argument to select_stuff.
(fhandler_*::select_write): Ditto.
(fhandler_*::select_except): Ditto.
* select.cc (UNIX_FD_ZERO): Use memset rather than bzero.
(select_stuff::test_and_set): Change return type to bool. Allocate
select_record on entry and let fhandler_*::select_* operate on the start.next
field of select_stuff.
(pipeinf): Delete.
(select_pipe_info::select_pipe_info): New constructor. Allocates event for
controlling pipe waits.
(select_pipe_info::~select_pipe_info): New destructor. Destroy event. Stop
thread.
(select_pipe_info::add_watch_handle): New function.
(thread_pipe): Wait for the hEvent part of any overlapped pipes before peeking.
(start_thread_pipe): Don't allocate device_specific_pipe stuff here. Assume
that it has been allocated earlier.
(pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe
paraphenalia.
(fhandler_*::select_*): Derive select_record from new select_stuff argument.
(fhandler_pipe::select_*): Ditto. Allocate pipe-specific field if not already
allocated.
(serialinf): Delete.
(thread_serial): serialinf -> select_serial_info.
(fhandler_base::ready_for_read): Rewrite to accommodate change in argument to
fhandler_*::select_*.
(socketinf): Delete.
(thread_socket): socketinf -> select_socket_info.
(mailslotinf): Delete.
(thread_mailslot): mailslotinf -> select_mailslot_info.
* cygheap.h (struct cygheap_locale): New structure.
(struct user_heap_info): Add cygheap_locale member locale.
* dcrt0.cc (dll_crt0_1): Revert to calling _setlocale_r so that only
the applications locale is reverted to "C".
* environ.cc (environ_init): Remove unused got_lc variable.
* fhandler.h (class dev_console): Remove now unsed locale variables.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Remove
setting dev_console's locale members.
(dev_console::con_to_str): Use internal locale settings. Default to
__ascii_wctomb if charset is "ASCII".
(fhandler_console::write_normal): Ditto.
* strfuncs.cc (__ascii_wctomb): Drop declaration.
(__db_wctomb): Use fixed value 2 instead of not
necessarily matching MB_CUR_MAX.
(__eucjp_wctomb): Use 3 instead of MB_CUR_MAX.
(sys_cp_wcstombs): Remove special case for "C" locale.
(sys_wcstombs): Implement here. Use internal locale data stored on
cygheap.
(sys_cp_mbstowcs): Remove special case for "C" locale.
(sys_mbstowcs): Implement here. Use internal locale data stored on
cygheap.
* syscalls.cc (internal_setlocale): New function to set cygheap locale
data and to reset CWD posix path.
(setlocale): Just call internal_setlocale from here if necessary.
* wchar.h (__ascii_wctomb): Declare.
(sys_wcstombs): Don't define inline, just declare.
(sys_mbstowcs): Ditto.
(try_to_bin): Return bin_status. Rename win32_path to pc. Rename h
to fh. Rename fh to tmp_fh. Add code to set delete dispostion and
more code to replace file moved to bin by another, temporary file.
Add comments to explain why.
(unlink_nt): Replace move_to_bin with bin_stat. Only set bin_stat
to move_to_bin for non-remote files. As a last resort, call try_to_bin
if setting delete-on-close failed. Only re-set R/O DOS attribute
and only close handle if it's still valid.
where appropriate.
* globals.cc: New file for generic global variables.
* mkglobals_h: New file to generate globals.h.
* mkstatic: New Script used to build a (currently non-working) static
libcygwin_s.a.
* Makefile.in: Add unused rule to build a non-working libcygwin_s.a.
(DLL_OFILES): Add globals.o. Make all objects rely on globals.h.
(globals.h): New target. Generate globals.h.
* cygtls.h: Honor new CYGTLS_HANDLE define to control when the HANDLE operator
is allowed in _cygtls.
* dcrt0.cc: Move most globals to globals.cc.
* init.cc: Ditto.
* environ.cc (strip_title_path): Remove now-unneeded extern.
* fhandler_serial.cc (fhandler_serial::open): Ditto.
* pinfo.cc: Ditto.
(commune_process): Ditto.
* shared.cc: Ditto.
* glob.cc: Ditto.
* strace.cc: Ditto.
* exceptions.cc: Define CYGTLS_HANDLE before including winsup.h.
* path.cc (stat_suffixes): Move here.
* security.h: Add forward class path_conv declaration.
* smallprint.cc (__small_vsprintf): Make a true c++ function.
(__small_sprintf): Ditto.
(small_printf): Ditto.
(console_printf): Ditto.
(__small_vswprintf): Ditto.
(__small_swprintf): Ditto.
* spawn.cc (spawn_guts): Remove _stdcall decoration in favor of regparm.
(hExeced): Move to globals.cc
* strfuncs.cc (current_codepage): Ditto.
(active_codepage): Ditto.
* sync.cc (lock_process::locker): Move here from dcrt0.cc.
* syscalls.cc (stat_suffixes): Move to path.cc.
* tty.cc (tty::create_master): Uncapitalize fatal warning for consistency.
* winsup.h: Include globals.h to declare most of the grab bag list of globals
which were previously defined here.
* mount.h: Move USER_* defines back to shared_info.h.
* speclib: Force temporary directory cleanup.
* fhandler_fifo.cc (fhandler_fifo::open): Rework to cause errno to be set to
ENXIO when opening a fifo write/nonblocking.
* environ.cc (ucreqenv): Rename to ucenv. Move code from old ucenv here and
conditionalize it on create_upcaseenv.
(ucenv): Delete.
(environ_init): Fix compiler warning by moving create_upcaseenv test to ucenv.
Don't bother checking for child_proc_info when calling ucenv since it is
assumed to be NULL at the point where the function is called.
* path.cc (symlink_worker): Turn off MS-DOS path warnings when dealing with
devices since the device handler passes in a translated MS-DOS path.
* sec_auth.cc (lsaprivkeyauth): Avoid variable initialization which causes a
compiler error.
* fhandler_netdrive.cc: Update copyright.
* cygserver.h (CYGWIN_SERVER_VERSION_API): Bump.
(request_code_t): Define CYGSERVER_REQUEST_SETPWD request type.
* cygserver_msg.h (client_request_msg::retval): Use default value of -1
for retval if msglen is 0.
* cygserver_sem.h (client_request_sem::retval): Ditto.
* cygserver_shm.h (client_request_shm::retval): Ditto.
* cygserver_setpwd.h: New file.
* external.cc (cygwin_internal): Implement new CW_SET_PRIV_KEY type.
* sec_auth.cc (open_local_policy): Make externally available.
Get ACCESS_MASK as argument.
(create_token): Accommodate change to open_local_policy.
(lsaauth): Ditto.
(lsaprivkeyauth): New function fetching token by retrieving
password stored in Cygwin or Interix LSA private data area and
calling LogonUser with it.
* security.h (lsaprivkeyauth): Declare.
(open_local_policy): Declare.
* setlsapwd.cc: New file implementing setting LSA private data password
using LsaStorePrivateData or by calling cygserver if available.
* syscalls.cc (seteuid32): Add workaround to get the original token
when switching back to the original privileged user, even if
setgroups group list is still active. Add long comment to explain why.
Call lsaprivkeyauth first, only if that fails call lsaauth or
create_token.
* include/cygwin/version.h: Bump API minor number.
* include/sys/cygwin.h (cygwin_getinfo_types): Add CW_SET_PRIV_KEY.
* dtable.cc (handle_to_fn): Ditto.
* fhandler_console.cc (fhandler_console::read): Ditto.
(fhandler_console::scroll_screen): Ditto.
(dev_console::set_color): Ditto.
* fhandler_dsp.cc (fhandler_dev_dsp::write): Ditto.
(fhandler_dev_dsp::read): Ditto.
* fhandler_tape.cc (mtinfo_drive::get_status): Ditto.
* hookapi.cc (find_first_notloaded_dll): Ditto.
* mmap.cc (msync): Ditto.
* pipe.cc (pipesync::pipesync): Ditto.
* sec_acl.cc (getace): Ditto.
* sec_auth.cc (create_token): Ditto.
(lsaauth): Ditto.
* select.cc (peek_pipe): Ditto.
* spawn.cc (av::fixup): Ditto.
* syscalls.cc (popen): Ditto.
* tty.cc (tty::init_session): Ditto.
* uinfo.cc (pwdgrp::load): Ditto.
* fhandler.cc (fhandler_base::setup_overlapped): Ditto.
(fhandler_base::wait_overlapped): Rename second use of res variable to wres or
errors are not returned correctly.
* dcrt0.cc: Remove obsolete variable.
* dll_init.cc (release_upto): Fix typo involving incorrect use of '|'.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Avoid a compiler
warning regarding coercing type-punned variables.
(fhandler_base::fstat_by_name): Ditto. fhandler_fifo.cc
(fhandler_fifo::open_nonserver): Fix = vs. == typo.
(fhandler_fifo::wait): Add all conditions to switch statement to avoid a
compiler warning.
* fhandler_process.cc: Avoid unneeded initialization of variables to zero.
(fhandler_socket::listen): Add braces around initializer.
* flock.cc (inode_t::get_all_locks_list): Reorganize to avoid a compiler
warning. Fix problem with EWOULDBLOCK error return.
* path.cc (GUID_shortcut): Use braces around struct initializer.
(cygwin_conv_path): Reorganize to avoid a compiler warning.
* random.cc (dummy): Mark variable as volatile to avoid a "used uninitialized"
warning.
* libc/getopt.c: Mark some variables as dllexport although gcc doesn't seem to
do the right thing with them.
* libc/minires-os-if.c (get_registry_dns_items): Coerce some function arguments
to avoid a compiler warning.
user_shared_initialize_1 from here.
(dll_crt0_1): Remove dynamically_loaded check. Just call malloc_init and
user_shared_initialize unconditionally.
* shared.cc (user_shared_create): Rename from user_shared_initialize.
(user_shared_initialize): Rename from user_shared_initialize_1. Move complete
user_shared content initialization code here from user_shared_create.
* syscalls.cc (seteuid32): Remove call to user_shared_initialize_1. That is
implied by the "true" argument to user_shared_create().
here in case we're dynamically loaded. Explain why.
(dll_crt0_1): Call user_shared_initialize_1 from here.
* mount.cc (is_native_path): New inline function testing for native
and long Win32 path prefix.
(is_unc_share): Remove long WIn32 path prefix test.
(mount_info::create_root_entry): Use PATH_MAX buffer.
(mount_info::init): Ditto.
(mount_info::add_item): Test for is_native_path as well.
* path.cc (normalize_win32_path): Simplify native path prefix code.
* shared.cc (user_shared_initialize_1): New function taking user
shared initialization code relying on malloc and cygtls.
(user_shared_initialize): Move mountinfo initialization to
user_shared_initialize_1.
* shared_info.h (user_shared_initialize_1): Declare.
* syscalls.cc (seteuid32): Call user_shared_initialize_1 after user
changed.
Unconditionally handle mount points case-sensitive.
Unconditionally handle virtual paths case-sensitive.
Unconditionally handle registry paths case-insensitive.
Otherwise, accommodate case-sensitivity of given path throughout.
* cygheap.cc (cygheap_root::set): Get additional caseinsensitive
parameter and store it.
* cygheap.h (struct cygheap_root_mount_info): Add member
caseinsensitive.
* dlfcn.cc (get_full_path_of_dll): Drop PC_NOFULL parameter from call
to path_conv::check.
* environ.cc (pcheck_case): Remove.
(check_case_init): Remove.
(known): Drop "check_case" option.
* exceptions.cc (open_stackdumpfile): Add comment.
* fhandler.cc (fhandler_base::get_default_fmode): Call pathmatch
instead of strcasematch.
* fhandler_disk_file.cc: Accommodate case-sensitivity of given path
throughout.
(__DIR_mounts::check_mount): Unconditionally check virtual paths
case-sensitive.
(fhandler_disk_file::link): Drop case clash handling.
(fhandler_disk_file::open): Ditto.
(fhandler_disk_file::readdir_helper): Drop managed mount code.
* mount.cc: Remove managed mount code and datastructures.
(struct opt): Remove "managed" option. Add "posix=0" and "posix=1"
options.
(fillout_mntent): Remove "managed" output. Add "posix" output.
* path.cc (struct symlink_info): Remove case_clash member and
case_check method.
(pcheck_case): Remove.
(path_prefix_p): Take additional bool parameter "caseinsensitive".
(pathnmatch): Ditto.
(pathmatch): Ditto.
(mkrelpath): Ditto.
(fs_info::update): Set caseinsensitive flag according to file system
name and FILE_CASE_SENSITIVE_SEARCH flag. Add comment.
(tfx_chars_managed): Remove.
(transform_chars): Drop "managed" parameter. Always use tfx_chars.
(get_nt_native_path): Drop "managed" parameter. Make sure drive letters
are always upper case.
(getfileattr): Change second parameter to denote caseinsensitivity.
(path_conv::check): Initialize caseinsensitive to OBJ_CASE_INSENSITIVE.
Set caseinsensitive according to global obcaseinsensitive flag, file
system case sensitivity and MOUNT_NOPOSIX mount flag.
Drop case_clash and all the related code.
(symlink_worker): Drop case clash handling.
(symlink_info::set): Drop setting case_clash.
(symlink_info::case_check): Remove.
(cwdstuff::set): Add comment.
(etc::init): Take path_conv instead of PUNICODE_STRING as parameter to
allow case sensitivity.
* path.h (enum pathconv_arg): Drop PC_SYM_IGNORE.
(enum case_checking): Remove.
(enum path_types): Drop PATH_ENC, add PATH_NOPOSIX flag.
(struct fs_info): Add caseinsensitive flag and accessor methods.
(class path_conv): Add caseinsensitive member and define
objcaseinsensitive method. Drop case_clash member and isencoded method.
(pathmatch): Change prototype according to above change.
(pathnmatch): Ditto.
(path_prefix_p): Ditto.
(get_nt_native_path): Ditto.
(class etc): Ditto.
(fnunmunge): Remove prototype.
* shared.cc (shared_info::init_obcaseinsensitive): Initialize
obcaseinsensitive flag from obcaseinsensitive registry value.
(shared_info::initialize): Call init_obcaseinsensitive here by the
first process creating the shared memory.
* shared_info.h (mount_item::fnmunge): Remove.
(shared_info::obcaseinsensitive): Rename from obcaseinsensitivity.
(shared_info::init_obcaseinsensitive): Declare.
* syscalls.cc (try_to_bin): Add comment.
* include/sys/mount.h (MOUNT_ENC): Remove flag.
(MOUNT_NOPOSIX): Add flag.
(NtCreateTransaction): Define.
(NtCommitTransaction): Define.
(NtRollbackTransaction): Define.
(RtlGetCurrentTransaction): Define.
(RtlSetCurrentTransaction): Define.
* ntdll.h (TRANSACTION_ALL_ACCESS): Define.
(NtCreateTransaction): Declare.
(NtCommitTransaction): Declare.
(NtRollbackTransaction): Declare.
(RtlGetCurrentTransaction): Declare.
(RtlSetCurrentTransaction): Declare.
* syscalls.cc (start_transaction): New static function to start TxF
transaction.
(stop_transaction): New static function to end TxF transaction.
(rename): Call start_transaction and stop_transaction where appropriate
on systems supporting transactions.
* wincap.h (wincaps::has_transactions): New element.
* wincap.cc: Implement above element throughout.
* exceptions.cc (windows_system_directory): Make static. Convert to
WCHAR.
(_cygtls::inside_kernel): Accommodate above change. Check module
path name for leading \\?\ and skip, if so.
(try_to_debug): Call GetEnvironmentStringsW and convert evaluation to
WCHAR to avoid truncated environment problem.
(has_visible_window_station): Call GetUserObjectInformationW.
(events_init): Accommodate above conversion of windows_system_directory.
* init.cc (respawn_wow64_process): Use WCHAR functions to start new
process.
* net.cc (__dup_ent): Drop Windows 9x consideration.
(load_ipv6_funcs): Use WCHAR functions to load IPv6 libs.
* syscalls.cc (syscalls.cc): Remove call to GetDiskFreeSpace.
Revamp advisory file locking to avoid cross reference pointers as well
as to allow BSD flock semantics. More agressively delete unused nodes
and sync objects.
* fhandler.h (fhandler_base::ino): Rename from namehash. Fix comment.
(fhandler_base::node): Remove.
(fhandler_base::unique_id): Add.
(fhandler_base::del_my_locks): New method.
(get_ino): Rename from get_namehash. Change usage throughout Cygwin.
(get_unique_id): New method.
* fhandler.cc (fhandler_base::close): Call own del_my_locks method.
Fix comment.
(fhandler_base::fhandler_base): Accommodate new and changed members.
(fhandler_base::fixup_after_fork): Call del_my_locks.
(fhandler_base::fixup_after_exec): Ditto for files with close-on-exec
flag set.
* fhandler_disk_file.cc (get_ino_by_handle): Rename from
readdir_get_ino_by_handle. Accommodate throughout.
(fhandler_base::open_fs): Fill ino with inode number if FS has good
inodes. Allocate a LUID and store in unique_id to recognize file
descriptors referencing the same file object.
* flock.cc: Drop flock TODO comments. Use explicit types __dev32_t
and __ino64_t instead of dev_t and ino_t.
(LOCK_OBJ_NAME_LEN): Change to reflect longer lf_id length.
(get_obj_handle_count): New method.
(lockf_t::lf_id): Change type to long long.
(inode_t::get_lock_obj_handle_count): Drop in favor of static function
get_obj_handle_count.
(inode_t::del_locks): Remove.
(inode_t::get): Add create_if_missing flag argument.
(inode_t::del_my_locks): Reimplement to handle POSIX and BSD flock
locks. Return if node can be deleted or not.
(inode_t::~inode_t): Ditto. Close handles to i_dir and i_mtx.
(fixup_lockf_after_fork): Remove.
(fhandler_base::del_my_locks): New method.
(fixup_lockf_after_exec): Check if node can be deleted.
(inode_t::get): Only create node if create_if_missing is set. Lock
the returned node here before unlocking the node list.
(inode_t::get_all_locks_list): Accommodate new lf_id length.
(inode_t::create_lock_obj): Ditto.
(lockf_t::open_lock_obj): Ditto. Change return type to bool. De-const.
Set lf_obj instead of returning a handle.
(lockf_t::del_lock_obj): Call SetEvent only if new incoming parameters
allow it. Explain how it's supposed to work.
(fhandler_disk_file::lock): Only fetch file length in SEEK_END case.
Use NtQueryInformationFile(FileStandardInformation) instead of
calling fstat_by_handle. Always unlock node before returning.
Use fhandler's unique id to create lf_id for BSD flock locks.
Rely on node lock from inode_t::get. Call del_lock_obj on removed
locks here to allow explicit unlocking. Delete node if no lock exists
on the file anymore.
(lf_setlock): Get file handle as additional parameter. Handle the fact
that lf_getblock now always opens the attached event object. Reactivate
erroneously applied patch which deactivates setting thread priority.
Additionally handle blocking on BSD flock locks.
(lf_clearlock): Get file handle as additional parameter.
(lf_getlock): Close event handle opened by lf_getblock.
(lf_getblock): Open potentially blocking event object here and check
its signal state if it's a BSD flock lock.
(lf_wakelock): Get file handle as additional parameter.
* fork.cc (frok::child): Drop call to fixup_lockf_after_fork.
* ntdll.h (struct _EVENT_BASIC_INFORMATION): Define.
(enum _EVENT_INFORMATION_CLASS): Define.
(NtQueryEvent): Declare.
* fhandler.h (fhandler_base::fs_flags): Remove.
(fhandler_base::set_fs_flags): Remove.
(fhandler_base::get_fs_flags): Remove.
* fhandler.cc (fhandler_base::write): Check for sparse file using
pc.fs_flags().
* fhandler_disk_file.cc (fhandler_disk_file::ftruncate): Ditto.
The return of the volume serial number in fs_info.
* fhandler.h (get_dev): New method.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Drop call to
NtQueryVolumeInformationFile(FileFsVolumeInformation). Just use
get_dev() method.
* fhandler_fifo.cc (fhandler_fifo::open) Use device ID and inode number
to generate fifo name.
* path.h (fs_info::sernum): New member.
(fs_info::serial_number): New method.
(path_conv::fs_serial_number): New method.
* path.cc (fs_info::update): Fetch volume serial number and store in
sernum.
* pinfo.cc (status_exit): New function. Issue message when dll not found. Use
find_first_notloaded_dll to find a nonexistent dll.
(pinfo::maybe_set_exit_code_from_windows): Call status_exit when exit code >=
0xc0000000UL.
* sigproc.cc (child_info::proc_retry): Return exit code when
STATUS_DLL_NOT_FOUND.
* spawn.cc (spawn_guts): Minor cleanup.
* syscalls.cc (close_all_files): Don't actually close stderr filehandle. Just
make it noninheritable.
* winsup.h (find_first_notloaded_dll): Declare new function.
* ntdll.h: Add several missing NTSTATUS defines.
* autoload.cc (CreateDesktopW): Replace CreateDesktopA.
(CreateWindowStationW): Replace CreateWindowStationA.
(GetUserObjectInformationW): Replace GetUserObjectInformationA.
* cygheap.h (cwdstuff::get): Assume default buffer size NT_MAX_PATH.
* cygtls.cc (_cygtls::remove): Free temporary TLS path buffers.
* cygtls.h (TP_NUM_C_BUFS): Define.
(TP_NUM_W_BUFS): Define.
(class tls_pathbuf): New class to store pointers to thread local
temporary path buffers.
(_local_storage::pathbufs): New member.
* environ.cc (win_env::add_cache): Use temporary TLS path buffer instead
of stack based buffer.
(posify): Get temporary outenv buffer from calling function.
(environ_init): Create temporary TLS path buffer for posify.
(build_env): Create Windows environment block as WCHAR buffer.
* environ.h (build_env): Change declaration accordingly.
* external.cc (sync_winenv): Accommodate build_env change.
* fhandler_console.cc (fhandler_console::need_invisible): Use
GetUserObjectInformationW and CreateWindowStationW.
* fhandler_process.cc (format_process_maps): Use temporary TLS path
buffer instead of stack based buffer.
* fork.cc (frok::parent): Convert to use CreateProcessW.
* path.cc: Throughout use temporary TLS path buffers instead of stack
based buffer. Replace checks for CYG_MAX_PATH by checks for
NT_MAX_PATH.
(getfileattr): New function to replace GetFileAttributesA.
(normalize_win32_path): Remove Win32 and NT long path prefixes.
(getwd): Assume PATH_MAX + 1 buffer per SUSv3.
* path.h (class path_conv): Set path buffer to size NT_MAX_PATH.
(iswdrive): Define.
* pinfo.cc (commune_process): Use temporary TLS path buffer instead of
stack based buffer.
* registry.cc (get_registry_hive_path): Ditto.
(load_registry_hive): Ditto.
* spawn.cc (spawn_guts): Convert to use CreateProcessW and
CreateProcessAsUserW.
(av::fixup): Open/close file using NtOpenFile/NtClose.
* syscalls.cc (mknod_worker): Allow PATH_MAX file name.
(mknod32): Ditto.
(getusershell): Ditto.
* tls_pbuf.cc: New file implementing tls_pathbuf and tmp_pathbuf
methods.
* tls_pbuf.h: New header for files using tmp_pathbuf.
* tlsoffsets.h: Regenerate.
* winsup.h (NT_MAX_PATH): Define as 32767 to avoid USHORT overflow.
(cwcsdup1): New function.
* cygheap.h (cygheap_user::get_windows_id): New method returning PWCHAR.
(cwcsdup): Declare.
(cwcsdup1): Declare.
* registry.cc (get_registry_hive_path): Use WCHAR instead of char
throughout.
(load_registry_hive): Ditto.
* registry.h (get_registry_hive_path): Change declaration accordingly.
(load_registry_hive): Ditto.
* sec_helper.cc (cygpsid::string): New method returning PWCHAR.
* security.h (cygpsid::string): Declare.
* syscalls.cc (seteuid32): Convert local name var to WCHAR.
* uinfo.cc (cygheap_user::env_userprofile): Convert local name buffers
to WCHAR. Call sys_wcstombs_alloc to generate puserprof buffer.
* winsup.h: Fix comment.
(NT_MAX_PATH): New definition for maximum internal path length.
Use throughout where appropriate.
* include/limits.h (PATH_MAX): Set to 4096 as on Linux.
CYG_MAX_PATH.
* fhandler_tty.cc (fhandler_pty_master::ptsname): Set buffer size to
TTY_NAME_MAX.
* syscalls.cc (ttyname): Eliminate the `+ 1' from the name buffer size
since TTY_NAME_MAX already counts the trailing NUL.
* libc/bsdlib.cc (openpty): Set pts buffer size to TTY_NAME_MAX.
have no native NT path representation for simplified debug output.
* syscalls.cc: Convert debug output to print native NT path.
(unlink): Drop redundant debug output.
* delqueue.cc: Delete.
* fhandler.h (fhandler_base::close_fs): Drop declaration.
(fhandler_disk_file::close): Drop declaration.
* fhandler_disk_file.cc (fhandler_base::fstat_fs): Call close instead of
close_fs.
(fhandler_base::fstat_helper): Use open FH_UNIX handle in call to
get_file_attribute.
(fhandler_base::open_fs): Call close instead of get_file_attribute.
(fhandler_disk_file::close): Remove.
(fhandler_base::close_fs): Remove.
* fhandler_socket.cc (fhandler_socket::close): Just call
fhandler_base::close for FH_UNIX sockets.
* shared.cc (user_shared_initialize): Drop call to
user_shared->delqueue.init.
* shared_info.h (CURR_USER_MAGIC): Change according to below change.
(MAX_DELQUEUES_PENDING): Remove.
(class delqueue_list): Remove.
(class user_info): Remove delqueue.
* syscalls.cc (close_all_files): Drop call to
user_shared->delqueue.process_queue.
(unlink): Drop delqueue handling.
(STATUS_OBJECT_PATH_NOT_FOUND): Define.
(STATUS_BUFFER_OVERFLOW): Define.
(FILE_SUPERSEDED): Define.
(FILE_OPENED): Define.
(FILE_CREATED): Define.
(FILE_OVERWRITTEN): Define.
(FILE_EXISTS): Define.
(FILE_DOES_NOT_EXIST): Define.
(PIO_APC_ROUTINE): Typedef.
(NtFsControlFile): Fix parameter types to use PIO_APC_ROUTINE.
(NtWriteFile): Declare.
(RtlInt64ToHexUnicodeString): Declare.
* strfuncs.cc: Include ntdll.h.
(RtlInt64ToHexUnicodeString): New function.
* syscalls.cc (try_to_bin): Rewrite using native NT functions.
Only try to create recycle bin after unsuccessfully trying to move
file. Also try to create special files in recycle bin so that Windows
Explorer isn't unnecessarily stampeded.
separators, require them to be existing directories if so. Check
for a request to change only the case of the filename. Check paths
for case insensitve equality only once. Handle renaming a directory
to another, existing directory by unlinking the destination directory
first. If newpath points to an existing file with R/O attribute set,
try to unset R/O attribute first. Augment hardlink test by not
checking directories. If renaming fails with STATUS_ACCESS_DENIED,
try to unlink existing destination filename and try renaming again.
Drop useless test for non-empty directory. Always close fh at the
end of the function.
trying to rename it. Use nfh handle when checking for non-empty
newpath directory. Only change status if check_dir_not_empty really
returns STATUS_DIRECTORY_NOT_EMPTY.
oldpath and newpath referring to the same file. Test if oldpath
has more than one hardlink before opening oldpath (idea by Eric Blake).
Reorder test so that file id is tested before volume serial number.
* syscalls.cc (check_dir_not_empty): New static function.
(unlink_nt): Move code checking for non-empty dir to check_dir_not_empty
and call check_dir_not_empty instead.
(rename): Add fault handler. Check oldpath and newpath for trailing
. and .. path components and return EINVAL if so. Check oldpath
for being on a vrtual file system. If renaming a dir fails with
STATUS_ACCESS_DENIED, check if the target dir is non-empty and return
ENOTEMPTY if so.
for binary in case of .exe files.
* ntdll.h (RtlPrefixUnicodeString): Declare.
* path.cc (path_conv::is_binary): New method.
* path.h (path_conv::is_binary): Declare.
* syscalls.cc (rename_append_suffix): New static helper function for
rename.
(rename): Rewrite. New suffix tests. Use native NT functions.
FileAttributes set to 0 when calling NtSetInformationFile since it has
a special meaning.
(fhandler_disk_file::facl): Ditto.
(fhandler_disk_file::link): Only set attributes after copying files.
Use SetFileAttributesW.
* syscalls.cc (unlink_nt): Only care for actual FILE_ATTRIBUTE_READONLY.
Don't allow FileAttributes set to 0 when calling NtSetInformationFile.
After marking for deletion, restore R/O attribute on files to
accommodate hardlinks.
(fhandler_base::utimes_fs): Fix white space.
(fhandler_disk_file::lock): Remove 9x blurb from comment.
(fhandler_disk_file::mkdir): Use NtCreateFile/NtClose instead of
CreateDirectoryA.
(fhandler_disk_file::rmdir): Accommodate changes to unlink_nt.
Simplify post-delete SMB-related tests. Use NtQueryAttributesFile
instead of GetFileAttributes.
* ntdll.h (STATUS_DIRECTORY_NOT_EMPTY): Define.
(NtQueryAttributesFile): Declare.
* syscalls.cc (unlink_nt): Return NTSTATUS. Drop setattrs parameter.
Never use FILE_DELETE_ON_CLOSE, always use
NtSetInformationFile(FileDispositionInformation) instead.
Check for R/O attributes and open file with FILE_WRITE_ATTRIBUTES
access if any of them are set. Remove R/O attributes before
marking for delete if necessary. Revert them afterwards if necessary.
(unlink): Accommodate changes to unlink_nt.
readdir_get_ino.
* fhandler.h (fhandler_disk_file::readdir_helper): Switch file name
parameter to PUNICODE_STRING.
* fhandler_disk_file.cc: Drop including ntdef.h.
(class __DIR_mounts): Store mount points in UNICODE. Additionally
store cygdrive prefix in unicode here. Change methods accordingly.
(__DIR_mounts::eval_ino): Call new stat_worker instead of lstat64.
(__DIR_mounts::~__DIR_mounts): New destructor to free UNICODE buffers.
(path_conv::ndisk_links): Rewrite using native NT functions.
(fhandler_base::fstat_by_handle): Use NAME_MAX instead of CYG_MAX_PATH.
Always set pfvi->VolumeSerialNumber to non-0. Remove last resort
code.
(fhandler_base::fstat_by_name): Rewrite using native NT functions.
(fhandler_base::fstat_fs): Always call fstat_by_name if fstat_by_handle
fails.
(fhandler_base::fstat_helper): Rely on dwVolumeSerialNumber.
(fhandler_disk_file::facl): Call fstat_by_name if fstat_by_handle fails.
(DIR_BUF_SIZE): Define using NAME_MAX instead of CYG_MAX_PATH.
(__DIR_cache): Remove __name.
(d_dirname): Remove.
(fhandler_disk_file::opendir): Drop pathname length check.
Remove outdated comment. Use get_name method instead of accessing
pc.normalized_path directly.
(readdir_get_ino): Drop unused dir parameter. Accomodate throughout.
Allocate fname dynamically. Call new stat_worker instead of lstat64.
Call NtOpenFile instead of CreateFile. Call NtClose instead of
CloseHandle.
(fhandler_disk_file::readdir_helper): Use native NT functions.
Check for volume mount points and use correct inode number.
(fhandler_disk_file::readdir): Simplify slightly.
Use get_name instead of pc.normalized_path.
(fhandler_disk_file::rewinddir): Use RtlInitUnicodeString.
(fhandler_cygdrive::fstat): Ignore floppy drives. Set st_nlink
correctly.
(fhandler_cygdrive::readdir): Ignore floppy drives.
* fhandler_netdrive.cc (fhandler_netdrive::readdir): Accommodate
change to readdir_get_ino.
* fhandler_proc.cc (PROC_DIR_COUNT): Define.
(fhandler_proc::fstat): Evaluate correct link count for /proc.
* ntdll.h (struct _FILE_DIRECTORY_INFORMATION): Define.
(NtFsControlFile): Declare.
(RtlAppendUnicodeToString): Declare.
(RtlAppendUnicodeStringToString): Declare.
(RtlCompareUnicodeString): Declare.
(RtlCopyUnicodeString): Declare.
(RtlCreateUnicodeStringFromAsciiz): Declare.
(RtlEqualUnicodeString): Declare.
(RtlFreeUnicodeString): Declare.
(RtlInitEmptyUnicodeString): Declare.
(RtlSecondsSince1970ToTime): Declare.
(RtlInitEmptyUnicodeString): Define as inline function.
(RtlInitCountedUnicodeString): Define as inline function.
* path.cc (path_conv::check): New method with PUNICODE_STRING as path,
preliminary implementation.
(mount_info::get_mounts_here): Change to create UNICODE_STRINGs.
Also copy cygpath prefix into UNICODE_STRING.
(is_floppy): Drop 9x consideration.
* path.h: Drop including ntdef.h.
(path_conv::check): Add declaration.
(path_conv::path_conv): Add constructor for UNICODE_STRING paths.
* shared_info.h (mount_info::get_mounts_here): Change declaration.
* syscalls.cc: Drop forward declaration of stat_worker.
(stat_worke): Take path_conv as parameter. Drop nofollow flag.
(stat64): Create matching path_conv and call stat_worker with it.
(lstat64): Ditto.
* winsup.h: Include ntdef.h.
(stat_worker): Declare.
(readdir_get_ino): Change declaration.
variables. Call pc.get_object_attr to create object attributes.
* fhandler_disk_file.cc (fhandler_disk_file::opendir): Ditto.
* syscalls.cc (unlink_nt): Ditto.
* path.cc (path_conv::set_normalized_path): Set wide_path to NULL.
(path_conv::get_nt_native_path): Drop parameter. Create path in
wide_path/uni_path members.
(path_conv::get_object_attr): New method to create object attributes.
(path_conv::get_wide_win32_path): New method to create Win32 wide path.
(path_conv::check): Initialize wide_path to NULL.
(path_conv::~path_conv): cfree wide_path.
* path.h (class path_conv): New members wide_path and uni_path.
Add declarations of get_object_attr and get_wide_win32_path.
(path_conv::path_conv): Initialize wide_path to NULL.
(path_conv::get_nt_native_path): Drop parameter.
Accommodate changge throughout Cygwin.
(cygheap_user::imp_token): Rename from token. Accommodate changge
throughout Cygwin.
(rcygheap_user::eimpersonate): Use primary token for impersonation.
* grp.cc (internal_getgroups): Use primary impersonation token when
impersonated.
* security.h (_push_thread_privilege): Use primary impersonation token
when impersonated.
(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.
* 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.
* 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.
(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.
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.
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.
(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.
* 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.
* 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.
(child_info::retry): Move here from fork subclass.
(child_info::exit_code): New field.
(child_info::retry_count): Max retry count for process start.
(child_info::proc_retry): Declare new function.
(child_info_fork::retry): Move to parent.
(child_info_fork::fork_retry): Ditto.
* dcrt0.cc (child_info::fork_retry): Rename and move.
(child_info_fork::handle_failure): Move.
(dll_crt0_0): Initialize console handler based on whether we have a controlling
tty or not. Avoid nonsensical check for fork where it can never occur.
* environ.cc (set_proc_retry): Rename from set_fork_retry. Set retry_count in
child_info.
(parse_thing): Reflect above change.
* exceptions.cc (dummy_ctrl_c_handler): Remove unused variable name.
(ctrl_c_handler): Always return TRUE for the annoying CTRL_LOGOFF_EVENT.
* fhandler_termios.cc (fhandler_termios::tcsetpgrp): Remove call to
init_console_handler.
* fhandler_tty.cc (fhandler_tty_slave::open): Just call mange_console_count
here and let it decide what to do with initializing console control handling.
* fork.cc (fork_retry): Remove definition.
(frok::parent): Define static errbuf and use in error messages (not thread safe
yet). Close pi.hThread as soon as possible. Protect pi.hProcess as soon as
possible. Don't set retry_count. That happens automatically in the
constructor now. Accommodate name change from fork_retry to proc_retry.
* init.cc (dll_entry): Turn off ctrl-c handling early until we know how it is
supposed to be handled.
* pinfo.cc (_pinfo::dup_proc_pipe): Remember original proc pipe value for
failure error message. Tweak debug message slightly.
* sigproc.cc (child_info::retry_count): Define.
(child_info::child_info): Initialize retry count.
(child_info::sync): Set exit code if process dies before synchronization.
(child_info::proc_retry): Rename from child_info_fork::fork_retry. Use
previously derived exit code. Be more defensive about what is classified as an
error exit.
(child_info_fork::handle_failure): Move here from dcrt0.cc.
* spawn.cc (spawn_guts): Maintain error mode when starting new process to avoid
annoying pop ups. Move deimpersonate call within new loop. Move envblock
freeing to end. Loop if process dies prematurely with bad exit code.
* syscalls.cc (init_console_handler): Remove hopefully unneeded call to
init_console_handler.
* dll_init.cc (cygwin_detach_dll): Use new tls function to find return address
since this function is now signal guarded.
(update_envptrs): Remove unneeded braces.
* syscalls.cc (statvfs): Coerce full_path to avoid a gcc warning.