Commit Graph

10969 Commits

Author SHA1 Message Date
Corinna Vinschen 11a37290c6 Fix missing 'user' in usertemp docs
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-27 15:37:46 +01:00
Corinna Vinschen 69f98f5f18 Add 2.4.1 release message file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-23 22:33:31 +01:00
Corinna Vinschen 79b1b77b1f cygpath: Avoid returning SysWOW64
On Cygwin 32 running under WOW64:

	When case-correcting the path fetched with -S, the underlying
	Windows function fetching the normalized path returns the real
	path C:\Windows\SysWOW64 instead of the path redirection
	enabled C:\Windows\System32 path.  This breaks using the result
	of `cygpath -S' to fetch the POSIX path of the network related
	files under SYSTEMROOT\drivers\etc.  This path is in fact under
	the *real* C:\Windows\System32 and only mapped into the 32 bit
	C:\Windows\System32 (aka C:\Windows\SysWOW64) via path redirection.
	Sounds messy?

	This patch checks if we're running under WOW64.  If so, it
	changes the path returned by GetSystemDirectoryW from "system32"
	to "Sysnative".  This in turn is changed to "System32" by
	NtQueryInformationFile, so we're back to what we need.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-21 18:40:30 +01:00
Corinna Vinschen b5c80f5a59 cygwin_logon_user: Return non-privileged token as well
If the calling process doesn't have sufficient privileges to
	fetch the linked token of an admin-user token, cygwin_logon_user
	fails.  This patch changes that by returning the original,
	unprivileged token of the admin user to allow authentication
	and calling setuid for the current process.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-21 18:32:16 +01:00
Corinna Vinschen d44ec01ea1 Fix formatting in sec_auth.cc
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-21 18:27:05 +01:00
Corinna Vinschen 3a720bf3f0 Bump cygwin version to 2.4.1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-16 12:57:53 +01:00
Jon Turney 9c8a6e5646 faq: Update FAQ question and answer about gdb and signals
* faq-programming.xml: Update question and answer about gdb and signals.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-01-15 14:59:07 +00:00
Corinna Vinschen d2216272f5 get_posix_access: Fix group deny bits leaking into file type attribute bits
* sec_acl.cc (get_posix_access): Fix bracketing in expression
	constructing POSIX group permissions so as not leaking deny bits
	into POSIX file type bits.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-15 15:13:11 +01:00
Corinna Vinschen fc449e1c1f Initialize handle in dll_load to avoid compiler warning
* autoload.cc (dll_load): Initialize h to NULL.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-12 15:45:17 +01:00
Corinna Vinschen 8cd1ff7a45 Use MAKEWORD macro in WSAStartup call per documentation
* autoload.cc (wsock_init): Use MAKEWORD macro to create requested
	version rather than handcrafted expression.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-12 15:25:15 +01:00
Corinna Vinschen 15d6f564cd Try loading with safe path using LOAD_LIBRARY_SEARCH_SYSTEM32 first
* autoload.cc (dll_load): Move safe loading from std_dll_init here.
	Add code to handle systems supporting LOAD_LIBRARY_SEARCH flags.
	Add comments to explain what the code is doing.  Fix up comment
	preceeding this function.
	(std_dll_init): Move safe loading code to dll_load.
	* wincap.h (wincaps::has_load_lib_search_flags): New element.
        * wincap.cc: Implement above element throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-12 15:23:14 +01:00
Corinna Vinschen 27086d628e Fix previous fix for generating unique inode numbers for sockets
* fhandler.h (fhandler_base::get_plain_ino): New inline method.
	Add comment to explain what it's supposed to be used for.
	* fhandler_socket.cc (fhandler_socket::get_proc_fd_name): Create
	filename using inode number.
	(fhandler_socket::fstat): Generate inode number from filename if
	ino is not set (that's the case in a stat(2) call).
	* pipe.cc: Throughout, use get_plain_ino when appropriate.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-11 19:10:45 +01:00
Corinna Vinschen b4cf3f454d Revert "autoload.cc: Drop using full paths for system DLLs"
This reverts commit 4b104ce070.

The DLLs always guaranteed to be loaded from the system dir are only
those in the KnownDLLs list.  We're using some DLLs not in that list on
all supported OSes, thus we need to make sure to use full paths.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-11 18:46:01 +01:00
Corinna Vinschen a10d969231 Return unique inode numbers when calling stat/fstat on pipes and IP sockets
* fhandler.h (class fhandler_base): Convert unique_id to int64_t.
        (fhandler_base::set_ino): New protected inline method.
        (fhandler_base::get_unique_id): Convert to int64_t.
        (fhandler_base::set_unique_id): New inline method taking int64_t.
        (fhandler_pipe::fstat): Declare.
        (fhandler_pipe::init): Take extra parameter.
        (fhandler_pipe::create): Ditto.
        * fhandler_socket.cc (fhandler_socket::init_events): Set inode number
        to serial number.
        (fhandler_socket::fstat): Set device to DEV_TCP_MAJOR.  Create st_ino
        from get_ino.
        * include/cygwin/signal.h (struct _sigcommune): Replace
        _si_pipe_fhandler with _si_pipe_unique_id.
        * pinfo.h (_pinfo::pipe_fhandler): Take unique id instead of HANDLE.
        * pinfo.cc (commune_process): Accommodate change to _si_pipe_unique_id.
        (_pinfo::commune_request): Ditto.
        (_pinfo::pipe_fhandler): Ditto.
        * pipe.cc (fhandler_pipe::init): Take unique id as argument and set
        inode number and unique_id from there.
        (fhandler_pipe::open): Rework to find any matching pipe from unique
        id in filename.
        (fhandler_pipe::get_proc_fd_name): Create filename using inode number.
        (fhandler_pipe::create): Generate and return unique id from process pid
        and pipe_unique_id.  In outer method, call init with additional unique
        id as parameter.
        (fhandler_pipe::fstat): New method.
        (pipe_worker): Accommodate using 64 bit inode number in filename.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-11 12:35:41 +01:00
Corinna Vinschen 20ddde2f55 select(2): Drop checking descriptors in case of immediate timeout.
* select.cc (select): Call sel.poll only if sel.wait returned
	select_ok.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-11 10:36:33 +01:00
Corinna Vinschen e3b230b043 Add release message for previous commit
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-09 15:05:21 +01:00
Corinna Vinschen 3069a93fbe select: Don't timeout without setting descriptor arrays to all zero
* select.cc (copyfd_set): Remove.
        (select): Don't copy local wait fd arrays over to returned fd arrays
        since bits set there are not accounted for in return value.  Zero out
        returned fd arrays instead.  Always call sel.poll even in case of a
        timeout.  Always zero out fd array when timing out.  Convert while/do
        to do/while for clarity.  Use dedicated variable as return value to
        decouple return value from artificial return code from sel.wait.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-09 14:53:06 +01:00
Johannes Schindelin e0d4e3fec7 Do not treat the command line or environment like paths
* dcrt0.cc (dll_crt0_1), environ.cc (environ_init, getwinenveq,
	build_env), strfuncs.cc (sys_wcstombs, sys_wcstombs_alloc),
	wchar.c (sys_wcstombs, sys_wcstombs_alloc): avoid mis-conversions
	of text that does not, actually, refer to a path or file name

Detailed explanation:

Our WCS -> UTF conversion handles the private Unicode page specially
to allow for otherwise invalid file names. However, this handling makes
no sense for command-lines, nor environment variables, which we would
rather convert verbatim.

As a stop-gap solution, let's just introduce a version of the
sys_wcstombs() function that specifically excludes that file name
conversion magic.

The proper solution is to change sys_wcstombs() to assume that it is not
a path that wants to be converted, and introduce sys_wcstombs_path()
that does, but that is a bigger task which we leave for another patch.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-01-08 15:17:52 +01:00
Corinna Vinschen 9ee2624240 Deprecate all winsup ChangeLog files
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-07 21:16:01 +01:00
Corinna Vinschen e70dbe774a cygpath: Try to return system directories with correct case
* cygpath.cc (do_sysfolders): Drop lame workaround to fix case of
	directory returned by GetSystemDirectoryW.  Try to fix case of
	any path returned by this function in case it has to return a
	POSIX path to support case-sensitivity.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-07 21:07:56 +01:00
Corinna Vinschen 9614a29f17 select: Set exceptfd bit if fetching mailslot info fails
* select.cc (peek_mailslot): Set except_ready if GetMailslotInfo fails.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-07 18:01:44 +01:00
Corinna Vinschen 8be00880a0 select.cc: Fit comments into 80 columns
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-07 18:00:39 +01:00
Corinna Vinschen 80a800978b Convert utmp{x}name to int, return useful value. Define _PATH_UTMPX
* syscalls.cc (utmpname): Convert to int.  Return 0 if strdup
	worked, -1 otherwise.
	* include/utmpx.h (_PATH_UTMPX): Define as _PATH_UTMP.
	(utmpxname): Declare as int function.
	* include/sys/utmp.h (utmpname): Ditto.
	* include/cygwin/version.h: Bump API minor version.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-07 15:40:40 +01:00
Corinna Vinschen b8f9d8de2c Drop use of not yet available type acl_perm_t
* sec_acl.cc (__aclcalcmask): Use mode_t instead of acl_perm_t

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-07 13:28:12 +01:00
Corinna Vinschen a2d0100644 Deprecate Cygwin ChangeLog file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-07 13:23:05 +01:00
Corinna Vinschen 8607476cf2 setfacl: Remove unused local variable
* setfacl.cc (delacl): Remove unused local variable.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-25 21:41:52 +01:00
Corinna Vinschen e983bd6aa4 Only request WRITE_DAC rights when writing an ACL
* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Only request
        query_write_dac rather than query_write_control access when writing
        an ACL.  Fix a comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-25 21:40:51 +01:00
Corinna Vinschen ed3c07215c aclsort: Honor calclass argument and allow recalculating ACL mask.
* sec_acl.cc (__aclcalcmask): New function to recalculate ACL masks.
        (aclsort32): Honor calclass argument.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-24 00:48:20 +01:00
Corinna Vinschen 7a1ac642f6 aclfromtext: Actually return aclcnt parameter
* sec_acl.cc (aclfromtext32): Return missing aclcnt parameter.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-24 00:39:45 +01:00
Corinna Vinschen 3b8372c1f2 Use TLS buffer in ACL<->text conversion
* sec_acl.cc (acltotext32): Use tmp_pathbuf rather than stack buffer.
        (aclfromtext32): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-24 00:32:54 +01:00
Corinna Vinschen 62fe4404a7 sec_acl.cc: Cosmetic changes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-24 00:24:39 +01:00
Corinna Vinschen bb231f6a62 setfacl(1): Fix handling of -m and -x on a single commandline
* setfacl.cc (delace): New helper function to delete a single ACE.
        (delacl): Call delace.
        (modacl): Ditto, if entry is supposed to get deleted.  Align comments.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-21 18:15:57 +01:00
Corinna Vinschen ddb7e770dd setfacl(1): Rewrite support for mask recomputation
* setfacl.cc (modacl): Move recomputing mask into new function.
        (check_got_mask): New function checking if mask is in input.
        (recompute_mask): New function to recompute mask.
        (addmissing): Align mask computation to Linux setfacl.
        (setfacl): Call check_got_mask and recompute_mask on Set, Delete and
        Modify actions.
        (usage): Rename --substitute to --set.
        (longopts): Add --set option.

        * utils.xml (setfacl): Rename --substitute to --set.
        * new-features.xml (ov-new2.4): Rephrase setfacl changes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-21 13:05:41 +01:00
Houder f5ad6fbb66 setfacl --mask/--no-mask really don't need an argument
* setfacl.cc (longopts): Drop accidentally requiring an argument to
        the --mask and --no-mask options.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-20 13:14:57 +01:00
Houder f97241dcb4 Fix missing arg requirement for setfacl -x option
* setfacl.cc (opts): Add colon to x option.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-19 21:01:59 +01:00
Corinna Vinschen ac39f7b4e8 Drop sys_cp_wcstombs and save two arguments per call
* strfuncs.cc (sys_cp_wcstombs): Delete and move functionality into
        sys_wcstombs.
        * wchar.h (sys_cp_wcstombs): Drop declaration.
        * fhandler_console.cc (dev_console::con_to_str): Call sys_wcstombs.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-18 12:42:40 +01:00
Corinna Vinschen 1abcd49f0d Add release message for previous commit
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-16 12:35:08 +01:00
Corinna Vinschen c7432b13fa Fix crash reading invalid SIDs from passwd and group files
* grp.cc (pwdgrp::parse_group): Only copy the SID if it's valid.
        * passwd.cc (pwdgrp::parse_passwd): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-16 12:25:27 +01:00
Corinna Vinschen 4fbb2eb2c0 Add usertemp to 2.4.0 release text 2015-12-15 11:25:23 +01:00
Sebastian Huber 01885f533d FreeBSD compatibility for <sys/select.h>
* libc/include/sys/_sigset.h: New.
	* libc/include/sys/select.h: Do not include <sys/types.h> and
	<sys/time.h> to avoid cyclic header file dependencies.  Include
	specialized header files instead.
	(sigset_t): Conditionally define.
	* libc/include/sys/signal.h (sigset_t): Likewise.
	* libc/include/sys/time.h: Include <sys/select.h> if
	__BSD_VISIBLE.
	* libc/include/sys/types.h: Likewise.
2015-12-14 15:39:44 +01:00
Ken Brown ecfba2bb2c Fix regparm attribute of fhandler_base::fstat_helper
* winsup/cygwin/fhandler_disk_file.cc (fhandler_base::fstat_helper):
Align regparm attribute to declaration in fhandler.h.
2015-12-14 10:22:12 +01:00
Corinna Vinschen eed35efbe6 Fetch and store FileAllInformation rather than FileNetworkOpenInformation
* path.h (class path_conv_handle): Use FILE_ALL_INFORMATION instead of
        FILE_NETWORK_OPEN_INFORMATION.  Use definitions from ntdll.h since it's
        included anyway.
        (path_conv_handle::fai): Change name from fnoi.
        (path_conv::fai): Ditto.
        (file_get_fai): Change name from file_get_fnoi.  Drop second parameter.
        * path.cc (file_get_fai): Ditto.  Fetch FileAllInformation rather than
        FileNetworkOpenInformation.  Convert STATUS_BUFFER_OVERFLOW to
        STATUS_SUCCESS.  Remove workaround to fetch FileBasicInformation and
        FileStandardInformation on filesystems with broken
        FileNetworkOpenInformation handling.
        (symlink_info::check): Accommodate above changes.  In case of using
        the NtQueryDirectoryFile fallback, fetch FileIdBothDirectoryInformation
        to get inode number as well.
        * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Drop outdated
        comment.  Accommodate change to using FileAllInformation.  Drop
        extra function calls to fetch NumberOfLinks and IndexNumber.  Set ino
        directly from IndexNumber stored in pc.fai().  Drop second argument
        from call to fstat_helper.
        (fhandler_base::fstat_by_name): Drop second argument from call to
        fstat_helper.
        (fhandler_base::fstat_helper): Drop second parameter.  Accommodate
        the fact that we access a FILE_ALL_INFORMATION structure now.
        (fhandler_base::open_fs): Set ino directly from IndexNumber stored in
        pc.fai().
        * fhandler.h (fhandler_base::fstat_helper): Fix declaration accrdingly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-10 00:02:34 +01:00
Corinna Vinschen a0e7563eb0 Drop unused path_conv::ndisk_links method
* fhandler_disk_file.cc (path_conv::ndisk_links): Drop unused method.
        (fhandler_base::fstat_helper): Drop unused call to ndisk_links.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-09 23:56:47 +01:00
Corinna Vinschen ab73edc056 Use fii instead of fai for FILE_INTERNAL_INFORMATION vars
* fhandler_disk_file.cc (path_conv::get_ino_by_handle): Rename fai to
        fii for clearness.
        (fhandler_disk_file::readdir): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-09 23:51:48 +01:00
Corinna Vinschen 3da81956e2 In FILE_ID_BOTH_DIR_INFORMATION it's actually FileId, not IndexNumber
* ntdll.h (FILE_ID_BOTH_DIR_INFORMATION): Revert IndexNumber to FileId
        since it's actually right here.
        * fhandler_disk_file.cc: Accommodate above change.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-09 18:11:47 +01:00
Corinna Vinschen 6c3a5d263f Remove unnecessary locking in pthread_setcancelstate/pthread_setcanceltype
* thread.cc (pthread::setcancelstate): Remove unnecessary locking.
        (pthread::setcanceltype): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-08 17:55:33 +01:00
Corinna Vinschen d0f5f4c422 Rename FileId to IndexNumber in NT structures to align with upstream
* ntdll.h (FILE_ID_BOTH_DIR_INFORMATION): Rename FileId to IndexNumber
        to align with Microsoft naming scheme.
        (FILE_INTERNAL_INFORMATION): Ditto.
        * fhandler_disk_file.cc: Rename FileId to IndexNumber throughout.
        * syscalls.cc: Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-08 14:33:07 +01:00
Corinna Vinschen 87db9e0680 Fix minor style issue in _dll_crt0.
Fix missing space.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-07 18:41:15 +01:00
Johannes Schindelin fb71716d2c Introduce the 'usertemp' filesystem type
* mount.cc (mount_info::from_fstab_line): Support mounting the current
	user's temp folder as /tmp/.  This is particularly useful a feature
	when Cygwin's own files are write-protected.

	* pathnames.xml: document the new usertemp file system type

Detailed explanation:

In the context of Windows, there is a per-user directory for temporary
files, by default specified via the environment variable %TEMP%. Let's
allow to use that directory for our /tmp/ directory.

With this patch, we introduce the special filesystem type "usertemp":
By specifying

	none /tmp usertemp binary,posix=0 0 0

in /etc/fstab, the /tmp/ directory gets auto-mounted to the directory
specified by the %TEMP% variable.

This feature comes handy in particularly in scenarios where the
administrator might want to write-protect the entire Cygwin directory
yet still needs to allow users to write into the /tmp/ directory.
This is the case in the context of Git for Windows, where the
Cygwin (MSys2) root directory lives inside C:\Program Files and hence
/tmp/ would not be writable otherwise.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-12-07 17:37:44 +01:00
Corinna Vinschen 08184b362e Move fd_stuff from sys/types.h to sys/select.h
* libc/include/sys/types.h: Move definitions of NBBY and howmany to
	sys/param.h.  Move definitions of select(2) macros to sys/select.h.
	* libc/include/sys/param.h: See above.
	* libc/include/sys/select.h: Move Cygwin's sys/select.h here.

	* include/sys/select.h: Move select(2) macros from newlib's sys/types.h
	here.  Rename howmany to _howmany to unclutter namespace. Move file to
	newlib.
	* libc/rexex.cc: Add declaration for cygwin_gethostname.
	* poll.cc: Include sys/param.h and locale select.h.
	* select.h (cygwin_select): Declare.
	* uname.cc: Declare cygwin_gethostname.
	* winsup.h: Drop declarations of cygwin_select and cygwin_gethostname.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-07 16:28:22 +01:00