and `RegLoadKeyA'.
* registry.cc (get_registry_hive_path): New function.
(load_registry_hive): Ditto.
* security.cc (convert_sid_to_string_sid): New function.
(get_ssid): Renamed to `convert_string_sid_to_sid'.
(get_pw_sid): Call `convert_string_sid_to_sid' instead of `get_ssid'.
(get_gr_sid): Ditto.
(get_admin_sid): Ditto.
(get_system_sid): Ditto.
(get_creator_owner_sid): Ditto.
(get_world_sid): Ditto.
* shared.h: New prototypes for `get_registry_hive_path' and
`load_registry_hive'.
* spawn.cc (spawn_guts): Set child->psid to NULL to force calling
`internal_getlogin' from child process in case of changing user context.
Call `load_registry_hive' in case of changing user context.
(_spawnve): Copy user infos only if user context remains the same.
* uinfo.cc: Add load statement for `NetUserGetInfo'.
Remove load statement for `NetGetDCName'.
(internal_getlogin): Rewrite to speed up process startup
and to correct user environment in case user context changes.
(uinfo_init): Call internal_getlogin only if myself->psid is NULL,
that is user context changes.
* winsup.h: Add prototypes for `convert_sid_to_string_sid',
`convert_string_sid_to_sid' and `get_pw_sid'.
`cygwin_set_impersonation_token'.
* dcrt0.cc (dll_crt0_1): Eliminate superfluous conditional
statements.
Add load statements for `ImpersonateLoggedOnUser', `LogonUserA'
and `RevertToSelf'.
* fork.cc (fork): Care for correct impersonation of parent
and child process.
* security.cc (cygwin_set_impersonation_token): New function.
(cygwin_logon_user): Ditto.
shared.h (class pinfo): New members `orig_uid', `orig_gid',
`real_uid' nad `real_gid'.
spawn.cc (spawn_guts): Care for impersonation when starting
child process in a different user context.
* syscalls.cc (setgid): Call `setegid' now. Set real_gid.
(setuid): Call `seteuid' now. Set real_uid.
(seteuid): Functionality moved from setuid to here. Care for
correct impersonation.
(setegid): Functionality moved from setgid to here.
* uinfo.cc (uinfo_init): Initialization of additional pinfo
members.
(getuid): Return real uid.
(getgid): Return real gid.
(geteuid): Return effective uid.
(getegid): Return effective gid.
include/sys/cygwin.h: Add prototypes for `cygwin_logon_user' and
`cygwin_set_impersonation_token'.
include/cygwin/version.h: Bumb API minor version to 22.
* path.cc: Ditto.
(normalize_posix_path): Add some extra debugging info.
(chdir): Ditto. Store chdir'ed posix and MS-DOS directory names in "cache"
here rather than trying to derive them later.
(mount_slash): Eliminated.
(mount_info::read_mounts): Eliminate looking up existing entries. The
loop for deleting cygpath entries is done only when such entries exist.
(mount_info::from_registry): Eliminate sorting.
(mount_info::add_item): Call add_reg_mount if necessary. Check nmounts
more precisely. Use strcasematch in looking up existing entries.
(mount_info::del_item): Call del_reg_mount if necessary. Use
strcasematch. Use memmove instead of memcpy.
(mount_info::import_v1_registry): Everything is done in this method.
(mount_info::to_registry): Eliminated.
(mount_info::from_v1_registry): Eliminated.
(cygwin_umount): Simply call del_item.
shared.h: Modify the declaration of add_item and del_item. Remove the
declaration of from_v1_registry.
* autoload.h: Add additional field to autoload block for handling unimplemented
functions.
(LoadDLLfuncEx): New function which accepts additional parameter for
controlling unimplemented function behavior.
(LoadDLLfunc): Use LoadDLLfuncEx.
* dcrt0.cc: Use new arguments for LoadDLLfunc. Add advapi32 routines.
(noload): Rewrite in assembler. Handle new unimplemented function type.
* exceptions.cc: Eliminate another vestige of StackWalk stuff.
* net.cc: Use new arguments for LoadDLLfunc.
* uinfo.cc: Ditto.
* config.h.in: Remove obsolete define.
* path.h (isdrive): New macro.
* dcrt0.cc (globify): Use new macro to determine if a string refers to an
MS-DOS drive.
* environ.cc (winenv): Ditto.
* spawn.cc (find_exec): Ditto.
* path.cc (get_raw_device_number): Ditto.
(mount_info::conv_to_posix_path): Ditto.
(chdir): Ditto.
(cygwin_posix_path_list_p): Ditto.
(cygwin_split_path): Ditto.
(path_conv::check): Move tmp_buf to beginning of function since it can be used
earlier in the loop. Use tmp_buf rather than 'root' to hold root information.
(mount_info::conv_to_win32_path): Add trailing slash to end of mount path when
it translates to a drive. Add defensive code to avoid writing beyond the end
of 'dst'.
return always 1 for now.
(mkdir): Call set_file_attribute explicitely with S_IFDIR mode bit.
* syscalls.cc (chown_worker): Ditto.
(chmod): Ditto.
* security.cc (get_nt_attribute): Fix error in debug output.
Never set FILE_DELETE_CHILD for files.
Construct appropriate inherit attribute according to file type.
directory name when the ms-dos path spec is a root directory of a device.
* registry.cc (reg_key::build_reg): Set 'key_is_invalid' flag rather than using
an INVALID_HANDLE_KEY.
(reg_key::get_int): Test for key validity before performing registry
operations.
(reg_key::set_int): Ditto.
(reg_key::get_string): Ditto.
(reg_key::set_string): Ditto.
(reg_key::kill): Ditto.
(reg_key::~reg_key): Ditto.
when trying to remove a directory on a samba share.
Eliminate superfluous else branch.
* syscalls.cc (_rename): Additional check for ERROR_FILE_EXISTS
if MoveFile fails.
race.
(noload): Add an extra argument for debugging.
* uinfo.cc (uinfo_init): Eliminate test for multiple calls.
(getlogin): Assume that uinfo_init has already been called.
just checks for validity. Flag module handle == 0 as noninterrupible.
(call_handler): Always acquire and release ebp lock. Loop for only a fixed
amount of time attempting to grab mutos and find an interruptible PC.
* external.cc: Eliminate obsolete include.
* getopt.c (getopt_long): Fix compiler warning.
* shared.h: Moved PID_ definitions to include/sys/cygwin so that they can be
used by external programs.
* include/sys/cygwin.h: Move external definitions here. Include sys/resource.h
to avoid having to do this everywhere.
referring to something like c:\.
* dcrt0.cc (dll_crt0_1): Move uinfo initialization prior to sig_send
initialization to give signal thread a chance to finish.
* debug.cc (WFSO): Move to sigproc.cc
(WFMO): Ditto.
* exceptions.cc (interruptible): Allocate slightly more space for directory
just for paranoia's sake.
(call_handler): Eliminate nonmain argument. Determine if main thread has set a
frame pointer and use it if so.
(sig_handle): Eliminate nonmain argument.
* net.cc: Record frame information in appropriate routines throughout.
* select.cc (select): Ditto.
* sigproc.cc: Use sigthread structure to record mainthread id throughout.
(sig_send): Record frame information for signal handler.
(wait_sig): Reflect argument change in sig_handle.
(WFSO): Move here and record frame information for signal handler.
(WFMO): Ditto.
* sigproc.h: Implement new "sigthread" class. Implement "sigframe" class for
manipulating signal frame info.
* thread.cc (__pthread_kill): Use standard _kill() function rather than calling
sig_send directly.
* winsup.h: Eliminate ebp element from signal_dispatch class.
for WriteFile and ReadFile to get rid of ERROR_MEDIA_CHANGED
and ERROR_BUS_RESET in case of first access to tape.
(fhandler_dev_raw::raw_write): Use write_file instead of WriteFile.
(fhandler_dev_raw::raw_read): Use read_file instead of ReadFile.
better handling of symbols.
* configure: Regenerate.
* delqueue.cc (delqueue_list::process_queue): Allow ERROR_ACCESS_DENIED to
indicate that a file is being shared under Windows 95.
* syscalls.cc (_unlink): Use full path name. Take special action for Windows
95. Assume that an ERROR_ACCESS_DENIED indicates a sharing violation unless
it's on a remote drive. Punt if there is an ERROR_ACCESS_DENIED on a remote
drive.
* fhandler.h: Add device type FH_RANDOM. Add class
fhandler_dev_random.
* fhandler_random.cc: New file. Implementation of
fhandler_dev_random.
* hinfo.cc (build_fhandler): Add case for FH_RANDOM.
* path.cc: Add device names for random devices to
windows_device_names.
(get_device_number): Add if branch for random devices.
(win32_device_name): Add device name generation for
random devices.
winsup.h: Include <wincrypt.h>.
name check. Windows 95 seems to null-terminate the directory otherwise.
(interrupt_on_return): Issue a fatal error if we can't find the caller's stack.
* spawn.cc (find_exec): Accept a path_conv argument rather than a buffer so
that the caller can find things out about a translated path.
(perhaps_suffix): Ditto.
(spawn_guts): Allocate path_conv stuff here so that we can find out stuff about
the translated path (this is work in progress).
* environ.cc (environ_init): Accept an as-yet unused argument indicating
whether we were invoked from a cygwin parent or not.
(winenv): Ditto.
(posify): Accept an argument indicating whether the path has already been
translated.
* dlfcn.cc (check_access): Provide a path_conv buffer to find_exec.
* exec.cc (sexecvpe): Ditto.
* path.cc (path_conv::check): Rename from path_conv::path_conv.
(mount_item::getmntent): Recognize "Cygwin executable" bit.
(symlink_info::check): Remove debugging statements.
* path.h (class path_conv): Add iscygexec method. Rewrite constructor to call
"check" method to allow multiple operations on a path_conv variable.
* pinfo.cc (pinfo_init): Pass argument to environ_init.
* shared.h: Bump PROC_MAGIC.
* winsup.h: Reflect above changes to function arguments.
* include/sys/mount.h: Add MOUNT_CYGWIN_EXEC type.
when determining exec flag.
* path.cc (symlink_info::check): Remove call to get_file_attribute().
* security.cc (read_sd): Rename, ditto for variables to conform
to common naming convention. Use GetFileSecurity() instead of
BackupRead() to avoid permission problems when reading ACLs.
(write_sd): Same renaming as for read_sd().
(alloc_sd): Change default permissions according to Linux permissions
for group and world when write permission is set.
* syscalls.cc (stat_worker): Avoid different permission problems
when requesting file informations.
rewrite this function to deal with trailing dots.
(mount_info::conv_to_win32_path): Just check for '/' where appropriate.
Eliminate nofinalslash call since it is handled in normalize_posix_path now.
(fhandler_base::set_inheritance): Make this a method so that we can use the
appropriate close methods.
* fhandler.cc (fhandler_base::set_inheritance): Ditto.
* path.cc (normalize_posix_path): Eliminate /. trailing path component.
* path.cc (symlink_info::check): Rename from symlink_check_one. Use new
symlink_info struct for communication.
(path_conv::path_conv): Use symlink_info structure for communication with
symlink_info::check. Fix typo which resulted in symbolic links always being
resolved.
(readlink): Use stat_suffixes array when resolving a link.
* syscalls.cc (stat_suffixes): Make global.
in forked process.
(interruptible): Flag as interruptible when running in main process module.
(interrupt_setup): Save return address and address of return address.
(signal_fixup_after_fork): New function. Uses above two values to restore
proper behavior to forked process.
(interrupt_on_return): Pass return address address to interupt_setup.
(interrupt_now): Pass NULL for return address address to interrupt_setup.
* fork.cc (fork): Call signal_fixup_after_fork.
* shared.h: Lint cleanups.
* winsup.h: Ditto.
fchmod, fchown, lchown.
* winsup/cygwin/syscalls.cc (chown_worker): Use previous
uid/gid if new uid/gid is -1.
New static function with chown functionality.
(chown): Call chown_worker with SYMLINK_FOLLOW.
(fchown): New function. Call chown_worker with SYMLINK_FOLLOW.
(lchown): New function. Call chown_worker with SYMLINK_IGNORE.
* cygwin.din: Add symbols for fchown, lchown.
* path.cc (symlink): Call `set_file_attribute()' and
`SetFileAttributeA()' instead of `chmod()' to set
uid/gid correct.
* path.h: Make PATH_SYMLINK an alias for MOUNT_SYMLINK.
* syscalls.cc (stat_worker): Use extension search mechanism in path_conv to
look for .exe rather than trying to special case it here.
* mount.h: Make MOUNT_SYMLINK a real option.
* path.h (class path_conv): Add a char * operator for the most common case.
* syscalls.cc (_unlink): Rewrite to use FILE_FLAG_DELETE_ON_CLOSE when possible
(i.e., on NT).
(get_nt_attribute): Returns uid and gid additionally. Removed call
to set_process_privileges().
(get_file_attribute): Returns uid and gid additionally. Don't
call ntea if ntsec is ON.
(set_nt_attribute): Removed call to set_process_privileges().
Don't call ntea if ntsec is ON.
(acl): Removed call to set_process_privileges().
* dcrt0.cc (dll_crt0_1): Calls set_process_privileges() now.
* winsup.h: New prototype for set_process_privileges(),
changed prototype for get_file_attribute().
* fhandler.cc (get_file_owner): Discarded.
(get_file_group): Ditto.
(fhandler_disk_file::fstat): Discard calls to get_file_owner() and
get_file_group().
* path.cc (path_conv::path_conv): Added debugging output for result
of GetVolumeInformation().
(mount_info::conv_to_win32_path): Call backslashify() with pathbuf
instead of src_path.
* syscalls.cc (chown): Reformatted.
(chmod): Replace get_file_owner() and get_file_group() calls
by a call to get_file_attribute(). Discard local variable has_acls.
Slightly reformatted.
(stat_worker): Replaced idiot's (it's me) root dir check by call
to rootdir(). Don't call num_entries() on remote drives.
Discard local variable has_acls.
* debug.cc (threadname_init): Pass name of lock as arg 2 of new_muto.
* malloc.cc (malloc_init): Ditto.
* sigproc.cc (sigproc_init): Ditto.
* exceptions.cc (events_init): Ditto.
(call_handler): Eliminate special case for hExeced. Report locked thread in
debugging output.
* fhandler.cc (fhandker_pipe::fhandler_pipe): Propagate device type to base
class.
* fhandler.h (fhandler_pipe): Ditto.
* hinfo.cc (hinfo::build_fhandler): Pass specific type of pipe to constructor.
* spawn.cc (spawn_guts): Eliminate dependency on signal when waiting for
subprocess.
* strace.cc: Remove obsolete #ifdef.
* sync.cc (muto::muto): Save the name of the muto.
(muto:~muto): Also release the muto.
* sync.h: Add a muto name field.
* select.cc (peek_pipe): Avoid doing a PeekNamedPipe on the write end of a
pipe.
* fhandler.h: Declare new function. Add extra argument to
process_slave_output.
* fhandler_console.cc (fhandler_console::read): Move read ahead code to new
function.
* fhandler_tty.cc (fhandler_pty_master::process_slave_output): Move common code
here.
(fhandler_tty_slave::read): Understand readahead.
(fhandler_pty_master::read): Move code to process_slave_output.
* select.cc (peek_pipe): Avoid performing certain checks when non-read and on
inappropriate fh types.
on interrupt if executing in a "cygwin" thread.
* fhandler_tty.cc (fhandler_pty_master::process_slave_output): Streamline,
simplify code.
* sigproc.cc (sig_send): Remove debugging statement.
* exceptions.cc (sfta): Eliminate obsolete function.
(sgmb): Eliminate obsolete function.
(class stack_info): Remove MS method for walking the stack.
(stack_info::init): Just initialize required fields.
(stack_info::brute_force): Rename to stack_info::walk.
(handle_exceptions): Pass derived frame pointer to sig_send.
(interrupt_setup): Clear saved frame pointer here.
(interrupt_on_return): thestack is no longer a pointer.
(call_handler): Accept a flag to indicate when a signal was sent from other
than the main thread. Use saved frame pointer for determining where to place
signal handler call.
(sig_handle): Accept "nonmain" argument. Pass it to call_handler.
* fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Change
debugging output slightly.
* (fhandler_tty_common::__release_output_mutex): Ditto.
(fhandler_tty_slave::read): Fix a comment, remove a goto.
* sigproc.cc (sig_send): Accept an optional frame pointer argument for use when
suspending the main process. sigcomplete_main is an autoreset event now. Save
frame pointer for non-main operation.
(wait_sig): Make sigcomplete_main an autoreset event. Eliminate NOSIGQUEUE.
Pass rc to sig_handle to signify if this was a nonmain process.
* sigproc.h: Reflect change to sig_send argument.
* syscalls.cc (swab): Eliminate swab function since it is now available in
newlib.
* winsup.h (signal_dispatch): Change CONTEXT cx to DWORD ebp.
(getprogname): Eliminate obsolete function.
(dll_crt0_1): Move initial strace initialization output to set_myself.
* exceptions.cc (interruptible): Add debugging output.
(interrupt_setup): New function.
(interrupt_now): Use interrupt_setup to set up common interrupt handler stuff.
(interrupt_on_return): Ditto.
(call_handler): Move signal_arrived arm and clear threads to region where
signalled thread is suspended or suffer races.
* pinfo.cc (set_myself): Output interesting information when strace is first
initialized. Initialize progname here.
* sigproc.cc (sig_dispatch_pending): Modify to ensure that flush signal are
sent synchronously.
* strace.cc (strace_vsprintf): Move code into strace program.
* uname.cc (uname): Use 'osname' global to construct cygwin name + Windows type
+ version.
(call_handler): Allow signals to be sent even if signalled thread is stopped.
Change order of signal_arrived arming/waiting threads clearing to eliminate a
race.
(reset_signal_arrived): New helper function.
* malloc.cc (malloc_init): Use mutos so that signal handler can keep track of
who owns the lock.
(__malloc_lock): Ditto.
(__malloc_unlock): Ditto.
* sync.h (new_muto): Actually use a muto for the "buffer".
* Makefile.in: Fix a dependency.
* debug.cc (iscygthread): New function.
* debug.h: Declare it.
* exceptions.cc (set_process_mask): Flush pending signals.
(handle_sigsuspend): No need to flush pending signals.
(call_handler): Refine previous tests of muto ownership. Only clear wait()'s
when we have definitely responded to a signal.
* fhandler_console.cc (fhandler_console::read): Don't set EINTR if executing in
a "cygwin" thread.
* sigproc.cc (proc_subproc): Use second argument to control whether CLEARWAIT
actually sets "signalled" flag.
* sync.h (muto): Add 'unstable' method.
interruptible.
(call_handler): Avoid suspending a thread if it owns a mutex. Only set
signal_arrived if the thread was actually interrupted.
(events_init): Initialize module information needed by interruptible().
(sigdelayed): Don't call sig_dispatch_pending since it could screw up
* init.cc (dll_entry): Record module handle of main for use by interruptible().
(proc_subproc): Reorganize handling of terminated child so that the bulk of the
processing comes from the signal thread.
(wait_sig): Force processing of waiting threads if SIGCHLD is not processed.
* sync.cc (muto::release): Set tid == 0 after lock is released or signal
processor will be confused.