Commit Graph

5032 Commits

Author SHA1 Message Date
Charles Wilson 73ddc92062 Correct pseudo-reloc size bug wrt error messages 2009-10-26 14:50:09 +00:00
Charles Wilson 15c59df67f Sync pseudo-reloc.c with mingw64 2009-10-25 23:37:48 +00:00
Corinna Vinschen e83fef9d35 * fhandler.cc (fhandler_base::open): Remove unused variables sa and sd. 2009-10-24 08:40:15 +00:00
Corinna Vinschen 1647bf67c1 * fhandler.cc (fhandler_base::open): Always create file with default
security descriptor and fix descriptor afterwards.  Change comment to
	explain why.
	* security.cc (alloc_sd): Drop setting the SE_DACL_PROTECTED flag.
	* wincap.cc: Remove has_dacl_protect throughout.
	* wincap.h: Ditto.
2009-10-24 08:26:01 +00:00
Corinna Vinschen 959684bf05 * fhandler_random.cc (fhandler_dev_random::lseek): Allow negative
dummy file positions as on Linux.
2009-10-23 09:22:14 +00:00
Corinna Vinschen a4f31f1b1b * registry.cc (reg_key::get_int): Add alternative implementation
taking WCHAR strings.
	(reg_key::set_int): Ditto.
	(reg_key::get_string): Ditto.
	(reg_key::set_string): Ditto.
	* registry.h (struct reg_key): Add prototypes for added methods.
2009-10-20 14:54:47 +00:00
Corinna Vinschen c94a1006c6 * smallprint.cc (__small_vsprintf): Simplify UNICODE string handling
and allow empty strings.
2009-10-20 14:52:43 +00:00
Corinna Vinschen cbea3f7d93 * fhandler_disk_file.cc (fhander_disk_file::readdir): Handle a status
code STATUS_NOT_SUPPORTED.  Add matching comment.
2009-10-20 10:12:05 +00:00
Corinna Vinschen 8d648dc555 * syscalls.cc (internal_setlocale): Only convert $PATH if there is a
$PATH.
2009-10-19 19:47:15 +00:00
Corinna Vinschen b3f5fb3718 * spawn.cc (av::fixup): Treat non-readable, but executable files as
Cygwin executables.
2009-10-19 08:33:00 +00:00
Corinna Vinschen a6f3658d44 * uinfo.cc (uinfo_init): Deimpersonate, don't reimpersonate, if
not in a setuid condition.
2009-10-18 09:07:13 +00:00
Eric Blake 4cd31fc8f9 Consistently use va_end.
* external.cc (cygwin_internal): Use va_end.
* fork.cc (child_copy): Likewise.
* libc/bsdlib.cc (warn, warnx, err, errx): Likewise.
* pinfo.cc (commune_request): Likewise.
* strace.cc (strace::prntf, strace_printf): Likewise.
2009-10-14 04:17:05 +00:00
Corinna Vinschen bc3aedd061 * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. 2009-10-13 12:08:22 +00:00
Corinna Vinschen 0191627a26 * include/sys/cygwin.h: Add new cygwin_getinfo_type
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.
2009-10-13 10:23:31 +00:00
Eric Blake b8a35083c6 Improve clock_gettime and utimensat resolution.
* hires.h (hires_ms): Change initime_us to initime_ns, with 10x
more resolution.
(hires_ms::nsecs): New prototype.
(hires_ms::usecs, hires_ms::msecs, hires_ms::uptime): Adjust.
* times.cc (systime_ns): New helper function.
(hires_ms::prime): Use it for more resolution.
(hires_ms::usecs): Change to...
(hires_ms::nsecs): ...with more resolution.
(clock_gettime): Use more resolution.
(systime): Rewrite in terms of systime_ns.
(timespec_to_filetime): Rewrite math to reflect true operation.
* fhandler_disk_file.cc (utimens_fs): Use higher resolution.
2009-10-13 02:26:33 +00:00
Corinna Vinschen 2fc007681e * external.cc (cygwin_internal): Return 0 in CW_SET_DOS_FILE_WARNING
and CW_SETERRNO cases.
2009-10-12 19:26:08 +00:00
Corinna Vinschen d358c9e9b0 * fhandler_disk_file.cc (fhandler_disk_file::link): Only append .lnk
if the original device had one, too.  Add comment.

	* fhandler_socket.cc (fhandler_socket::fstat): Always return a size of
	0 on sockets.
2009-10-12 11:57:29 +00:00
Corinna Vinschen 9fa1c6420b * path.cc (tfx_chars): Convert all ASCII control characters except
ASCII NUL as well.  Change layout to make the conversions more clear.
	Add comment.
2009-10-09 11:17:17 +00:00
Corinna Vinschen 1441f6a3d1 * include/cygwin/config.h (DEFAULT_LOCALE): Define as "C.UTF-8". 2009-10-09 08:36:21 +00:00
Christopher Faylor 5391a40c89 * exceptions.cc (_cygtls::signal_exit): There's no need to set signal_arrived
if we're exiting.
2009-10-08 15:56:14 +00:00
Eric Blake 80636211bc * fhandler_disk_file.cc (utimens_fs): Plug fd leak on EINVAL. 2009-10-08 11:13:45 +00:00
Charles Wilson dc4e4aabba Support pseudo-reloc version 2 2009-10-07 15:47:38 +00:00
Corinna Vinschen dfbf36f8db * syscalls.cc (seteuid32): Call set_cygwin_privileges on primary token
as well.
2009-10-07 08:20:49 +00:00
Corinna Vinschen b4311a9067 * fhandler.h (fhandler_pty_master::tcgetpgrp): Declare.
* fhandler_termios.cc (fhandler_termios::tcgetpgrp): Only return
	valid pgid if tty is controlling tty.  Set errno to ENOTTY and
	return -1 otherwise.
	(fhandler_pty_master::tcgetpgrp): New function.  Return 0 for
	master side of pty if it's not the controlling tty of the process.
2009-10-07 07:52:30 +00:00
Charles Wilson c8ee587a8e Add cygwin wrapper for ExitProcess and TerminateProcess. 2009-10-06 21:51:17 +00:00
Christopher Faylor a12518a37c * exceptions.cc: Move global variable sigExeced...
* globals.cc: here.
* pinfo.cc (pinfo::maybe_set_exit_code_from_windows): Remove now unneeded
declaration.
2009-10-06 03:39:38 +00:00
Dave Korn 3772467948 * Makefile.in (CFLAGS): Add -mno-use-libstdc-wrappers. 2009-10-04 17:48:05 +00:00
Corinna Vinschen 960624f47e * syscalls.cc (internal_setlocale): Add comment. 2009-10-04 11:32:07 +00:00
Corinna Vinschen 0ca6c6b802 * dcrt0.cc (dll_crt0_1): Drop calls to setlocale/_setlocale_r. Just
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.
2009-10-02 14:58:10 +00:00
Christopher Faylor 284c5ea0a5 * dcrt0.cc (dll_crt0_1): Move cxx_malloc reset kluge from here.
(check_sanity_and_sync): to here.
* path.cc (has_dot_last_component): Rewrite to detect some corner cases that
were previously uncaught.
2009-10-02 06:04:57 +00:00
Corinna Vinschen 4180b64df4 * fhandler_console.cc (beep): Move up to avoid forward declaration.
(fhandler_console::read): Just beep on characters invalid in current
	charset.  Add comment.
2009-09-30 09:23:45 +00:00
Eric Blake 1c0909882c * syscalls.cc (rename): Fix regression in rename("dir","d/"). 2009-09-30 02:11:05 +00:00
Corinna Vinschen 4abcdf2717 * fhandler_socket.cc (fhandler_socket::recv_internal): Always call
WSARecv on SOCK_STREAM sockets.
2009-09-29 08:46:29 +00:00
Corinna Vinschen 587b75f7bd * fhandler.h (class dev_console): Constify charset parameter of
str_to_con.
	* fhandler_console.cc (dev_console::con_to_str): Simplify.  Always
	default to the current internal locale.
	(dev_console::get_console_cp): Always use codepage 437 for alternate
	charset.
	(dev_console::str_to_con): Constify charset parameter.
	(fhandler_console::write_normal): Always use codepage 437 for alternate
	charset.  Otherwise always default to the current internal locale.
	Replace ASCII SO with ASCII CAN.
	* strfuncs.cc: Tweka comments according to below changes.
	(sys_cp_wcstombs): Constify charset parameter.  Convert all wchar_t
	values in the Unicode private use area U+F0xx to the singlebyte
	counterpart.  Drop special handling creating ASCII SO sequence from
	U+DCxx value.  Rearrange for performance.  Replace ASCII SO with
	ASCII CAN.
	(sys_cp_mbstowcs): Constify charset parameter.  Replace ASCII SO with
	ASCII CAN.  Drop special case for U+DCxx ASCII SO sequences.  Always
	create a replacement from the Unicode private use area U+F0xx for
	invalid byte values in a multibyte sequence.  Do the same for wchar_t
	values from the U+F0xx range to make them roundtrip safe.
	* wchar.h (sys_cp_wcstombs): Constify charset parameter.
	(sys_cp_mbstowcs): Ditto.
2009-09-28 12:10:32 +00:00
Corinna Vinschen d856640e1c * cygheap.cc (cygheap_init): Default locale.charset to "UTF-8".
* 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.
2009-09-28 10:43:49 +00:00
Eric Blake 15e9ecd14a Add fexecve, execvpe.
* exec.cc (fexecve): New function.
* cygwin.din (execvpe, fexecve): Export new fexecve and existing
execvpe.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* posix.sgml: Mention them.
2009-09-26 21:01:10 +00:00
Eric Blake 52dba6a5c4 Fix some POSIX-compliance bugs in link, rename, mkdir.
* syscalls.cc (link): Delete obsolete comment.  Reject directories
and missing source up front.
(rename): Use correct errno for trailing '.'.  Detect empty
strings.  Allow trailing slash to newpath iff oldpath is
directory.
* dir.cc (mkdir): Reject dangling symlink with trailing slash.
* fhandler_disk_file.cc (fhandler_disk_file::link): Reject
trailing slash.
* fhandler.cc (fhandler_base::link): Match Linux errno.
2009-09-26 15:51:53 +00:00
Eric Blake 2bf78f0928 Provide euidaccess, canonicalize_file_name; fix fchmodat.
* syscalls.cc (fchmodat): lchmod is not yet implemented.
(euidaccess): New function.
* path.cc (realpath): Update comment.
(canonicalize_file_name): New function.
* include/cygwin/stdlib.h (canonicalize_file_name): Declare it.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* cygwin.din: Export canonicalize_file_name, eaccess, euidaccess.
* posix.sgml: Mention them.
2009-09-25 23:55:00 +00:00
Eric Blake 3dbe243afa Fix faccessat(,0) and access() semantics.
* fhandler.h (fhandler_base::fhaccess): Add parameter.
* security.h (check_file_access, check_registry_access): Likewise.
* security.cc (check_file_access, check_registry_access)
(check_access): Implement new parameter.
* fhandler.cc (fhandler_base::fhaccess): Likewise.
(device_access_denied): Update caller.
* syscalls.cc (access, faccessat): Update callers.
* spawn.cc (find_exec, fixup): Likewise.
2009-09-25 13:44:45 +00:00
Corinna Vinschen 599d462dfa * posix_ipc.cc (mq_open): Avoid closing the same descriptor twice in
case of errors.
	(sem_open): Ditto.
2009-09-24 09:25:35 +00:00
Corinna Vinschen 1c23aff7a3 * kernel32.cc (CreateMutexW): Use correct access mask.
(CreateSemaphoreW): Ditto.
2009-09-24 09:09:45 +00:00
Corinna Vinschen 8e3607fcee * strfuncs.cc (__set_charset_from_codepage): Fetch current ANSI
codepage if cp is 0.
2009-09-23 17:13:55 +00:00
Corinna Vinschen 565d6ede3f Fix typo. 2009-09-23 12:01:42 +00:00
Corinna Vinschen e664429d77 * strfuncs.cc (sys_cp_wcstombs): Convert lone surrogate pair
second halves to unambiguous ASCII SO sequence.  When converting
	chars invalid in current codepage to ASCII SO sequence, make
	sure to check for surrogate pair second half only if ct least
	one wide characters is left.  Decrement nwc if valid second half has
	been converted.
	(sys_cp_mbstowcs): Improve ASCII SO handling.  Never break from loop
	if invalid character has been found.  Recognize ASCII SO sequence
	representing originally invalid mulitbyte char converted into a
	lone surrogate pair second half.  Convert accordingly.
2009-09-23 11:31:00 +00:00
Corinna Vinschen 5e8d7527af * autoload.cc (WSARecv): Define.
* fhandler_socket.cc (fhandler_socket::recv_internal): Call WSARecv
	instead of WSARecvFrom if no name parameter is given.  Explain why.
2009-09-22 14:27:57 +00:00
Eric Blake 74a67d01a5 Make *at functions more like Linux.
* syscalls.cc (faccessat): Fix typo, reject bad flags.
(fchmodat, fchownat, fstatat, utimensat, linkat, unlinkat): Reject
bad flags.
2009-09-22 12:13:53 +00:00
Corinna Vinschen abe6b5a3e2 * strfuncs.cc (sys_cp_mbstowcs): Reset shift state after handling
invalid multibyte sequence.
2009-09-22 09:44:32 +00:00
Corinna Vinschen 4401b147bb * path.cc (symlink_worker): Rework error handling to generate Linux
compatible errno in case of trailing slash in newpath.
2009-09-22 09:24:30 +00:00
Eric Blake 29bca9bb0c Match dup2 and fcntl error values to POSIX.
* dtable.h (OPEN_MAX_MAX): New macro.
* resource.cc (getrlimit) [RLIMIT_NOFILE]: Use it.
* dtable.cc (dtable::extend): Likewise.
* fcntl.cc (fcntl64): Obey POSIX rule with too-large F_DUPFD.
* syscalls.cc (dup2): Likewise.
2009-09-22 04:09:03 +00:00
Eric Blake a7b24e14d7 * ChangeLog-2002: Fix typo.
* ChangeLog-2008: Likewise.
2009-09-22 02:49:15 +00:00