* cygheap.h (init_cygheap): Move heap pointers here.
* include/sys/cygwin.h (perprocess): Remove heap pointers. * dcrt0.cc (__cygwin_user_data): Reflect obsolete perprocess stuff. (_dll_crt0): Don't initialize heap pointers. (cygwin_dll_init): Ditto. (release_upto): Use heap pointers from cygheap. * heap.h: Ditto. * fork.cc (fork_parent): Ditto. Don't set heap pointers in ch. (fork_child): Remove obsolete sigproc_fixup_after_fork. * shared.cc (memory_init): Reorganize so that cygheap initialization is called prior to regular heap since regular heap uses cygheap now. * sigproc.cc (proc_subproc): Eliminate zombies allocation. (sigproc_init): Move zombies alloation here. Don't free up array on fork, just reuse it. (sigproc_fixup_after_fork): Eliminate. * sigproc.h: Ditto. * include/cygwin/version.h: Reflect change to perprocess structure.
This commit is contained in:
parent
b2d319cb3e
commit
1ff9f4b937
|
@ -1,3 +1,23 @@
|
||||||
|
Fri Sep 7 17:11:11 2001 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* cygheap.h (init_cygheap): Move heap pointers here.
|
||||||
|
* include/sys/cygwin.h (perprocess): Remove heap pointers.
|
||||||
|
* dcrt0.cc (__cygwin_user_data): Reflect obsolete perprocess stuff.
|
||||||
|
(_dll_crt0): Don't initialize heap pointers.
|
||||||
|
(cygwin_dll_init): Ditto.
|
||||||
|
(release_upto): Use heap pointers from cygheap.
|
||||||
|
* heap.h: Ditto.
|
||||||
|
* fork.cc (fork_parent): Ditto. Don't set heap pointers in ch.
|
||||||
|
(fork_child): Remove obsolete sigproc_fixup_after_fork.
|
||||||
|
* shared.cc (memory_init): Reorganize so that cygheap initialization is
|
||||||
|
called prior to regular heap since regular heap uses cygheap now.
|
||||||
|
* sigproc.cc (proc_subproc): Eliminate zombies allocation.
|
||||||
|
(sigproc_init): Move zombies alloation here. Don't free up array on
|
||||||
|
fork, just reuse it.
|
||||||
|
(sigproc_fixup_after_fork): Eliminate.
|
||||||
|
* sigproc.h: Ditto.
|
||||||
|
* include/cygwin/version.h: Reflect change to perprocess structure.
|
||||||
|
|
||||||
Fri Sep 7 10:53:34 2001 Jason Tishler <jason@tishler.net>
|
Fri Sep 7 10:53:34 2001 Jason Tishler <jason@tishler.net>
|
||||||
|
|
||||||
* poll.cc (poll): Change implementation to only call select() when no
|
* poll.cc (poll): Change implementation to only call select() when no
|
||||||
|
@ -86,7 +106,7 @@ Tue Sep 4 22:14:00 2001 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
2001-09-04 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
|
2001-09-04 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
|
||||||
|
|
||||||
* fhandler_console.cc (fhandler_console::char_command): Save the cursor
|
* fhandler_console.cc (fhandler_console::char_command): Save the cursor
|
||||||
position relative to the top of the window.
|
position relative to the top of the window.
|
||||||
* fhandler_cc (fhandler_console::write): Ditto.
|
* fhandler_cc (fhandler_console::write): Ditto.
|
||||||
|
|
||||||
|
|
|
@ -268,9 +268,9 @@ wsock_init ()
|
||||||
int (*wsastartup) (int, WSADATA *);
|
int (*wsastartup) (int, WSADATA *);
|
||||||
|
|
||||||
wsastartup = (int (*)(int, WSADATA *))
|
wsastartup = (int (*)(int, WSADATA *))
|
||||||
GetProcAddress ((HMODULE) (dll->handle), "WSAStartup");
|
GetProcAddress ((HMODULE) (dll->handle), "WSAStartup");
|
||||||
if (wsastartup)
|
if (wsastartup)
|
||||||
{
|
{
|
||||||
int res = wsastartup ((2<<8) | 2, &wsadata);
|
int res = wsastartup ((2<<8) | 2, &wsadata);
|
||||||
|
|
||||||
debug_printf ("res %d", res);
|
debug_printf ("res %d", res);
|
||||||
|
@ -283,7 +283,7 @@ wsock_init ()
|
||||||
debug_printf ("lpVendorInfo %d", wsadata.lpVendorInfo);
|
debug_printf ("lpVendorInfo %d", wsadata.lpVendorInfo);
|
||||||
|
|
||||||
wsock_started = 1;
|
wsock_started = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InterlockedDecrement (&here);
|
InterlockedDecrement (&here);
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
if (!m)
|
if (!m)
|
||||||
return 1;
|
return 1;
|
||||||
return strncasematch (m->native_path, path, m->native_pathlen)
|
return strncasematch (m->native_path, path, m->native_pathlen)
|
||||||
&& (path[m->native_pathlen] == '\\' || !path[m->native_pathlen]);
|
&& (path[m->native_pathlen] == '\\' || !path[m->native_pathlen]);
|
||||||
}
|
}
|
||||||
const char *unchroot (const char *path)
|
const char *unchroot (const char *path)
|
||||||
{
|
{
|
||||||
|
@ -153,6 +153,9 @@ struct init_cygheap
|
||||||
{
|
{
|
||||||
_cmalloc_entry *chain;
|
_cmalloc_entry *chain;
|
||||||
char *buckets[32];
|
char *buckets[32];
|
||||||
|
void *heapbase;
|
||||||
|
void *heapptr;
|
||||||
|
void *heaptop;
|
||||||
cygheap_root root;
|
cygheap_root root;
|
||||||
cygheap_user user;
|
cygheap_user user;
|
||||||
mode_t umask;
|
mode_t umask;
|
||||||
|
|
|
@ -101,9 +101,9 @@ extern "C"
|
||||||
/* calloc */ export_calloc,
|
/* calloc */ export_calloc,
|
||||||
/* premain */ {NULL, NULL, NULL, NULL},
|
/* premain */ {NULL, NULL, NULL, NULL},
|
||||||
/* run_ctors_p */ 0,
|
/* run_ctors_p */ 0,
|
||||||
/* unused */ { 0, 0, 0},
|
/* unused */ {0, 0, 0, 0, 0, 0, 0},
|
||||||
/* heapbase */ NULL, /* heapptr */ NULL, /* heaptop */ NULL,
|
/* forkee */ 0,
|
||||||
/* unused1 */ 0, /* forkee */ 0, /* hmodule */ NULL,
|
/* hmodule */ NULL,
|
||||||
/* api_major */ CYGWIN_VERSION_API_MAJOR,
|
/* api_major */ CYGWIN_VERSION_API_MAJOR,
|
||||||
/* api_minor */ CYGWIN_VERSION_API_MINOR,
|
/* api_minor */ CYGWIN_VERSION_API_MINOR,
|
||||||
/* unused2 */ {0, 0, 0, 0, 0},
|
/* unused2 */ {0, 0, 0, 0, 0},
|
||||||
|
@ -683,9 +683,6 @@ dll_crt0_1 ()
|
||||||
cygheap_fixup_in_child (child_proc_info, 0);
|
cygheap_fixup_in_child (child_proc_info, 0);
|
||||||
alloc_stack (fork_info);
|
alloc_stack (fork_info);
|
||||||
set_myself (mypid);
|
set_myself (mypid);
|
||||||
user_data->heaptop = child_proc_info->heaptop;
|
|
||||||
user_data->heapbase = child_proc_info->heapbase;
|
|
||||||
user_data->heapptr = child_proc_info->heapptr;
|
|
||||||
ProtectHandle (child_proc_info->forker_finished);
|
ProtectHandle (child_proc_info->forker_finished);
|
||||||
break;
|
break;
|
||||||
case PROC_SPAWN:
|
case PROC_SPAWN:
|
||||||
|
@ -896,7 +893,6 @@ _dll_crt0 ()
|
||||||
|
|
||||||
main_environ = user_data->envptr;
|
main_environ = user_data->envptr;
|
||||||
*main_environ = NULL;
|
*main_environ = NULL;
|
||||||
user_data->heapbase = user_data->heapptr = user_data->heaptop = NULL;
|
|
||||||
|
|
||||||
set_console_handler ();
|
set_console_handler ();
|
||||||
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (),
|
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (),
|
||||||
|
@ -954,7 +950,6 @@ cygwin_dll_init ()
|
||||||
{
|
{
|
||||||
static char **envp;
|
static char **envp;
|
||||||
static int _fmode;
|
static int _fmode;
|
||||||
user_data->heapbase = user_data->heapptr = user_data->heaptop = NULL;
|
|
||||||
|
|
||||||
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (),
|
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (),
|
||||||
GetCurrentProcess (), &hMainProc, 0, FALSE,
|
GetCurrentProcess (), &hMainProc, 0, FALSE,
|
||||||
|
|
|
@ -201,14 +201,14 @@ readdir (DIR * dir)
|
||||||
char *c = dir->__d_dirent->d_name;
|
char *c = dir->__d_dirent->d_name;
|
||||||
int len = strlen (c);
|
int len = strlen (c);
|
||||||
if (strcasematch (c + len - 4, ".lnk"))
|
if (strcasematch (c + len - 4, ".lnk"))
|
||||||
{
|
{
|
||||||
char fbuf[MAX_PATH + 1];
|
char fbuf[MAX_PATH + 1];
|
||||||
strcpy (fbuf, dir->__d_dirname);
|
strcpy (fbuf, dir->__d_dirname);
|
||||||
strcpy (fbuf + strlen (fbuf) - 1, dir->__d_dirent->d_name);
|
strcpy (fbuf + strlen (fbuf) - 1, dir->__d_dirent->d_name);
|
||||||
path_conv fpath (fbuf, PC_SYM_NOFOLLOW);
|
path_conv fpath (fbuf, PC_SYM_NOFOLLOW);
|
||||||
if (fpath.issymlink ())
|
if (fpath.issymlink ())
|
||||||
c[len - 4] = '\0';
|
c[len - 4] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute d_ino by combining filename hash with the directory hash
|
/* Compute d_ino by combining filename hash with the directory hash
|
||||||
|
@ -387,7 +387,7 @@ rmdir (const char *dir)
|
||||||
/* Even own directories can't be removed if R/O attribute is set. */
|
/* Even own directories can't be removed if R/O attribute is set. */
|
||||||
if (real_dir.file_attributes () & FILE_ATTRIBUTE_READONLY)
|
if (real_dir.file_attributes () & FILE_ATTRIBUTE_READONLY)
|
||||||
SetFileAttributes (real_dir.get_win32 (), real_dir.file_attributes () &
|
SetFileAttributes (real_dir.get_win32 (), real_dir.file_attributes () &
|
||||||
~FILE_ATTRIBUTE_READONLY);
|
~FILE_ATTRIBUTE_READONLY);
|
||||||
|
|
||||||
if (RemoveDirectoryA (real_dir.get_win32 ()))
|
if (RemoveDirectoryA (real_dir.get_win32 ()))
|
||||||
{
|
{
|
||||||
|
@ -402,7 +402,7 @@ rmdir (const char *dir)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (GetLastError() == ERROR_ACCESS_DENIED)
|
if (GetLastError() == ERROR_ACCESS_DENIED)
|
||||||
{
|
{
|
||||||
/* On 9X ERROR_ACCESS_DENIED is returned if you try to remove
|
/* On 9X ERROR_ACCESS_DENIED is returned if you try to remove
|
||||||
a non-empty directory. */
|
a non-empty directory. */
|
||||||
if (!iswinnt)
|
if (!iswinnt)
|
||||||
|
|
|
@ -13,6 +13,10 @@ details. */
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "dll_init.h"
|
#include "dll_init.h"
|
||||||
#include "environ.h"
|
#include "environ.h"
|
||||||
|
#include "security.h"
|
||||||
|
#include "fhandler.h"
|
||||||
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
|
|
||||||
extern void __stdcall check_sanity_and_sync (per_process *);
|
extern void __stdcall check_sanity_and_sync (per_process *);
|
||||||
|
|
||||||
|
@ -253,7 +257,7 @@ release_upto (const char *name, DWORD here)
|
||||||
{
|
{
|
||||||
size = mb.RegionSize;
|
size = mb.RegionSize;
|
||||||
if (!(mb.State == MEM_RESERVE && mb.AllocationProtect == PAGE_NOACCESS &&
|
if (!(mb.State == MEM_RESERVE && mb.AllocationProtect == PAGE_NOACCESS &&
|
||||||
((void *) start < user_data->heapbase || (void *) start > user_data->heaptop)))
|
((void *) start < cygheap->heapbase || (void *) start > cygheap->heaptop)))
|
||||||
continue;
|
continue;
|
||||||
if (!VirtualFree ((void *) start, 0, MEM_RELEASE))
|
if (!VirtualFree ((void *) start, 0, MEM_RELEASE))
|
||||||
api_fatal ("couldn't release memory %p(%d) for '%s' alignment, %E\n",
|
api_fatal ("couldn't release memory %p(%d) for '%s' alignment, %E\n",
|
||||||
|
|
|
@ -28,6 +28,25 @@
|
||||||
* malloc_usable_size(P) is equivalent to realloc(P, malloc_usable_size(P))
|
* malloc_usable_size(P) is equivalent to realloc(P, malloc_usable_size(P))
|
||||||
*
|
*
|
||||||
* $Log$
|
* $Log$
|
||||||
|
* Revision 1.4 2001/09/07 21:32:04 cgf
|
||||||
|
* * cygheap.h (init_cygheap): Move heap pointers here.
|
||||||
|
* * include/sys/cygwin.h (perprocess): Remove heap pointers.
|
||||||
|
* * dcrt0.cc (__cygwin_user_data): Reflect obsolete perprocess stuff.
|
||||||
|
* (_dll_crt0): Don't initialize heap pointers.
|
||||||
|
* (cygwin_dll_init): Ditto.
|
||||||
|
* (release_upto): Use heap pointers from cygheap.
|
||||||
|
* * heap.h: Ditto.
|
||||||
|
* * fork.cc (fork_parent): Ditto. Don't set heap pointers in ch.
|
||||||
|
* (fork_child): Remove obsolete sigproc_fixup_after_fork.
|
||||||
|
* * shared.cc (memory_init): Reorganize so that cygheap initialization is called
|
||||||
|
* prior to regular heap since regular heap uses cygheap now.
|
||||||
|
* * sigproc.cc (proc_subproc): Eliminate zombies allocation.
|
||||||
|
* (sigproc_init): Move zombies alloation here. Don't free up array on fork, just
|
||||||
|
* reuse it.
|
||||||
|
* (sigproc_fixup_after_fork): Eliminate.
|
||||||
|
* * sigproc.h: Ditto.
|
||||||
|
* * include/cygwin/version.h: Reflect change to perprocess structure.
|
||||||
|
*
|
||||||
* Revision 1.3 2001/06/26 14:47:48 cgf
|
* Revision 1.3 2001/06/26 14:47:48 cgf
|
||||||
* * mmap.cc: Clean up *ResourceLock calls throughout.
|
* * mmap.cc: Clean up *ResourceLock calls throughout.
|
||||||
* * thread.cc (pthread_cond::TimedWait): Check for WAIT_TIMEOUT as well as
|
* * thread.cc (pthread_cond::TimedWait): Check for WAIT_TIMEOUT as well as
|
||||||
|
@ -64,8 +83,8 @@
|
||||||
* VERSION 2.6.4 Thu Nov 28 07:54:55 1996 Doug Lea (dl at gee)
|
* VERSION 2.6.4 Thu Nov 28 07:54:55 1996 Doug Lea (dl at gee)
|
||||||
|
|
||||||
Note: There may be an updated version of this malloc obtainable at
|
Note: There may be an updated version of this malloc obtainable at
|
||||||
ftp://g.oswego.edu/pub/misc/malloc.c
|
ftp://g.oswego.edu/pub/misc/malloc.c
|
||||||
Check before installing!
|
Check before installing!
|
||||||
|
|
||||||
* Why use this malloc?
|
* Why use this malloc?
|
||||||
|
|
||||||
|
@ -142,7 +161,7 @@
|
||||||
and status information.
|
and status information.
|
||||||
|
|
||||||
Minimum allocated size: 4-byte ptrs: 16 bytes (including 4 overhead)
|
Minimum allocated size: 4-byte ptrs: 16 bytes (including 4 overhead)
|
||||||
8-byte ptrs: 24/32 bytes (including, 4/8 overhead)
|
8-byte ptrs: 24/32 bytes (including, 4/8 overhead)
|
||||||
|
|
||||||
When a chunk is freed, 12 (for 4byte ptrs) or 20 (for 8 byte
|
When a chunk is freed, 12 (for 4byte ptrs) or 20 (for 8 byte
|
||||||
ptrs but 4 byte size) or 24 (for 8/8) additional bytes are
|
ptrs but 4 byte size) or 24 (for 8/8) additional bytes are
|
||||||
|
@ -154,7 +173,7 @@
|
||||||
pointer to something of the minimum allocatable size.
|
pointer to something of the minimum allocatable size.
|
||||||
|
|
||||||
Maximum allocated size: 4-byte size_t: 2^31 - 8 bytes
|
Maximum allocated size: 4-byte size_t: 2^31 - 8 bytes
|
||||||
8-byte size_t: 2^63 - 16 bytes
|
8-byte size_t: 2^63 - 16 bytes
|
||||||
|
|
||||||
It is assumed that (possibly signed) size_t bit values suffice to
|
It is assumed that (possibly signed) size_t bit values suffice to
|
||||||
represent chunk sizes. `Possibly signed' is due to the fact
|
represent chunk sizes. `Possibly signed' is due to the fact
|
||||||
|
@ -170,11 +189,11 @@
|
||||||
make the normal worst-case wastage 15 bytes (i.e., up to 15
|
make the normal worst-case wastage 15 bytes (i.e., up to 15
|
||||||
more bytes will be allocated than were requested in malloc), with
|
more bytes will be allocated than were requested in malloc), with
|
||||||
two exceptions:
|
two exceptions:
|
||||||
1. Because requests for zero bytes allocate non-zero space,
|
1. Because requests for zero bytes allocate non-zero space,
|
||||||
the worst case wastage for a request of zero bytes is 24 bytes.
|
the worst case wastage for a request of zero bytes is 24 bytes.
|
||||||
2. For requests >= mmap_threshold that are serviced via
|
2. For requests >= mmap_threshold that are serviced via
|
||||||
mmap(), the worst case wastage is 8 bytes plus the remainder
|
mmap(), the worst case wastage is 8 bytes plus the remainder
|
||||||
from a system page (the minimal mmap unit); typically 4096 bytes.
|
from a system page (the minimal mmap unit); typically 4096 bytes.
|
||||||
|
|
||||||
* Limitations
|
* Limitations
|
||||||
|
|
||||||
|
@ -435,14 +454,14 @@ do { \
|
||||||
if(mzsz <= 9*sizeof(mzsz)) { \
|
if(mzsz <= 9*sizeof(mzsz)) { \
|
||||||
INTERNAL_SIZE_T* mz = (INTERNAL_SIZE_T*) (charp); \
|
INTERNAL_SIZE_T* mz = (INTERNAL_SIZE_T*) (charp); \
|
||||||
if(mzsz >= 5*sizeof(mzsz)) { *mz++ = 0; \
|
if(mzsz >= 5*sizeof(mzsz)) { *mz++ = 0; \
|
||||||
*mz++ = 0; \
|
*mz++ = 0; \
|
||||||
if(mzsz >= 7*sizeof(mzsz)) { *mz++ = 0; \
|
if(mzsz >= 7*sizeof(mzsz)) { *mz++ = 0; \
|
||||||
*mz++ = 0; \
|
*mz++ = 0; \
|
||||||
if(mzsz >= 9*sizeof(mzsz)) { *mz++ = 0; \
|
if(mzsz >= 9*sizeof(mzsz)) { *mz++ = 0; \
|
||||||
*mz++ = 0; }}} \
|
*mz++ = 0; }}} \
|
||||||
*mz++ = 0; \
|
*mz++ = 0; \
|
||||||
*mz++ = 0; \
|
*mz++ = 0; \
|
||||||
*mz = 0; \
|
*mz = 0; \
|
||||||
} else memset((charp), 0, mzsz); \
|
} else memset((charp), 0, mzsz); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
@ -453,14 +472,14 @@ do { \
|
||||||
INTERNAL_SIZE_T* mcsrc = (INTERNAL_SIZE_T*) (src); \
|
INTERNAL_SIZE_T* mcsrc = (INTERNAL_SIZE_T*) (src); \
|
||||||
INTERNAL_SIZE_T* mcdst = (INTERNAL_SIZE_T*) (dest); \
|
INTERNAL_SIZE_T* mcdst = (INTERNAL_SIZE_T*) (dest); \
|
||||||
if(mcsz >= 5*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \
|
if(mcsz >= 5*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \
|
||||||
*mcdst++ = *mcsrc++; \
|
*mcdst++ = *mcsrc++; \
|
||||||
if(mcsz >= 7*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \
|
if(mcsz >= 7*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \
|
||||||
*mcdst++ = *mcsrc++; \
|
*mcdst++ = *mcsrc++; \
|
||||||
if(mcsz >= 9*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \
|
if(mcsz >= 9*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \
|
||||||
*mcdst++ = *mcsrc++; }}} \
|
*mcdst++ = *mcsrc++; }}} \
|
||||||
*mcdst++ = *mcsrc++; \
|
*mcdst++ = *mcsrc++; \
|
||||||
*mcdst++ = *mcsrc++; \
|
*mcdst++ = *mcsrc++; \
|
||||||
*mcdst = *mcsrc ; \
|
*mcdst = *mcsrc ; \
|
||||||
} else memcpy(dest, src, mcsz); \
|
} else memcpy(dest, src, mcsz); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
@ -588,9 +607,9 @@ do { \
|
||||||
# else
|
# else
|
||||||
# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE)
|
# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE)
|
||||||
# if __STD_C
|
# if __STD_C
|
||||||
extern size_t getpagesize(void);
|
extern size_t getpagesize(void);
|
||||||
# else
|
# else
|
||||||
extern size_t getpagesize();
|
extern size_t getpagesize();
|
||||||
# endif
|
# endif
|
||||||
# define malloc_getpagesize getpagesize()
|
# define malloc_getpagesize getpagesize()
|
||||||
# else
|
# else
|
||||||
|
@ -751,11 +770,11 @@ struct mallinfo {
|
||||||
retain whenever sbrk is called. It is used in two ways internally:
|
retain whenever sbrk is called. It is used in two ways internally:
|
||||||
|
|
||||||
* When sbrk is called to extend the top of the arena to satisfy
|
* When sbrk is called to extend the top of the arena to satisfy
|
||||||
a new malloc request, this much padding is added to the sbrk
|
a new malloc request, this much padding is added to the sbrk
|
||||||
request.
|
request.
|
||||||
|
|
||||||
* When malloc_trim is called automatically from free(),
|
* When malloc_trim is called automatically from free(),
|
||||||
it is used as the `pad' argument.
|
it is used as the `pad' argument.
|
||||||
|
|
||||||
In both cases, the actual amount of padding is rounded
|
In both cases, the actual amount of padding is rounded
|
||||||
so that the end of the arena is always a system page boundary.
|
so that the end of the arena is always a system page boundary.
|
||||||
|
@ -801,15 +820,15 @@ struct mallinfo {
|
||||||
|
|
||||||
However, it has the disadvantages that:
|
However, it has the disadvantages that:
|
||||||
|
|
||||||
1. The space cannot be reclaimed, consolidated, and then
|
1. The space cannot be reclaimed, consolidated, and then
|
||||||
used to service later requests, as happens with normal chunks.
|
used to service later requests, as happens with normal chunks.
|
||||||
2. It can lead to more wastage because of mmap page alignment
|
2. It can lead to more wastage because of mmap page alignment
|
||||||
requirements
|
requirements
|
||||||
3. It causes malloc performance to be more dependent on host
|
3. It causes malloc performance to be more dependent on host
|
||||||
system memory management support routines which may vary in
|
system memory management support routines which may vary in
|
||||||
implementation quality and may impose arbitrary
|
implementation quality and may impose arbitrary
|
||||||
limitations. Generally, servicing a request via normal
|
limitations. Generally, servicing a request via normal
|
||||||
malloc steps is faster than going through a system's mmap.
|
malloc steps is faster than going through a system's mmap.
|
||||||
|
|
||||||
All together, these considerations should lead you to use mmap
|
All together, these considerations should lead you to use mmap
|
||||||
only for relatively large requests.
|
only for relatively large requests.
|
||||||
|
@ -831,15 +850,15 @@ struct mallinfo {
|
||||||
M_MMAP_MAX is the maximum number of requests to simultaneously
|
M_MMAP_MAX is the maximum number of requests to simultaneously
|
||||||
service using mmap. This parameter exists because:
|
service using mmap. This parameter exists because:
|
||||||
|
|
||||||
1. Some systems have a limited number of internal tables for
|
1. Some systems have a limited number of internal tables for
|
||||||
use by mmap.
|
use by mmap.
|
||||||
2. In most systems, overreliance on mmap can degrade overall
|
2. In most systems, overreliance on mmap can degrade overall
|
||||||
performance.
|
performance.
|
||||||
3. If a program allocates many large regions, it is probably
|
3. If a program allocates many large regions, it is probably
|
||||||
better off using normal sbrk-based allocation routines that
|
better off using normal sbrk-based allocation routines that
|
||||||
can reclaim and reallocate normal heap memory. Using a
|
can reclaim and reallocate normal heap memory. Using a
|
||||||
small value allows transition into this mode after the
|
small value allows transition into this mode after the
|
||||||
first few allocations.
|
first few allocations.
|
||||||
|
|
||||||
Setting to 0 disables all use of mmap. If HAVE_MMAP is not set,
|
Setting to 0 disables all use of mmap. If HAVE_MMAP is not set,
|
||||||
the default value is 0, and attempts to set it to non-zero values
|
the default value is 0, and attempts to set it to non-zero values
|
||||||
|
@ -1162,7 +1181,7 @@ void gcleanup ()
|
||||||
rval = VirtualFree ((void*)gAddressBase,
|
rval = VirtualFree ((void*)gAddressBase,
|
||||||
gNextAddress - gAddressBase,
|
gNextAddress - gAddressBase,
|
||||||
MEM_DECOMMIT);
|
MEM_DECOMMIT);
|
||||||
ASSERT (rval);
|
ASSERT (rval);
|
||||||
}
|
}
|
||||||
while (head)
|
while (head)
|
||||||
{
|
{
|
||||||
|
@ -1326,17 +1345,17 @@ typedef Chunk* mchunkptr;
|
||||||
|
|
||||||
|
|
||||||
chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| Size of previous chunk, if allocated | |
|
| Size of previous chunk, if allocated | |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| Size of chunk, in bytes |P|
|
| Size of chunk, in bytes |P|
|
||||||
mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| User data starts here... .
|
| User data starts here... .
|
||||||
. .
|
. .
|
||||||
. (malloc_usable_space() bytes) .
|
. (malloc_usable_space() bytes) .
|
||||||
. |
|
. |
|
||||||
nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| Size of chunk |
|
| Size of chunk |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|
||||||
|
|
||||||
Where "chunk" is the front of the chunk for the purpose of most of
|
Where "chunk" is the front of the chunk for the purpose of most of
|
||||||
|
@ -1350,20 +1369,20 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
Free chunks are stored in circular doubly-linked lists, and look like this:
|
Free chunks are stored in circular doubly-linked lists, and look like this:
|
||||||
|
|
||||||
chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| Size of previous chunk |
|
| Size of previous chunk |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
`head:' | Size of chunk, in bytes |P|
|
`head:' | Size of chunk, in bytes |P|
|
||||||
mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| Forward pointer to next chunk in list |
|
| Forward pointer to next chunk in list |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| Back pointer to previous chunk in list |
|
| Back pointer to previous chunk in list |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| Unused space (may be 0 bytes long) .
|
| Unused space (may be 0 bytes long) .
|
||||||
. .
|
. .
|
||||||
. |
|
. |
|
||||||
nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
`foot:' | Size of chunk, in bytes |
|
`foot:' | Size of chunk, in bytes |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|
||||||
The P (PREV_INUSE) bit, stored in the unused low-order bit of the
|
The P (PREV_INUSE) bit, stored in the unused low-order bit of the
|
||||||
chunk size (which is always a multiple of two words), is an in-use
|
chunk size (which is always a multiple of two words), is an in-use
|
||||||
|
@ -1380,16 +1399,16 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
The two exceptions to all this are
|
The two exceptions to all this are
|
||||||
|
|
||||||
1. The special chunk `top', which doesn't bother using the
|
1. The special chunk `top', which doesn't bother using the
|
||||||
trailing size field since there is no
|
trailing size field since there is no
|
||||||
next contiguous chunk that would have to index off it. (After
|
next contiguous chunk that would have to index off it. (After
|
||||||
initialization, `top' is forced to always exist. If it would
|
initialization, `top' is forced to always exist. If it would
|
||||||
become less than MINSIZE bytes long, it is replenished via
|
become less than MINSIZE bytes long, it is replenished via
|
||||||
malloc_extend_top.)
|
malloc_extend_top.)
|
||||||
|
|
||||||
2. Chunks allocated via mmap, which have the second-lowest-order
|
2. Chunks allocated via mmap, which have the second-lowest-order
|
||||||
bit (IS_MMAPPED) set in their size fields. Because they are
|
bit (IS_MMAPPED) set in their size fields. Because they are
|
||||||
never merged or traversed from any other chunk, they have no
|
never merged or traversed from any other chunk, they have no
|
||||||
foot size or inuse information.
|
foot size or inuse information.
|
||||||
|
|
||||||
Available chunks are kept in any of several places (all declared below):
|
Available chunks are kept in any of several places (all declared below):
|
||||||
|
|
||||||
|
@ -1682,7 +1701,7 @@ static mbinptr av_[NAV * 2 + 2] = {
|
||||||
((((unsigned long)(sz)) >> 9) <= 84) ? 110 + (((unsigned long)(sz)) >> 12): \
|
((((unsigned long)(sz)) >> 9) <= 84) ? 110 + (((unsigned long)(sz)) >> 12): \
|
||||||
((((unsigned long)(sz)) >> 9) <= 340) ? 119 + (((unsigned long)(sz)) >> 15): \
|
((((unsigned long)(sz)) >> 9) <= 340) ? 119 + (((unsigned long)(sz)) >> 15): \
|
||||||
((((unsigned long)(sz)) >> 9) <= 1364) ? 124 + (((unsigned long)(sz)) >> 18): \
|
((((unsigned long)(sz)) >> 9) <= 1364) ? 124 + (((unsigned long)(sz)) >> 18): \
|
||||||
126)
|
126)
|
||||||
/*
|
/*
|
||||||
bins for chunks < 512 are all spaced 8 bytes apart, and hold
|
bins for chunks < 512 are all spaced 8 bytes apart, and hold
|
||||||
identically sized chunks. This is exploited in malloc.
|
identically sized chunks. This is exploited in malloc.
|
||||||
|
@ -2565,20 +2584,20 @@ static void malloc_extend_top(nb) INTERNAL_SIZE_T nb;
|
||||||
/* If not enough space to do this, then user did something very wrong */
|
/* If not enough space to do this, then user did something very wrong */
|
||||||
if (old_top_size < MINSIZE)
|
if (old_top_size < MINSIZE)
|
||||||
{
|
{
|
||||||
set_head(top, PREV_INUSE); /* will force null return from malloc */
|
set_head(top, PREV_INUSE); /* will force null return from malloc */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
old_top_size -= 2*SIZE_SZ;
|
old_top_size -= 2*SIZE_SZ;
|
||||||
chunk_at_offset(old_top, old_top_size )->size =
|
chunk_at_offset(old_top, old_top_size )->size =
|
||||||
SIZE_SZ|PREV_INUSE;
|
SIZE_SZ|PREV_INUSE;
|
||||||
chunk_at_offset(old_top, old_top_size + SIZE_SZ)->size =
|
chunk_at_offset(old_top, old_top_size + SIZE_SZ)->size =
|
||||||
SIZE_SZ|PREV_INUSE;
|
SIZE_SZ|PREV_INUSE;
|
||||||
set_head_size(old_top, old_top_size);
|
set_head_size(old_top, old_top_size);
|
||||||
/* If possible, release the rest. */
|
/* If possible, release the rest. */
|
||||||
if (old_top_size >= MINSIZE) {
|
if (old_top_size >= MINSIZE) {
|
||||||
init_freeable_chunk(old_top);
|
init_freeable_chunk(old_top);
|
||||||
fREe(chunk2mem(old_top));
|
fREe(chunk2mem(old_top));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* OTHER_SBRKS */
|
#endif /* OTHER_SBRKS */
|
||||||
|
@ -2613,43 +2632,43 @@ static void malloc_extend_top(nb) INTERNAL_SIZE_T nb;
|
||||||
From there, the first successful of the following steps is taken:
|
From there, the first successful of the following steps is taken:
|
||||||
|
|
||||||
1. The bin corresponding to the request size is scanned, and if
|
1. The bin corresponding to the request size is scanned, and if
|
||||||
a chunk of exactly the right size is found, it is taken.
|
a chunk of exactly the right size is found, it is taken.
|
||||||
|
|
||||||
2. The most recently remaindered chunk is used if it is big
|
2. The most recently remaindered chunk is used if it is big
|
||||||
enough. This is a form of (roving) first fit, used only in
|
enough. This is a form of (roving) first fit, used only in
|
||||||
the absence of exact fits. Runs of consecutive requests use
|
the absence of exact fits. Runs of consecutive requests use
|
||||||
the remainder of the chunk used for the previous such request
|
the remainder of the chunk used for the previous such request
|
||||||
whenever possible. This limited use of a first-fit style
|
whenever possible. This limited use of a first-fit style
|
||||||
allocation strategy tends to give contiguous chunks
|
allocation strategy tends to give contiguous chunks
|
||||||
coextensive lifetimes, which improves locality and can reduce
|
coextensive lifetimes, which improves locality and can reduce
|
||||||
fragmentation in the long run.
|
fragmentation in the long run.
|
||||||
|
|
||||||
3. Other bins are scanned in increasing size order, using a
|
3. Other bins are scanned in increasing size order, using a
|
||||||
chunk big enough to fulfill the request, and splitting off
|
chunk big enough to fulfill the request, and splitting off
|
||||||
any remainder. This search is strictly by best-fit; i.e.,
|
any remainder. This search is strictly by best-fit; i.e.,
|
||||||
the smallest (with ties going to approximately the least
|
the smallest (with ties going to approximately the least
|
||||||
recently used) chunk that fits is selected.
|
recently used) chunk that fits is selected.
|
||||||
|
|
||||||
4. If large enough, the chunk bordering the end of memory
|
4. If large enough, the chunk bordering the end of memory
|
||||||
(`top') is split off. (This use of `top' is in accord with
|
(`top') is split off. (This use of `top' is in accord with
|
||||||
the best-fit search rule. In effect, `top' is treated as
|
the best-fit search rule. In effect, `top' is treated as
|
||||||
larger (and thus less well fitting) than any other available
|
larger (and thus less well fitting) than any other available
|
||||||
chunk since it can be extended to be as large as necessary
|
chunk since it can be extended to be as large as necessary
|
||||||
(up to system limitations).
|
(up to system limitations).
|
||||||
|
|
||||||
5. If the request size meets the mmap threshold and the
|
5. If the request size meets the mmap threshold and the
|
||||||
system supports mmap, and there are few enough currently
|
system supports mmap, and there are few enough currently
|
||||||
allocated mmapped regions, and a call to mmap succeeds,
|
allocated mmapped regions, and a call to mmap succeeds,
|
||||||
the request is allocated via direct memory mapping.
|
the request is allocated via direct memory mapping.
|
||||||
|
|
||||||
6. Otherwise, the top of memory is extended by
|
6. Otherwise, the top of memory is extended by
|
||||||
obtaining more space from the system (normally using sbrk,
|
obtaining more space from the system (normally using sbrk,
|
||||||
but definable to anything else via the MORECORE macro).
|
but definable to anything else via the MORECORE macro).
|
||||||
Memory is gathered from the system (in system page-sized
|
Memory is gathered from the system (in system page-sized
|
||||||
units) in a way that allows chunks obtained across different
|
units) in a way that allows chunks obtained across different
|
||||||
sbrk calls to be consolidated, but does not require
|
sbrk calls to be consolidated, but does not require
|
||||||
contiguous memory. Thus, it should be safe to intersperse
|
contiguous memory. Thus, it should be safe to intersperse
|
||||||
mallocs with other sbrk calls.
|
mallocs with other sbrk calls.
|
||||||
|
|
||||||
|
|
||||||
All allocations are made from the the `lowest' part of any found
|
All allocations are made from the the `lowest' part of any found
|
||||||
|
@ -2725,18 +2744,18 @@ Void_t* mALLOc(bytes) size_t bytes;
|
||||||
|
|
||||||
if (remainder_size >= (long)MINSIZE) /* too big */
|
if (remainder_size >= (long)MINSIZE) /* too big */
|
||||||
{
|
{
|
||||||
--idx; /* adjust to rescan below after checking last remainder */
|
--idx; /* adjust to rescan below after checking last remainder */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (remainder_size >= 0) /* exact fit */
|
else if (remainder_size >= 0) /* exact fit */
|
||||||
{
|
{
|
||||||
unlink(victim, bck, fwd);
|
unlink(victim, bck, fwd);
|
||||||
set_inuse_bit_at_offset(victim, victim_size);
|
set_inuse_bit_at_offset(victim, victim_size);
|
||||||
check_freefill(victim, victim_size, victim_size);
|
check_freefill(victim, victim_size, victim_size);
|
||||||
init_malloced_chunk(victim, bytes);
|
init_malloced_chunk(victim, bytes);
|
||||||
check_malloced_chunk(victim, nb);
|
check_malloced_chunk(victim, nb);
|
||||||
return chunk2mem(victim);
|
return chunk2mem(victim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2798,8 +2817,8 @@ Void_t* mALLOc(bytes) size_t bytes;
|
||||||
block <<= 1;
|
block <<= 1;
|
||||||
while ((block & binblocks) == 0)
|
while ((block & binblocks) == 0)
|
||||||
{
|
{
|
||||||
idx += BINBLOCKWIDTH;
|
idx += BINBLOCKWIDTH;
|
||||||
block <<= 1;
|
block <<= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2812,39 +2831,39 @@ Void_t* mALLOc(bytes) size_t bytes;
|
||||||
/* For each bin in this block ... */
|
/* For each bin in this block ... */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* Find and use first big enough chunk ... */
|
/* Find and use first big enough chunk ... */
|
||||||
|
|
||||||
for (victim = last(bin); victim != bin; victim = victim->bk)
|
for (victim = last(bin); victim != bin; victim = victim->bk)
|
||||||
{
|
{
|
||||||
victim_size = chunksize(victim);
|
victim_size = chunksize(victim);
|
||||||
remainder_size = victim_size - nb;
|
remainder_size = victim_size - nb;
|
||||||
|
|
||||||
if (remainder_size >= (long)MINSIZE) /* split */
|
if (remainder_size >= (long)MINSIZE) /* split */
|
||||||
{
|
{
|
||||||
remainder = chunk_at_offset(victim, nb);
|
remainder = chunk_at_offset(victim, nb);
|
||||||
set_head(victim, nb | PREV_INUSE);
|
set_head(victim, nb | PREV_INUSE);
|
||||||
check_freefill(victim, nb, victim_size);
|
check_freefill(victim, nb, victim_size);
|
||||||
unlink(victim, bck, fwd);
|
unlink(victim, bck, fwd);
|
||||||
init_malloced_chunk(victim, bytes);
|
init_malloced_chunk(victim, bytes);
|
||||||
link_last_remainder(remainder);
|
link_last_remainder(remainder);
|
||||||
set_head(remainder, remainder_size | PREV_INUSE);
|
set_head(remainder, remainder_size | PREV_INUSE);
|
||||||
set_foot(remainder, remainder_size);
|
set_foot(remainder, remainder_size);
|
||||||
init_freed_chunk(remainder, remainder_size, 0);
|
init_freed_chunk(remainder, remainder_size, 0);
|
||||||
check_malloced_chunk(victim, nb);
|
check_malloced_chunk(victim, nb);
|
||||||
return chunk2mem(victim);
|
return chunk2mem(victim);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (remainder_size >= 0) /* take */
|
else if (remainder_size >= 0) /* take */
|
||||||
{
|
{
|
||||||
check_freefill(victim, victim_size, victim_size);
|
check_freefill(victim, victim_size, victim_size);
|
||||||
set_inuse_bit_at_offset(victim, victim_size);
|
set_inuse_bit_at_offset(victim, victim_size);
|
||||||
unlink(victim, bck, fwd);
|
unlink(victim, bck, fwd);
|
||||||
init_malloced_chunk(victim, bytes);
|
init_malloced_chunk(victim, bytes);
|
||||||
check_malloced_chunk(victim, nb);
|
check_malloced_chunk(victim, nb);
|
||||||
return chunk2mem(victim);
|
return chunk2mem(victim);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bin = next_bin(bin);
|
bin = next_bin(bin);
|
||||||
|
|
||||||
|
@ -2854,12 +2873,12 @@ Void_t* mALLOc(bytes) size_t bytes;
|
||||||
|
|
||||||
do /* Possibly backtrack to try to clear a partial block */
|
do /* Possibly backtrack to try to clear a partial block */
|
||||||
{
|
{
|
||||||
if ((startidx & (BINBLOCKWIDTH - 1)) == 0)
|
if ((startidx & (BINBLOCKWIDTH - 1)) == 0)
|
||||||
{
|
{
|
||||||
binblocks &= ~block;
|
binblocks &= ~block;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
--startidx;
|
--startidx;
|
||||||
q = prev_bin(q);
|
q = prev_bin(q);
|
||||||
} while (first(q) == q);
|
} while (first(q) == q);
|
||||||
|
|
||||||
|
@ -2867,14 +2886,14 @@ Void_t* mALLOc(bytes) size_t bytes;
|
||||||
|
|
||||||
if ( (block <<= 1) <= binblocks && (block != 0) )
|
if ( (block <<= 1) <= binblocks && (block != 0) )
|
||||||
{
|
{
|
||||||
while ((block & binblocks) == 0)
|
while ((block & binblocks) == 0)
|
||||||
{
|
{
|
||||||
idx += BINBLOCKWIDTH;
|
idx += BINBLOCKWIDTH;
|
||||||
block <<= 1;
|
block <<= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2888,7 +2907,7 @@ Void_t* mALLOc(bytes) size_t bytes;
|
||||||
#if HAVE_MMAP
|
#if HAVE_MMAP
|
||||||
/* If big and would otherwise need to extend, try to use mmap instead */
|
/* If big and would otherwise need to extend, try to use mmap instead */
|
||||||
if ((unsigned long)nb >= (unsigned long)mmap_threshold &&
|
if ((unsigned long)nb >= (unsigned long)mmap_threshold &&
|
||||||
(victim = mmap_chunk(nb)) != 0) {
|
(victim = mmap_chunk(nb)) != 0) {
|
||||||
init_malloced_chunk(victim, bytes);
|
init_malloced_chunk(victim, bytes);
|
||||||
return chunk2mem(victim);
|
return chunk2mem(victim);
|
||||||
}
|
}
|
||||||
|
@ -2926,13 +2945,13 @@ Void_t* mALLOc(bytes) size_t bytes;
|
||||||
2. If the chunk was allocated via mmap, it is release via munmap().
|
2. If the chunk was allocated via mmap, it is release via munmap().
|
||||||
|
|
||||||
3. If a returned chunk borders the current high end of memory,
|
3. If a returned chunk borders the current high end of memory,
|
||||||
it is consolidated into the top, and if the total unused
|
it is consolidated into the top, and if the total unused
|
||||||
topmost memory exceeds the trim threshold, malloc_trim is
|
topmost memory exceeds the trim threshold, malloc_trim is
|
||||||
called.
|
called.
|
||||||
|
|
||||||
4. Other chunks are consolidated as they arrive, and
|
4. Other chunks are consolidated as they arrive, and
|
||||||
placed in corresponding bins. (This includes the case of
|
placed in corresponding bins. (This includes the case of
|
||||||
consolidating with the current `last_remainder').
|
consolidating with the current `last_remainder').
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3152,26 +3171,26 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
|
||||||
/* Forward into top only if a remainder */
|
/* Forward into top only if a remainder */
|
||||||
if (next == top)
|
if (next == top)
|
||||||
{
|
{
|
||||||
if ((long)(nextsize + newsize) >= (long)(nb + MINSIZE))
|
if ((long)(nextsize + newsize) >= (long)(nb + MINSIZE))
|
||||||
{
|
{
|
||||||
check_freefill(next, nb - oldsize, nextsize);
|
check_freefill(next, nb - oldsize, nextsize);
|
||||||
newsize += nextsize;
|
newsize += nextsize;
|
||||||
top = chunk_at_offset(oldp, nb);
|
top = chunk_at_offset(oldp, nb);
|
||||||
set_head(top, (newsize - nb) | PREV_INUSE);
|
set_head(top, (newsize - nb) | PREV_INUSE);
|
||||||
init_freed_chunk(top, newsize - nb, 0);
|
init_freed_chunk(top, newsize - nb, 0);
|
||||||
set_head_size(oldp, nb);
|
set_head_size(oldp, nb);
|
||||||
init_realloced_chunk(oldp, bytes, oldsize);
|
init_realloced_chunk(oldp, bytes, oldsize);
|
||||||
return chunk2mem(oldp);
|
return chunk2mem(oldp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Forward into next chunk */
|
/* Forward into next chunk */
|
||||||
else if (((long)(nextsize + newsize) >= (long)nb))
|
else if (((long)(nextsize + newsize) >= (long)nb))
|
||||||
{
|
{
|
||||||
check_freefill(next, nb - oldsize, nextsize);
|
check_freefill(next, nb - oldsize, nextsize);
|
||||||
unlink(next, bck, fwd);
|
unlink(next, bck, fwd);
|
||||||
newsize += nextsize;
|
newsize += nextsize;
|
||||||
goto split;
|
goto split;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3191,52 +3210,52 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
|
||||||
|
|
||||||
if (next != 0)
|
if (next != 0)
|
||||||
{
|
{
|
||||||
/* into top */
|
/* into top */
|
||||||
if (next == top)
|
if (next == top)
|
||||||
{
|
{
|
||||||
if ((long)(nextsize + prevsize + newsize) >= (long)(nb + MINSIZE))
|
if ((long)(nextsize + prevsize + newsize) >= (long)(nb + MINSIZE))
|
||||||
{
|
{
|
||||||
check_freefill(prev, nb, prevsize);
|
check_freefill(prev, nb, prevsize);
|
||||||
check_freefill(next, nb - (prevsize + newsize), nextsize);
|
check_freefill(next, nb - (prevsize + newsize), nextsize);
|
||||||
unlink(prev, bck, fwd);
|
unlink(prev, bck, fwd);
|
||||||
newp = prev;
|
newp = prev;
|
||||||
newsize += prevsize + nextsize;
|
newsize += prevsize + nextsize;
|
||||||
newmem = chunk2mem(newp);
|
newmem = chunk2mem(newp);
|
||||||
malloc_COPY(newmem, oldmem, oldsize - OVERHEAD);
|
malloc_COPY(newmem, oldmem, oldsize - OVERHEAD);
|
||||||
top = chunk_at_offset(newp, nb);
|
top = chunk_at_offset(newp, nb);
|
||||||
set_head(top, (newsize - nb) | PREV_INUSE);
|
set_head(top, (newsize - nb) | PREV_INUSE);
|
||||||
init_freed_chunk(top, newsize - nb, 0);
|
init_freed_chunk(top, newsize - nb, 0);
|
||||||
set_head_size(newp, nb);
|
set_head_size(newp, nb);
|
||||||
init_realloced_chunk(newp, bytes, oldsize);
|
init_realloced_chunk(newp, bytes, oldsize);
|
||||||
return newmem;
|
return newmem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* into next chunk */
|
/* into next chunk */
|
||||||
else if (((long)(nextsize + prevsize + newsize) >= (long)(nb)))
|
else if (((long)(nextsize + prevsize + newsize) >= (long)(nb)))
|
||||||
{
|
{
|
||||||
check_freefill(prev, nb, prevsize);
|
check_freefill(prev, nb, prevsize);
|
||||||
check_freefill(next, nb - (prevsize + newsize), nextsize);
|
check_freefill(next, nb - (prevsize + newsize), nextsize);
|
||||||
unlink(next, bck, fwd);
|
unlink(next, bck, fwd);
|
||||||
unlink(prev, bck, fwd);
|
unlink(prev, bck, fwd);
|
||||||
newp = prev;
|
newp = prev;
|
||||||
newsize += nextsize + prevsize;
|
newsize += nextsize + prevsize;
|
||||||
newmem = chunk2mem(newp);
|
newmem = chunk2mem(newp);
|
||||||
malloc_COPY(newmem, oldmem, oldsize - OVERHEAD);
|
malloc_COPY(newmem, oldmem, oldsize - OVERHEAD);
|
||||||
goto split;
|
goto split;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* backward only */
|
/* backward only */
|
||||||
if (prev != 0 && (long)(prevsize + newsize) >= (long)nb)
|
if (prev != 0 && (long)(prevsize + newsize) >= (long)nb)
|
||||||
{
|
{
|
||||||
check_freefill(prev, nb, prevsize);
|
check_freefill(prev, nb, prevsize);
|
||||||
unlink(prev, bck, fwd);
|
unlink(prev, bck, fwd);
|
||||||
newp = prev;
|
newp = prev;
|
||||||
newsize += prevsize;
|
newsize += prevsize;
|
||||||
newmem = chunk2mem(newp);
|
newmem = chunk2mem(newp);
|
||||||
malloc_COPY(newmem, oldmem, oldsize - OVERHEAD);
|
malloc_COPY(newmem, oldmem, oldsize - OVERHEAD);
|
||||||
goto split;
|
goto split;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3572,27 +3591,27 @@ int malloc_trim(pad) size_t pad;
|
||||||
|
|
||||||
if (new_lim == (char*)(MORECORE_FAILURE)) /* sbrk failed? */
|
if (new_lim == (char*)(MORECORE_FAILURE)) /* sbrk failed? */
|
||||||
{
|
{
|
||||||
/* Try to figure out what we have */
|
/* Try to figure out what we have */
|
||||||
current_lim = (char*)(MORECORE (0));
|
current_lim = (char*)(MORECORE (0));
|
||||||
top_size = current_lim - (char*)top;
|
top_size = current_lim - (char*)top;
|
||||||
if (top_size >= (long)MINSIZE) /* if not, we are very very dead! */
|
if (top_size >= (long)MINSIZE) /* if not, we are very very dead! */
|
||||||
{
|
{
|
||||||
sbrked_mem = current_lim - sbrk_base;
|
sbrked_mem = current_lim - sbrk_base;
|
||||||
set_head(top, top_size | PREV_INUSE);
|
set_head(top, top_size | PREV_INUSE);
|
||||||
init_freed_chunk(top, top_size, 0);
|
init_freed_chunk(top, top_size, 0);
|
||||||
}
|
}
|
||||||
check_chunk(top);
|
check_chunk(top);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Success. Adjust top accordingly. */
|
/* Success. Adjust top accordingly. */
|
||||||
set_head(top, (top_size - extra) | PREV_INUSE);
|
set_head(top, (top_size - extra) | PREV_INUSE);
|
||||||
sbrked_mem -= extra;
|
sbrked_mem -= extra;
|
||||||
init_freed_chunk(top, top_size - extra, 0);
|
init_freed_chunk(top, top_size - extra, 0);
|
||||||
check_chunk(top);
|
check_chunk(top);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ fillout_pinfo (pid_t pid, int winpid)
|
||||||
|
|
||||||
static DWORD
|
static DWORD
|
||||||
get_cygdrive_info (char *user, char *system, char *user_flags,
|
get_cygdrive_info (char *user, char *system, char *user_flags,
|
||||||
char *system_flags)
|
char *system_flags)
|
||||||
{
|
{
|
||||||
int res = mount_table->get_cygdrive_info (user, system, user_flags,
|
int res = mount_table->get_cygdrive_info (user, system, user_flags,
|
||||||
system_flags);
|
system_flags);
|
||||||
|
|
|
@ -960,7 +960,7 @@ fhandler_disk_file::fstat (struct stat *buf)
|
||||||
{
|
{
|
||||||
/* If read-only attribute is set, modify ntsec return value */
|
/* If read-only attribute is set, modify ntsec return value */
|
||||||
if ((local.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
|
if ((local.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
|
||||||
&& !get_symlink_p ())
|
&& !get_symlink_p ())
|
||||||
buf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
|
buf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
|
||||||
|
|
||||||
if (!(buf->st_mode & S_IFMT))
|
if (!(buf->st_mode & S_IFMT))
|
||||||
|
@ -1094,9 +1094,9 @@ int fhandler_base::fcntl (int cmd, void *arg)
|
||||||
* Since O_ASYNC isn't defined in fcntl.h it's currently
|
* Since O_ASYNC isn't defined in fcntl.h it's currently
|
||||||
* ignored as well.
|
* ignored as well.
|
||||||
*/
|
*/
|
||||||
const int allowed_flags = O_APPEND | O_NONBLOCK_MASK;
|
const int allowed_flags = O_APPEND | O_NONBLOCK_MASK;
|
||||||
int new_flags = (int) arg & allowed_flags;
|
int new_flags = (int) arg & allowed_flags;
|
||||||
/* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
|
/* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
|
||||||
Set only the flag that has been passed in. If both are set, just
|
Set only the flag that has been passed in. If both are set, just
|
||||||
record O_NONBLOCK. */
|
record O_NONBLOCK. */
|
||||||
if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK))
|
if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK))
|
||||||
|
@ -1249,7 +1249,7 @@ fhandler_disk_file::open (const char *path, int flags, mode_t mode)
|
||||||
|| !(flags & O_CREAT) || real_path.case_clash))
|
|| !(flags & O_CREAT) || real_path.case_clash))
|
||||||
{
|
{
|
||||||
set_errno (flags & O_CREAT && real_path.case_clash ? ECASECLASH
|
set_errno (flags & O_CREAT && real_path.case_clash ? ECASECLASH
|
||||||
: real_path.error);
|
: real_path.error);
|
||||||
syscall_printf ("0 = fhandler_disk_file::open (%s, %p)", path, flags);
|
syscall_printf ("0 = fhandler_disk_file::open (%s, %p)", path, flags);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,7 +321,7 @@ fhandler_console::read (void *pv, size_t buflen)
|
||||||
an ASCII control character, interpret is as META. */
|
an ASCII control character, interpret is as META. */
|
||||||
meta = (control_key_state & ALT_PRESSED) != 0
|
meta = (control_key_state & ALT_PRESSED) != 0
|
||||||
&& ((control_key_state & CTRL_PRESSED) == 0
|
&& ((control_key_state & CTRL_PRESSED) == 0
|
||||||
|| (ich >= 0 && ich <= 0x1f || ich == 0x7f));
|
|| (ich >= 0 && ich <= 0x1f || ich == 0x7f));
|
||||||
else
|
else
|
||||||
/* Win9x: there's no way to distinguish Alt from AltGr, so rely
|
/* Win9x: there's no way to distinguish Alt from AltGr, so rely
|
||||||
on meta_mask heuristic (see fhandler_console constructor). */
|
on meta_mask heuristic (see fhandler_console constructor). */
|
||||||
|
|
|
@ -179,8 +179,8 @@ fhandler_dev_floppy::lseek (off_t offset, int whence)
|
||||||
devbufstart = devbufend = 0;
|
devbufstart = devbufend = 0;
|
||||||
|
|
||||||
if (SetFilePointer (get_handle (), sector_aligned_offset, NULL, FILE_BEGIN)
|
if (SetFilePointer (get_handle (), sector_aligned_offset, NULL, FILE_BEGIN)
|
||||||
== INVALID_SET_FILE_POINTER)
|
== INVALID_SET_FILE_POINTER)
|
||||||
{
|
{
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,15 +39,15 @@ fhandler_dev_mem::fhandler_dev_mem (const char *name, int nunit)
|
||||||
NTSTATUS ret;
|
NTSTATUS ret;
|
||||||
SYSTEM_BASIC_INFORMATION sbi;
|
SYSTEM_BASIC_INFORMATION sbi;
|
||||||
if ((ret = NtQuerySystemInformation (SystemBasicInformation, (PVOID) &sbi,
|
if ((ret = NtQuerySystemInformation (SystemBasicInformation, (PVOID) &sbi,
|
||||||
sizeof sbi, NULL)) != STATUS_SUCCESS)
|
sizeof sbi, NULL)) != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
__seterrno_from_win_error (RtlNtStatusToDosError (ret));
|
__seterrno_from_win_error (RtlNtStatusToDosError (ret));
|
||||||
debug_printf("NtQuerySystemInformation: ret = %d, Dos(ret) = %d",
|
debug_printf("NtQuerySystemInformation: ret = %d, Dos(ret) = %d",
|
||||||
ret, RtlNtStatusToDosError (ret));
|
ret, RtlNtStatusToDosError (ret));
|
||||||
mem_size = 0;
|
mem_size = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mem_size = sbi.PhysicalPageSize * sbi.NumberOfPhysicalPages;
|
mem_size = sbi.PhysicalPageSize * sbi.NumberOfPhysicalPages;
|
||||||
debug_printf ("MemSize: %d MB", mem_size >> 20);
|
debug_printf ("MemSize: %d MB", mem_size >> 20);
|
||||||
}
|
}
|
||||||
else if (unit == 2) /* /dev/kmem - Not yet supported */
|
else if (unit == 2) /* /dev/kmem - Not yet supported */
|
||||||
|
@ -78,9 +78,9 @@ fhandler_dev_mem::open (const char *, int flags, mode_t)
|
||||||
{
|
{
|
||||||
set_errno (ENOENT);
|
set_errno (ENOENT);
|
||||||
debug_printf ("%s is accessible under NT/W2K only",
|
debug_printf ("%s is accessible under NT/W2K only",
|
||||||
unit == 1 ? "/dev/mem" :
|
unit == 1 ? "/dev/mem" :
|
||||||
unit == 2 ? "/dev/kmem" :
|
unit == 2 ? "/dev/kmem" :
|
||||||
"/dev/port");
|
"/dev/port");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ fhandler_dev_mem::open (const char *, int flags, mode_t)
|
||||||
|
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
InitializeObjectAttributes(&attr, &memstr,
|
InitializeObjectAttributes(&attr, &memstr,
|
||||||
OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
|
OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
ACCESS_MASK section_access;
|
ACCESS_MASK section_access;
|
||||||
|
@ -152,15 +152,15 @@ fhandler_dev_mem::write (const void *ptr, size_t ulen)
|
||||||
|
|
||||||
phys.QuadPart = (ULONGLONG) pos;
|
phys.QuadPart = (ULONGLONG) pos;
|
||||||
if ((ret = NtMapViewOfSection (get_handle (),
|
if ((ret = NtMapViewOfSection (get_handle (),
|
||||||
INVALID_HANDLE_VALUE,
|
INVALID_HANDLE_VALUE,
|
||||||
&viewmem,
|
&viewmem,
|
||||||
0L,
|
0L,
|
||||||
len,
|
len,
|
||||||
&phys,
|
&phys,
|
||||||
&len,
|
&len,
|
||||||
ViewShare,
|
ViewShare,
|
||||||
0,
|
0,
|
||||||
PAGE_READONLY)) != STATUS_SUCCESS)
|
PAGE_READONLY)) != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
__seterrno_from_win_error (RtlNtStatusToDosError (ret));
|
__seterrno_from_win_error (RtlNtStatusToDosError (ret));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -200,15 +200,15 @@ fhandler_dev_mem::read (void *ptr, size_t ulen)
|
||||||
|
|
||||||
phys.QuadPart = (ULONGLONG) pos;
|
phys.QuadPart = (ULONGLONG) pos;
|
||||||
if ((ret = NtMapViewOfSection (get_handle (),
|
if ((ret = NtMapViewOfSection (get_handle (),
|
||||||
INVALID_HANDLE_VALUE,
|
INVALID_HANDLE_VALUE,
|
||||||
&viewmem,
|
&viewmem,
|
||||||
0L,
|
0L,
|
||||||
len,
|
len,
|
||||||
&phys,
|
&phys,
|
||||||
&len,
|
&len,
|
||||||
ViewShare,
|
ViewShare,
|
||||||
0,
|
0,
|
||||||
PAGE_READONLY)) != STATUS_SUCCESS)
|
PAGE_READONLY)) != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
__seterrno_from_win_error (RtlNtStatusToDosError (ret));
|
__seterrno_from_win_error (RtlNtStatusToDosError (ret));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -283,7 +283,7 @@ fhandler_dev_mem::mmap (caddr_t *addr, size_t len, DWORD access,
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
InitializeObjectAttributes(&attr, &memstr,
|
InitializeObjectAttributes(&attr, &memstr,
|
||||||
OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
|
OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
ACCESS_MASK section_access;
|
ACCESS_MASK section_access;
|
||||||
ULONG protect;
|
ULONG protect;
|
||||||
|
|
|
@ -46,7 +46,7 @@ fhandler_socket::fhandler_socket (const char *name) :
|
||||||
set_cb (sizeof *this);
|
set_cb (sizeof *this);
|
||||||
set_need_fork_fixup ();
|
set_need_fork_fixup ();
|
||||||
prot_info_ptr = (LPWSAPROTOCOL_INFOA) ccalloc (HEAP_BUF, 1,
|
prot_info_ptr = (LPWSAPROTOCOL_INFOA) ccalloc (HEAP_BUF, 1,
|
||||||
sizeof (WSAPROTOCOL_INFOA));
|
sizeof (WSAPROTOCOL_INFOA));
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_socket::~fhandler_socket ()
|
fhandler_socket::~fhandler_socket ()
|
||||||
|
@ -134,8 +134,8 @@ fhandler_socket::check_peer_secret_event (struct sockaddr_in* peer, int* secret)
|
||||||
int* secret_ptr = (secret ? : connect_secret);
|
int* secret_ptr = (secret ? : connect_secret);
|
||||||
|
|
||||||
__small_sprintf (buf, SECRET_EVENT_NAME, peer->sin_port,
|
__small_sprintf (buf, SECRET_EVENT_NAME, peer->sin_port,
|
||||||
secret_ptr [0], secret_ptr [1],
|
secret_ptr [0], secret_ptr [1],
|
||||||
secret_ptr [2], secret_ptr [3]);
|
secret_ptr [2], secret_ptr [3]);
|
||||||
ev = CreateEvent (&sec_all_nih, FALSE, FALSE, buf);
|
ev = CreateEvent (&sec_all_nih, FALSE, FALSE, buf);
|
||||||
if (!ev && GetLastError () == ERROR_ALREADY_EXISTS)
|
if (!ev && GetLastError () == ERROR_ALREADY_EXISTS)
|
||||||
{
|
{
|
||||||
|
@ -188,9 +188,9 @@ fhandler_socket::fixup_after_fork (HANDLE parent)
|
||||||
prot_info_ptr->dwServiceFlags1);
|
prot_info_ptr->dwServiceFlags1);
|
||||||
if (prot_info_ptr &&
|
if (prot_info_ptr &&
|
||||||
(new_sock = WSASocketA (FROM_PROTOCOL_INFO,
|
(new_sock = WSASocketA (FROM_PROTOCOL_INFO,
|
||||||
FROM_PROTOCOL_INFO,
|
FROM_PROTOCOL_INFO,
|
||||||
FROM_PROTOCOL_INFO,
|
FROM_PROTOCOL_INFO,
|
||||||
prot_info_ptr, 0, 0)) == INVALID_SOCKET)
|
prot_info_ptr, 0, 0)) == INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
debug_printf ("WSASocket error");
|
debug_printf ("WSASocket error");
|
||||||
set_winsock_errno ();
|
set_winsock_errno ();
|
||||||
|
@ -312,10 +312,10 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
|
||||||
}
|
}
|
||||||
ifr->ifr_flags = IFF_NOTRAILERS | IFF_UP | IFF_RUNNING;
|
ifr->ifr_flags = IFF_NOTRAILERS | IFF_UP | IFF_RUNNING;
|
||||||
if (ntohl (((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr)
|
if (ntohl (((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr)
|
||||||
== INADDR_LOOPBACK)
|
== INADDR_LOOPBACK)
|
||||||
ifr->ifr_flags |= IFF_LOOPBACK;
|
ifr->ifr_flags |= IFF_LOOPBACK;
|
||||||
else
|
else
|
||||||
ifr->ifr_flags |= IFF_BROADCAST;
|
ifr->ifr_flags |= IFF_BROADCAST;
|
||||||
res = 0;
|
res = 0;
|
||||||
break;
|
break;
|
||||||
case SIOCGIFBRDADDR:
|
case SIOCGIFBRDADDR:
|
||||||
|
@ -424,18 +424,18 @@ fhandler_socket::fcntl (int cmd, void *arg)
|
||||||
{
|
{
|
||||||
case F_SETFL:
|
case F_SETFL:
|
||||||
{
|
{
|
||||||
/* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
|
/* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
|
||||||
Set only the flag that has been passed in. If both are set, just
|
Set only the flag that has been passed in. If both are set, just
|
||||||
record O_NONBLOCK. */
|
record O_NONBLOCK. */
|
||||||
int new_flags = (int) arg & O_NONBLOCK_MASK;
|
int new_flags = (int) arg & O_NONBLOCK_MASK;
|
||||||
if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK))
|
if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK))
|
||||||
new_flags = O_NONBLOCK;
|
new_flags = O_NONBLOCK;
|
||||||
current = get_flags () & O_NONBLOCK_MASK;
|
current = get_flags () & O_NONBLOCK_MASK;
|
||||||
request = new_flags ? 1 : 0;
|
request = new_flags ? 1 : 0;
|
||||||
if (!!current != !!new_flags && (res = ioctl (FIONBIO, &request)))
|
if (!!current != !!new_flags && (res = ioctl (FIONBIO, &request)))
|
||||||
break;
|
break;
|
||||||
set_flags ((get_flags () & ~O_NONBLOCK_MASK) | new_flags);
|
set_flags ((get_flags () & ~O_NONBLOCK_MASK) | new_flags);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
res = fhandler_base::fcntl (cmd, arg);
|
res = fhandler_base::fcntl (cmd, arg);
|
||||||
|
|
|
@ -711,11 +711,11 @@ fhandler_tty_slave::read (void *ptr, size_t len)
|
||||||
termios_printf ("read failed, %E");
|
termios_printf ("read failed, %E");
|
||||||
_raise (SIGHUP);
|
_raise (SIGHUP);
|
||||||
}
|
}
|
||||||
/* MSDN states that 5th prameter can be used to determine total
|
/* MSDN states that 5th prameter can be used to determine total
|
||||||
number of bytes in pipe, but for some reason this number doesn't
|
number of bytes in pipe, but for some reason this number doesn't
|
||||||
change after successful read. So we have to peek into the pipe
|
change after successful read. So we have to peek into the pipe
|
||||||
again to see if input is still available */
|
again to see if input is still available */
|
||||||
if (!PeekNamedPipe (get_handle (), peek_buf, 1, &bytes_in_pipe, NULL, NULL))
|
if (!PeekNamedPipe (get_handle (), peek_buf, 1, &bytes_in_pipe, NULL, NULL))
|
||||||
{
|
{
|
||||||
termios_printf ("PeekNamedPipe failed, %E");
|
termios_printf ("PeekNamedPipe failed, %E");
|
||||||
_raise (SIGHUP);
|
_raise (SIGHUP);
|
||||||
|
|
|
@ -246,7 +246,7 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
|
||||||
sync_with_parent ("after longjmp.", TRUE);
|
sync_with_parent ("after longjmp.", TRUE);
|
||||||
ProtectHandle (hParent);
|
ProtectHandle (hParent);
|
||||||
sigproc_printf ("hParent %p, child 1 first_dll %p, load_dlls %d\n", hParent,
|
sigproc_printf ("hParent %p, child 1 first_dll %p, load_dlls %d\n", hParent,
|
||||||
first_dll, load_dlls);
|
first_dll, load_dlls);
|
||||||
|
|
||||||
#ifdef DEBUGGING
|
#ifdef DEBUGGING
|
||||||
char c;
|
char c;
|
||||||
|
@ -279,7 +279,6 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
|
||||||
debug_fixup_after_fork ();
|
debug_fixup_after_fork ();
|
||||||
pinfo_fixup_after_fork ();
|
pinfo_fixup_after_fork ();
|
||||||
cygheap->fdtab.fixup_after_fork (hParent);
|
cygheap->fdtab.fixup_after_fork (hParent);
|
||||||
sigproc_fixup_after_fork ();
|
|
||||||
signal_fixup_after_fork ();
|
signal_fixup_after_fork ();
|
||||||
|
|
||||||
MALLOC_CHECK;
|
MALLOC_CHECK;
|
||||||
|
@ -430,9 +429,6 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
|
||||||
init_child_info (PROC_FORK1, &ch, 1, subproc_ready);
|
init_child_info (PROC_FORK1, &ch, 1, subproc_ready);
|
||||||
|
|
||||||
ch.forker_finished = forker_finished;
|
ch.forker_finished = forker_finished;
|
||||||
ch.heaptop = user_data->heaptop;
|
|
||||||
ch.heapbase = user_data->heapbase;
|
|
||||||
ch.heapptr = user_data->heapptr;
|
|
||||||
|
|
||||||
stack_base (ch);
|
stack_base (ch);
|
||||||
|
|
||||||
|
@ -489,7 +485,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
|
||||||
ForceCloseHandle(forker_finished);
|
ForceCloseHandle(forker_finished);
|
||||||
/* Restore impersonation */
|
/* Restore impersonation */
|
||||||
if (cygheap->user.impersonated
|
if (cygheap->user.impersonated
|
||||||
&& cygheap->user.token != INVALID_HANDLE_VALUE)
|
&& cygheap->user.token != INVALID_HANDLE_VALUE)
|
||||||
ImpersonateLoggedOnUser (cygheap->user.token);
|
ImpersonateLoggedOnUser (cygheap->user.token);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -556,7 +552,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
|
||||||
rc = fork_copy (pi, "user/cygwin data",
|
rc = fork_copy (pi, "user/cygwin data",
|
||||||
user_data->data_start, user_data->data_end,
|
user_data->data_start, user_data->data_end,
|
||||||
user_data->bss_start, user_data->bss_end,
|
user_data->bss_start, user_data->bss_end,
|
||||||
ch.heapbase, ch.heapptr,
|
cygheap->heapbase, cygheap->heapptr,
|
||||||
stack_here, ch.stackbottom,
|
stack_here, ch.stackbottom,
|
||||||
dll_data_start, dll_data_end,
|
dll_data_start, dll_data_end,
|
||||||
dll_bss_start, dll_bss_end, NULL);
|
dll_bss_start, dll_bss_end, NULL);
|
||||||
|
|
|
@ -104,7 +104,7 @@ monstartup(lowpc, highpc)
|
||||||
cp += p->kcountsize;
|
cp += p->kcountsize;
|
||||||
p->froms = (u_short *)cp;
|
p->froms = (u_short *)cp;
|
||||||
|
|
||||||
/* XXX minbrk needed? */
|
/* XXX minbrk needed? */
|
||||||
//minbrk = fake_sbrk(0);
|
//minbrk = fake_sbrk(0);
|
||||||
p->tos[0].link = 0;
|
p->tos[0].link = 0;
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ _mcleanup()
|
||||||
if (p->state == GMON_PROF_ERROR)
|
if (p->state == GMON_PROF_ERROR)
|
||||||
ERR("_mcleanup: tos overflow\n");
|
ERR("_mcleanup: tos overflow\n");
|
||||||
|
|
||||||
hz = PROF_HZ;
|
hz = PROF_HZ;
|
||||||
moncontrol(0);
|
moncontrol(0);
|
||||||
|
|
||||||
#ifdef nope
|
#ifdef nope
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
last_modified = data.ftLastWriteTime;
|
last_modified = data.ftLastWriteTime;
|
||||||
}
|
}
|
||||||
FindClose (h);
|
FindClose (h);
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
void operator = (grp_state nstate)
|
void operator = (grp_state nstate)
|
||||||
|
@ -118,37 +118,37 @@ parse_grp (struct group &grp, const char *line)
|
||||||
{
|
{
|
||||||
*dp++ = '\0';
|
*dp++ = '\0';
|
||||||
if (!strlen (grp.gr_passwd))
|
if (!strlen (grp.gr_passwd))
|
||||||
grp.gr_passwd = NULL;
|
grp.gr_passwd = NULL;
|
||||||
|
|
||||||
grp.gr_gid = strtol (dp, NULL, 10);
|
grp.gr_gid = strtol (dp, NULL, 10);
|
||||||
dp = strchr (dp, ':');
|
dp = strchr (dp, ':');
|
||||||
if (dp)
|
if (dp)
|
||||||
{
|
{
|
||||||
if (*++dp)
|
if (*++dp)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
for (cp = dp; (cp = strchr (cp, ',')) != NULL; ++cp)
|
for (cp = dp; (cp = strchr (cp, ',')) != NULL; ++cp)
|
||||||
++i;
|
++i;
|
||||||
char **namearray = (char **) calloc (i + 2, sizeof (char *));
|
char **namearray = (char **) calloc (i + 2, sizeof (char *));
|
||||||
if (namearray)
|
if (namearray)
|
||||||
{
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
for (cp = dp; (cp = strchr (dp, ',')) != NULL; dp = cp + 1)
|
for (cp = dp; (cp = strchr (dp, ',')) != NULL; dp = cp + 1)
|
||||||
{
|
{
|
||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
namearray[i++] = dp;
|
namearray[i++] = dp;
|
||||||
}
|
}
|
||||||
namearray[i++] = dp;
|
namearray[i++] = dp;
|
||||||
namearray[i] = NULL;
|
namearray[i] = NULL;
|
||||||
}
|
}
|
||||||
grp.gr_mem = namearray;
|
grp.gr_mem = namearray;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
grp.gr_mem = (char **) calloc (1, sizeof (char *));
|
grp.gr_mem = (char **) calloc (1, sizeof (char *));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ read_etc_group ()
|
||||||
{
|
{
|
||||||
group_state = initializing;
|
group_state = initializing;
|
||||||
if (max_lines) /* When rereading, free allocated memory first. */
|
if (max_lines) /* When rereading, free allocated memory first. */
|
||||||
{
|
{
|
||||||
for (int i = 0; i < curr_lines; ++i)
|
for (int i = 0; i < curr_lines; ++i)
|
||||||
{
|
{
|
||||||
free (group_buf[i].gr_name);
|
free (group_buf[i].gr_name);
|
||||||
|
@ -256,9 +256,9 @@ getgrgid (gid_t gid)
|
||||||
for (int i = 0; i < curr_lines; i++)
|
for (int i = 0; i < curr_lines; i++)
|
||||||
{
|
{
|
||||||
if (group_buf[i].gr_gid == DEFAULT_GID)
|
if (group_buf[i].gr_gid == DEFAULT_GID)
|
||||||
default_grp = group_buf + i;
|
default_grp = group_buf + i;
|
||||||
if (group_buf[i].gr_gid == gid)
|
if (group_buf[i].gr_gid == gid)
|
||||||
return group_buf + i;
|
return group_buf + i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return default_grp;
|
return default_grp;
|
||||||
|
@ -333,8 +333,8 @@ getgroups (int gidsetsize, gid_t *grouplist, gid_t gid, const char *username)
|
||||||
OpenProcessToken (hMainProc, TOKEN_QUERY, &hToken))
|
OpenProcessToken (hMainProc, TOKEN_QUERY, &hToken))
|
||||||
{
|
{
|
||||||
if (GetTokenInformation (hToken, TokenGroups, NULL, 0, &size)
|
if (GetTokenInformation (hToken, TokenGroups, NULL, 0, &size)
|
||||||
|| GetLastError () == ERROR_INSUFFICIENT_BUFFER)
|
|| GetLastError () == ERROR_INSUFFICIENT_BUFFER)
|
||||||
{
|
{
|
||||||
char buf[size];
|
char buf[size];
|
||||||
TOKEN_GROUPS *groups = (TOKEN_GROUPS *) buf;
|
TOKEN_GROUPS *groups = (TOKEN_GROUPS *) buf;
|
||||||
|
|
||||||
|
@ -358,12 +358,12 @@ getgroups (int gidsetsize, gid_t *grouplist, gid_t gid, const char *username)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
debug_printf ("%d = GetTokenInformation(NULL) %E", size);
|
debug_printf ("%d = GetTokenInformation(NULL) %E", size);
|
||||||
CloseHandle (hToken);
|
CloseHandle (hToken);
|
||||||
if (cnt)
|
if (cnt)
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx)
|
for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx)
|
||||||
|
|
|
@ -16,6 +16,10 @@ details. */
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "shared_info.h"
|
#include "shared_info.h"
|
||||||
|
#include "security.h"
|
||||||
|
#include "fhandler.h"
|
||||||
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
|
|
||||||
#define assert(x)
|
#define assert(x)
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,9 @@ void malloc_init ();
|
||||||
|
|
||||||
#define inheap(s) (brk && ((char *) (s) >= (char *) brkbase) && ((char *) (s) <= (char *) brktop))
|
#define inheap(s) (brk && ((char *) (s) >= (char *) brkbase) && ((char *) (s) <= (char *) brktop))
|
||||||
|
|
||||||
#define brksize ((char *) user_data->heaptop - (char *) user_data->heapbase)
|
#define brksize ((char *) cygheap->heaptop - (char *) cygheap->heapbase)
|
||||||
#define brk (user_data->heapptr)
|
#define brk (cygheap->heapptr)
|
||||||
#define brkbase (user_data->heapbase)
|
#define brkbase (cygheap->heapbase)
|
||||||
#define brktop (user_data->heaptop)
|
#define brktop (cygheap->heaptop)
|
||||||
#define brkchunk (cygwin_shared->heap_chunk_size ())
|
#define brkchunk (cygwin_shared->heap_chunk_size ())
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,7 @@ details. */
|
||||||
42: sys_errlist, sys_nerr
|
42: sys_errlist, sys_nerr
|
||||||
43: sigsetjmp, siglongjmp fixed
|
43: sigsetjmp, siglongjmp fixed
|
||||||
44: Export dirfd
|
44: Export dirfd
|
||||||
|
45: perprocess change
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CYGWIN_VERSION_API_MAJOR 0
|
#define CYGWIN_VERSION_API_MAJOR 0
|
||||||
|
|
|
@ -163,14 +163,7 @@ struct per_process
|
||||||
/* non-zero of ctors have been run. Inherited from parent. */
|
/* non-zero of ctors have been run. Inherited from parent. */
|
||||||
int run_ctors_p;
|
int run_ctors_p;
|
||||||
|
|
||||||
DWORD unused[3];
|
DWORD unused[7];
|
||||||
|
|
||||||
/* Heap management. Inherited from parent. */
|
|
||||||
void *heapbase; /* bottom of the heap */
|
|
||||||
void *heapptr; /* current index into heap */
|
|
||||||
void *heaptop; /* current top of heap */
|
|
||||||
|
|
||||||
DWORD unused1;
|
|
||||||
|
|
||||||
/* Non-zero means the task was forked. The value is the pid.
|
/* Non-zero means the task was forked. The value is the pid.
|
||||||
Inherited from parent. */
|
Inherited from parent. */
|
||||||
|
|
|
@ -129,11 +129,11 @@ check_null_empty_str (const char *name)
|
||||||
|
|
||||||
int __stdcall
|
int __stdcall
|
||||||
check_null_empty_str_errno (const char *name)
|
check_null_empty_str_errno (const char *name)
|
||||||
{
|
{
|
||||||
int __err;
|
int __err;
|
||||||
if ((__err = check_null_empty_str (name)))
|
if ((__err = check_null_empty_str (name)))
|
||||||
set_errno (__err);
|
set_errno (__err);
|
||||||
return __err;
|
return __err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int __stdcall
|
int __stdcall
|
||||||
|
@ -147,9 +147,9 @@ __check_null_invalid_struct (const void *s, unsigned sz)
|
||||||
|
|
||||||
int __stdcall
|
int __stdcall
|
||||||
__check_null_invalid_struct_errno (const void *s, unsigned sz)
|
__check_null_invalid_struct_errno (const void *s, unsigned sz)
|
||||||
{
|
{
|
||||||
int __err;
|
int __err;
|
||||||
if ((__err = __check_null_invalid_struct (s, sz)))
|
if ((__err = __check_null_invalid_struct (s, sz)))
|
||||||
set_errno (__err);
|
set_errno (__err);
|
||||||
return __err;
|
return __err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,7 +388,7 @@ free_char_list (char **clist)
|
||||||
if (clist)
|
if (clist)
|
||||||
{
|
{
|
||||||
for (char **cl = clist; *cl; ++cl)
|
for (char **cl = clist; *cl; ++cl)
|
||||||
free (*cl);
|
free (*cl);
|
||||||
free (clist);
|
free (clist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,7 +416,7 @@ dup_addr_list (char **src, unsigned int size)
|
||||||
{
|
{
|
||||||
char **dst;
|
char **dst;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
|
||||||
for (char **cl = src; *cl; ++cl)
|
for (char **cl = src; *cl; ++cl)
|
||||||
++cnt;
|
++cnt;
|
||||||
if (!(dst = (char **) calloc (cnt + 1, sizeof *dst)))
|
if (!(dst = (char **) calloc (cnt + 1, sizeof *dst)))
|
||||||
|
@ -424,7 +424,7 @@ dup_addr_list (char **src, unsigned int size)
|
||||||
while (cnt-- > 0)
|
while (cnt-- > 0)
|
||||||
{
|
{
|
||||||
if (!(dst[cnt] = (char *) malloc(size)))
|
if (!(dst[cnt] = (char *) malloc(size)))
|
||||||
return NULL;
|
return NULL;
|
||||||
memcpy(dst[cnt], src[cnt], size);
|
memcpy(dst[cnt], src[cnt], size);
|
||||||
}
|
}
|
||||||
return dst;
|
return dst;
|
||||||
|
@ -438,7 +438,7 @@ free_protoent_ptr (struct protoent *&p)
|
||||||
debug_printf ("protoent: %s", p->p_name);
|
debug_printf ("protoent: %s", p->p_name);
|
||||||
|
|
||||||
if (p->p_name)
|
if (p->p_name)
|
||||||
free (p->p_name);
|
free (p->p_name);
|
||||||
free_char_list (p->p_aliases);
|
free_char_list (p->p_aliases);
|
||||||
p = NULL;
|
p = NULL;
|
||||||
}
|
}
|
||||||
|
@ -878,7 +878,7 @@ cygwin_connect (int fd,
|
||||||
in_progress = TRUE;
|
in_progress = TRUE;
|
||||||
}
|
}
|
||||||
else if (err == WSAEINVAL)
|
else if (err == WSAEINVAL)
|
||||||
WSASetLastError (WSAEISCONN);
|
WSASetLastError (WSAEISCONN);
|
||||||
}
|
}
|
||||||
set_winsock_errno ();
|
set_winsock_errno ();
|
||||||
}
|
}
|
||||||
|
@ -924,9 +924,9 @@ free_servent_ptr (struct servent *&p)
|
||||||
debug_printf ("servent: %s", p->s_name);
|
debug_printf ("servent: %s", p->s_name);
|
||||||
|
|
||||||
if (p->s_name)
|
if (p->s_name)
|
||||||
free (p->s_name);
|
free (p->s_name);
|
||||||
if (p->s_proto)
|
if (p->s_proto)
|
||||||
free (p->s_proto);
|
free (p->s_proto);
|
||||||
free_char_list (p->s_aliases);
|
free_char_list (p->s_aliases);
|
||||||
p = NULL;
|
p = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1022,7 +1022,7 @@ free_hostent_ptr (struct hostent *&p)
|
||||||
debug_printf ("hostent: %s", p->h_name);
|
debug_printf ("hostent: %s", p->h_name);
|
||||||
|
|
||||||
if (p->h_name)
|
if (p->h_name)
|
||||||
free ((void *)p->h_name);
|
free ((void *)p->h_name);
|
||||||
free_char_list (p->h_aliases);
|
free_char_list (p->h_aliases);
|
||||||
free_addr_list (p->h_addr_list);
|
free_addr_list (p->h_addr_list);
|
||||||
p = NULL;
|
p = NULL;
|
||||||
|
@ -1858,18 +1858,18 @@ get_nt_ifconf (struct ifconf *ifc, int what)
|
||||||
/*
|
/*
|
||||||
* IFCONF Windows 95:
|
* IFCONF Windows 95:
|
||||||
* HKLM/Enum/Network/MSTCP/"*"
|
* HKLM/Enum/Network/MSTCP/"*"
|
||||||
* -> Value "Driver" enthält Subkey relativ zu
|
* -> Value "Driver" enthält Subkey relativ zu
|
||||||
* HKLM/System/CurrentControlSet/Class/
|
* HKLM/System/CurrentControlSet/Class/
|
||||||
* -> In Subkey "Bindings" die Values aufzählen
|
* -> In Subkey "Bindings" die Values aufzählen
|
||||||
* -> Enthält Subkeys der Form "VREDIR\*"
|
* -> Enthält Subkeys der Form "VREDIR\*"
|
||||||
* Das * ist ein Subkey relativ zu
|
* Das * ist ein Subkey relativ zu
|
||||||
* HKLM/System/CurrentControlSet/Class/Net/
|
* HKLM/System/CurrentControlSet/Class/Net/
|
||||||
* HKLM/System/CurrentControlSet/Class/"Driver"
|
* HKLM/System/CurrentControlSet/Class/"Driver"
|
||||||
* -> Value "IPAddress"
|
* -> Value "IPAddress"
|
||||||
* -> Value "IPMask"
|
* -> Value "IPMask"
|
||||||
* HKLM/System/CurrentControlSet/Class/Net/"*"(aus "VREDIR\*")
|
* HKLM/System/CurrentControlSet/Class/Net/"*"(aus "VREDIR\*")
|
||||||
* -> Wenn Value "AdapterName" == "MS$PPP" -> ppp interface
|
* -> Wenn Value "AdapterName" == "MS$PPP" -> ppp interface
|
||||||
* -> Value "DriverDesc" enthält den Namen
|
* -> Value "DriverDesc" enthält den Namen
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -137,10 +137,10 @@ typedef struct _SYSTEM_PROCESSES
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
NTSTATUS NTAPI NtCreateToken (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
|
NTSTATUS NTAPI NtCreateToken (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
|
||||||
TOKEN_TYPE, PLUID, PLARGE_INTEGER, PTOKEN_USER,
|
TOKEN_TYPE, PLUID, PLARGE_INTEGER, PTOKEN_USER,
|
||||||
PTOKEN_GROUPS, PTOKEN_PRIVILEGES, PTOKEN_OWNER,
|
PTOKEN_GROUPS, PTOKEN_PRIVILEGES, PTOKEN_OWNER,
|
||||||
PTOKEN_PRIMARY_GROUP, PTOKEN_DEFAULT_DACL,
|
PTOKEN_PRIMARY_GROUP, PTOKEN_DEFAULT_DACL,
|
||||||
PTOKEN_SOURCE);
|
PTOKEN_SOURCE);
|
||||||
NTSTATUS NTAPI NtMapViewOfSection (HANDLE, HANDLE, PVOID *, ULONG, ULONG,
|
NTSTATUS NTAPI NtMapViewOfSection (HANDLE, HANDLE, PVOID *, ULONG, ULONG,
|
||||||
PLARGE_INTEGER, PULONG, SECTION_INHERIT,
|
PLARGE_INTEGER, PULONG, SECTION_INHERIT,
|
||||||
ULONG, ULONG);
|
ULONG, ULONG);
|
||||||
|
|
|
@ -72,7 +72,7 @@ public:
|
||||||
last_modified = data.ftLastWriteTime;
|
last_modified = data.ftLastWriteTime;
|
||||||
}
|
}
|
||||||
FindClose (h);
|
FindClose (h);
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
void operator = (pwd_state nstate)
|
void operator = (pwd_state nstate)
|
||||||
|
|
|
@ -3115,7 +3115,7 @@ fchdir (int fd)
|
||||||
char path[MAX_PATH];
|
char path[MAX_PATH];
|
||||||
char posix_path[MAX_PATH];
|
char posix_path[MAX_PATH];
|
||||||
mount_table->conv_to_posix_path (cygheap->cwd.get (path, 0, 1),
|
mount_table->conv_to_posix_path (cygheap->cwd.get (path, 0, 1),
|
||||||
posix_path, 0);
|
posix_path, 0);
|
||||||
cygheap->fdtab[fd]->set_name (path, posix_path);
|
cygheap->fdtab[fd]->set_name (path, posix_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ getrlimit (int resource, struct rlimit *rlp)
|
||||||
if (!VirtualQuery ((LPCVOID) &m, &m, sizeof m))
|
if (!VirtualQuery ((LPCVOID) &m, &m, sizeof m))
|
||||||
debug_printf ("couldn't get stack info, returning def.values. %E");
|
debug_printf ("couldn't get stack info, returning def.values. %E");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rlp->rlim_cur = (DWORD) &m - (DWORD) m.AllocationBase;
|
rlp->rlim_cur = (DWORD) &m - (DWORD) m.AllocationBase;
|
||||||
rlp->rlim_max = (DWORD) m.BaseAddress + m.RegionSize
|
rlp->rlim_max = (DWORD) m.BaseAddress + m.RegionSize
|
||||||
- (DWORD) m.AllocationBase;
|
- (DWORD) m.AllocationBase;
|
||||||
|
@ -174,7 +174,7 @@ setrlimit (int resource, const struct rlimit *rlp)
|
||||||
break;
|
break;
|
||||||
case RLIMIT_NOFILE:
|
case RLIMIT_NOFILE:
|
||||||
if (rlp->rlim_cur != RLIM_INFINITY)
|
if (rlp->rlim_cur != RLIM_INFINITY)
|
||||||
return setdtablesize (rlp->rlim_cur);
|
return setdtablesize (rlp->rlim_cur);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
set_errno (EINVAL);
|
set_errno (EINVAL);
|
||||||
|
|
|
@ -125,7 +125,7 @@ setacl (const char *file, int nentries, aclent_t *aclbufp)
|
||||||
if (aclbufp[i].a_perm & S_IXOTH)
|
if (aclbufp[i].a_perm & S_IXOTH)
|
||||||
allow |= FILE_GENERIC_EXECUTE;
|
allow |= FILE_GENERIC_EXECUTE;
|
||||||
if ((aclbufp[i].a_perm & (S_IWOTH | S_IXOTH)) == (S_IWOTH | S_IXOTH))
|
if ((aclbufp[i].a_perm & (S_IWOTH | S_IXOTH)) == (S_IWOTH | S_IXOTH))
|
||||||
allow |= FILE_DELETE_CHILD;
|
allow |= FILE_DELETE_CHILD;
|
||||||
/* Set inherit property. */
|
/* Set inherit property. */
|
||||||
DWORD inheritance = (aclbufp[i].a_type & ACL_DEFAULT)
|
DWORD inheritance = (aclbufp[i].a_type & ACL_DEFAULT)
|
||||||
? INHERIT_ONLY : DONT_INHERIT;
|
? INHERIT_ONLY : DONT_INHERIT;
|
||||||
|
@ -433,7 +433,7 @@ acl_access (const char *path, int flags)
|
||||||
&& owner == group
|
&& owner == group
|
||||||
&& is_grp_member (myself->uid, gr->gr_gid))
|
&& is_grp_member (myself->uid, gr->gr_gid))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!gr)
|
if (!gr)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,12 +36,12 @@ details. */
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
|
||||||
SID_IDENTIFIER_AUTHORITY sid_auth[] = {
|
SID_IDENTIFIER_AUTHORITY sid_auth[] = {
|
||||||
{SECURITY_NULL_SID_AUTHORITY},
|
{SECURITY_NULL_SID_AUTHORITY},
|
||||||
{SECURITY_WORLD_SID_AUTHORITY},
|
{SECURITY_WORLD_SID_AUTHORITY},
|
||||||
{SECURITY_LOCAL_SID_AUTHORITY},
|
{SECURITY_LOCAL_SID_AUTHORITY},
|
||||||
{SECURITY_CREATOR_SID_AUTHORITY},
|
{SECURITY_CREATOR_SID_AUTHORITY},
|
||||||
{SECURITY_NON_UNIQUE_AUTHORITY},
|
{SECURITY_NON_UNIQUE_AUTHORITY},
|
||||||
{SECURITY_NT_AUTHORITY}
|
{SECURITY_NT_AUTHORITY}
|
||||||
};
|
};
|
||||||
|
|
||||||
cygsid well_known_null_sid ("S-1-0-0");
|
cygsid well_known_null_sid ("S-1-0-0");
|
||||||
|
@ -348,7 +348,7 @@ set_process_privilege (const char *privilege, BOOL enable)
|
||||||
DWORD size;
|
DWORD size;
|
||||||
|
|
||||||
if (!OpenProcessToken (hMainProc, TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES,
|
if (!OpenProcessToken (hMainProc, TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES,
|
||||||
&hToken))
|
&hToken))
|
||||||
{
|
{
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -365,7 +365,7 @@ set_process_privilege (const char *privilege, BOOL enable)
|
||||||
new_priv.Privileges[0].Attributes = enable ? SE_PRIVILEGE_ENABLED : 0;
|
new_priv.Privileges[0].Attributes = enable ? SE_PRIVILEGE_ENABLED : 0;
|
||||||
|
|
||||||
if (!AdjustTokenPrivileges (hToken, FALSE, &new_priv,
|
if (!AdjustTokenPrivileges (hToken, FALSE, &new_priv,
|
||||||
sizeof orig_priv, &orig_priv, &size))
|
sizeof orig_priv, &orig_priv, &size))
|
||||||
{
|
{
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -83,7 +83,7 @@ extract_nt_dom_user (const struct passwd *pw, char *domain, char *user)
|
||||||
if (pw->pw_gecos)
|
if (pw->pw_gecos)
|
||||||
{
|
{
|
||||||
if ((c = strstr (pw->pw_gecos, "U-")) != NULL &&
|
if ((c = strstr (pw->pw_gecos, "U-")) != NULL &&
|
||||||
(c == pw->pw_gecos || c[-1] == ','))
|
(c == pw->pw_gecos || c[-1] == ','))
|
||||||
{
|
{
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
strncat (buf, c + 2, INTERNET_MAX_HOST_NAME_LENGTH + UNLEN + 1);
|
strncat (buf, c + 2, INTERNET_MAX_HOST_NAME_LENGTH + UNLEN + 1);
|
||||||
|
@ -210,7 +210,7 @@ get_lsa_srv_inf (LSA_HANDLE lsa, char *logonserver, char *domain)
|
||||||
PPOLICY_PRIMARY_DOMAIN_INFO pdi;
|
PPOLICY_PRIMARY_DOMAIN_INFO pdi;
|
||||||
|
|
||||||
if ((ret = LsaQueryInformationPolicy (lsa, PolicyAccountDomainInformation,
|
if ((ret = LsaQueryInformationPolicy (lsa, PolicyAccountDomainInformation,
|
||||||
(PVOID *) &adi)) != STATUS_SUCCESS)
|
(PVOID *) &adi)) != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
set_errno (LsaNtStatusToWinError(ret));
|
set_errno (LsaNtStatusToWinError(ret));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -218,7 +218,7 @@ get_lsa_srv_inf (LSA_HANDLE lsa, char *logonserver, char *domain)
|
||||||
lsa2wchar (account, adi->DomainName, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
lsa2wchar (account, adi->DomainName, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||||
LsaFreeMemory (adi);
|
LsaFreeMemory (adi);
|
||||||
if ((ret = LsaQueryInformationPolicy (lsa, PolicyPrimaryDomainInformation,
|
if ((ret = LsaQueryInformationPolicy (lsa, PolicyPrimaryDomainInformation,
|
||||||
(PVOID *) &pdi)) != STATUS_SUCCESS)
|
(PVOID *) &pdi)) != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
set_errno (LsaNtStatusToWinError(ret));
|
set_errno (LsaNtStatusToWinError(ret));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -226,18 +226,18 @@ get_lsa_srv_inf (LSA_HANDLE lsa, char *logonserver, char *domain)
|
||||||
lsa2wchar (primary, pdi->Name, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
lsa2wchar (primary, pdi->Name, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||||
LsaFreeMemory (pdi);
|
LsaFreeMemory (pdi);
|
||||||
if ((ret = NetServerEnum (NULL, 101, (LPBYTE *) &buf, MAX_PREFERRED_LENGTH,
|
if ((ret = NetServerEnum (NULL, 101, (LPBYTE *) &buf, MAX_PREFERRED_LENGTH,
|
||||||
&cnt, &tot, SV_TYPE_DOMAIN_CTRL, primary, NULL))
|
&cnt, &tot, SV_TYPE_DOMAIN_CTRL, primary, NULL))
|
||||||
== STATUS_SUCCESS && cnt > 0)
|
== STATUS_SUCCESS && cnt > 0)
|
||||||
{
|
{
|
||||||
sys_wcstombs (name, buf[0].sv101_name, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
sys_wcstombs (name, buf[0].sv101_name, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||||
if (domain)
|
if (domain)
|
||||||
sys_wcstombs (domain, primary, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
sys_wcstombs (domain, primary, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sys_wcstombs (name, account, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
sys_wcstombs (name, account, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||||
if (domain)
|
if (domain)
|
||||||
sys_wcstombs (domain, account, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
sys_wcstombs (domain, account, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||||
}
|
}
|
||||||
if (ret == STATUS_SUCCESS)
|
if (ret == STATUS_SUCCESS)
|
||||||
NetApiBufferFree (buf);
|
NetApiBufferFree (buf);
|
||||||
|
@ -298,19 +298,19 @@ get_user_groups (WCHAR *wlogonserver, cygsidlist &grp_list, char *user)
|
||||||
|
|
||||||
sys_wcstombs (group, buf[i].grui0_name, UNLEN + 1);
|
sys_wcstombs (group, buf[i].grui0_name, UNLEN + 1);
|
||||||
if (!LookupAccountName (NULL, group, gsid, &glen, domain, &dlen, &use))
|
if (!LookupAccountName (NULL, group, gsid, &glen, domain, &dlen, &use))
|
||||||
debug_printf ("LookupAccountName(%s): %lu\n", group, GetLastError ());
|
debug_printf ("LookupAccountName(%s): %lu\n", group, GetLastError ());
|
||||||
if (!legal_sid_type (use))
|
if (!legal_sid_type (use))
|
||||||
{
|
{
|
||||||
strcat (strcpy (group, domain), "\\");
|
strcat (strcpy (group, domain), "\\");
|
||||||
sys_wcstombs (group + strlen (group), buf[i].grui0_name,
|
sys_wcstombs (group + strlen (group), buf[i].grui0_name,
|
||||||
UNLEN + 1 - strlen (group));
|
UNLEN + 1 - strlen (group));
|
||||||
glen = UNLEN + 1;
|
glen = UNLEN + 1;
|
||||||
dlen = INTERNET_MAX_HOST_NAME_LENGTH + 1;
|
dlen = INTERNET_MAX_HOST_NAME_LENGTH + 1;
|
||||||
if (!LookupAccountName(NULL, group, gsid, &glen, domain, &dlen, &use))
|
if (!LookupAccountName(NULL, group, gsid, &glen, domain, &dlen, &use))
|
||||||
debug_printf ("LookupAccountName(%s): %lu\n", group,GetLastError());
|
debug_printf ("LookupAccountName(%s): %lu\n", group,GetLastError());
|
||||||
}
|
}
|
||||||
if (legal_sid_type (use))
|
if (legal_sid_type (use))
|
||||||
grp_list += gsid;
|
grp_list += gsid;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetApiBufferFree (buf);
|
NetApiBufferFree (buf);
|
||||||
|
@ -319,7 +319,7 @@ get_user_groups (WCHAR *wlogonserver, cygsidlist &grp_list, char *user)
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
is_group_member (WCHAR *wlogonserver, WCHAR *wgroup,
|
is_group_member (WCHAR *wlogonserver, WCHAR *wgroup,
|
||||||
cygsid &usersid, cygsidlist &grp_list)
|
cygsid &usersid, cygsidlist &grp_list)
|
||||||
{
|
{
|
||||||
LPLOCALGROUP_MEMBERS_INFO_0 buf;
|
LPLOCALGROUP_MEMBERS_INFO_0 buf;
|
||||||
DWORD cnt, tot;
|
DWORD cnt, tot;
|
||||||
|
@ -390,7 +390,7 @@ get_user_local_groups (WCHAR *wlogonserver, const char *logonserver,
|
||||||
{
|
{
|
||||||
strcat (strcpy (group, domain), "\\");
|
strcat (strcpy (group, domain), "\\");
|
||||||
sys_wcstombs (group + strlen (group), buf[i].lgrpi0_name,
|
sys_wcstombs (group + strlen (group), buf[i].lgrpi0_name,
|
||||||
UNLEN + 1 - strlen (group));
|
UNLEN + 1 - strlen (group));
|
||||||
glen = UNLEN + 1;
|
glen = UNLEN + 1;
|
||||||
dlen = INTERNET_MAX_HOST_NAME_LENGTH + 1;
|
dlen = INTERNET_MAX_HOST_NAME_LENGTH + 1;
|
||||||
if (!LookupAccountName (NULL, group, gsid, &glen,
|
if (!LookupAccountName (NULL, group, gsid, &glen,
|
||||||
|
@ -565,7 +565,7 @@ get_system_priv_list (cygsidlist &grp_list)
|
||||||
{
|
{
|
||||||
privs->Privileges[privs->PrivilegeCount].Luid = priv;
|
privs->Privileges[privs->PrivilegeCount].Luid = priv;
|
||||||
privs->Privileges[privs->PrivilegeCount].Attributes =
|
privs->Privileges[privs->PrivilegeCount].Attributes =
|
||||||
SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT;
|
SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT;
|
||||||
++privs->PrivilegeCount;
|
++privs->PrivilegeCount;
|
||||||
}
|
}
|
||||||
return privs;
|
return privs;
|
||||||
|
@ -586,52 +586,52 @@ get_priv_list (LSA_HANDLE lsa, cygsid &usersid, cygsidlist &grp_list)
|
||||||
for (int grp = -1; grp < grp_list.count; ++grp)
|
for (int grp = -1; grp < grp_list.count; ++grp)
|
||||||
{
|
{
|
||||||
if (grp == -1)
|
if (grp == -1)
|
||||||
{
|
{
|
||||||
if ((ret = LsaEnumerateAccountRights (lsa, usersid, &privstrs, &cnt))
|
if ((ret = LsaEnumerateAccountRights (lsa, usersid, &privstrs, &cnt))
|
||||||
!= STATUS_SUCCESS)
|
!= STATUS_SUCCESS)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if ((ret = LsaEnumerateAccountRights (lsa, grp_list.sids[grp],
|
else if ((ret = LsaEnumerateAccountRights (lsa, grp_list.sids[grp],
|
||||||
&privstrs, &cnt))
|
&privstrs, &cnt))
|
||||||
!= STATUS_SUCCESS)
|
!= STATUS_SUCCESS)
|
||||||
continue;
|
continue;
|
||||||
for (ULONG i = 0; i < cnt; ++i)
|
for (ULONG i = 0; i < cnt; ++i)
|
||||||
{
|
{
|
||||||
LUID priv;
|
LUID priv;
|
||||||
PTOKEN_PRIVILEGES tmp;
|
PTOKEN_PRIVILEGES tmp;
|
||||||
DWORD tmp_count;
|
DWORD tmp_count;
|
||||||
|
|
||||||
sys_wcstombs (buf, privstrs[i].Buffer,
|
sys_wcstombs (buf, privstrs[i].Buffer,
|
||||||
INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||||
if (!LookupPrivilegeValue (NULL, buf, &priv))
|
if (!LookupPrivilegeValue (NULL, buf, &priv))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (DWORD p = 0; privs && p < privs->PrivilegeCount; ++p)
|
for (DWORD p = 0; privs && p < privs->PrivilegeCount; ++p)
|
||||||
if (!memcmp (&priv, &privs->Privileges[p].Luid, sizeof (LUID)))
|
if (!memcmp (&priv, &privs->Privileges[p].Luid, sizeof (LUID)))
|
||||||
goto next_account_right;
|
goto next_account_right;
|
||||||
|
|
||||||
tmp_count = privs ? privs->PrivilegeCount : 0;
|
tmp_count = privs ? privs->PrivilegeCount : 0;
|
||||||
tmp = (PTOKEN_PRIVILEGES)
|
tmp = (PTOKEN_PRIVILEGES)
|
||||||
realloc (privs, sizeof (ULONG) +
|
realloc (privs, sizeof (ULONG) +
|
||||||
(tmp_count + 1) * sizeof (LUID_AND_ATTRIBUTES));
|
(tmp_count + 1) * sizeof (LUID_AND_ATTRIBUTES));
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
{
|
{
|
||||||
if (privs)
|
if (privs)
|
||||||
free (privs);
|
free (privs);
|
||||||
LsaFreeMemory (privstrs);
|
LsaFreeMemory (privstrs);
|
||||||
debug_printf ("realloc (privs) failed.");
|
debug_printf ("realloc (privs) failed.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
tmp->PrivilegeCount = tmp_count;
|
tmp->PrivilegeCount = tmp_count;
|
||||||
privs = tmp;
|
privs = tmp;
|
||||||
privs->Privileges[privs->PrivilegeCount].Luid = priv;
|
privs->Privileges[privs->PrivilegeCount].Luid = priv;
|
||||||
privs->Privileges[privs->PrivilegeCount].Attributes =
|
privs->Privileges[privs->PrivilegeCount].Attributes =
|
||||||
SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT;
|
SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT;
|
||||||
++privs->PrivilegeCount;
|
++privs->PrivilegeCount;
|
||||||
|
|
||||||
next_account_right:
|
next_account_right:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
LsaFreeMemory (privstrs);
|
LsaFreeMemory (privstrs);
|
||||||
}
|
}
|
||||||
return privs;
|
return privs;
|
||||||
|
@ -652,10 +652,10 @@ get_dacl (PACL acl, cygsid usersid, cygsidlist &grp_list)
|
||||||
{
|
{
|
||||||
if (!AddAccessAllowedAce(acl, ACL_REVISION, GENERIC_ALL,
|
if (!AddAccessAllowedAce(acl, ACL_REVISION, GENERIC_ALL,
|
||||||
well_known_admins_sid))
|
well_known_admins_sid))
|
||||||
{
|
{
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!AddAccessAllowedAce(acl, ACL_REVISION, GENERIC_ALL, usersid))
|
else if (!AddAccessAllowedAce(acl, ACL_REVISION, GENERIC_ALL, usersid))
|
||||||
{
|
{
|
||||||
|
@ -712,7 +712,7 @@ create_token (cygsid &usersid, cygsid &pgrpsid)
|
||||||
/* SE_CREATE_TOKEN_NAME privilege needed to call NtCreateToken. */
|
/* SE_CREATE_TOKEN_NAME privilege needed to call NtCreateToken. */
|
||||||
if ((old_priv_state = set_process_privilege (SE_CREATE_TOKEN_NAME)) < 0)
|
if ((old_priv_state = set_process_privilege (SE_CREATE_TOKEN_NAME)) < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* Open policy object. */
|
/* Open policy object. */
|
||||||
if ((lsa = open_local_policy ()) == INVALID_HANDLE_VALUE)
|
if ((lsa = open_local_policy ()) == INVALID_HANDLE_VALUE)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -1191,7 +1191,7 @@ get_nt_attribute (const char *file, int *attribute,
|
||||||
*flags |= S_ISVTX;
|
*flags |= S_ISVTX;
|
||||||
}
|
}
|
||||||
else if (ace_sid == well_known_null_sid)
|
else if (ace_sid == well_known_null_sid)
|
||||||
{
|
{
|
||||||
/* Read SUID, SGID and VTX bits from NULL ACE. */
|
/* Read SUID, SGID and VTX bits from NULL ACE. */
|
||||||
if (ace->Mask & FILE_READ_DATA)
|
if (ace->Mask & FILE_READ_DATA)
|
||||||
*flags |= S_ISVTX;
|
*flags |= S_ISVTX;
|
||||||
|
@ -1416,11 +1416,11 @@ alloc_sd (uid_t uid, gid_t gid, const char *logsrv, int attribute,
|
||||||
if (attribute & (S_ISUID | S_ISGID | S_ISVTX))
|
if (attribute & (S_ISUID | S_ISGID | S_ISVTX))
|
||||||
{
|
{
|
||||||
if (attribute & S_ISUID)
|
if (attribute & S_ISUID)
|
||||||
null_allow |= FILE_APPEND_DATA;
|
null_allow |= FILE_APPEND_DATA;
|
||||||
if (attribute & S_ISGID)
|
if (attribute & S_ISGID)
|
||||||
null_allow |= FILE_WRITE_DATA;
|
null_allow |= FILE_WRITE_DATA;
|
||||||
if (attribute & S_ISVTX)
|
if (attribute & S_ISVTX)
|
||||||
null_allow |= FILE_READ_DATA;
|
null_allow |= FILE_READ_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Construct deny attributes for owner and group. */
|
/* Construct deny attributes for owner and group. */
|
||||||
|
@ -1548,7 +1548,7 @@ set_security_attribute (int attribute, PSECURITY_ATTRIBUTES psa,
|
||||||
|
|
||||||
psa->lpSecurityDescriptor = sd_buf;
|
psa->lpSecurityDescriptor = sd_buf;
|
||||||
InitializeSecurityDescriptor ((PSECURITY_DESCRIPTOR)sd_buf,
|
InitializeSecurityDescriptor ((PSECURITY_DESCRIPTOR)sd_buf,
|
||||||
SECURITY_DESCRIPTOR_REVISION);
|
SECURITY_DESCRIPTOR_REVISION);
|
||||||
psa->lpSecurityDescriptor = alloc_sd (geteuid (), getegid (),
|
psa->lpSecurityDescriptor = alloc_sd (geteuid (), getegid (),
|
||||||
cygheap->user.logsrv (),
|
cygheap->user.logsrv (),
|
||||||
attribute, (PSECURITY_DESCRIPTOR)sd_buf,
|
attribute, (PSECURITY_DESCRIPTOR)sd_buf,
|
||||||
|
|
|
@ -29,12 +29,12 @@ class cygsid {
|
||||||
inline const PSID assign (const PSID nsid)
|
inline const PSID assign (const PSID nsid)
|
||||||
{
|
{
|
||||||
if (!nsid)
|
if (!nsid)
|
||||||
psid = NO_SID;
|
psid = NO_SID;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
psid = (PSID) sbuf;
|
psid = (PSID) sbuf;
|
||||||
CopySid (MAX_SID_LEN, psid, nsid);
|
CopySid (MAX_SID_LEN, psid, nsid);
|
||||||
}
|
}
|
||||||
return psid;
|
return psid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public:
|
||||||
inline BOOL operator== (const PSID nsid) const
|
inline BOOL operator== (const PSID nsid) const
|
||||||
{
|
{
|
||||||
if (!psid || !nsid)
|
if (!psid || !nsid)
|
||||||
return nsid == psid;
|
return nsid == psid;
|
||||||
return EqualSid (psid, nsid);
|
return EqualSid (psid, nsid);
|
||||||
}
|
}
|
||||||
inline BOOL operator== (const char *nsidstr) const
|
inline BOOL operator== (const char *nsidstr) const
|
||||||
|
@ -98,9 +98,9 @@ public:
|
||||||
{
|
{
|
||||||
cygsid *tmp = new cygsid [count + 1];
|
cygsid *tmp = new cygsid [count + 1];
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
tmp[i] = sids[i];
|
tmp[i] = sids[i];
|
||||||
delete [] sids;
|
delete [] sids;
|
||||||
sids = tmp;
|
sids = tmp;
|
||||||
sids[count++] = nsi;
|
sids[count++] = nsi;
|
||||||
|
@ -116,7 +116,7 @@ public:
|
||||||
BOOL contains (cygsid &sid) const
|
BOOL contains (cygsid &sid) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
if (sids[i] == sid)
|
if (sids[i] == sid)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -124,9 +124,9 @@ public:
|
||||||
{
|
{
|
||||||
debug_printf ("-- begin sidlist ---");
|
debug_printf ("-- begin sidlist ---");
|
||||||
if (!count)
|
if (!count)
|
||||||
debug_printf ("No elements");
|
debug_printf ("No elements");
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
sids[i].debug_print (prefix);
|
sids[i].debug_print (prefix);
|
||||||
debug_printf ("-- ende sidlist ---");
|
debug_printf ("-- ende sidlist ---");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -151,7 +151,6 @@ memory_init ()
|
||||||
cygwin_shared_address);
|
cygwin_shared_address);
|
||||||
|
|
||||||
cygwin_shared->initialize ();
|
cygwin_shared->initialize ();
|
||||||
heap_init ();
|
|
||||||
|
|
||||||
/* Allocate memory for the per-user mount table */
|
/* Allocate memory for the per-user mount table */
|
||||||
char user_name[UNLEN + 1];
|
char user_name[UNLEN + 1];
|
||||||
|
@ -159,12 +158,6 @@ memory_init ()
|
||||||
|
|
||||||
if (!GetUserName (user_name, &user_name_len))
|
if (!GetUserName (user_name, &user_name_len))
|
||||||
strcpy (user_name, "unknown");
|
strcpy (user_name, "unknown");
|
||||||
mount_table = (mount_info *) open_shared (user_name, cygwin_mount_h,
|
|
||||||
sizeof (mount_info), 0);
|
|
||||||
debug_printf ("opening mount table for '%s' at %p", cygheap->user.name (),
|
|
||||||
mount_table_address);
|
|
||||||
ProtectHandle (cygwin_mount_h);
|
|
||||||
debug_printf ("mount table version %x at %p", mount_table->version, mount_table);
|
|
||||||
|
|
||||||
/* Initialize the Cygwin heap, if necessary */
|
/* Initialize the Cygwin heap, if necessary */
|
||||||
if (!cygheap)
|
if (!cygheap)
|
||||||
|
@ -172,9 +165,18 @@ memory_init ()
|
||||||
cygheap_init ();
|
cygheap_init ();
|
||||||
cygheap->user.set_name (user_name);
|
cygheap->user.set_name (user_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
cygheap->shared_h = shared_h;
|
cygheap->shared_h = shared_h;
|
||||||
ProtectHandle (cygheap->shared_h);
|
ProtectHandle (cygheap->shared_h);
|
||||||
|
|
||||||
|
heap_init ();
|
||||||
|
mount_table = (mount_info *) open_shared (user_name, cygwin_mount_h,
|
||||||
|
sizeof (mount_info), 0);
|
||||||
|
debug_printf ("opening mount table for '%s' at %p", cygheap->user.name (),
|
||||||
|
mount_table_address);
|
||||||
|
ProtectHandle (cygwin_mount_h);
|
||||||
|
debug_printf ("mount table version %x at %p", mount_table->version, mount_table);
|
||||||
|
|
||||||
/* Initialize the Cygwin per-user mount table, if necessary */
|
/* Initialize the Cygwin per-user mount table, if necessary */
|
||||||
if (!mount_table->version)
|
if (!mount_table->version)
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,7 +85,7 @@ class mount_info
|
||||||
int write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsigned flags);
|
int write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsigned flags);
|
||||||
int remove_cygdrive_info_from_registry (const char *cygdrive_prefix, unsigned flags);
|
int remove_cygdrive_info_from_registry (const char *cygdrive_prefix, unsigned flags);
|
||||||
int get_cygdrive_info (char *user, char *system, char* user_flags,
|
int get_cygdrive_info (char *user, char *system, char* user_flags,
|
||||||
char* system_flags);
|
char* system_flags);
|
||||||
|
|
||||||
void import_v1_mounts ();
|
void import_v1_mounts ();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* shortcut.c: Read shortcuts. This part of the code must be in C because
|
/* shortcut.c: Read shortcuts. This part of the code must be in C because
|
||||||
the C++ interface to COM doesn't work without -fvtable-thunk
|
the C++ interface to COM doesn't work without -fvtable-thunk
|
||||||
which is too dangerous to use.
|
which is too dangerous to use.
|
||||||
|
|
||||||
Copyright 2001 Red Hat, Inc.
|
Copyright 2001 Red Hat, Inc.
|
||||||
|
@ -107,7 +107,7 @@ check_shortcut (const char *path, DWORD fileattr, HANDLE h,
|
||||||
{
|
{
|
||||||
/* Check header if the shortcut is really created by Cygwin or U/WIN. */
|
/* Check header if the shortcut is really created by Cygwin or U/WIN. */
|
||||||
if (got == SHORTCUT_HDR_SIZE && !cmp_shortcut_header (file_header))
|
if (got == SHORTCUT_HDR_SIZE && !cmp_shortcut_header (file_header))
|
||||||
{
|
{
|
||||||
hres = psl->lpVtbl->GetDescription (psl, contents, MAX_PATH);
|
hres = psl->lpVtbl->GetDescription (psl, contents, MAX_PATH);
|
||||||
if (FAILED (hres))
|
if (FAILED (hres))
|
||||||
goto file_not_symlink;
|
goto file_not_symlink;
|
||||||
|
|
|
@ -224,8 +224,8 @@ kill_pgrp (pid_t pid, int sig)
|
||||||
|
|
||||||
/* Is it a process we want to kill? */
|
/* Is it a process we want to kill? */
|
||||||
if ((pid == 0 && (p->pgid != myself->pgid || p->ctty != myself->ctty)) ||
|
if ((pid == 0 && (p->pgid != myself->pgid || p->ctty != myself->ctty)) ||
|
||||||
(pid > 1 && p->pgid != pid) ||
|
(pid > 1 && p->pgid != pid) ||
|
||||||
(sig < 0 && NOTSTATE(p, PID_STOPPED)))
|
(sig < 0 && NOTSTATE(p, PID_STOPPED)))
|
||||||
continue;
|
continue;
|
||||||
sigproc_printf ("killing pid %d, pgrp %d, p->ctty %d, myself->ctty %d",
|
sigproc_printf ("killing pid %d, pgrp %d, p->ctty %d, myself->ctty %d",
|
||||||
p->pid, p->pgid, p->ctty, myself->ctty);
|
p->pid, p->pgid, p->ctty, myself->ctty);
|
||||||
|
|
|
@ -303,8 +303,6 @@ proc_subproc (DWORD what, DWORD val)
|
||||||
|
|
||||||
int thiszombie;
|
int thiszombie;
|
||||||
thiszombie = nzombies;
|
thiszombie = nzombies;
|
||||||
if (!zombies)
|
|
||||||
zombies = (pinfo *) malloc (sizeof (pinfo) * ZOMBIEMAX);
|
|
||||||
zombies[nzombies] = pchildren[val]; // Add to zombie array
|
zombies[nzombies] = pchildren[val]; // Add to zombie array
|
||||||
zombies[nzombies++]->process_state = PID_ZOMBIE;// Walking dead
|
zombies[nzombies++]->process_state = PID_ZOMBIE;// Walking dead
|
||||||
|
|
||||||
|
@ -545,6 +543,11 @@ sig_dispatch_pending (int justwake)
|
||||||
void __stdcall
|
void __stdcall
|
||||||
sigproc_init ()
|
sigproc_init ()
|
||||||
{
|
{
|
||||||
|
if (!zombies)
|
||||||
|
zombies = (pinfo *) malloc (sizeof (pinfo) * ZOMBIEMAX);
|
||||||
|
else
|
||||||
|
nzombies = 0;
|
||||||
|
|
||||||
wait_sig_inited = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
|
wait_sig_inited = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
|
||||||
ProtectHandle (wait_sig_inited);
|
ProtectHandle (wait_sig_inited);
|
||||||
|
|
||||||
|
@ -1304,17 +1307,6 @@ wait_subproc (VOID *)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __stdcall
|
|
||||||
sigproc_fixup_after_fork ()
|
|
||||||
{
|
|
||||||
if (zombies)
|
|
||||||
{
|
|
||||||
free (zombies);
|
|
||||||
nzombies = 0;
|
|
||||||
zombies = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
/* Provide a stack frame when calling WaitFor* functions */
|
/* Provide a stack frame when calling WaitFor* functions */
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,6 @@ int __stdcall sig_send (_pinfo *, int, DWORD ebp = (DWORD) __builtin_frame_addre
|
||||||
bool exception = 0) __attribute__ ((regparm(3)));
|
bool exception = 0) __attribute__ ((regparm(3)));
|
||||||
void __stdcall signal_fixup_after_fork ();
|
void __stdcall signal_fixup_after_fork ();
|
||||||
void __stdcall signal_fixup_after_exec (bool);
|
void __stdcall signal_fixup_after_exec (bool);
|
||||||
void __stdcall sigproc_fixup_after_fork ();
|
|
||||||
|
|
||||||
extern char myself_nowait_dummy[];
|
extern char myself_nowait_dummy[];
|
||||||
extern char myself_nowait_nonmain_dummy[];
|
extern char myself_nowait_nonmain_dummy[];
|
||||||
|
|
|
@ -616,7 +616,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
|
||||||
cygsid sid;
|
cygsid sid;
|
||||||
DWORD ret_len;
|
DWORD ret_len;
|
||||||
if (!GetTokenInformation (hToken, TokenUser, &sid, sizeof sid, &ret_len))
|
if (!GetTokenInformation (hToken, TokenUser, &sid, sizeof sid, &ret_len))
|
||||||
{
|
{
|
||||||
sid = NO_SID;
|
sid = NO_SID;
|
||||||
system_printf ("GetTokenInformation: %E");
|
system_printf ("GetTokenInformation: %E");
|
||||||
}
|
}
|
||||||
|
@ -628,15 +628,15 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
|
||||||
|
|
||||||
/* Remove impersonation */
|
/* Remove impersonation */
|
||||||
if (cygheap->user.impersonated
|
if (cygheap->user.impersonated
|
||||||
&& cygheap->user.token != INVALID_HANDLE_VALUE)
|
&& cygheap->user.token != INVALID_HANDLE_VALUE)
|
||||||
RevertToSelf ();
|
RevertToSelf ();
|
||||||
|
|
||||||
static BOOL first_time = TRUE;
|
static BOOL first_time = TRUE;
|
||||||
if (first_time)
|
if (first_time)
|
||||||
{
|
{
|
||||||
set_process_privilege (SE_RESTORE_NAME);
|
set_process_privilege (SE_RESTORE_NAME);
|
||||||
first_time = FALSE;
|
first_time = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load users registry hive. */
|
/* Load users registry hive. */
|
||||||
load_registry_hive (sid);
|
load_registry_hive (sid);
|
||||||
|
@ -703,7 +703,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
|
||||||
{
|
{
|
||||||
cygheap->fdtab.fixup_before_exec (pi.dwProcessId);
|
cygheap->fdtab.fixup_before_exec (pi.dwProcessId);
|
||||||
if (mode == _P_OVERLAY)
|
if (mode == _P_OVERLAY)
|
||||||
ResumeThread (pi.hThread);
|
ResumeThread (pi.hThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == _P_OVERLAY)
|
if (mode == _P_OVERLAY)
|
||||||
|
|
|
@ -1138,7 +1138,7 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (atts != -1 && (oret || (!oret && get_errno () != ENOENT
|
if (atts != -1 && (oret || (!oret && get_errno () != ENOENT
|
||||||
&& get_errno () != ENOSHARE)))
|
&& get_errno () != ENOSHARE)))
|
||||||
{
|
{
|
||||||
/* Unfortunately, the above open may fail if the file exists, though.
|
/* Unfortunately, the above open may fail if the file exists, though.
|
||||||
So we have to care for this case here, too. */
|
So we have to care for this case here, too. */
|
||||||
|
@ -1340,7 +1340,7 @@ _rename (const char *oldpath, const char *newpath)
|
||||||
if (real_new.file_attributes () != (DWORD) -1 &&
|
if (real_new.file_attributes () != (DWORD) -1 &&
|
||||||
real_new.file_attributes () & FILE_ATTRIBUTE_READONLY)
|
real_new.file_attributes () & FILE_ATTRIBUTE_READONLY)
|
||||||
SetFileAttributesA (real_new.get_win32 (),
|
SetFileAttributesA (real_new.get_win32 (),
|
||||||
real_new.file_attributes () & ~FILE_ATTRIBUTE_READONLY);
|
real_new.file_attributes () & ~FILE_ATTRIBUTE_READONLY);
|
||||||
|
|
||||||
/* Shortcut hack No. 2, part 1 */
|
/* Shortcut hack No. 2, part 1 */
|
||||||
if (!real_old.issymlink () && !real_new.error && real_new.issymlink () &&
|
if (!real_old.issymlink () && !real_new.error && real_new.issymlink () &&
|
||||||
|
@ -1400,9 +1400,9 @@ done:
|
||||||
|
|
||||||
/* Shortcut hack, No. 2, part 2 */
|
/* Shortcut hack, No. 2, part 2 */
|
||||||
/* if the new filename was an existing shortcut, remove it now if the
|
/* if the new filename was an existing shortcut, remove it now if the
|
||||||
new filename is equal to the shortcut name without .lnk suffix. */
|
new filename is equal to the shortcut name without .lnk suffix. */
|
||||||
if (lnk_suffix)
|
if (lnk_suffix)
|
||||||
{
|
{
|
||||||
*lnk_suffix = '.';
|
*lnk_suffix = '.';
|
||||||
DeleteFile (real_new.get_win32 ());
|
DeleteFile (real_new.get_win32 ());
|
||||||
}
|
}
|
||||||
|
@ -1494,7 +1494,7 @@ check_posix_perm (const char *fname, int v)
|
||||||
|
|
||||||
if (!allow_smbntsec
|
if (!allow_smbntsec
|
||||||
&& ((root[0] == '\\' && root[1] == '\\')
|
&& ((root[0] == '\\' && root[1] == '\\')
|
||||||
|| GetDriveType (root) == DRIVE_REMOTE))
|
|| GetDriveType (root) == DRIVE_REMOTE))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
DWORD vsn, len, flags;
|
DWORD vsn, len, flags;
|
||||||
|
@ -1584,7 +1584,7 @@ pathconf (const char *file, int v)
|
||||||
case _PC_POSIX_PERMISSIONS:
|
case _PC_POSIX_PERMISSIONS:
|
||||||
case _PC_POSIX_SECURITY:
|
case _PC_POSIX_SECURITY:
|
||||||
{
|
{
|
||||||
path_conv full_path (file, PC_SYM_FOLLOW | PC_FULL);
|
path_conv full_path (file, PC_SYM_FOLLOW | PC_FULL);
|
||||||
if (full_path.error)
|
if (full_path.error)
|
||||||
{
|
{
|
||||||
set_errno (full_path.error);
|
set_errno (full_path.error);
|
||||||
|
@ -1595,7 +1595,7 @@ pathconf (const char *file, int v)
|
||||||
set_errno (EINVAL);
|
set_errno (EINVAL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return check_posix_perm (full_path, v);
|
return check_posix_perm (full_path, v);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
set_errno (EINVAL);
|
set_errno (EINVAL);
|
||||||
|
@ -2048,9 +2048,9 @@ seteuid (uid_t uid)
|
||||||
char *env;
|
char *env;
|
||||||
orig_username[0] = orig_domain[0] = '\0';
|
orig_username[0] = orig_domain[0] = '\0';
|
||||||
if ((env = getenv ("USERNAME")))
|
if ((env = getenv ("USERNAME")))
|
||||||
strncat (orig_username, env, UNLEN + 1);
|
strncat (orig_username, env, UNLEN + 1);
|
||||||
if ((env = getenv ("USERDOMAIN")))
|
if ((env = getenv ("USERDOMAIN")))
|
||||||
strncat (orig_domain, env, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
strncat (orig_domain, env, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||||
if (uid == cygheap->user.orig_uid)
|
if (uid == cygheap->user.orig_uid)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -2064,7 +2064,7 @@ seteuid (uid_t uid)
|
||||||
if (!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &ptok))
|
if (!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &ptok))
|
||||||
debug_printf ("OpenProcessToken(): %E\n");
|
debug_printf ("OpenProcessToken(): %E\n");
|
||||||
else if (!GetTokenInformation (ptok, TokenUser, &tok_usersid,
|
else if (!GetTokenInformation (ptok, TokenUser, &tok_usersid,
|
||||||
sizeof tok_usersid, &siz))
|
sizeof tok_usersid, &siz))
|
||||||
debug_printf ("GetTokenInformation(): %E");
|
debug_printf ("GetTokenInformation(): %E");
|
||||||
else if (!LookupAccountSid (NULL, tok_usersid, username, &ulen,
|
else if (!LookupAccountSid (NULL, tok_usersid, username, &ulen,
|
||||||
domain, &dlen, &use))
|
domain, &dlen, &use))
|
||||||
|
@ -2100,7 +2100,7 @@ seteuid (uid_t uid)
|
||||||
&tok_usersid, sizeof tok_usersid, &siz))
|
&tok_usersid, sizeof tok_usersid, &siz))
|
||||||
{
|
{
|
||||||
debug_printf ("GetTokenInformation(): %E");
|
debug_printf ("GetTokenInformation(): %E");
|
||||||
tok_usersid = NO_SID;
|
tok_usersid = NO_SID;
|
||||||
}
|
}
|
||||||
if (!GetTokenInformation (cygheap->user.token, TokenPrimaryGroup,
|
if (!GetTokenInformation (cygheap->user.token, TokenPrimaryGroup,
|
||||||
&tok_pgrpsid, sizeof tok_pgrpsid, &siz))
|
&tok_pgrpsid, sizeof tok_pgrpsid, &siz))
|
||||||
|
@ -2119,7 +2119,7 @@ seteuid (uid_t uid)
|
||||||
/* Check for pgrp only if current token is an internal
|
/* Check for pgrp only if current token is an internal
|
||||||
token. Otherwise the external provided token is
|
token. Otherwise the external provided token is
|
||||||
very likely overwritten here. */
|
very likely overwritten here. */
|
||||||
(current_token_is_internal_token &&
|
(current_token_is_internal_token &&
|
||||||
pgrpsid && tok_pgrpsid && pgrpsid != tok_pgrpsid))
|
pgrpsid && tok_pgrpsid && pgrpsid != tok_pgrpsid))
|
||||||
{
|
{
|
||||||
/* If not, RevertToSelf and close old token. */
|
/* If not, RevertToSelf and close old token. */
|
||||||
|
@ -2143,19 +2143,19 @@ seteuid (uid_t uid)
|
||||||
if (ptok != INVALID_HANDLE_VALUE)
|
if (ptok != INVALID_HANDLE_VALUE)
|
||||||
explicitely_created_token = TRUE;
|
explicitely_created_token = TRUE;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* create_token failed. Try subauthentication. */
|
/* create_token failed. Try subauthentication. */
|
||||||
debug_printf ("create token failed, try subauthentication.");
|
debug_printf ("create token failed, try subauthentication.");
|
||||||
ptok = subauth (pw_new);
|
ptok = subauth (pw_new);
|
||||||
}
|
}
|
||||||
if (ptok != INVALID_HANDLE_VALUE)
|
if (ptok != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
cygwin_set_impersonation_token (ptok);
|
cygwin_set_impersonation_token (ptok);
|
||||||
/* If sav_token was internally created, destroy it. */
|
/* If sav_token was internally created, destroy it. */
|
||||||
if (sav_token != INVALID_HANDLE_VALUE &&
|
if (sav_token != INVALID_HANDLE_VALUE &&
|
||||||
current_token_is_internal_token)
|
current_token_is_internal_token)
|
||||||
CloseHandle (sav_token);
|
CloseHandle (sav_token);
|
||||||
}
|
}
|
||||||
else if (sav_token != INVALID_HANDLE_VALUE)
|
else if (sav_token != INVALID_HANDLE_VALUE)
|
||||||
cygheap->user.token = sav_token;
|
cygheap->user.token = sav_token;
|
||||||
}
|
}
|
||||||
|
@ -2168,9 +2168,9 @@ seteuid (uid_t uid)
|
||||||
RevertToSelf ();
|
RevertToSelf ();
|
||||||
|
|
||||||
/* If the token was explicitely created, all information has
|
/* If the token was explicitely created, all information has
|
||||||
already been set correctly. */
|
already been set correctly. */
|
||||||
if (!explicitely_created_token)
|
if (!explicitely_created_token)
|
||||||
{
|
{
|
||||||
/* Try setting owner to same value as user. */
|
/* Try setting owner to same value as user. */
|
||||||
if (usersid &&
|
if (usersid &&
|
||||||
!SetTokenInformation (cygheap->user.token, TokenOwner,
|
!SetTokenInformation (cygheap->user.token, TokenOwner,
|
||||||
|
@ -2186,7 +2186,7 @@ seteuid (uid_t uid)
|
||||||
debug_printf ("SetTokenInformation(user.token, "
|
debug_printf ("SetTokenInformation(user.token, "
|
||||||
"TokenPrimaryGroup): %E");
|
"TokenPrimaryGroup): %E");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now try to impersonate. */
|
/* Now try to impersonate. */
|
||||||
if (!LookupAccountSid (NULL, usersid, username, &ulen,
|
if (!LookupAccountSid (NULL, usersid, username, &ulen,
|
||||||
|
@ -2196,11 +2196,11 @@ seteuid (uid_t uid)
|
||||||
system_printf ("Impersonating (%d) in set(e)uid failed: %E",
|
system_printf ("Impersonating (%d) in set(e)uid failed: %E",
|
||||||
cygheap->user.token);
|
cygheap->user.token);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cygheap->user.impersonated = TRUE;
|
cygheap->user.impersonated = TRUE;
|
||||||
setenv ("USERNAME", username, 1);
|
setenv ("USERNAME", username, 1);
|
||||||
setenv ("USERDOMAIN", domain, 1);
|
setenv ("USERDOMAIN", domain, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2253,7 +2253,7 @@ setegid (gid_t gid)
|
||||||
HANDLE ptok;
|
HANDLE ptok;
|
||||||
|
|
||||||
if (gsid.getfromgr (gr))
|
if (gsid.getfromgr (gr))
|
||||||
{
|
{
|
||||||
if (!OpenProcessToken (GetCurrentProcess (),
|
if (!OpenProcessToken (GetCurrentProcess (),
|
||||||
TOKEN_ADJUST_DEFAULT,
|
TOKEN_ADJUST_DEFAULT,
|
||||||
&ptok))
|
&ptok))
|
||||||
|
@ -2261,12 +2261,12 @@ setegid (gid_t gid)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!SetTokenInformation (ptok, TokenPrimaryGroup,
|
if (!SetTokenInformation (ptok, TokenPrimaryGroup,
|
||||||
&gsid, sizeof gsid))
|
&gsid, sizeof gsid))
|
||||||
debug_printf ("SetTokenInformation(myself, "
|
debug_printf ("SetTokenInformation(myself, "
|
||||||
"TokenPrimaryGroup): %E");
|
"TokenPrimaryGroup): %E");
|
||||||
CloseHandle (ptok);
|
CloseHandle (ptok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,20 +61,20 @@ sysconf (int in)
|
||||||
/*FALLTHRU*/
|
/*FALLTHRU*/
|
||||||
case _SC_PHYS_PAGES:
|
case _SC_PHYS_PAGES:
|
||||||
case _SC_AVPHYS_PAGES:
|
case _SC_AVPHYS_PAGES:
|
||||||
{
|
{
|
||||||
NTSTATUS ret;
|
NTSTATUS ret;
|
||||||
SYSTEM_BASIC_INFORMATION sbi;
|
SYSTEM_BASIC_INFORMATION sbi;
|
||||||
if ((ret = NtQuerySystemInformation (SystemBasicInformation,
|
if ((ret = NtQuerySystemInformation (SystemBasicInformation,
|
||||||
(PVOID) &sbi,
|
(PVOID) &sbi,
|
||||||
sizeof sbi, NULL))
|
sizeof sbi, NULL))
|
||||||
!= STATUS_SUCCESS)
|
!= STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
__seterrno_from_win_error (RtlNtStatusToDosError (ret));
|
__seterrno_from_win_error (RtlNtStatusToDosError (ret));
|
||||||
debug_printf("NtQuerySystemInformation: ret = %d, "
|
debug_printf("NtQuerySystemInformation: ret = %d, "
|
||||||
"Dos(ret) = %d",
|
"Dos(ret) = %d",
|
||||||
ret, RtlNtStatusToDosError (ret));
|
ret, RtlNtStatusToDosError (ret));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
switch (in)
|
switch (in)
|
||||||
{
|
{
|
||||||
case _SC_NPROCESSORS_CONF:
|
case _SC_NPROCESSORS_CONF:
|
||||||
|
|
|
@ -102,11 +102,11 @@ settimeofday (const struct timeval *tv, const struct timezone *tz)
|
||||||
tz = tz; /* silence warning about unused variable */
|
tz = tz; /* silence warning about unused variable */
|
||||||
|
|
||||||
ptm = gmtime(&tv->tv_sec);
|
ptm = gmtime(&tv->tv_sec);
|
||||||
st.wYear = ptm->tm_year + 1900;
|
st.wYear = ptm->tm_year + 1900;
|
||||||
st.wMonth = ptm->tm_mon + 1;
|
st.wMonth = ptm->tm_mon + 1;
|
||||||
st.wDayOfWeek = ptm->tm_wday;
|
st.wDayOfWeek = ptm->tm_wday;
|
||||||
st.wDay = ptm->tm_mday;
|
st.wDay = ptm->tm_mday;
|
||||||
st.wHour = ptm->tm_hour;
|
st.wHour = ptm->tm_hour;
|
||||||
st.wMinute = ptm->tm_min;
|
st.wMinute = ptm->tm_min;
|
||||||
st.wSecond = ptm->tm_sec;
|
st.wSecond = ptm->tm_sec;
|
||||||
st.wMilliseconds = tv->tv_usec / 1000;
|
st.wMilliseconds = tv->tv_usec / 1000;
|
||||||
|
|
|
@ -63,13 +63,13 @@ internal_getlogin (cygheap_user &user)
|
||||||
sys_wcstombs (buf, wui->wkui1_username, UNLEN + 1);
|
sys_wcstombs (buf, wui->wkui1_username, UNLEN + 1);
|
||||||
user.set_name (buf);
|
user.set_name (buf);
|
||||||
sys_wcstombs (buf, wui->wkui1_logon_server,
|
sys_wcstombs (buf, wui->wkui1_logon_server,
|
||||||
INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||||
user.set_logsrv (buf);
|
user.set_logsrv (buf);
|
||||||
sys_wcstombs (buf, wui->wkui1_logon_domain,
|
sys_wcstombs (buf, wui->wkui1_logon_domain,
|
||||||
INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||||
user.set_domain (buf);
|
user.set_domain (buf);
|
||||||
NetApiBufferFree (wui);
|
NetApiBufferFree (wui);
|
||||||
}
|
}
|
||||||
if (!user.logsrv () && get_logon_server_and_user_domain (buf, NULL))
|
if (!user.logsrv () && get_logon_server_and_user_domain (buf, NULL))
|
||||||
{
|
{
|
||||||
user.set_logsrv (buf + 2);
|
user.set_logsrv (buf + 2);
|
||||||
|
@ -84,7 +84,7 @@ internal_getlogin (cygheap_user &user)
|
||||||
sys_mbstowcs (wuser, user.name (), UNLEN + 1);
|
sys_mbstowcs (wuser, user.name (), UNLEN + 1);
|
||||||
wlogsrv[0] = '\0';
|
wlogsrv[0] = '\0';
|
||||||
if (user.logsrv ())
|
if (user.logsrv ())
|
||||||
{
|
{
|
||||||
strcat (strcpy (buf, "\\\\"), user.logsrv ());
|
strcat (strcpy (buf, "\\\\"), user.logsrv ());
|
||||||
sys_mbstowcs (wlogsrv, buf, INTERNET_MAX_HOST_NAME_LENGTH + 3);
|
sys_mbstowcs (wlogsrv, buf, INTERNET_MAX_HOST_NAME_LENGTH + 3);
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ internal_getlogin (cygheap_user &user)
|
||||||
in a process token of a currently impersonated process. */
|
in a process token of a currently impersonated process. */
|
||||||
if (ptok == INVALID_HANDLE_VALUE
|
if (ptok == INVALID_HANDLE_VALUE
|
||||||
&& !OpenProcessToken (GetCurrentProcess (),
|
&& !OpenProcessToken (GetCurrentProcess (),
|
||||||
TOKEN_ADJUST_DEFAULT | TOKEN_QUERY,
|
TOKEN_ADJUST_DEFAULT | TOKEN_QUERY,
|
||||||
&ptok))
|
&ptok))
|
||||||
debug_printf ("OpenProcessToken(): %E\n");
|
debug_printf ("OpenProcessToken(): %E\n");
|
||||||
else if (!GetTokenInformation (ptok, TokenUser, &tu, sizeof tu, &siz))
|
else if (!GetTokenInformation (ptok, TokenUser, &tu, sizeof tu, &siz))
|
||||||
|
@ -188,7 +188,7 @@ internal_getlogin (cygheap_user &user)
|
||||||
if (!SetTokenInformation (ptok, TokenOwner, &tu, sizeof tu))
|
if (!SetTokenInformation (ptok, TokenOwner, &tu, sizeof tu))
|
||||||
debug_printf ("SetTokenInformation(TokenOwner): %E");
|
debug_printf ("SetTokenInformation(TokenOwner): %E");
|
||||||
if (gsid && !SetTokenInformation (ptok, TokenPrimaryGroup,
|
if (gsid && !SetTokenInformation (ptok, TokenPrimaryGroup,
|
||||||
&gsid, sizeof gsid))
|
&gsid, sizeof gsid))
|
||||||
debug_printf ("SetTokenInformation(TokenPrimaryGroup): %E");
|
debug_printf ("SetTokenInformation(TokenPrimaryGroup): %E");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ uname (struct utsname *name)
|
||||||
else
|
else
|
||||||
ptype = sysinfo.dwProcessorType;
|
ptype = sysinfo.dwProcessorType;
|
||||||
|
|
||||||
__small_sprintf (name->machine, "i%d86", ptype);
|
__small_sprintf (name->machine, "i%d86", ptype);
|
||||||
break;
|
break;
|
||||||
case PROCESSOR_ARCHITECTURE_ALPHA:
|
case PROCESSOR_ARCHITECTURE_ALPHA:
|
||||||
strcpy (name->machine, "alpha");
|
strcpy (name->machine, "alpha");
|
||||||
|
|
Loading…
Reference in New Issue