Commit Graph

42 Commits

Author SHA1 Message Date
Corinna Vinschen 37f4fea07c Cygwin: utils: change 3rd readlink param to size_t
Avoid gcc warnings

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-08-08 10:50:19 +02:00
Corinna Vinschen 26bcedda20 Cygwin: fix utils path handling in case cygdrive path is just '/'
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-16 17:21:48 +01:00
Corinna Vinschen bbeef8ef3f cygcheck: Fix broken test for invalid wcstombs conversion reading symlinks
Fixes Coverity CID 66905

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-22 22:53:29 +02:00
Corinna Vinschen 7909b528e5 cygcheck: Fix check for Cygwin symlink
Fixes Coverity CID 66904 and 66906

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-22 22:50:33 +02:00
Corinna Vinschen 6e623e9320 Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option
Bump GPLv2+ to GPLv3+ for some files, clarify BSD 2-clause.

Everything else stays under GPLv3+.

New Linking Exception exempts resulting executables from LGPLv3 section 4.

Add CONTRIBUTORS file to keep track of licensing.

Remove 'Copyright Red Hat Inc' comments.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-23 10:09:17 +02:00
Corinna Vinschen 117ebc802f Bind mounts require POSIX paths
* path.cc (from_fstab_line): Don't convert slashes to backslashes for
	bind mounts.  Explain why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-08 17:37:55 +02:00
Christopher Faylor 40f11fc133 * cygcheck.cc (dll_info): Detect and report on symlinks. Output wrong
architecture message inline with stdout for clarity.
* path.cc (is_symlink): Always reset file pointer to beginning on exit.
(readlink): Assume that file pointer is set to the beginning.
2013-07-07 16:57:11 +00:00
Corinna Vinschen 61522196c7 * Merge in cygwin-64bit-branch. 2013-04-23 09:44:36 +00:00
Christopher Faylor df0f949cfd Update copyrights 2013-01-21 16:28:27 +00:00
Corinna Vinschen 41783b90a2 * path.cc (vcygpath): Handle cygdrive prefix. 2012-11-09 08:53:01 +00:00
Yaakov Selkowitz 7c61aa7ece * configure.in: Add check for MINGW_CXX. Remove libiconv check.
* configure: Regenerate.
	* Makefile.in: Remove references to mingw and w32api directories.
	Use MINGW_CXX instead of mingw script to build MINGW_BINS.
	Check for libiconv with $CC --print-file-name.
	* cygcheck.cc: Use relative include paths for Cygwin headers.
	* path.cc: Ditto.
	* strace.cc: Ditto
	* mingw: Remove.
2012-10-24 10:15:27 +00:00
Christopher Faylor 1b23b30b29 Clean up whitespace. 2011-12-17 23:39:47 +00:00
Corinna Vinschen d7d8e7ce07 * cygcheck.cc (handle_unique_object_name): Avoid a compiler warning.
(dump_sysinfo): Ditto.
	* loadlib.h (_load_sys_library): Mark as used, to avoid a compiler
	warning.
	* path.cc (oopt): Gurad with !FSTAB_ONLY to avoid a compiler warning.
	(read_flags): Ditto.
2011-03-29 11:02:58 +00:00
Corinna Vinschen 71d8f118da * loadlib.h: New header implementing safe LoadLibrary calls.
Include throughout files using LoadLibrary function.
	* cygcheck.cc (dump_sysinfo): Retrieve kernel32.dll handle via
	GetModuleHandle, rather than using LoadLibrary.
	* cygpath.cc (get_long_name): Ditto.
	(do_sysfolders): Append .dll suffix in LoadLibrary call.
	* ldh.cc (WinMain): Use LoadLibraryExW with DONT_RESOLVE_DLL_REFERENCES
	to avoid loading malicious library code.
	* locale.cc (print_locale_with_codeset): Change way to retrieve
	kernel32.dll path.
2010-08-28 11:22:37 +00:00
Corinna Vinschen a361b4715f * path.cc: Include sys/cygwin.h if built for mount(1).
(struct opt): Add "dos" and "ihash" options.
	(from_fstab_line): Call cygwin_internal rather than read_flags if
	built for mount(1).
2010-04-29 10:39:35 +00:00
Corinna Vinschen 13e8e14ab5 * path.cc (read_mounts): Skip unnecessary test if path has been
fetched from loaded cygwin1.dll.
2009-11-04 17:09:32 +00:00
Corinna Vinschen b5f48aa961 * cygcheck.cc (cygwin_dll_path): New global variable.
(load_cygwin): Fetch cygwin DLL path and store in cygwin_dll_path.
	* strace.cc: Full ditto.
	* path.cc (read_mounts): First use the path stored in cygwin_dll_path,
	if available.  Then fall back to fetching own path.  Add comment.
	Drop printing warnings since they look funny in strace output.
2009-11-04 17:00:45 +00:00
Corinna Vinschen 44a019897f * path.cc (read_mounts): First get installation path from own path.
Check if cygwin1.dll exists in same directory.  Only if not, try to
	get installation path from setup registry key.  Add ample warnings.
2009-11-04 15:47:29 +00:00
Corinna Vinschen 3955529c8b * mount.cc (do_mount): Replace --no-executable flag with notexec
mount option in hint for remote filesystems.
	* path.cc (getmntent): Fix typo (noexec -> notexec).
2009-07-22 16:24:17 +00:00
Corinna Vinschen 1e497ebd33 * Makefile.in (path-mount.o): Add a rule to build stripped down version
of path.cc for usage in mount.
	(mount.exe): Add dependency to path-mount.o.
	* mount.cc (force): Convert to bool value.  Accommodate throughout.
	(from_fstab): New function.
	(do_mount_from_fstab): New function.
	(longopts): Add --all option.
	(opts): Add -a option.
	(usage): Document -a/--all option.
	(main): Handle -a option as well as single parameter.
	* path.cc: Add FSTAB_ONLY conditional to allow building path-mount.o.
	(mount_table): Remove static storage class.
	(max_mount_entry): Ditto.
	(root_here): Unused.  Remove.
	(from_fstab_line): Remove static.
	* path.h (struct mnt_t): Define here rather than in path.cc.
	(from_fstab_line): Declare.
	(mount_table): Declare.
	(max_mount_entry): Declare.
	* utils.sgml (mount): Document -a/--all option and mounting of single
	path from fstab files.
2009-07-22 10:20:26 +00:00
Corinna Vinschen 070a99e8aa * path.cc (oopts): Sort alphabetically, add missing "auto" and
"override" entries.
	(from_fstab_line): Handle mount points same as Cygwin itself.  Use
	"cygdrive prefix" as posix name of cygdrive prefix.
	(from_fstab): Add auto entries for /usr/bin and /usr/lib.  Add
	MOUNT_AUTOMATIC and MOUNT_IMMUTABLE flags to default root dir entry.
	Use "cygdrive prefix" as posix name of default cygdrive prefix.
	(getmntent): Allocate smaller buffers.  Align output closer to output
	of mount(1).
2009-06-10 10:42:22 +00:00
Corinna Vinschen 18ac7638b9 * path.cc (readlink): Accommodate new UTF-16 symlinks. 2009-04-07 16:24:50 +00:00
Corinna Vinschen 5c8c49cc43 * path.cc (from_fstab): Use wcstombs/mbstowcs instead of
WideCharToMultiByte/MultiByteToWideChar to accommodate current locale.
2009-03-14 14:58:05 +00:00
Christopher Faylor a35d9f1a67 * cygcheck.cc (pathlike::check_existence): Remove class name from declaration.
(display_internet_error): Use proper format specifier for DWORD.
(environ): Remove unneeded declaration.
(main): Use brace around nested if to avoid an overly-helpful compiler warning.
* dump_setup.cc (parse_filename): Reorganize nested if to avoid an
overly-helpful compiler warning.
* path.cc (GUID_shortcut): Use braces around part of initializer which needs
them.
(conv_fstab_spaces): Parenthesize assignment in while loop to avoid a compiler
warning.
(struct opt): Make static.
* ps.cc (main): Reorganize nested if to avoid an overly-helpful compiler
warning.
* regtool.cc: Make some anonymous structs static to avoid a compiler warning.
* ssp.c (lookup_thread_id): Initialize *tix to zero to avoid potential
uninitialized use.
* strace.cc (add_child): Use proper format specifier for DWORD.
(remove_child): Ditto.
(proc_child): Ditto.
2008-09-12 22:43:10 +00:00
Corinna Vinschen a1e1990348 * Makefile.in (cygcheck.exe): Link against ntdll.
* bloda.cc: Use statically linked functions throughout.
	* cygpath.cc: Drop 9x considerations.
	* mkgroup.c: Revamp.  Redefine -l and -d options to take optional
	machine and domain parameters.  Redefine -c to work always, using
	token information.  Add -L, -D, -C to create unique groupnames in
	domain\group syntax.  Add -S option to define domain\group separator
	char.  Ignore -u and -s options.
	* mkpasswd.c: Revamp.  Redefine -l and -d options to take optional
	machine and domain parameters.  Redefine -c to work always, using
	token information.  Add -L, -D, -C to create unique usernames in
	domain\user syntax.  Add -S option to define domain\user separator
	char.  Ignore -g and -s options.  Prefer to take homedir from $HOME
	over $HOMEDRIVE/$HOMEPATH.
	* path.cc (oopts): Add "acl", "noacl", "posix=0" and "posix=1" options.
	(getmntent): Accomodate throughout.
	* ps.cc: Fix copyright dates.
	* utils.sgml: Fix text for mkgroup and mkpasswd.
2008-07-22 14:40:05 +00:00
Corinna Vinschen 874149c80c * mount.cc (do_mount): Remove MOUNT_ENC code.
(oopts): Remove "managed" option.
	(mount_commands): Drop "managed" handling.
	* path.cc (oopts): Remove "managed" option.
	(getmntent): Remove MOUNT_ENC code.
2008-07-17 15:07:48 +00:00
Corinna Vinschen b677a99b34 * cygcheck.cc (dump_sysinfo): Fix multiple Cygwin DLL test.
* path.cc: Fetch mount points from fstab files instead of from
	registry.  Use adapted functions copied from Cygwin DLL.
	(mnt_t): Drop issys member.  Define as "mnt_t" instead of "struct mnt_t"
	subsequently.
	(max_mount_entry): New variable.
	(unconvert_slashes): Move to earlier location in file.  Make inline.
	(find2): Remove.
	(get_cygdrive0): Remove.
	(get_cygdrive): Remove.
	(skip_ws): New function.
	(find_ws): Ditto.
	(conv_fstab_spaces): Ditto.
	(read_flags): Ditto.
	(from_fstab_line): Ditto.
	(get_user): Ditto.
	(from_fstab): Ditto.
	(mnt_sort): Ditto.
	(read_mounts): Drop old registry code.  Fetch
	"Software\Cygwin\Setup\rootdir" value from HKCU or HKLM key.  Use
	rootdir extracted from module path as fallback.  Call from_fstab for
	nouser and user mount points.
	(setmntent): Check max_mount_entry to test if read_mounts must be
	called.
	(getmntent): Use MOUNT_SYSTEM flag instead of mnt_t's issys member.
2008-04-22 14:42:05 +00:00
Brian Dessent bff091bcfe * path.cc: Include malloc.h for alloca.
(is_symlink): Rewrite.  Just read the whole file in memory rather
	than by parts.  Account for an ITEMIDLIST if present, as well as
	the new style of Cygwin shortcut supporting targets > MAX_PATH.
2008-03-16 17:04:02 +00:00
Brian Dessent 60efa4e546 * cygcheck.cc (dirname): New static function.
(find_app_on_path): Use SYMLINK_MAX.  Resolve symlink relative
	to link's location.  Adjust to the fact that cygpath already
	normalizes its return value.
	* path.cc (rel_vconcat): Add cwd parameter, and use it instead
	of calling GetCurrentDirectory() if possible.  Rename throughout.
	(vcygpath): Rename from cygpath and accept cwd and va_list.  Pass
	cwd on to rel_vconcat().
	(cygpath_rel): New front end for vcygpath.
	(cygpath): Ditto.
	* path.h (cygpath_rel): Declare.
	(SYMLINK_MAX): Define to 4095.
2008-03-11 17:20:02 +00:00
Brian Dessent 59fb00ae07 * Makefile.in: Add a 'check' target that builds and runs
testsuite.exe from path-testsuite.o and testsuite.o.
	* path.cc: Include testsuite.h.
	(struct mnt): Change to a mnt_t typedef and don't define
	mount_table when TESTSUITE is defined.
	(find2): Don't include when TESTSUITE is defined to avoid warning.
	(get_cygdrive0): Ditto.
	(get_cygdrive): Ditto.
	(read_mounts): Provide empty implementation when TESTSUITE is
	defined.
	(vconcat): Use the isslash macro.
	(unconvert_slashes): New helper to convert to backslashses.
	(rel_vconcat): Handle relative paths more gracefully.
	(cygpath): Skip a leading "./" sequence.  Avoid double-slashes.
	Normalize final output to backslashes and remove redundant path
	sequences.
	* testsuite.cc: New file implementing testsuite driver.
	* testsuite.h: New header implementing harness mount table and
	series of tests.
2008-03-09 04:10:10 +00:00
Christopher Faylor f0136ac908 * cygcheck.cc (pathlike): New class.
(paths): Redefine as type pathlike.
(display_error): Declare a few different ways to allow more flexible usage
throughout.
(display_error_fmt): New function for those cases where C++ just isn't enough.
(add_path): Rewrite to allocate pathlike paths.  Always tack on a trailing
slash since that's what everyone who uses it wants.  NULL terminate the path
list.  Register "it's a system path" field.
(init_path): Call add_path with info regarding whether path is a system path or
not.
(pathlike::check_existence): Move into pathlike class.  Accept file and
extension arguments to build up path on the fly.  Modify other arguments.
(find_on_path): Constify return value and appropriate arguments.  Eliminate
short-circuit for fully-qualified paths.  Simplify loop which iterates over
path.
(already_did): Constify argument.
(track_down): Ditto.  Regularize some error messages.
(find_app_on_path): Ditto.
(cygcheck): Constify argument.  Use 20th century string handling functions.
(dump_sysinfo): Remove odd inclusion of '\\bin' "Just in case".  Accommodate
change of paths to pathlike.
* path.cc (isslash): Rename from SLASH_P and use throughout.
(rel_vconcat): Front-end to vconcat which prepends cwd to path before passing
along for conversion to native windows.
(cygpath): Remove "./" test.  Call rel_vconcat if filename appears to be
relative.
2007-06-04 01:57:16 +00:00
Corinna Vinschen cea9b62102 * cygcheck.cc (get_word, get_dword): Move to path.cc.
(LINK_EXTENSION): New macro.
	(check_existence): New static function.
	(find_on_path): Check for symbolic links if asked.
	(dll_info): New error handling.
	(track_down): Only call dll_info() for executables, display
	an error for symlinks, and print magic number for others.
	(find_app_on_path): New static function.
	(cygcheck, dump_sysinfo): Call find_app_on_path() instead of
	find_on_path().
	* path.cc (cmp_shortcut_header): New static function.
	(get_word, get_dword): Moved from cygcheck.cc.
	(EXE_MAGIC, SHORTCUT_MAGIC, SYMLINK_COOKIE, SYMLINK_MAGIC): New
	macros.
	(is_exe, is_symlink, readlink): New functions.
	* path.h (is_exe, is_symlink, readlink): Declare.
	(get_word, get_dword): Ditto.
2006-10-05 17:24:13 +00:00
Corinna Vinschen fb43e6237c * path.cc (vconcat): Don't convert backslahes to slashes.
(cygpath): Return native path with all backslashes.
2006-08-03 15:29:30 +00:00
Dave Korn 65e941162d * path.cc (getmntent): Add previously-omitted 'noexec' and 'managed'flags to
mnt_opts string if present in mount flags.
2005-04-29 16:39:34 +00:00
Christopher Faylor b07b167eec * Makefile.in (MINGW_CXX): Define and use for mingw-compiled files.
* path.cc: Include more path info in cygwin-specific includes since the cygwin
directory is no longer included by default.
2003-09-11 02:00:42 +00:00
Christopher Faylor 229f2bb465 * Makefile.in (strace.exe): Include mingw_getopt.o in link line.
* cygcheck.cc (print_version): Update copyright.
* strace.cc (print_version): Ditto.
(main): Allow cygwin paths for -o option.
(create_child): Allow cygwin path as argv[0].
* path.cc (path.cc): Allow UNC paths.
2003-03-04 05:30:50 +00:00
Christopher Faylor 4a9cbef09d * cygcheck.cc (common_apps): Add some more apps.
* path.cc (get_cygdrive): Correctly set system flag.
2003-02-07 04:51:26 +00:00
Christopher Faylor 548e0dad4b * path.cc (cygpath): Change MOUNT_AUTO to MOUNT_CYGDRIVE.
(getmntent): Ditto.
2002-06-09 05:08:44 +00:00
Christopher Faylor 53e61a867b * path.cc (cygpath): Don't consider cygpath stuff when trying to derive native
paths.
2001-11-22 00:29:04 +00:00
Christopher Faylor 71f90de808 * cygcheck.cc (scan_registry): Open registry with read-only access.
(main): Reflect argument change for dump_setup.
* dump_setup.cc (dump_setup): Add preliminary extra argument for future use.
* path.cc (read_mounts): Open registry with read-only access.
2001-11-12 00:14:27 +00:00
Christopher Faylor d0d517913c * dump_setup.cc: New file.
* Makefile.in: Add info for dump_setup.o.
* cygcheck.cc (main): Recognize '-c' option for checking setup installed base.
* path.cc (cygpath): Read mount table if not loaded.
2001-11-11 06:07:36 +00:00
Christopher Faylor 2fac517df4 * Makefile.in (cygcheck.exe): Compile as -mno-cygwin executable.
* path.cc: New file.
* cygcheck.cc (init_paths): Use MS-DOS path syntax.
(cygwin_info): Properly display cygwin version numbers.  Prettify some output.
(dump_sysinfo): Calculate max names of posix and ms-dos paths for prettier
output.
2001-11-11 03:06:59 +00:00