Commit Graph

155 Commits

Author SHA1 Message Date
Christopher Faylor 6b91b8d53b Throughout, reorganize header file inclusion to put security.h prior to
fhandler.h.
* fhandler.h (fhandler_base::get_inheritance): New method.
* fhandler_socket.cc (fhandler_socket::create_secret_event): Use proper
close-on-exec inheritance when creating.
(fhandler_socket::check_peer_secret_event): Create handle as non-inheritable.
2001-07-26 19:22:24 +00:00
Christopher Faylor 7a4078ee34 Change check_null_empty_path* to check_null_empty_str* throughout.
* path.cc (path_conv::check): Add signal protection here since retrieving info
about remote shares can take some time.
* path.h (check_null_empty_str_errno): Convert to a function prototype.
* path.cc (check_null_empty_str): Move to miscfuncs.cc.
* miscfuncs.cc (check_null_empty_str_errno): New function.
(__check_null_invalid_struct): Ditto.
(__check_null_invalid_struct_errno): Ditto.
(check_null_empty_str): Change from VirtualQuery to IsBadWritePtr.
* thread.cc (check_valid_pointer): Ditto.
* resource.cc (getrlimit): Use check_null_invalid_struct macro for checking
validity of pointer.
(setrlimit): Ditto.
2001-06-28 02:19:57 +00:00
Christopher Faylor 99a5bd2fab * exceptions.cc (sig_handle_tty_stop): Reset PID_STOPPED if not actually
stopping.
* fhandler_console.cc (fhandler_console::fixup_after_fork): Don't set
controlling terminal if just inheriting a handle.
(fhandler_console::fixup_after_exec): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::init): Ditto.
* signal.cc (kill_worker): Set appropriate errno if proc_exists determines that
process does not really exist.
2001-06-16 17:09:19 +00:00
Christopher Faylor 947ab99ee9 * path.cc (path_conv::check): Deal more robustly with foo/ behavior. 2001-06-15 20:35:51 +00:00
Christopher Faylor f375b8d9f4 * path.cc (chdir): Fix call to path_conv constructor so that it REALLY doesn't
check for the null/non-empty path.
2001-06-11 15:20:49 +00:00
Christopher Faylor fc633b63a2 * path.cc (path_conv::update_fs_info): Don't consider remote drives to be NTFS.
Set root_dir before invoking GetDriveType (from Kazuhiro Fujieda
<fujieda@jaist.ac.jp>).  Eliminate extra checks for rootdir.
2001-06-11 03:38:32 +00:00
Christopher Faylor 02782489a9 * path.cc (chdir): Pre-check path for validity before eating trailing space.
Then, ensure that path_conv doesn't check the path for validity again.
2001-06-11 00:24:28 +00:00
Corinna Vinschen 463513f0e2 * cygwin.din: Add fchdir symbols.
* path.cc (chdir): Guard against invalid parameter.
         (fchdir): New function.
         * include/cygwin/version.h: Bump API minor version to 40.
         * uinfo.cc (internal_getlogin): Remove unused variable.
2001-06-10 10:00:21 +00:00
Egor Duda 149da470f3 * security.h (NTWriteEA): Change prototype.
* ntea.cc (NTReadEA): Don't check for global ntea setting, now
it's caller responsibility.
(NTWriteEA): Ditto.
* security.cc (get_file_attribute): Read attribute from EA only
if 'ntea' is enabled.
(set_file_attribute): Ditto.
* path.h: (class path_conv): Add members to store file system
information.
(path_conv::get_drive_type): New function.
* syscalls.cc (stat_worker): Use it.
* path.cc (path_conv::update_fs_info): New functions.
(path_conv::check): Get file system information from device where
file resides. On NTFS, try to read symlink contents from EA.
(get_symlink_ea): New function.
(set_symlink_ea): Ditto.
(symlink): Store symlink in extended attribute, if possible.
2001-06-05 10:45:52 +00:00
Christopher Faylor ac5561f2ed * path.cc (normalize_posix_path): Revert .. check removed by previous changes.
* cygheap.h: Temporarily declare path_prefix_p here.
2001-06-04 01:28:09 +00:00
Christopher Faylor 7ceb1cac3a * cygheap.cc (cygheap_root::cygheap_rot): Remove constructor.
(cygheap_root::~cygheap_root): Remove destructor.
(cygheap_root::operator =): Remove.
(cygheap_root::set): New method.
* cygheap.h (cygheap_root): Reflect above changes.  Store root info in
mount-like structure.
(cygheap_root:posix_ok): New method.
(cygheap_root::ischroot_native): Ditto.
(cygheap_root::unchroot): Ditto.
(cygheap_root::exists): Ditto.
(cygheap_root::posix_length): Ditto.
(cygheap_root::posix_path): Ditto.
(cygheap_root::native_length): Ditto.
(cygheap_root::native_path): Ditto.
* dir.cc (opendir): Remove special chroot test.
* path.cc (path_prefix_p): Remove front end.
(normalize_posix_path): Reorganize chroot tests to accomodate new convention of
allowing paths using posix chroot prefix.
(path_conv::check): Pass a "already ran normalize" option to
conv_to_win32_path.  Return if there is an error from this function.
(mount_info::conv_to_win32_path): Add extra argument.  Don't call
normalize_posix_path if caller has already done so.  Substitute chroot setting,
if any, for root translation.  Add chroot checking to final output step.
* shared_info (mount_info): Accomodate additional argument to
conv_to_win32_path.
* syscalls.cc (chroot): Store both normalized posix path and native path in
chroot.
2001-06-03 02:31:16 +00:00
Christopher Faylor bb8251474c * path.cc (chdir): Really make sure that isspace gets only an unsigned char. 2001-06-01 14:57:52 +00:00
Christopher Faylor ecfb6f11bc * path.cc (chdir): Always send unsigned chars to isspace since newlib's isspace
doesn't deal well with "negative" chars.
* fhandler.cc (fhandler_disk_file::open): Propagate remote status of file
garnered from path_conv.  Move #! checking to fstat.
(fhandler_disk_file::fstat): Reorganize st_mode setting to eliminate
duplication.  Move check for #! here from fhandler::open.
* fhandler.h (fhandler_base::isremote): New method.
(fhandler_base::set_isremote): Ditto.
(fhandler_base::set_execable_p): Also record "don't care if executable state".
(fhandler_base::dont_care_if_execable): New method.
* path.cc (path_conv::check): Clear new flags.  Appropriately set vol_flags,
drive_type, and is_remote_drive.
* path.h: Add new flags and methods for manipulating them.
* syscalls.cc (_unlink): Use isremote() to determine if a path is remote rather
than calling GetDriveType.
(stat_worker): Ditto.
* security.cc (get_file_attribute): Or attribute with result of NTReadEA to be
consistent with get_nt_attribute.
2001-05-31 05:25:46 +00:00
Christopher Faylor b9ce814089 * path.cc (symlink_info::check): Correctly set 'ext_tacked_on'. Use this to
determine if user specified 'foo.lnk' explicitly.  Reorganize slightly to get
rid of one goto.
2001-05-25 15:07:46 +00:00
Corinna Vinschen fdc5ebe9bf * path.cc (symlink_info::check): Add a check to return correctly
if incoming `*.lnk' file is not a symlink.
2001-05-25 08:31:57 +00:00
Christopher Faylor 86f41a0954 * path.cc (slash_drive_prefix_p): Remove.
(mount_info::slash_drive_to_win32_path): Ditto.
(mount_info::conv_to_win32_path): Remove slash drive prefix check.
(mount_info::add_item): Ditto.
(mount_info::del_item): Ditto.
* shared_info.h (mount_info): Remove slash_drive_to_win32_path declaration.
2001-05-25 03:13:14 +00:00
Christopher Faylor df7320e1ba * path.cc (path_conv::check): Revert allow_ntsec check so that volume info is
always retrieved and isdisk setting is properly set.
2001-05-14 02:52:12 +00:00
Christopher Faylor c3a245f5bf * external.cc (fillout_pinfo): Use correct pids.
* path.cc (mount_info::conv_to_win32_path): Correct test for whether to include
a slash.
2001-05-11 21:01:44 +00:00
Christopher Faylor cedb00be89 * path.cc (mount_info::conv_to_win32_path): Treat UNC paths the same as paths
including `:' or `\'.
2001-05-09 18:59:10 +00:00
Christopher Faylor 792011508a * cygheap.cc (_cfree): Add regparm attribute.
(_crealloc): Ditto.
* dcrt0.cc (dll_crt0_1): Default to always checking for executable for now.
* dtable.cc (dtable::not_open): Move method.
* dtable.h (dtable): Here.
* exceptions.cc (ctrl_c_handler): Don't expect process group leader to handle a
signal if it doesn't exist.
* fhandler.h (fhandler_base): Make openflags protected.
* localtime.c (tzsetwall): Check for __CYGWIN__ as well as __WIN32__.
* path.cc (path_conv::check): Add some comments.  Change strcat to assignment.
* lib/_cygwin_S_IEXEC.cc (_cygwin_bob__): Eliminate.
* fhandler_tty.cc (fhandler_console::dup): Set controlling terminal if
necessary.
* fhandler_tty.cc (fhandler_tty_slave::dup): Ditto.
2001-05-08 15:16:49 +00:00
Christopher Faylor 17743fbc49 * exceptions.cc (ctrl_c_handler): Always send signal to process if it has no
tty.
2001-05-04 20:39:38 +00:00
Christopher Faylor 4c265f4ab9 * path.cc (mount_info::conv_to_win32_path): More path tweaking. 2001-05-01 05:26:06 +00:00
Christopher Faylor beab320f33 * path.cc (mount_info::conv_to_win32_path): Fix debugging output to avoid a
SIGSEGV.  Avoid double backslashes in middle of filename.
2001-05-01 04:45:19 +00:00
Christopher Faylor d3c7e9de28 * path.cc (mkrelpath): New function.
(mount_info::conv_to_win32_path): Eliminate now-unneeded relative path name arg
and processing.
(path_conv::check): Accomodate relative path names again.  Accomodate one extra
argument in mount_info::conv_to_win32_path.  Tack trailing slash on end of
relative path as a side effect, like before.
* shared_info.h (mount_info::conv_to_win32_path): Reflect new argument
ordering.
2001-05-01 02:03:10 +00:00
Christopher Faylor c0a45b92cc * path.cc (path_conv::check): Don't use path_flags when converting to MS-DOS
syntax unless parsing tail of path component.  Stop parsing path when we reach
the 'root' of the path.  Correctly copy tail to path component.
2001-04-30 16:52:53 +00:00
Christopher Faylor 2b5803d4b7 * path.cc (symlink_info::check): Remove extra arguments, move functionality
back to path_conv::check.  Clear symlink bit from pflags argument before
detecting if this is a symlink.
(path_conv::check): Convert posix path here instead of symlink_info::check.
Only grab volflags when using ntsec.
(symlink_info::check_case): Just replace appropriate part of input path.
2001-04-30 01:46:31 +00:00
Christopher Faylor b98ebf5470 Throughout, change 'tty_attached' to 'real_tty_attached', for clarity.
Throughout, change 'OutputStopped' to 'output_stopped', for consistency.
* dtable.cc (stdio_init): Set controlling tty if not set by stdio opens.
* exceptions.cc (ctrl_c_handler): Avoid special pgid checking if no tty is
associated with the process.
(Suggested by Tim Baker <dbaker@direct.ca>)
* external.cc (fillout_pinfo): Return actual tty number for ctty.
* fhandler_console.cc (get_tty_stuff): Set ctty when shared memory is
allocated.  Accept flags input from open().
(set_console_ctty): New function.
(fhandler_console::open): Pass flags to get_tty_stuff and rely on this function
to set the ctty, if appropriate.
* fhandler_termios.cc (fhandler_termios::set_ctty): Move to tty_min class.
* fhandler_tty.cc (fhandler_tty_slave::open): Use tc field to access
set_ctty().
* tty.h (TTY_CONSOLE): Move to include/sys/cygwin.h.
(tty_min): Add set_ctty class here.
* include/sys/cygwin.h (TTY_CONSOLE): New home here.
* path.cc (symlink_info): Make contents an actual buffer.  Pass more flags to
case_check.
(path_conv::check): Reorganize to do parsing based on posix path rather than
native path.
(symlink_info::check): Expect posix path as input.  Translate to native path
here.  Accept path_conv flags.  Stop parsing if not a symlink regardless of
whether previous path was a symlink.
2001-04-28 23:48:28 +00:00
Christopher Faylor 96dc5dd7e5 * shortcut.c (check_shortcut): Close input file handle before returning.
* path.cc (check_sysfile): Ditto.
(symlink_info::check): Rely on opened file handle being closed by symlink
checking routines.  Set ext_tacked_on when .lnk is detected.
2001-04-22 16:19:27 +00:00
Christopher Faylor b9815dc3dc * path.cc (path_conv::check): Always initialize member variables. 2001-04-20 16:40:04 +00:00
Christopher Faylor 0381fec68f Throughout, change fdtab references to cygheap->fdtab.
* child_info.h (cygheap_exec_info): Eliminate special fdtab stuff.
* spawn.cc (spawn_guts): Ditto.
* cygheap.cc (cygheap_init): Initialize fdtab, if appropriate.
* cygheap.h (CYGHEAPSIZE): Include size of init_cygheap.
(_cmalloc_entry): Include fdtab here.
* dtable.h (dtable): Declare/define new methods.
* dtable.cc (dtable::vfork_child_fixup): New method.
(dtable::fixup_after_exec): Remove unneeded extra arguments.
* dcrt0.cc (dll_crt0_1): Ditto.
* environ.cc (getwinenv): Use case sensitive comparison.
(winenv): Make a copy of environment cache to avoid realloc problems when
duplicate environment variables exist in the environment.  (From Egor Duda)
* net.cc (cygwin_socket): Revert Apr 14 change.
* include/sys/file.h: Protect against previous X_OK definition.
* passwd.cc: Eliminate passwd_sem throughout.
* security.cc: Ditto.
* cygwin.din: Export New functions.
* passwd.cc (read_etc_passwd): Make race safe.
(getpwuid_r): New function.
(getpwnam_r): New function.
2001-04-18 21:10:15 +00:00
Christopher Faylor 4199e1e6fb * path.h (path_conv::add_ext_from_sym): Declare.
* path.cc (path_conv::add_ext_from_sym): Convert to pure inline method.
2001-04-17 23:12:11 +00:00
Corinna Vinschen e6629a8ad0 * path.cc (windows_device_names): Add missing NULL element. 2001-04-17 16:52:09 +00:00
Christopher Faylor adfd477da3 * path.cc (windows_device_names): Move dsp to proper location. 2001-04-17 16:16:27 +00:00
Corinna Vinschen 0f56512627 * path.cc (path_conv::check): Set case_clash even if pcheck_case
is set to PCHECK_ADJUST when a case clash is given for the last
        component in path.
        (symlink_info::case_check): Ditto.
        * syscalls.cc (_rename): Avoid overwriting an already existing file
        if a case clash is given even if pcheck_case is set to PCHECK_ADJUST.
2001-04-17 11:47:37 +00:00
Christopher Faylor 431ba7dd33 * path.h (cwdstuff): Move class.
* cygheap.h (cwdstuff): To here.
(init_cygheap): Add cwd field.
* child_info.h (cygheap_exec_info): Eliminate cwd stuff.
(child_info_spawn): Ditto.
* dcrt0.cc (dll_crt0_1): Remove cygcwd.fixup_after_exec call.  Convert cygcwd
reference to cygheap->cwd.
* path.cc: Ditto, throughout.
(cwdstuff::copy): Eliminate.
(cwdstuff::fixup_after_exec): Ditto.
* spawn.cc (spawn_guts): Eliminate call to cygcwd.copy.
* fhandler.h (FH_OSS_DSP): Move into "fast" device category.
2001-04-17 03:52:08 +00:00
Christopher Faylor b0a50cf34c * autoload.cc: Add winmm functions needed by fhandler_dsp.cc.
* fhandler_dsp.cc: New file.  Implements OSS like /dev/dsp.
* include/sys/soundcard.h: New file.  User land includes for OSS /dev/dsp.
* fhandler.h: Add new class fhandler_dev_dsp and a FH_OSS_DSP definition.
* dtable.cc (dtable::build_fhandler): Allow creation of the /dev/dsp device.
* path.cc (windows_device_names): Add /dev/dsp into list of device names.
* Makefile.in (DLL_OFILES): Add fhandler_dsp.o.
2001-04-16 03:27:16 +00:00
Corinna Vinschen 1ff87985a1 * path.cc (add_ext_from_sym): Redefine to call `add_ext_from_sym_'.
(add_ext_from_sym_): New inline function.
2001-04-15 14:00:45 +00:00
Corinna Vinschen e61cead397 * path.cc (add_ext_from_sym): New define evaluating `known'suffix'.
(path_conv::check): Use add_ext_from_sym throughout.
2001-04-13 07:54:20 +00:00
Corinna Vinschen 70c370d674 * dir.cc (mkdir): Check for case clash.
* environ.cc: Add extern declaration for `pcheck_case'.
        (check_case_init): New function.
        (struct parse_thing): Add "check_case" option.
        * errno.cc (_sys_nerrlist): Add text for ECASECLASH.
        (strerror): Add case branch for ECASECLASH.
        * fhandler.cc (fhandler_disk_file::open): Check for case clash.
        * path.cc: Add global variable `pcheck_case'.
        (struct symlink_info): Add member `case_clash' and method `case_check'.
        (path_prefix_p_): Call `pathnmatch' instead of `strncasematch'.
        (pathnmatch): New funtion.
        (pathmatch): Ditto.
        (path_conv::check): Add handling for case checking.
        (symlink): Check for case clash.
        (symlink_info::check): Add parameter for case checking.
        Handle case checking.
        (symlink_info::case_check): New method.
        (chdir): Don't use unconverted path if pcheck_case==PCHECK_STRICT.
        * path.h: Add extern declarations for `pathmatch' and
        `pathnmatch'.
        (enum case_checking): New enumeration type describing
        the case checking behaviour of path conversion routines.
        (class path_conv): Add member `case_clash'.
        * syscalls.cc (_link): Check for case clash.
2001-04-12 21:21:37 +00:00
Christopher Faylor fc672fb26c * path.cc (struct symlink_info): Add extn and ext_tacked_on fields.
(path_conv::check): Only tack on extension if a known one didn't already exist.
(suffix_scan::has): Return pointer to known extension.
(symlink_info::check): Record location of extension, if any.
2001-04-11 19:09:53 +00:00
Christopher Faylor f97adf983d * shared_info.h (mount_info): Remove mnt_ elements.
* thread.h (struct _winsup_t): Add mnt_ elements.
* path.cc (fillout_mntent): Use mnt_ elements from reent_winsup ().
2001-04-02 04:27:12 +00:00
Christopher Faylor 5817ee2d09 * path.cc (fillout_mntent): Always remove drive root directories from future
consideration by "/cygdrive" reporting.
(cygdrive_getmnt): Avoid reporting removable drives or drives with no media
mounted.
2001-04-01 05:09:57 +00:00
Christopher Faylor f2aeff27f0 * thread.h (struct _winsup_t): Remove obsolete elements. Add available_drives
element.
* path.cc (mount_info::getmntent): Report "/cygdrive" drives when mounted
drives are exhausted.
(fillout_mntent): New function.
(mount_item::getmntent): Use fillout_mntent.
(cygdrives_mntent): New function.  Returns next available "/cygdrive".
(setmntent): Initialize available "/cygdrives".
* syscalls.cc: Remove some if 0'ed code.
* times.cc (timezone): Use more descriptive variable name.
2001-04-01 03:06:02 +00:00
Christopher Faylor b5eb3d0f15 * path.cc (chdir): Eat trailing whitespace on input path. 2001-03-29 00:30:39 +00:00
Christopher Faylor 57499703f2 * path.cc (suffix_scan::next): Avoid searching for foo.lnk twice when input is
"foo".
2001-03-17 17:44:53 +00:00
Christopher Faylor b63a3f55a7 * dir.cc (readdir): Use strcasematch for consistency.
* path.cc (symlink_info): Eliminate known_suffix.
(path_conv::check): Always copy ext_here to end of buffer, if found.
(suffix_scan): Eliminate ext_here, add suffixes_start.
(suffix_scan::has): Eliminate an argument.  Reorganize.  Always return pointer
to end of input path.
(suffix_scan::next): Take a second pass through the suffix list looking for
.lnk.
(symlink_info::check): Eliminate known_suffix usage.
2001-03-17 07:09:41 +00:00
Christopher Faylor b65c6896c8 * path.cc: Translate scan states from defines to enums.
(suffix_scan): Rename state to nextstate for clarity.
(lnk_match): Change to allow multiple states to indicate that a .lnk has been
matched.
(suffix_scan::has): Eliminate a goto.  Handle .lnk as a special case, since a
.lnk may also need to be tacked on the end of a .lnk.
(suffix_scan::next): Don't increment next state.  Set it specifically.
Recognize new .lnk states.
2001-03-17 01:29:14 +00:00
Corinna Vinschen 78d2c08cd9 * path.cc (lnk_suffixes): Remove.
(class suffix_scan): Add `lnk_state' flag.
        (suffix_scan::lnk_match): Return state of `lnk_state' now.
        (suffix_scan::has): Changed behaviour if file has `.lnk' suffix.
        (suffix_scan::next): Set `lnk_state' where appropriate.
        (symlink_info::check): Fix a wrong `break'.
        * syscalls.cc (chown_worker): Change debug statement to reflect
        lchown fix.
        (lchown): Call chown_worker with `PC_SYM_NOFOLLOW' instead of
        `PC_SYM_IGNORE'.
2001-03-14 11:13:46 +00:00
Corinna Vinschen bf11a54f54 * path.cc (suffix_scan::has): Change order of conditionals
to allow checking for .lnk suffixes even if in_suffixes is empty.
2001-03-06 13:05:56 +00:00
Christopher Faylor 95a8465ba0 * dlopen.c (dlopen): Return NULL when name is NULL (suggested by
chrisiasci@aol.com).
* cygwin.din: Add a new, internally used export - _check_for_executable.
* dcrt0.cc (dll_crt0_1): Set _check_for_executable for older binaries.  Pass
user_data to premain functions.
* fhandler.cc (fhandler_disk_file::open): Only check for executable if the
linked program is intereested in the executable bit.
(fhandler_disk_file::check_execable_p): Delete.
* fhandler.h (executable_states): New enumeration of various states of
executable bit caring.
(fhandler_base::set_execable_p): New method.
* fhandler_termios.cc (fhandler_termios::line_edit): Flag when a signal has
been sent to the tty.  Return -1 when this is so.
* fhandler_console.cc (fhandler_console::read): Return -1 when signal sending
character encountered.
* path.cc (path_conv::check): Record when path refers to a disk device.  Move
executable extension check here.
(check_sysfile): Accomodate new EXEC path states.
(has_suffix): Remove.
(next_suffix): Remove.
(class suffix_scan): New clas.
(suffix_scan::has): New method.
(suffix_scan:next): New method.
(symlink_info::check): Use suffix_scan method to control for scanning for
suffixes.
* path.h (path_conv::exec_state): New method.
* perprocess.h: Make "C" friendly.
* include/cygwin/version.h: Define CYGWIN_VERSION_CHECK_FOR_S_IEXEC.  Bump
CYGWIN_VERSION_API_MINOR.
* include/sys/cygwin.h: Change premain declarations.
* winsup.h: Move __cplusplus test to after builtin defines.
2001-03-05 06:28:25 +00:00