mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-20 16:01:10 +08:00
* mmap.cc: Clean up *ResourceLock calls throughout.
* thread.cc (pthread_cond::TimedWait): Check for WAIT_TIMEOUT as well as WAIT_ABANDONED. (__pthread_cond_timedwait): Calculate a relative wait from the abstime parameter.
This commit is contained in:
parent
d006404dae
commit
462f4effb1
@ -1,3 +1,14 @@
|
||||
Tue Jun 26 10:47:24 2001 Christopher Faylor <cgf@cygnus.com>
|
||||
|
||||
* mmap.cc: Clean up *ResourceLock calls throughout.
|
||||
|
||||
Tue Jun 26 22:10:00 2001 Robert Collins rbtcollins@hotmail.com
|
||||
|
||||
* thread.cc (pthread_cond::TimedWait): Check for WAIT_TIMEOUT as well
|
||||
as WAIT_ABANDONED.
|
||||
(__pthread_cond_timedwait): Calculate a relative wait from the abstime
|
||||
parameter.
|
||||
|
||||
Sun Jun 24 17:38:19 2001 Christopher Faylor <cgf@cygnus.com>
|
||||
|
||||
* exceptions.cc (interrupt_setup): Move actions from setup_handler to
|
||||
@ -29,7 +40,7 @@ Thu Jun 21 22:01:39 2001 Marius Gedminas <mgedmin@delfi.lt>
|
||||
|
||||
2001-06-22 Robert Collins <rbbtcollins@hotmail.com>
|
||||
|
||||
* thread.cc (__pthread_cond_timedwait): Lock the waiting mutex before
|
||||
* thread.cc (__pthread_cond_timedwait): Lock the waiting mutex before
|
||||
the condition protect mutex to avoid deadlocking. (Found by Greg Smith).
|
||||
(__pthread_cond_wait): Ditto.
|
||||
|
||||
|
@ -68,7 +68,6 @@ public:
|
||||
return 1;
|
||||
return strncasematch (m->native_path, path, m->native_pathlen)
|
||||
&& (path[m->native_pathlen] == '\\' || !path[m->native_pathlen]);
|
||||
|
||||
}
|
||||
const char *unchroot (const char *path)
|
||||
{
|
||||
|
@ -28,6 +28,13 @@
|
||||
* malloc_usable_size(P) is equivalent to realloc(P, malloc_usable_size(P))
|
||||
*
|
||||
* $Log$
|
||||
* Revision 1.3 2001/06/26 14:47:48 cgf
|
||||
* * mmap.cc: Clean up *ResourceLock calls throughout.
|
||||
* * thread.cc (pthread_cond::TimedWait): Check for WAIT_TIMEOUT as well as
|
||||
* WAIT_ABANDONED.
|
||||
* (__pthread_cond_timedwait): Calculate a relative wait from the abstime
|
||||
* parameter.
|
||||
*
|
||||
* Revision 1.2 2001/06/24 22:26:49 cgf
|
||||
* forced commit
|
||||
*
|
||||
@ -2001,7 +2008,7 @@ static void do_check_chunk(p) mchunkptr p;
|
||||
if (!chunk_is_mmapped(p))
|
||||
{
|
||||
INTERNAL_SIZE_T sz;
|
||||
|
||||
|
||||
unless((char*)p >= sbrk_base, "chunk precedes sbrk_base", p);
|
||||
unless((char*)p + MINSIZE <= (char*)top + chunksize(top),
|
||||
"chunk past sbrk area", p);
|
||||
@ -2057,7 +2064,7 @@ static void do_check_inuse_chunk(p) mchunkptr p;
|
||||
{
|
||||
mchunkptr next;
|
||||
do_check_chunk(p);
|
||||
|
||||
|
||||
if (chunk_is_mmapped(p))
|
||||
return;
|
||||
|
||||
@ -2178,7 +2185,7 @@ static void do_init_freed_chunk(mchunkptr p, INTERNAL_SIZE_T freehead,
|
||||
p->alloced = 0;
|
||||
memset((char *)mem - MOATWIDTH, MOATFILL, MOATWIDTH);
|
||||
memset((char *)mem + bytes, MOATFILL, MOATWIDTH);
|
||||
|
||||
|
||||
/* To avoid terrible O(n^2) performance when free() repeatedly grows a free
|
||||
* chunk, it's important not to free-fill regions that are already
|
||||
* free-filled.
|
||||
@ -2576,7 +2583,7 @@ static void malloc_extend_top(nb) INTERNAL_SIZE_T nb;
|
||||
}
|
||||
#endif /* OTHER_SBRKS */
|
||||
}
|
||||
|
||||
|
||||
init_freed_chunk(top, old_top == initial_top ? old_top_size : 0, 0);
|
||||
|
||||
if ((unsigned long)sbrked_mem > (unsigned long)max_sbrked_mem)
|
||||
@ -2699,7 +2706,7 @@ Void_t* mALLOc(bytes) size_t bytes;
|
||||
check_freefill(victim, victim_size, victim_size);
|
||||
init_malloced_chunk(victim, bytes);
|
||||
check_malloced_chunk(victim, nb);
|
||||
|
||||
|
||||
return chunk2mem(victim);
|
||||
}
|
||||
|
||||
@ -2952,7 +2959,7 @@ void fREe(mem) Void_t* mem;
|
||||
|
||||
p = mem2chunk(mem);
|
||||
check_inuse_chunk(p);
|
||||
|
||||
|
||||
hd = p->size;
|
||||
|
||||
#if HAVE_MMAP
|
||||
@ -3644,7 +3651,7 @@ static void malloc_update_mallinfo(void)
|
||||
INTERNAL_SIZE_T avail = chunksize(top);
|
||||
int navail = avail >= MINSIZE ? 1 : 0;
|
||||
check_freefill(top, avail, avail);
|
||||
|
||||
|
||||
#if DEBUG
|
||||
if (lowest_chunk)
|
||||
for (p = lowest_chunk;
|
||||
@ -3652,7 +3659,7 @@ static void malloc_update_mallinfo(void)
|
||||
p = next_chunk(p))
|
||||
check_inuse_chunk(p);
|
||||
#endif
|
||||
|
||||
|
||||
for (i = 1; i < NAV; ++i)
|
||||
{
|
||||
b = bin_at(i);
|
||||
@ -3662,9 +3669,9 @@ static void malloc_update_mallinfo(void)
|
||||
check_free_chunk(p);
|
||||
check_freefill(p, chunksize(p), chunksize(p));
|
||||
for (q = next_chunk(p);
|
||||
q < top && inuse(q) && chunksize(q) >= MINSIZE;
|
||||
q = next_chunk(q))
|
||||
check_inuse_chunk(q);
|
||||
q < top && inuse(q) && chunksize(q) >= MINSIZE;
|
||||
q = next_chunk(q))
|
||||
check_inuse_chunk(q);
|
||||
#endif
|
||||
avail += chunksize(p);
|
||||
navail++;
|
||||
@ -3701,14 +3708,14 @@ void malloc_stats(void)
|
||||
{
|
||||
malloc_update_mallinfo();
|
||||
fprintf(stderr, "max system bytes = %10u\n",
|
||||
(unsigned int)(max_total_mem));
|
||||
(unsigned int)(max_total_mem));
|
||||
fprintf(stderr, "system bytes = %10u\n",
|
||||
(unsigned int)(sbrked_mem + mmapped_mem));
|
||||
(unsigned int)(sbrked_mem + mmapped_mem));
|
||||
fprintf(stderr, "in use bytes = %10u\n",
|
||||
(unsigned int)(current_mallinfo.uordblks + mmapped_mem));
|
||||
(unsigned int)(current_mallinfo.uordblks + mmapped_mem));
|
||||
#if HAVE_MMAP
|
||||
fprintf(stderr, "max mmap regions = %10u\n",
|
||||
(unsigned int)max_n_mmaps);
|
||||
(unsigned int)max_n_mmaps);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -3779,13 +3786,13 @@ History:
|
||||
* Added anonymously donated WIN32 sbrk emulation
|
||||
* Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen
|
||||
* malloc_extend_top: fix mask error that caused wastage after
|
||||
foreign sbrks
|
||||
foreign sbrks
|
||||
* Add linux mremap support code from HJ Liu
|
||||
|
||||
V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee)
|
||||
* Integrated most documentation with the code.
|
||||
* Add support for mmap, with help from
|
||||
Wolfram Gloger (Gloger@lrz.uni-muenchen.de).
|
||||
Wolfram Gloger (Gloger@lrz.uni-muenchen.de).
|
||||
* Use last_remainder in more cases.
|
||||
* Pack bins using idea from colin@nyx10.cs.du.edu
|
||||
* Use ordered bins instead of best-fit threshhold
|
||||
@ -3793,34 +3800,34 @@ History:
|
||||
* Support another case of realloc via move into top
|
||||
* Fix error occuring when initial sbrk_base not word-aligned.
|
||||
* Rely on page size for units instead of SBRK_UNIT to
|
||||
avoid surprises about sbrk alignment conventions.
|
||||
avoid surprises about sbrk alignment conventions.
|
||||
* Add mallinfo, mallopt. Thanks to Raymond Nijssen
|
||||
(raymond@es.ele.tue.nl) for the suggestion.
|
||||
(raymond@es.ele.tue.nl) for the suggestion.
|
||||
* Add `pad' argument to malloc_trim and top_pad mallopt parameter.
|
||||
* More precautions for cases where other routines call sbrk,
|
||||
courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de).
|
||||
courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de).
|
||||
* Added macros etc., allowing use in linux libc from
|
||||
H.J. Lu (hjl@gnu.ai.mit.edu)
|
||||
H.J. Lu (hjl@gnu.ai.mit.edu)
|
||||
* Inverted this history list
|
||||
|
||||
V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee)
|
||||
* Re-tuned and fixed to behave more nicely with V2.6.0 changes.
|
||||
* Removed all preallocation code since under current scheme
|
||||
the work required to undo bad preallocations exceeds
|
||||
the work saved in good cases for most test programs.
|
||||
the work required to undo bad preallocations exceeds
|
||||
the work saved in good cases for most test programs.
|
||||
* No longer use return list or unconsolidated bins since
|
||||
no scheme using them consistently outperforms those that don't
|
||||
given above changes.
|
||||
no scheme using them consistently outperforms those that don't
|
||||
given above changes.
|
||||
* Use best fit for very large chunks to prevent some worst-cases.
|
||||
* Added some support for debugging
|
||||
|
||||
V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee)
|
||||
* Removed footers when chunks are in use. Thanks to
|
||||
Paul Wilson (wilson@cs.texas.edu) for the suggestion.
|
||||
Paul Wilson (wilson@cs.texas.edu) for the suggestion.
|
||||
|
||||
V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee)
|
||||
* Added malloc_trim, with help from Wolfram Gloger
|
||||
(wmglo@Dent.MED.Uni-Muenchen.DE).
|
||||
(wmglo@Dent.MED.Uni-Muenchen.DE).
|
||||
|
||||
V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g)
|
||||
|
||||
@ -3836,11 +3843,11 @@ History:
|
||||
V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g)
|
||||
* faster bin computation & slightly different binning
|
||||
* merged all consolidations to one part of malloc proper
|
||||
(eliminating old malloc_find_space & malloc_clean_bin)
|
||||
(eliminating old malloc_find_space & malloc_clean_bin)
|
||||
* Scan 2 returns chunks (not just 1)
|
||||
* Propagate failure in realloc if malloc returns 0
|
||||
* Add stuff to allow compilation on non-ANSI compilers
|
||||
from kpv@research.att.com
|
||||
from kpv@research.att.com
|
||||
|
||||
V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu)
|
||||
* removed potential for odd address access in prev_chunk
|
||||
@ -3848,11 +3855,11 @@ History:
|
||||
* misc cosmetics and a bit more internal documentation
|
||||
* anticosmetics: mangled names in macros to evade debugger strangeness
|
||||
* tested on sparc, hp-700, dec-mips, rs6000
|
||||
with gcc & native cc (hp, dec only) allowing
|
||||
Detlefs & Zorn comparison study (in SIGPLAN Notices.)
|
||||
with gcc & native cc (hp, dec only) allowing
|
||||
Detlefs & Zorn comparison study (in SIGPLAN Notices.)
|
||||
|
||||
Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu)
|
||||
* Based loosely on libg++-1.2X malloc. (It retains some of the overall
|
||||
structure of old version, but most details differ.)
|
||||
structure of old version, but most details differ.)
|
||||
|
||||
*/
|
||||
|
@ -749,7 +749,7 @@ const char* forced_winenv_vars [] =
|
||||
NULL
|
||||
};
|
||||
|
||||
#define FORCED_WINENV_SIZE (sizeof (forced_winenv_vars) / sizeof (forced_winenv_vars[0]))
|
||||
#define FORCED_WINENV_SIZE (sizeof (forced_winenv_vars) / sizeof (forced_winenv_vars[0]))
|
||||
|
||||
/* Create a Windows-style environment block, i.e. a typical character buffer
|
||||
filled with null terminated strings, terminated by double null characters.
|
||||
|
@ -974,7 +974,6 @@ private:
|
||||
int audiobits_;
|
||||
int audiochannels_;
|
||||
bool setupwav(const char *pData, int nBytes);
|
||||
|
||||
public:
|
||||
fhandler_dev_dsp (const char *name = 0);
|
||||
~fhandler_dev_dsp();
|
||||
|
@ -1,11 +1,11 @@
|
||||
/* fhandler_dev_dsp: code to emulate OSS sound model /dev/dsp
|
||||
|
||||
|
||||
Copyright 2001 Red Hat, Inc
|
||||
|
||||
|
||||
Written by Andy Younger (andy@snoogie.demon.co.uk)
|
||||
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
|
||||
This software is a copyrighted work licensed under the terms of the
|
||||
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||
details. */
|
||||
|
@ -189,7 +189,7 @@ fhandler_serial::raw_write (const void *ptr, size_t len)
|
||||
}
|
||||
|
||||
ForceCloseHandle(write_status.hEvent);
|
||||
|
||||
|
||||
return bytes_written;
|
||||
|
||||
err:
|
||||
|
@ -428,7 +428,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
|
||||
if ((flags & MAP_PRIVATE) && (os_being_run == winNT || (prot & ~PROT_READ)))
|
||||
access = FILE_MAP_COPY;
|
||||
|
||||
SetResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
|
||||
SetResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
|
||||
|
||||
#if 0
|
||||
/* Windows 95 does not have fixed addresses */
|
||||
@ -452,7 +452,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
|
||||
{
|
||||
set_errno (ENOMEM);
|
||||
syscall_printf ("-1 = mmap(): ENOMEM");
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
|
||||
return MAP_FAILED;
|
||||
}
|
||||
}
|
||||
@ -475,7 +475,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
|
||||
{
|
||||
set_errno (EBADF);
|
||||
syscall_printf ("-1 = mmap(): EBADF");
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
|
||||
return MAP_FAILED;
|
||||
}
|
||||
fh = cygheap->fdtab[fd];
|
||||
@ -509,7 +509,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
|
||||
off = rec->map_map (off, len);
|
||||
caddr_t ret = rec->get_address () + off;
|
||||
syscall_printf ("%x = mmap() succeeded", ret);
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -518,7 +518,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
|
||||
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
|
||||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
@ -541,7 +541,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
|
||||
fh->munmap (h, base, gran_len);
|
||||
set_errno (ENOMEM);
|
||||
syscall_printf ("-1 = mmap(): ENOMEM");
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
|
||||
return MAP_FAILED;
|
||||
}
|
||||
l = mmapped_areas->add_list (l, fd);
|
||||
@ -552,7 +552,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
|
||||
off = rec->map_map (off, len);
|
||||
caddr_t ret = rec->get_address () + off;
|
||||
syscall_printf ("%x = mmap() succeeded", ret);
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -573,13 +573,13 @@ munmap (caddr_t addr, size_t len)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SetResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," munmap");
|
||||
SetResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap");
|
||||
/* Check if a mmap'ed area was ever created */
|
||||
if (mmapped_areas == NULL)
|
||||
{
|
||||
syscall_printf ("-1 = munmap(): mmapped_areas == NULL");
|
||||
set_errno (EINVAL);
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," munmap");
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -605,7 +605,7 @@ munmap (caddr_t addr, size_t len)
|
||||
l->erase (li);
|
||||
}
|
||||
syscall_printf ("0 = munmap(): %x", addr);
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," munmap");
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -614,7 +614,7 @@ munmap (caddr_t addr, size_t len)
|
||||
set_errno (EINVAL);
|
||||
syscall_printf ("-1 = munmap(): EINVAL");
|
||||
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," munmap");
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -636,13 +636,13 @@ msync (caddr_t addr, size_t len, int flags)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SetResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," msync");
|
||||
SetResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync");
|
||||
/* Check if a mmap'ed area was ever created */
|
||||
if (mmapped_areas == NULL)
|
||||
{
|
||||
syscall_printf ("-1 = msync(): mmapped_areas == NULL");
|
||||
set_errno (EINVAL);
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," msync");
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -668,7 +668,7 @@ msync (caddr_t addr, size_t len, int flags)
|
||||
else
|
||||
syscall_printf ("0 = msync()");
|
||||
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," msync");
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -679,7 +679,7 @@ msync (caddr_t addr, size_t len, int flags)
|
||||
set_errno (ENOMEM);
|
||||
syscall_printf ("-1 = msync(): ENOMEM");
|
||||
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," msync");
|
||||
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
~wsock_event ()
|
||||
{
|
||||
if (event)
|
||||
WSACloseEvent (event);
|
||||
WSACloseEvent (event);
|
||||
event = NULL;
|
||||
};
|
||||
|
||||
@ -77,7 +77,7 @@ wsock_event::prepare ()
|
||||
}
|
||||
else if (GetLastError () == ERROR_PROC_NOT_FOUND) /* winsock2 not available */
|
||||
WSASetLastError (0);
|
||||
|
||||
|
||||
debug_printf ("%d = wsock_event::prepare ()", ret);
|
||||
return ret;
|
||||
}
|
||||
@ -100,9 +100,9 @@ wsock_event::wait (int socket, LPDWORD flags)
|
||||
{
|
||||
debug_printf ("CancelIo() %E, fallback to blocking io");
|
||||
WSAGetOverlappedResult(socket, &ovr, &len, TRUE, flags);
|
||||
}
|
||||
}
|
||||
else
|
||||
WSASetLastError (WSAEINTR);
|
||||
WSASetLastError (WSAEINTR);
|
||||
break;
|
||||
case WSA_WAIT_FAILED:
|
||||
break;
|
||||
@ -470,7 +470,7 @@ static int get_inet_addr (const struct sockaddr *in, int inlen,
|
||||
char buf[128];
|
||||
memset (buf, 0, sizeof buf);
|
||||
if (read (fd, buf, sizeof buf) != -1)
|
||||
{
|
||||
{
|
||||
sockaddr_in sin;
|
||||
sin.sin_family = AF_INET;
|
||||
sscanf (buf + strlen (SOCKET_COOKIE), "%hu %08x-%08x-%08x-%08x",
|
||||
@ -481,7 +481,7 @@ static int get_inet_addr (const struct sockaddr *in, int inlen,
|
||||
*out = sin;
|
||||
*outlen = sizeof sin;
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
_close (fd);
|
||||
return ret;
|
||||
}
|
||||
@ -526,15 +526,15 @@ cygwin_sendto (int fd,
|
||||
WSABUF wsabuf = { len, (char *) buf };
|
||||
DWORD ret = 0;
|
||||
if (WSASendTo (h->get_socket (), &wsabuf, 1, &ret, (DWORD)flags,
|
||||
to, tolen, ovr, NULL) != SOCKET_ERROR)
|
||||
res = ret;
|
||||
to, tolen, ovr, NULL) != SOCKET_ERROR)
|
||||
res = ret;
|
||||
else if ((res = WSAGetLastError ()) != WSA_IO_PENDING)
|
||||
{
|
||||
set_winsock_errno ();
|
||||
res = -1;
|
||||
}
|
||||
{
|
||||
set_winsock_errno ();
|
||||
res = -1;
|
||||
}
|
||||
else if ((res = wsock_evt.wait (h->get_socket (), (DWORD *)&flags)) == -1)
|
||||
set_winsock_errno ();
|
||||
set_winsock_errno ();
|
||||
}
|
||||
|
||||
syscall_printf ("%d = sendto (%d, %x, %x, %x)", res, fd, buf, len, flags);
|
||||
@ -561,7 +561,7 @@ cygwin_recvfrom (int fd,
|
||||
{
|
||||
debug_printf ("Fallback to winsock 1 recvfrom call");
|
||||
if ((res = recvfrom (h->get_socket (), buf, len, flags, from, fromlen))
|
||||
== SOCKET_ERROR)
|
||||
== SOCKET_ERROR)
|
||||
{
|
||||
set_winsock_errno ();
|
||||
res = -1;
|
||||
@ -572,15 +572,15 @@ cygwin_recvfrom (int fd,
|
||||
WSABUF wsabuf = { len, (char *) buf };
|
||||
DWORD ret = 0;
|
||||
if (WSARecvFrom (h->get_socket (), &wsabuf, 1, &ret, (DWORD *)&flags,
|
||||
from, fromlen, ovr, NULL) != SOCKET_ERROR)
|
||||
res = ret;
|
||||
from, fromlen, ovr, NULL) != SOCKET_ERROR)
|
||||
res = ret;
|
||||
else if ((res = WSAGetLastError ()) != WSA_IO_PENDING)
|
||||
{
|
||||
set_winsock_errno ();
|
||||
res = -1;
|
||||
}
|
||||
{
|
||||
set_winsock_errno ();
|
||||
res = -1;
|
||||
}
|
||||
else if ((res = wsock_evt.wait (h->get_socket (), (DWORD *)&flags)) == -1)
|
||||
set_winsock_errno ();
|
||||
set_winsock_errno ();
|
||||
}
|
||||
|
||||
syscall_printf ("%d = recvfrom (%d, %x, %x, %x)", res, fd, buf, len, flags);
|
||||
@ -756,7 +756,7 @@ cygwin_connect (int fd,
|
||||
{
|
||||
res = connect (sock->get_socket (), (sockaddr *) &sin, namelen);
|
||||
if (res)
|
||||
{
|
||||
{
|
||||
/* Special handling for connect to return the correct error code
|
||||
when called to early on a non-blocking socket. */
|
||||
if (WSAGetLastError () == WSAEWOULDBLOCK)
|
||||
@ -766,37 +766,37 @@ cygwin_connect (int fd,
|
||||
}
|
||||
|
||||
set_winsock_errno ();
|
||||
}
|
||||
}
|
||||
if (sock->get_addr_family () == AF_UNIX)
|
||||
{
|
||||
if (!res || in_progress)
|
||||
{
|
||||
if (!sock->create_secret_event (secret))
|
||||
{
|
||||
{
|
||||
if (!res || in_progress)
|
||||
{
|
||||
if (!sock->create_secret_event (secret))
|
||||
{
|
||||
secret_check_failed = TRUE;
|
||||
}
|
||||
else if (in_progress)
|
||||
sock->signal_secret_event ();
|
||||
}
|
||||
}
|
||||
|
||||
if (!secret_check_failed && !res)
|
||||
{
|
||||
if (!secret_check_failed && !res)
|
||||
{
|
||||
if (!sock->check_peer_secret_event (&sin, secret))
|
||||
{
|
||||
debug_printf ( "accept from unauthorized server" );
|
||||
secret_check_failed = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (secret_check_failed)
|
||||
{
|
||||
if (secret_check_failed)
|
||||
{
|
||||
sock->close_secret_event ();
|
||||
if (res)
|
||||
closesocket (res);
|
||||
if (res)
|
||||
closesocket (res);
|
||||
set_errno (ECONNREFUSED);
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -913,7 +913,7 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
|
||||
in_progress = TRUE;
|
||||
|
||||
if (sock->get_addr_family () == AF_UNIX)
|
||||
{
|
||||
{
|
||||
if ((SOCKET) res != (SOCKET) INVALID_SOCKET || in_progress)
|
||||
{
|
||||
if (!sock->create_secret_event ())
|
||||
@ -923,25 +923,25 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
|
||||
}
|
||||
|
||||
if (!secret_check_failed &&
|
||||
(SOCKET) res != (SOCKET) INVALID_SOCKET)
|
||||
{
|
||||
(SOCKET) res != (SOCKET) INVALID_SOCKET)
|
||||
{
|
||||
if (!sock->check_peer_secret_event ((struct sockaddr_in*) peer))
|
||||
{
|
||||
debug_printf ("connect from unauthorized client");
|
||||
secret_check_failed = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (secret_check_failed)
|
||||
{
|
||||
sock->close_secret_event ();
|
||||
if ((SOCKET) res != (SOCKET) INVALID_SOCKET)
|
||||
closesocket (res);
|
||||
if (secret_check_failed)
|
||||
{
|
||||
sock->close_secret_event ();
|
||||
if ((SOCKET) res != (SOCKET) INVALID_SOCKET)
|
||||
closesocket (res);
|
||||
set_errno (ECONNABORTED);
|
||||
res = -1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
res = -1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "accept");
|
||||
|
||||
@ -1020,11 +1020,11 @@ cygwin_bind (int fd, const struct sockaddr *my_addr, int addrlen)
|
||||
goto out;
|
||||
}
|
||||
|
||||
sock->set_connect_secret ();
|
||||
sock->set_connect_secret ();
|
||||
|
||||
char buf[sizeof (SOCKET_COOKIE) + 80];
|
||||
__small_sprintf (buf, "%s%u ", SOCKET_COOKIE, sin.sin_port);
|
||||
sock->get_connect_secret (strchr (buf, '\0'));
|
||||
sock->get_connect_secret (strchr (buf, '\0'));
|
||||
len = strlen (buf) + 1;
|
||||
|
||||
/* Note that the terminating nul is written. */
|
||||
@ -1158,14 +1158,14 @@ cygwin_herror (const char *s)
|
||||
switch (h_errno)
|
||||
{
|
||||
case NETDB_INTERNAL:
|
||||
h_errstr = "Resolver internal error";
|
||||
break;
|
||||
h_errstr = "Resolver internal error";
|
||||
break;
|
||||
case NETDB_SUCCESS:
|
||||
h_errstr = "Resolver error 0 (no error)";
|
||||
break;
|
||||
h_errstr = "Resolver error 0 (no error)";
|
||||
break;
|
||||
default:
|
||||
h_errstr = "Unknown resolver error";
|
||||
break;
|
||||
h_errstr = "Unknown resolver error";
|
||||
break;
|
||||
}
|
||||
write (2, h_errstr, strlen (h_errstr));
|
||||
write (2, "\n", 1);
|
||||
@ -1200,7 +1200,7 @@ cygwin_recv (int fd, void *buf, int len, unsigned int flags)
|
||||
{
|
||||
debug_printf ("Fallback to winsock 1 recv call");
|
||||
if ((res = recv (h->get_socket (), (char *) buf, len, flags))
|
||||
== SOCKET_ERROR)
|
||||
== SOCKET_ERROR)
|
||||
{
|
||||
set_winsock_errno ();
|
||||
res = -1;
|
||||
@ -1252,15 +1252,15 @@ cygwin_send (int fd, const void *buf, int len, unsigned int flags)
|
||||
WSABUF wsabuf = { len, (char *) buf };
|
||||
DWORD ret = 0;
|
||||
if (WSASend (h->get_socket (), &wsabuf, 1, &ret, (DWORD)flags,
|
||||
ovr, NULL) != SOCKET_ERROR)
|
||||
res = ret;
|
||||
ovr, NULL) != SOCKET_ERROR)
|
||||
res = ret;
|
||||
else if ((res = WSAGetLastError ()) != WSA_IO_PENDING)
|
||||
{
|
||||
set_winsock_errno ();
|
||||
res = -1;
|
||||
}
|
||||
{
|
||||
set_winsock_errno ();
|
||||
res = -1;
|
||||
}
|
||||
else if ((res = wsock_evt.wait (h->get_socket (), (DWORD *)&flags)) == -1)
|
||||
set_winsock_errno ();
|
||||
set_winsock_errno ();
|
||||
}
|
||||
|
||||
syscall_printf ("%d = send (%d, %x, %d, %x)", res, fd, buf, len, flags);
|
||||
@ -1327,7 +1327,7 @@ get_2k_ifconf (struct ifconf *ifc, int what)
|
||||
!GetIpAddrTable(ipt, &siz_ip_table, TRUE))
|
||||
{
|
||||
for (if_cnt = 0; if_cnt < ift->dwNumEntries; ++if_cnt)
|
||||
{
|
||||
{
|
||||
switch (ift->table[if_cnt].dwType)
|
||||
{
|
||||
case MIB_IF_TYPE_ETHERNET:
|
||||
@ -1351,44 +1351,44 @@ get_2k_ifconf (struct ifconf *ifc, int what)
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
for (ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ++ip_cnt)
|
||||
if (ipt->table[ip_cnt].dwIndex == ift->table[if_cnt].dwIndex)
|
||||
for (ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ++ip_cnt)
|
||||
if (ipt->table[ip_cnt].dwIndex == ift->table[if_cnt].dwIndex)
|
||||
{
|
||||
switch (what)
|
||||
{
|
||||
case SIOCGIFCONF:
|
||||
case SIOCGIFADDR:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_addr;
|
||||
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwAddr;
|
||||
switch (what)
|
||||
{
|
||||
case SIOCGIFCONF:
|
||||
case SIOCGIFADDR:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_addr;
|
||||
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwAddr;
|
||||
sa->sin_family = AF_INET;
|
||||
sa->sin_port = 0;
|
||||
break;
|
||||
case SIOCGIFBRDADDR:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
|
||||
break;
|
||||
case SIOCGIFBRDADDR:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
|
||||
#if 0
|
||||
/* Unfortunately, the field returns only crap. */
|
||||
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwBCastAddr;
|
||||
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwBCastAddr;
|
||||
#else
|
||||
lip = ipt->table[ip_cnt].dwAddr;
|
||||
lnp = ipt->table[ip_cnt].dwMask;
|
||||
sa->sin_addr.s_addr = lip & lnp | ~lnp;
|
||||
lip = ipt->table[ip_cnt].dwAddr;
|
||||
lnp = ipt->table[ip_cnt].dwMask;
|
||||
sa->sin_addr.s_addr = lip & lnp | ~lnp;
|
||||
sa->sin_family = AF_INET;
|
||||
sa->sin_port = 0;
|
||||
#endif
|
||||
break;
|
||||
case SIOCGIFNETMASK:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
|
||||
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwMask;
|
||||
break;
|
||||
case SIOCGIFNETMASK:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
|
||||
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwMask;
|
||||
sa->sin_family = AF_INET;
|
||||
sa->sin_port = 0;
|
||||
break;
|
||||
break;
|
||||
case SIOCGIFHWADDR:
|
||||
so = &ifr->ifr_hwaddr;
|
||||
so = &ifr->ifr_hwaddr;
|
||||
for (UINT i = 0; i < IFHWADDRLEN; ++i)
|
||||
if (i >= ift->table[if_cnt].dwPhysAddrLen)
|
||||
so->sa_data[i] = '\0';
|
||||
so->sa_data[i] = '\0';
|
||||
else
|
||||
so->sa_data[i] = ift->table[if_cnt].bPhysAddr[i];
|
||||
so->sa_data[i] = ift->table[if_cnt].bPhysAddr[i];
|
||||
so->sa_family = AF_INET;
|
||||
break;
|
||||
case SIOCGIFMETRIC:
|
||||
@ -1397,13 +1397,13 @@ get_2k_ifconf (struct ifconf *ifc, int what)
|
||||
case SIOCGIFMTU:
|
||||
ifr->ifr_mtu = ift->table[if_cnt].dwMtu;
|
||||
break;
|
||||
}
|
||||
++cnt;
|
||||
if ((caddr_t) ++ifr >
|
||||
}
|
||||
++cnt;
|
||||
if ((caddr_t) ++ifr >
|
||||
ifc->ifc_buf + ifc->ifc_len - sizeof (struct ifreq))
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
done:
|
||||
@ -1438,26 +1438,26 @@ get_nt_ifconf (struct ifconf *ifc, int what)
|
||||
struct ifreq *ifr = ifc->ifc_req;
|
||||
|
||||
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE,
|
||||
"SYSTEM\\"
|
||||
"CurrentControlSet\\"
|
||||
"Services\\"
|
||||
"Tcpip\\"
|
||||
"Linkage",
|
||||
0, KEY_READ, &key) == ERROR_SUCCESS)
|
||||
"SYSTEM\\"
|
||||
"CurrentControlSet\\"
|
||||
"Services\\"
|
||||
"Tcpip\\"
|
||||
"Linkage",
|
||||
0, KEY_READ, &key) == ERROR_SUCCESS)
|
||||
{
|
||||
if (RegQueryValueEx (key, "Bind",
|
||||
NULL, NULL,
|
||||
NULL, &size) == ERROR_SUCCESS)
|
||||
{
|
||||
binding = (char *) alloca (size);
|
||||
if (RegQueryValueEx (key, "Bind",
|
||||
NULL, NULL,
|
||||
(unsigned char *) binding,
|
||||
&size) != ERROR_SUCCESS)
|
||||
{
|
||||
binding = NULL;
|
||||
}
|
||||
}
|
||||
NULL, NULL,
|
||||
NULL, &size) == ERROR_SUCCESS)
|
||||
{
|
||||
binding = (char *) alloca (size);
|
||||
if (RegQueryValueEx (key, "Bind",
|
||||
NULL, NULL,
|
||||
(unsigned char *) binding,
|
||||
&size) != ERROR_SUCCESS)
|
||||
{
|
||||
binding = NULL;
|
||||
}
|
||||
}
|
||||
RegCloseKey (key);
|
||||
}
|
||||
|
||||
@ -1467,141 +1467,141 @@ get_nt_ifconf (struct ifconf *ifc, int what)
|
||||
char cardkey[256], ipaddress[256], netmask[256];
|
||||
|
||||
for (bp = binding; *bp; bp += strlen (bp) + 1)
|
||||
{
|
||||
bp += strlen ("\\Device\\");
|
||||
strcpy (cardkey, "SYSTEM\\CurrentControlSet\\Services\\");
|
||||
strcat (cardkey, bp);
|
||||
strcat (cardkey, "\\Parameters\\Tcpip");
|
||||
{
|
||||
bp += strlen ("\\Device\\");
|
||||
strcpy (cardkey, "SYSTEM\\CurrentControlSet\\Services\\");
|
||||
strcat (cardkey, bp);
|
||||
strcat (cardkey, "\\Parameters\\Tcpip");
|
||||
|
||||
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, cardkey,
|
||||
0, KEY_READ, &key) != ERROR_SUCCESS)
|
||||
continue;
|
||||
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, cardkey,
|
||||
0, KEY_READ, &key) != ERROR_SUCCESS)
|
||||
continue;
|
||||
|
||||
if (RegQueryValueEx (key, "IPAddress",
|
||||
NULL, NULL,
|
||||
(unsigned char *) ipaddress,
|
||||
(size = 256, &size)) == ERROR_SUCCESS
|
||||
&& RegQueryValueEx (key, "SubnetMask",
|
||||
NULL, NULL,
|
||||
(unsigned char *) netmask,
|
||||
(size = 256, &size)) == ERROR_SUCCESS)
|
||||
{
|
||||
char *ip, *np;
|
||||
char dhcpaddress[256], dhcpnetmask[256];
|
||||
if (RegQueryValueEx (key, "IPAddress",
|
||||
NULL, NULL,
|
||||
(unsigned char *) ipaddress,
|
||||
(size = 256, &size)) == ERROR_SUCCESS
|
||||
&& RegQueryValueEx (key, "SubnetMask",
|
||||
NULL, NULL,
|
||||
(unsigned char *) netmask,
|
||||
(size = 256, &size)) == ERROR_SUCCESS)
|
||||
{
|
||||
char *ip, *np;
|
||||
char dhcpaddress[256], dhcpnetmask[256];
|
||||
|
||||
for (ip = ipaddress, np = netmask;
|
||||
*ip && *np;
|
||||
ip += strlen (ip) + 1, np += strlen (np) + 1)
|
||||
{
|
||||
if ((caddr_t) ++ifr > ifc->ifc_buf
|
||||
+ ifc->ifc_len
|
||||
- sizeof (struct ifreq))
|
||||
break;
|
||||
for (ip = ipaddress, np = netmask;
|
||||
*ip && *np;
|
||||
ip += strlen (ip) + 1, np += strlen (np) + 1)
|
||||
{
|
||||
if ((caddr_t) ++ifr > ifc->ifc_buf
|
||||
+ ifc->ifc_len
|
||||
- sizeof (struct ifreq))
|
||||
break;
|
||||
|
||||
if (! strncmp (bp, "NdisWan", 7))
|
||||
{
|
||||
strcpy (ifr->ifr_name, "ppp");
|
||||
strcat (ifr->ifr_name, bp + 7);
|
||||
}
|
||||
else
|
||||
{
|
||||
++*eth;
|
||||
strcpy (ifr->ifr_name, "eth");
|
||||
strcat (ifr->ifr_name, eth);
|
||||
}
|
||||
memset (&ifr->ifr_addr, '\0', sizeof ifr->ifr_addr);
|
||||
if (cygwin_inet_addr (ip) == 0L
|
||||
&& RegQueryValueEx (key, "DhcpIPAddress",
|
||||
NULL, NULL,
|
||||
(unsigned char *) dhcpaddress,
|
||||
(size = 256, &size))
|
||||
== ERROR_SUCCESS
|
||||
&& RegQueryValueEx (key, "DhcpSubnetMask",
|
||||
NULL, NULL,
|
||||
(unsigned char *) dhcpnetmask,
|
||||
(size = 256, &size))
|
||||
== ERROR_SUCCESS)
|
||||
{
|
||||
switch (what)
|
||||
{
|
||||
case SIOCGIFCONF:
|
||||
case SIOCGIFADDR:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_addr;
|
||||
sa->sin_addr.s_addr = cygwin_inet_addr (dhcpaddress);
|
||||
if (! strncmp (bp, "NdisWan", 7))
|
||||
{
|
||||
strcpy (ifr->ifr_name, "ppp");
|
||||
strcat (ifr->ifr_name, bp + 7);
|
||||
}
|
||||
else
|
||||
{
|
||||
++*eth;
|
||||
strcpy (ifr->ifr_name, "eth");
|
||||
strcat (ifr->ifr_name, eth);
|
||||
}
|
||||
memset (&ifr->ifr_addr, '\0', sizeof ifr->ifr_addr);
|
||||
if (cygwin_inet_addr (ip) == 0L
|
||||
&& RegQueryValueEx (key, "DhcpIPAddress",
|
||||
NULL, NULL,
|
||||
(unsigned char *) dhcpaddress,
|
||||
(size = 256, &size))
|
||||
== ERROR_SUCCESS
|
||||
&& RegQueryValueEx (key, "DhcpSubnetMask",
|
||||
NULL, NULL,
|
||||
(unsigned char *) dhcpnetmask,
|
||||
(size = 256, &size))
|
||||
== ERROR_SUCCESS)
|
||||
{
|
||||
switch (what)
|
||||
{
|
||||
case SIOCGIFCONF:
|
||||
case SIOCGIFADDR:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_addr;
|
||||
sa->sin_addr.s_addr = cygwin_inet_addr (dhcpaddress);
|
||||
sa->sin_family = AF_INET;
|
||||
sa->sin_port = 0;
|
||||
break;
|
||||
case SIOCGIFBRDADDR:
|
||||
lip = cygwin_inet_addr (dhcpaddress);
|
||||
lnp = cygwin_inet_addr (dhcpnetmask);
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
|
||||
sa->sin_addr.s_addr = lip & lnp | ~lnp;
|
||||
break;
|
||||
case SIOCGIFBRDADDR:
|
||||
lip = cygwin_inet_addr (dhcpaddress);
|
||||
lnp = cygwin_inet_addr (dhcpnetmask);
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
|
||||
sa->sin_addr.s_addr = lip & lnp | ~lnp;
|
||||
sa->sin_family = AF_INET;
|
||||
sa->sin_port = 0;
|
||||
break;
|
||||
case SIOCGIFNETMASK:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
|
||||
sa->sin_addr.s_addr =
|
||||
cygwin_inet_addr (dhcpnetmask);
|
||||
break;
|
||||
case SIOCGIFNETMASK:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
|
||||
sa->sin_addr.s_addr =
|
||||
cygwin_inet_addr (dhcpnetmask);
|
||||
sa->sin_family = AF_INET;
|
||||
sa->sin_port = 0;
|
||||
break;
|
||||
case SIOCGIFHWADDR:
|
||||
break;
|
||||
case SIOCGIFHWADDR:
|
||||
so = &ifr->ifr_hwaddr;
|
||||
memset (so->sa_data, 0, IFHWADDRLEN);
|
||||
so->sa_family = AF_INET;
|
||||
break;
|
||||
case SIOCGIFMETRIC:
|
||||
case SIOCGIFMETRIC:
|
||||
ifr->ifr_metric = 1;
|
||||
break;
|
||||
case SIOCGIFMTU:
|
||||
ifr->ifr_mtu = 1500;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (what)
|
||||
{
|
||||
case SIOCGIFCONF:
|
||||
case SIOCGIFADDR:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_addr;
|
||||
sa->sin_addr.s_addr = cygwin_inet_addr (ip);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (what)
|
||||
{
|
||||
case SIOCGIFCONF:
|
||||
case SIOCGIFADDR:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_addr;
|
||||
sa->sin_addr.s_addr = cygwin_inet_addr (ip);
|
||||
sa->sin_family = AF_INET;
|
||||
sa->sin_port = 0;
|
||||
break;
|
||||
case SIOCGIFBRDADDR:
|
||||
lip = cygwin_inet_addr (ip);
|
||||
lnp = cygwin_inet_addr (np);
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
|
||||
sa->sin_addr.s_addr = lip & lnp | ~lnp;
|
||||
break;
|
||||
case SIOCGIFBRDADDR:
|
||||
lip = cygwin_inet_addr (ip);
|
||||
lnp = cygwin_inet_addr (np);
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
|
||||
sa->sin_addr.s_addr = lip & lnp | ~lnp;
|
||||
sa->sin_family = AF_INET;
|
||||
sa->sin_port = 0;
|
||||
break;
|
||||
case SIOCGIFNETMASK:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
|
||||
sa->sin_addr.s_addr = cygwin_inet_addr (np);
|
||||
break;
|
||||
case SIOCGIFNETMASK:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
|
||||
sa->sin_addr.s_addr = cygwin_inet_addr (np);
|
||||
sa->sin_family = AF_INET;
|
||||
sa->sin_port = 0;
|
||||
break;
|
||||
case SIOCGIFHWADDR:
|
||||
break;
|
||||
case SIOCGIFHWADDR:
|
||||
so = &ifr->ifr_hwaddr;
|
||||
memset (so->sa_data, 0, IFHWADDRLEN);
|
||||
so->sa_family = AF_INET;
|
||||
break;
|
||||
case SIOCGIFMETRIC:
|
||||
case SIOCGIFMETRIC:
|
||||
ifr->ifr_metric = 1;
|
||||
break;
|
||||
case SIOCGIFMTU:
|
||||
ifr->ifr_mtu = 1500;
|
||||
break;
|
||||
}
|
||||
}
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
RegCloseKey (key);
|
||||
}
|
||||
}
|
||||
}
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
RegCloseKey (key);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the correct length */
|
||||
@ -1644,7 +1644,7 @@ get_95_ifconf (struct ifconf *ifc, int what)
|
||||
struct ifreq *ifr = ifc->ifc_req;
|
||||
|
||||
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Enum\\Network\\MSTCP",
|
||||
0, KEY_READ, &key) != ERROR_SUCCESS)
|
||||
0, KEY_READ, &key) != ERROR_SUCCESS)
|
||||
{
|
||||
/* Set the correct length */
|
||||
ifc->ifc_len = cnt * sizeof (struct ifreq);
|
||||
@ -1653,8 +1653,8 @@ get_95_ifconf (struct ifconf *ifc, int what)
|
||||
|
||||
for (int i = 0;
|
||||
(res = RegEnumKeyEx (key, i, ifname,
|
||||
(size = sizeof ifname, &size),
|
||||
0, 0, 0, &update)) != ERROR_NO_MORE_ITEMS;
|
||||
(size = sizeof ifname, &size),
|
||||
0, 0, 0, &update)) != ERROR_NO_MORE_ITEMS;
|
||||
++i)
|
||||
{
|
||||
HKEY ifkey, subkey;
|
||||
@ -1662,62 +1662,62 @@ get_95_ifconf (struct ifconf *ifc, int what)
|
||||
char adapter[256], ip[256], np[256];
|
||||
|
||||
if (res != ERROR_SUCCESS
|
||||
|| RegOpenKeyEx (key, ifname, 0,
|
||||
KEY_READ, &ifkey) != ERROR_SUCCESS)
|
||||
continue;
|
||||
|| RegOpenKeyEx (key, ifname, 0,
|
||||
KEY_READ, &ifkey) != ERROR_SUCCESS)
|
||||
continue;
|
||||
|
||||
if (RegQueryValueEx (ifkey, "Driver", 0,
|
||||
NULL, (unsigned char *) driver,
|
||||
(size = sizeof driver, &size)) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey (ifkey);
|
||||
continue;
|
||||
}
|
||||
NULL, (unsigned char *) driver,
|
||||
(size = sizeof driver, &size)) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey (ifkey);
|
||||
continue;
|
||||
}
|
||||
|
||||
strcpy (classname, "System\\CurrentControlSet\\Services\\Class\\");
|
||||
strcat (classname, driver);
|
||||
if ((res = RegOpenKeyEx (HKEY_LOCAL_MACHINE, classname,
|
||||
0, KEY_READ, &subkey)) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey (ifkey);
|
||||
continue;
|
||||
}
|
||||
0, KEY_READ, &subkey)) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey (ifkey);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegQueryValueEx (subkey, "IPAddress", 0,
|
||||
NULL, (unsigned char *) ip,
|
||||
(size = sizeof ip, &size)) == ERROR_SUCCESS
|
||||
&& RegQueryValueEx (subkey, "IPMask", 0,
|
||||
NULL, (unsigned char *) np,
|
||||
(size = sizeof np, &size)) == ERROR_SUCCESS)
|
||||
{
|
||||
if ((caddr_t)++ifr > ifc->ifc_buf
|
||||
+ ifc->ifc_len
|
||||
- sizeof (struct ifreq))
|
||||
goto out;
|
||||
NULL, (unsigned char *) ip,
|
||||
(size = sizeof ip, &size)) == ERROR_SUCCESS
|
||||
&& RegQueryValueEx (subkey, "IPMask", 0,
|
||||
NULL, (unsigned char *) np,
|
||||
(size = sizeof np, &size)) == ERROR_SUCCESS)
|
||||
{
|
||||
if ((caddr_t)++ifr > ifc->ifc_buf
|
||||
+ ifc->ifc_len
|
||||
- sizeof (struct ifreq))
|
||||
goto out;
|
||||
|
||||
switch (what)
|
||||
{
|
||||
case SIOCGIFCONF:
|
||||
case SIOCGIFADDR:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_addr;
|
||||
sa->sin_addr.s_addr = cygwin_inet_addr (ip);
|
||||
switch (what)
|
||||
{
|
||||
case SIOCGIFCONF:
|
||||
case SIOCGIFADDR:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_addr;
|
||||
sa->sin_addr.s_addr = cygwin_inet_addr (ip);
|
||||
sa->sin_family = AF_INET;
|
||||
sa->sin_port = 0;
|
||||
break;
|
||||
case SIOCGIFBRDADDR:
|
||||
lip = cygwin_inet_addr (ip);
|
||||
lnp = cygwin_inet_addr (np);
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
|
||||
sa->sin_addr.s_addr = lip & lnp | ~lnp;
|
||||
break;
|
||||
case SIOCGIFBRDADDR:
|
||||
lip = cygwin_inet_addr (ip);
|
||||
lnp = cygwin_inet_addr (np);
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
|
||||
sa->sin_addr.s_addr = lip & lnp | ~lnp;
|
||||
sa->sin_family = AF_INET;
|
||||
sa->sin_port = 0;
|
||||
break;
|
||||
case SIOCGIFNETMASK:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
|
||||
sa->sin_addr.s_addr = cygwin_inet_addr (np);
|
||||
break;
|
||||
case SIOCGIFNETMASK:
|
||||
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
|
||||
sa->sin_addr.s_addr = cygwin_inet_addr (np);
|
||||
sa->sin_family = AF_INET;
|
||||
sa->sin_port = 0;
|
||||
break;
|
||||
break;
|
||||
case SIOCGIFHWADDR:
|
||||
so = &ifr->ifr_hwaddr;
|
||||
memset (so->sa_data, 0, IFHWADDRLEN);
|
||||
@ -1729,61 +1729,61 @@ get_95_ifconf (struct ifconf *ifc, int what)
|
||||
case SIOCGIFMTU:
|
||||
ifr->ifr_mtu = 1500;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RegCloseKey (subkey);
|
||||
|
||||
if (RegOpenKeyEx (ifkey, "Bindings",
|
||||
0, KEY_READ, &subkey) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey (ifkey);
|
||||
--ifr;
|
||||
continue;
|
||||
}
|
||||
0, KEY_READ, &subkey) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey (ifkey);
|
||||
--ifr;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0;
|
||||
(res = RegEnumValue (subkey, j, bindname,
|
||||
(size = sizeof bindname, &size),
|
||||
0, NULL, NULL, NULL)) != ERROR_NO_MORE_ITEMS;
|
||||
++j)
|
||||
if (!strncasecmp (bindname, "VREDIR\\", 7))
|
||||
break;
|
||||
(res = RegEnumValue (subkey, j, bindname,
|
||||
(size = sizeof bindname, &size),
|
||||
0, NULL, NULL, NULL)) != ERROR_NO_MORE_ITEMS;
|
||||
++j)
|
||||
if (!strncasecmp (bindname, "VREDIR\\", 7))
|
||||
break;
|
||||
|
||||
RegCloseKey (subkey);
|
||||
|
||||
if (res == ERROR_SUCCESS)
|
||||
{
|
||||
strcpy (netname, "System\\CurrentControlSet\\Services\\Class\\Net\\");
|
||||
strcat (netname, bindname + 7);
|
||||
{
|
||||
strcpy (netname, "System\\CurrentControlSet\\Services\\Class\\Net\\");
|
||||
strcat (netname, bindname + 7);
|
||||
|
||||
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, netname,
|
||||
0, KEY_READ, &subkey) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey (ifkey);
|
||||
--ifr;
|
||||
continue;
|
||||
}
|
||||
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, netname,
|
||||
0, KEY_READ, &subkey) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey (ifkey);
|
||||
--ifr;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegQueryValueEx (subkey, "AdapterName", 0,
|
||||
NULL, (unsigned char *) adapter,
|
||||
(size = sizeof adapter, &size)) == ERROR_SUCCESS
|
||||
&& strcasematch (adapter, "MS$PPP"))
|
||||
{
|
||||
++*ppp;
|
||||
strcpy (ifr->ifr_name, "ppp");
|
||||
strcat (ifr->ifr_name, ppp);
|
||||
}
|
||||
else
|
||||
{
|
||||
++*eth;
|
||||
strcpy (ifr->ifr_name, "eth");
|
||||
strcat (ifr->ifr_name, eth);
|
||||
}
|
||||
if (RegQueryValueEx (subkey, "AdapterName", 0,
|
||||
NULL, (unsigned char *) adapter,
|
||||
(size = sizeof adapter, &size)) == ERROR_SUCCESS
|
||||
&& strcasematch (adapter, "MS$PPP"))
|
||||
{
|
||||
++*ppp;
|
||||
strcpy (ifr->ifr_name, "ppp");
|
||||
strcat (ifr->ifr_name, ppp);
|
||||
}
|
||||
else
|
||||
{
|
||||
++*eth;
|
||||
strcpy (ifr->ifr_name, "eth");
|
||||
strcat (ifr->ifr_name, eth);
|
||||
}
|
||||
|
||||
RegCloseKey (subkey);
|
||||
RegCloseKey (subkey);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
RegCloseKey (ifkey);
|
||||
|
||||
@ -1863,14 +1863,14 @@ get_ifconf (struct ifconf *ifc, int what)
|
||||
/* We have a win95 version... */
|
||||
if (os_version_info.dwPlatformId != VER_PLATFORM_WIN32_NT
|
||||
&& (os_version_info.dwMajorVersion < 4
|
||||
|| (os_version_info.dwMajorVersion == 4
|
||||
&& os_version_info.dwMinorVersion == 0)))
|
||||
|| (os_version_info.dwMajorVersion == 4
|
||||
&& os_version_info.dwMinorVersion == 0)))
|
||||
get_95_ifconf (ifc, what);
|
||||
/* ...and a NT <= SP3 version... */
|
||||
else if (os_version_info.dwPlatformId == VER_PLATFORM_WIN32_NT
|
||||
&& (os_version_info.dwMajorVersion < 4
|
||||
&& (os_version_info.dwMajorVersion < 4
|
||||
|| (os_version_info.dwMajorVersion == 4
|
||||
&& strcmp (os_version_info.szCSDVersion, "Service Pack 4") < 0)))
|
||||
&& strcmp (os_version_info.szCSDVersion, "Service Pack 4") < 0)))
|
||||
get_nt_ifconf (ifc, what);
|
||||
/* ...and finally a "modern" version for win98/ME, NT >= SP4 and W2K! */
|
||||
else
|
||||
|
@ -133,8 +133,8 @@ read_etc_passwd ()
|
||||
/* if we got blocked by the mutex, then etc_passwd may have been processed */
|
||||
if (passwd_state != uninitialized)
|
||||
{
|
||||
pthread_mutex_unlock(&etc_passwd_mutex);
|
||||
return;
|
||||
pthread_mutex_unlock(&etc_passwd_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
if (passwd_state != initializing)
|
||||
@ -206,13 +206,13 @@ getpwuid (uid_t uid)
|
||||
{
|
||||
if (passwd_state <= initializing)
|
||||
read_etc_passwd ();
|
||||
|
||||
|
||||
pthread_testcancel();
|
||||
|
||||
return search_for (uid, 0);
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
extern "C" int
|
||||
getpwuid_r (uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
|
||||
{
|
||||
*result = NULL;
|
||||
@ -232,7 +232,7 @@ getpwuid_r (uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct
|
||||
|
||||
/* check needed buffer size. */
|
||||
size_t needsize = strlen (temppw->pw_name) + strlen (temppw->pw_dir) +
|
||||
strlen (temppw->pw_shell) + strlen (temppw->pw_gecos) +
|
||||
strlen (temppw->pw_shell) + strlen (temppw->pw_gecos) +
|
||||
strlen (temppw->pw_passwd) + 5;
|
||||
if (needsize > bufsize)
|
||||
return ERANGE;
|
||||
@ -259,14 +259,14 @@ getpwnam (const char *name)
|
||||
{
|
||||
if (passwd_state <= initializing)
|
||||
read_etc_passwd ();
|
||||
|
||||
|
||||
pthread_testcancel();
|
||||
|
||||
return search_for (0, name);
|
||||
}
|
||||
|
||||
|
||||
/* the max size buffer we can expect to
|
||||
/* the max size buffer we can expect to
|
||||
* use is returned via sysconf with _SC_GETPW_R_SIZE_MAX.
|
||||
* This may need updating! - Rob Collins April 2001.
|
||||
*/
|
||||
@ -290,11 +290,11 @@ getpwnam_r (const char *nam, struct passwd *pwd, char *buffer, size_t bufsize, s
|
||||
|
||||
/* check needed buffer size. */
|
||||
size_t needsize = strlen (temppw->pw_name) + strlen (temppw->pw_dir) +
|
||||
strlen (temppw->pw_shell) + strlen (temppw->pw_gecos) +
|
||||
strlen (temppw->pw_shell) + strlen (temppw->pw_gecos) +
|
||||
strlen (temppw->pw_passwd) + 5;
|
||||
if (needsize > bufsize)
|
||||
return ERANGE;
|
||||
|
||||
|
||||
/* make a copy of temppw */
|
||||
*result = pwd;
|
||||
pwd->pw_uid = temppw->pw_uid;
|
||||
|
@ -27,31 +27,30 @@
|
||||
/* for getpid */
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
/* Win32 priority to UNIX priority Mapping.
|
||||
For now, I'm just following the spec: any range of priorities is ok.
|
||||
There are probably many many issues with this...
|
||||
|
||||
We don't want process's going realtime. Well, they probably could, but the issues
|
||||
|
||||
We don't want process's going realtime. Well, they probably could, but the issues
|
||||
with avoiding the priority values 17-22 and 27-30 (not supported before win2k)
|
||||
make that inefficient.
|
||||
make that inefficient.
|
||||
However to complicate things most unixes use lower is better priorities.
|
||||
|
||||
So we map -14 to 15, and 15 to 1 via (16- ((n+16) >> 1))
|
||||
|
||||
So we map -14 to 15, and 15 to 1 via (16- ((n+16) >> 1))
|
||||
we then map 1 to 15 to various process class and thread priority combinations
|
||||
|
||||
Then we need to look at the threads vi process priority. As win95 98 and NT 4
|
||||
|
||||
Then we need to look at the threads vi process priority. As win95 98 and NT 4
|
||||
Don't support opening threads cross-process (unless a thread HANDLE is passed around)
|
||||
for now, we'll just use the priority class.
|
||||
|
||||
for now, we'll just use the priority class.
|
||||
|
||||
The code and logic are present to calculate the priority for thread
|
||||
, if a thread handle can be obtained. Alternatively, if the symbols wouldn't be
|
||||
, if a thread handle can be obtained. Alternatively, if the symbols wouldn't be
|
||||
resolved until they are used
|
||||
we could support this on windows 2000 and ME now, and just fall back to the
|
||||
we could support this on windows 2000 and ME now, and just fall back to the
|
||||
class only on pre win2000 machines.
|
||||
|
||||
|
||||
Lastly, because we can't assume that the pid we're given are Windows pids, we can't
|
||||
alter non-cygwin started programs.
|
||||
alter non-cygwin started programs.
|
||||
*/
|
||||
|
||||
extern "C"
|
||||
@ -95,9 +94,9 @@ valid_sched_parameters(const struct sched_param *param)
|
||||
|
||||
/* get sched params for process
|
||||
|
||||
Note, I'm never returning EPERM,
|
||||
Note, I'm never returning EPERM,
|
||||
Always ESRCH. This is by design (If cygwin ever looks at paranoid security
|
||||
Walking the pid values is a known hole in some os's)
|
||||
Walking the pid values is a known hole in some os's)
|
||||
*/
|
||||
int
|
||||
sched_getparam (pid_t pid, struct sched_param *param)
|
||||
@ -222,7 +221,7 @@ sched_getparam (pid_t pid, struct sched_param *param)
|
||||
}
|
||||
|
||||
/* reverse out winpri = (16- ((unixpri+16) >> 1)) */
|
||||
/*
|
||||
/*
|
||||
winpri-16 = - (unixpri +16 ) >> 1
|
||||
|
||||
-(winpri-16) = unixpri +16 >> 1
|
||||
@ -238,7 +237,7 @@ sched_getparam (pid_t pid, struct sched_param *param)
|
||||
/* get the scheduler for pid
|
||||
|
||||
All process's on WIN32 run with SCHED_FIFO.
|
||||
So we just give an answer.
|
||||
So we just give an answer.
|
||||
(WIN32 uses a multi queue FIFO).
|
||||
*/
|
||||
int
|
||||
@ -255,11 +254,11 @@ sched_getscheduler (pid_t pid)
|
||||
We can't return -11, errno ENOSYS, because that implies that
|
||||
sched_get_priority_max & min are also not supported (according to the spec)
|
||||
so some spec-driven autoconf tests will likely assume they aren't present either
|
||||
|
||||
returning ESRCH might confuse some applications (if they assumed that when
|
||||
rr_get_interval is called on pid 0 it always works).
|
||||
|
||||
If someone knows the time quanta for the various win32 platforms, then a
|
||||
|
||||
returning ESRCH might confuse some applications (if they assumed that when
|
||||
rr_get_interval is called on pid 0 it always works).
|
||||
|
||||
If someone knows the time quanta for the various win32 platforms, then a
|
||||
simple check for the os we're running on will finish this function
|
||||
*/
|
||||
int
|
||||
@ -408,8 +407,8 @@ sched_set_thread_priority(HANDLE thread, int priority)
|
||||
real_pri = 16 - ((priority + 16) >> 1);
|
||||
if (real_pri <1 || real_pri > 15)
|
||||
return EINVAL;
|
||||
|
||||
if (real_pri < 4)
|
||||
|
||||
if (real_pri < 4)
|
||||
real_pri = THREAD_PRIORITY_LOWEST;
|
||||
else if (real_pri < 7)
|
||||
real_pri = THREAD_PRIORITY_BELOW_NORMAL;
|
||||
|
@ -268,9 +268,9 @@ get_logon_server_and_user_domain (char *logonserver, char *userdomain)
|
||||
static BOOL
|
||||
get_user_groups (WCHAR *wlogonserver, cygsidlist &grp_list, char *user)
|
||||
{
|
||||
WCHAR wuser[UNLEN + 1];
|
||||
WCHAR wuser[UNLEN + 1];
|
||||
sys_mbstowcs (wuser, user, UNLEN + 1);
|
||||
LPGROUP_USERS_INFO_0 buf;
|
||||
LPGROUP_USERS_INFO_0 buf;
|
||||
DWORD cnt, tot;
|
||||
NET_API_STATUS ret;
|
||||
|
||||
@ -443,7 +443,7 @@ get_group_sidlist (const char *logonserver, cygsidlist &grp_list,
|
||||
DWORD ulen = INTERNET_MAX_HOST_NAME_LENGTH + 1;
|
||||
DWORD dlen = INTERNET_MAX_HOST_NAME_LENGTH + 1;
|
||||
SID_NAME_USE use;
|
||||
|
||||
|
||||
auth_pos = -1;
|
||||
sys_mbstowcs (wserver, logonserver, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||
if (!LookupAccountSid (NULL, usersid, user, &ulen, domain, &dlen, &use))
|
||||
@ -625,7 +625,7 @@ get_dacl (PACL acl, cygsid usersid, cygsidlist &grp_list)
|
||||
{
|
||||
__seterrno ();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (grp_list.contains (well_known_admin_sid))
|
||||
{
|
||||
if (!AddAccessAllowedAce(acl, ACL_REVISION, GENERIC_ALL,
|
||||
@ -690,7 +690,7 @@ create_token (cygsid &usersid, cygsid &pgrpsid)
|
||||
/* SE_CREATE_TOKEN_NAME privilege needed to call NtCreateToken. */
|
||||
if ((old_priv_state = set_process_privilege (SE_CREATE_TOKEN_NAME)) < 0)
|
||||
goto out;
|
||||
|
||||
|
||||
/* Open policy object. */
|
||||
if ((lsa = open_local_policy ()) == INVALID_HANDLE_VALUE)
|
||||
goto out;
|
||||
@ -710,7 +710,7 @@ create_token (cygsid &usersid, cygsid &pgrpsid)
|
||||
else
|
||||
{
|
||||
/* Switching user context to SYSTEM doesn't inherit the authentication
|
||||
id of the user account running current process. */
|
||||
id of the user account running current process. */
|
||||
if (usersid != well_known_system_sid)
|
||||
if (!GetTokenInformation (my_token, TokenStatistics,
|
||||
&stats, sizeof stats, &size))
|
||||
@ -719,9 +719,9 @@ create_token (cygsid &usersid, cygsid &pgrpsid)
|
||||
auth_luid = stats.AuthenticationId;
|
||||
|
||||
/* Retrieving current processes group list to be able to inherit
|
||||
some important well known group sids. */
|
||||
some important well known group sids. */
|
||||
if (!GetTokenInformation (my_token, TokenGroups, NULL, 0, &size) &&
|
||||
GetLastError () != ERROR_INSUFFICIENT_BUFFER)
|
||||
GetLastError () != ERROR_INSUFFICIENT_BUFFER)
|
||||
debug_printf ("GetTokenInformation(my_token, TokenGroups): %E\n");
|
||||
else if (!(my_grps = (PTOKEN_GROUPS) malloc (size)))
|
||||
debug_printf ("malloc (my_grps) failed.");
|
||||
@ -751,10 +751,10 @@ create_token (cygsid &usersid, cygsid &pgrpsid)
|
||||
{
|
||||
grps->Groups[i].Sid = grpsids.sids[i];
|
||||
grps->Groups[i].Attributes = SE_GROUP_MANDATORY |
|
||||
SE_GROUP_ENABLED_BY_DEFAULT |
|
||||
SE_GROUP_ENABLED;
|
||||
SE_GROUP_ENABLED_BY_DEFAULT |
|
||||
SE_GROUP_ENABLED;
|
||||
if (auth_pos >= 0 && i == (DWORD) auth_pos)
|
||||
grps->Groups[i].Attributes |= SE_GROUP_LOGON_ID;
|
||||
grps->Groups[i].Attributes |= SE_GROUP_LOGON_ID;
|
||||
}
|
||||
|
||||
/* Retrieve list of privileges of that user. */
|
||||
@ -780,7 +780,7 @@ create_token (cygsid &usersid, cygsid &pgrpsid)
|
||||
|
||||
/* Convert to primary token. */
|
||||
if (!DuplicateTokenEx (token, TOKEN_ALL_ACCESS, &sa,
|
||||
SecurityImpersonation, TokenPrimary,
|
||||
SecurityImpersonation, TokenPrimary,
|
||||
&primary_token))
|
||||
__seterrno ();
|
||||
|
||||
@ -879,7 +879,7 @@ subauth (struct passwd *pw)
|
||||
subbuf.auth.ParameterControl = 0 | (subauth_id << 24);
|
||||
/* Try to logon... */
|
||||
ret = LsaLogonUser(lsa_hdl, (PLSA_STRING) &origin, Network,
|
||||
package_id, &subbuf, sizeof subbuf,
|
||||
package_id, &subbuf, sizeof subbuf,
|
||||
NULL, &ts, (PVOID *)&profile, &size,
|
||||
&luid, &user_token, "a, &ret2);
|
||||
if (ret != STATUS_SUCCESS)
|
||||
@ -892,7 +892,7 @@ subauth (struct passwd *pw)
|
||||
LsaFreeReturnBuffer(profile);
|
||||
/* Convert to primary token. */
|
||||
if (!DuplicateTokenEx (user_token, TOKEN_ALL_ACCESS, &sa,
|
||||
SecurityImpersonation, TokenPrimary,
|
||||
SecurityImpersonation, TokenPrimary,
|
||||
&primary_token))
|
||||
__seterrno ();
|
||||
|
||||
@ -943,7 +943,7 @@ read_sd(const char *file, PSECURITY_DESCRIPTOR sd_buf, LPDWORD sd_size)
|
||||
}
|
||||
|
||||
if (!GetFileSecurity (pfile,
|
||||
OWNER_SECURITY_INFORMATION
|
||||
OWNER_SECURITY_INFORMATION
|
||||
| GROUP_SECURITY_INFORMATION
|
||||
| DACL_SECURITY_INFORMATION,
|
||||
sd_buf, *sd_size, &len))
|
||||
|
@ -109,7 +109,7 @@ public:
|
||||
BOOL add (const PSID nsid) { return add (nsid); }
|
||||
BOOL add (const char *sidstr)
|
||||
{ cygsid nsi (sidstr); return add (nsi); }
|
||||
|
||||
|
||||
BOOL operator+= (cygsid &si) { return add (si); }
|
||||
BOOL operator+= (const char *sidstr) { return add (sidstr); }
|
||||
|
||||
|
@ -44,6 +44,7 @@ details. */
|
||||
#include "security.h"
|
||||
#include <semaphore.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/timeb.h>
|
||||
|
||||
extern int threadsafe;
|
||||
|
||||
@ -396,7 +397,7 @@ pthread_cond::pthread_cond (pthread_condattr * attr):verifyable_object (PTHREAD_
|
||||
NULL /* no name */);
|
||||
/* TODO: make a shared mem mutex if out attributes request shared mem cond */
|
||||
cond_access=NULL;
|
||||
if ((temperr = pthread_mutex_init (&this->cond_access, NULL)))
|
||||
if ((temperr = pthread_mutex_init (&this->cond_access, NULL)))
|
||||
{
|
||||
system_printf ("couldn't init mutex, this %0p errno=%d\n", this, temperr);
|
||||
/* we need the mutex for correct behaviour */
|
||||
@ -420,12 +421,12 @@ pthread_cond::BroadCast ()
|
||||
if (pthread_mutex_lock (&cond_access))
|
||||
system_printf ("Failed to lock condition variable access mutex, this %0p\n", this);
|
||||
int count = waiting;
|
||||
if (!verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC))
|
||||
if (!verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC))
|
||||
{
|
||||
if (pthread_mutex_unlock (&cond_access))
|
||||
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", this);
|
||||
/* This isn't and API error - users are allowed to call this when no threads
|
||||
are waiting
|
||||
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", this);
|
||||
/* This isn't and API error - users are allowed to call this when no threads
|
||||
are waiting
|
||||
system_printf ("Broadcast called with invalid mutex\n");
|
||||
*/
|
||||
return;
|
||||
@ -444,8 +445,8 @@ pthread_cond::Signal ()
|
||||
if (!verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC))
|
||||
{
|
||||
if (pthread_mutex_unlock (&cond_access))
|
||||
system_printf ("Failed to unlock condition variable access mutex, this %0p\n",
|
||||
this);
|
||||
system_printf ("Failed to unlock condition variable access mutex, this %0p\n",
|
||||
this);
|
||||
return;
|
||||
}
|
||||
PulseEvent (win32_obj_id);
|
||||
@ -472,6 +473,7 @@ pthread_cond::TimedWait (DWORD dwMilliseconds)
|
||||
case WAIT_FAILED:
|
||||
return 0; /* POSIX doesn't allow errors after we modify the mutex state */
|
||||
case WAIT_ABANDONED:
|
||||
case WAIT_TIMEOUT:
|
||||
return ETIMEDOUT;
|
||||
case WAIT_OBJECT_0:
|
||||
return 0; /* we have been signaled */
|
||||
@ -580,23 +582,23 @@ pthread_mutex::pthread_mutex (pthread_mutex_t *mutex, pthread_mutexattr * attr):
|
||||
char stringbuf[29];
|
||||
unsigned short id = 1;
|
||||
while (id < 256)
|
||||
{
|
||||
snprintf (stringbuf, 29, "CYGWINMUTEX0x%0x", id & 0x000f);
|
||||
system_printf ("name of mutex to create %s\n",stringbuf);
|
||||
this->win32_obj_id =::CreateMutex (&sec_none_nih, false, stringbuf);
|
||||
if (this->win32_obj_id && GetLastError () != ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
MT_INTERFACE->pshared_mutexs[id] = this;
|
||||
{
|
||||
snprintf (stringbuf, 29, "CYGWINMUTEX0x%0x", id & 0x000f);
|
||||
system_printf ("name of mutex to create %s\n",stringbuf);
|
||||
this->win32_obj_id =::CreateMutex (&sec_none_nih, false, stringbuf);
|
||||
if (this->win32_obj_id && GetLastError () != ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
MT_INTERFACE->pshared_mutexs[id] = this;
|
||||
pshared_mutex *pmutex=(pshared_mutex *)(mutex);
|
||||
pmutex->id = id;
|
||||
pmutex->flags = SYS_BASE;
|
||||
pmutex->flags = SYS_BASE;
|
||||
pshared = PTHREAD_PROCESS_SHARED;
|
||||
condwaits = 0;
|
||||
return;
|
||||
}
|
||||
id++;
|
||||
CloseHandle (win32_obj_id);
|
||||
}
|
||||
}
|
||||
magic = 0;
|
||||
win32_obj_id = NULL;
|
||||
}
|
||||
@ -605,7 +607,7 @@ pthread_mutex::pthread_mutex (pthread_mutex_t *mutex, pthread_mutexattr * attr):
|
||||
this->win32_obj_id =::CreateMutex (&sec_none_nih, false, NULL);
|
||||
|
||||
if (!win32_obj_id)
|
||||
magic = 0;
|
||||
magic = 0;
|
||||
condwaits = 0;
|
||||
pshared = PTHREAD_PROCESS_PRIVATE;
|
||||
}
|
||||
@ -1636,7 +1638,7 @@ int
|
||||
__pthread_cond_timedwait (pthread_cond_t * cond, pthread_mutex_t * mutex,
|
||||
const struct timespec *abstime)
|
||||
{
|
||||
// and yes cond_access here is still open to a race. (we increment, context swap,
|
||||
// and yes cond_access here is still open to a race. (we increment, context swap,
|
||||
// broadcast occurs - we miss the broadcast. the functions aren't split properly.
|
||||
int rv;
|
||||
if (!abstime)
|
||||
@ -1654,16 +1656,23 @@ __pthread_cond_timedwait (pthread_cond_t * cond, pthread_mutex_t * mutex,
|
||||
return EINVAL;
|
||||
if (!verifyable_object_isvalid (*cond, PTHREAD_COND_MAGIC))
|
||||
return EINVAL;
|
||||
struct timeb currSysTime;
|
||||
long waitlength;
|
||||
ftime(&currSysTime);
|
||||
waitlength = (abstime->tv_sec - currSysTime.time) * 1000;
|
||||
if (waitlength < 0)
|
||||
return ETIMEDOUT;
|
||||
|
||||
/* if the cond variable is blocked, then the above timer test maybe wrong. *shrug* */
|
||||
if (pthread_mutex_lock (&(*cond)->cond_access))
|
||||
system_printf ("Failed to lock condition variable access mutex, this %0p\n", *cond);
|
||||
|
||||
if ((*cond)->waiting)
|
||||
if ((*cond)->mutex && ((*cond)->mutex != (*themutex)))
|
||||
{
|
||||
if (pthread_mutex_unlock (&(*cond)->cond_access))
|
||||
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", *cond);
|
||||
return EINVAL;
|
||||
if (pthread_mutex_unlock (&(*cond)->cond_access))
|
||||
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", *cond);
|
||||
return EINVAL;
|
||||
}
|
||||
InterlockedIncrement (&((*cond)->waiting));
|
||||
|
||||
@ -1671,7 +1680,7 @@ __pthread_cond_timedwait (pthread_cond_t * cond, pthread_mutex_t * mutex,
|
||||
InterlockedIncrement (&((*themutex)->condwaits));
|
||||
if (pthread_mutex_unlock (&(*cond)->cond_access))
|
||||
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", *cond);
|
||||
rv = (*cond)->TimedWait (abstime->tv_sec * 1000);
|
||||
rv = (*cond)->TimedWait (waitlength);
|
||||
(*cond)->mutex->Lock ();
|
||||
if (pthread_mutex_lock (&(*cond)->cond_access))
|
||||
system_printf ("Failed to lock condition variable access mutex, this %0p\n", *cond);
|
||||
@ -1708,9 +1717,9 @@ __pthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex)
|
||||
if ((*cond)->waiting)
|
||||
if ((*cond)->mutex && ((*cond)->mutex != (*themutex)))
|
||||
{
|
||||
if (pthread_mutex_unlock (&(*cond)->cond_access))
|
||||
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", *cond);
|
||||
return EINVAL;
|
||||
if (pthread_mutex_unlock (&(*cond)->cond_access))
|
||||
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", *cond);
|
||||
return EINVAL;
|
||||
}
|
||||
InterlockedIncrement (&((*cond)->waiting));
|
||||
|
||||
@ -1856,11 +1865,11 @@ __pthread_mutex_init (pthread_mutex_t * mutex,
|
||||
mutex = __pthread_mutex_getpshared ((pthread_mutex_t *) mutex);
|
||||
|
||||
if (!verifyable_object_isvalid (*mutex, PTHREAD_MUTEX_MAGIC))
|
||||
{
|
||||
delete throwaway;
|
||||
*mutex = NULL;
|
||||
return EAGAIN;
|
||||
}
|
||||
{
|
||||
delete throwaway;
|
||||
*mutex = NULL;
|
||||
return EAGAIN;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
*mutex = new pthread_mutex (attr ? (*attr) : NULL);
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
Written by Marco Fuykschot <marco@ddi.nl>
|
||||
Major update 2001 Robert Collins <rbtcollins@hotmail.com>
|
||||
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
This software is a copyrighted work licensed under the terms of the
|
||||
@ -268,11 +268,11 @@ public:
|
||||
int Lock ();
|
||||
int TryLock ();
|
||||
int UnLock ();
|
||||
|
||||
pthread_mutex (unsigned short);
|
||||
pthread_mutex (pthread_mutexattr *);
|
||||
pthread_mutex (pthread_mutex_t *, pthread_mutexattr *);
|
||||
~pthread_mutex ();
|
||||
|
||||
pthread_mutex (unsigned short);
|
||||
pthread_mutex (pthread_mutexattr *);
|
||||
pthread_mutex (pthread_mutex_t *, pthread_mutexattr *);
|
||||
~pthread_mutex ();
|
||||
};
|
||||
|
||||
class pthread_condattr:public verifyable_object
|
||||
@ -280,8 +280,8 @@ class pthread_condattr:public verifyable_object
|
||||
public:
|
||||
int shared;
|
||||
|
||||
pthread_condattr ();
|
||||
~pthread_condattr ();
|
||||
pthread_condattr ();
|
||||
~pthread_condattr ();
|
||||
};
|
||||
|
||||
class pthread_cond:public verifyable_object
|
||||
|
Loading…
x
Reference in New Issue
Block a user