Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConrad Scott <conrad.scott@dsl.pipex.com>2002-06-28 22:15:48 +0400
committerConrad Scott <conrad.scott@dsl.pipex.com>2002-06-28 22:15:48 +0400
commit1f46dfd90c580baf71bd08285fdf89db0cb809b7 (patch)
tree0d9b6f9e35cac3ba319dbb61f276b28338e763fd /winsup/cygwin
parentbb2d1b84c6dd6b0dd091412a7761c73814c6df41 (diff)
Merged changes from HEAD
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog36
-rw-r--r--winsup/cygwin/cygheap.cc22
-rw-r--r--winsup/cygwin/cygheap.h21
-rw-r--r--winsup/cygwin/dcrt0.cc16
-rw-r--r--winsup/cygwin/environ.cc2
-rw-r--r--winsup/cygwin/mmap.cc10
-rw-r--r--winsup/cygwin/syscalls.cc1
-rw-r--r--winsup/cygwin/thread.cc5
-rw-r--r--winsup/cygwin/uinfo.cc71
-rw-r--r--winsup/cygwin/winsup.h2
10 files changed, 125 insertions, 61 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index cf6abf523..5c201839a 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -72,6 +72,42 @@
* cygwin_shm.h: Ditto.
* woutsup.h: Add definition of _WIN32_WINNT.
+2002-06-27 Christopher Faylor <cgf@redhat.com>
+
+ * cygheap.cc (cfree_and_set): New function.
+ (cygheap_user::set_name): Use cfree_and_set to reset members.
+ * cygheap.h (cygheap_user): Delete static members.
+ (cygheap_user::puserprof): New member.
+ (cfree_and_set): Declare.
+ * dcrt0.cc (almost_null): Define.
+ * environ.cc (env_dontadd): Redefine as "almost_null".
+ * winsup.h (almost_null): Declare.
+ * syscalls.cc (cfree_and_set): Remove unused variable.
+ * uinfo.cc (cygheap_user::homepath_env_buf): Eliminate.
+ (cygheap_user::homedrive_env_buf): Ditto.
+ (cygheap_user::userprofile_env_buf): Ditto.
+ (cygheap_user::ontherange): YA change to try to preserve existing
+ HOMEPATH and HOMEDRIVE. Return almost_null values when variables
+ should not actually exist.
+ (cygheap_user::env_logsrv): Ditto.
+ (cygheap_user::env_domain): Ditto.
+ (cygheap_user::env_userprofile): Ditto.
+
+2002-06-27 Corinna Vinschen <corinna@vinschen.de>
+
+ * dcrt0.cc (dll_crt0_1): Let __progname point to the applications
+ basename. Move eliminating ".exe" suffix from argv[0] so that it
+ always also affects __progname.
+
+2002-06-27 Thomas Pfaff <tpfaff@gmx.net>
+
+ * thread.cc (pthread::create): Added trace printf to get CreateThread
+ LastError.
+
+2002-06-27 Corinna Vinschen <corinna@vinschen.de>
+
+ * mmap.cc (list::match): Check using pagesize aligned size.
+
2002-06-26 Christopher Faylor <cgf@redhat.com>
* fhandler_disk_file.cc (fhandler_disk_file::fstat_by_name): Force
diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc
index 561e9330f..2cf7e2068 100644
--- a/winsup/cygwin/cygheap.cc
+++ b/winsup/cygwin/cygheap.cc
@@ -327,6 +327,14 @@ cfree (void *s)
MALLOC_CHECK;
}
+extern "C" void __stdcall
+cfree_and_set (char *&s, char *what)
+{
+ if (s && s != almost_null)
+ cfree (s);
+ s = what;
+}
+
extern "C" void *__stdcall
ccalloc (cygheap_types x, DWORD n, DWORD size)
{
@@ -453,15 +461,11 @@ cygheap_user::set_name (const char *new_name)
if (!allocated)
return; /* Initializing. Don't bother with other stuff. */
- homedrive = NULL;
- homepath = NULL;
- if (plogsrv)
- cfree (plogsrv);
- if (pdomain)
- cfree (pdomain);
- if (winname)
- cfree (winname);
- plogsrv = pdomain = winname = NULL;
+ cfree_and_set (homedrive);
+ cfree_and_set (homepath);
+ cfree_and_set (plogsrv);
+ cfree_and_set (pdomain);
+ cfree_and_set (winname);
}
BOOL
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index ff598e548..e2fcaec31 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -104,15 +104,9 @@ class cygheap_user
char *homedrive; /* User's home drive */
char *homepath; /* User's home path */
char *winname; /* User's name as far as Windows knows it */
+ char *puserprof; /* User profile */
PSID psid; /* buffer for user's SID */
PSID orig_psid; /* Remains intact even after impersonation */
- static char homedrive_env_buf[3]; /* Where the HOMEDRIVE environment variable
- info may live. */
- static char homepath_env_buf[MAX_PATH + 1]; /* Where the HOMEPATH environment
- variable info may live. */
- static char userprofile_env_buf[MAX_PATH + 1]; /* Where the USERPROFILE
- environment variable info
- may live. */
public:
__uid32_t orig_uid; /* Remains intact even after impersonation */
__gid32_t orig_gid; /* Ditto */
@@ -124,9 +118,17 @@ public:
HANDLE token;
BOOL impersonated;
+ /* CGF 2002-06-27. I removed the initializaton from this constructor
+ since this class is always allocated statically. That means that everything
+ is zero anyway so there is no need to initialize it to zero. Since the
+ token initialization is always handled during process startup as well,
+ I've removed the constructor entirely. Please reinstate this f this
+ situation ever changes.
cygheap_user () : pname (NULL), plogsrv (NULL), pdomain (NULL),
- homedrive (NULL), homepath (NULL),
- psid (NULL), token (INVALID_HANDLE_VALUE) {}
+ homedrive (NULL), homepath (NULL), psid (NULL),
+ token (INVALID_HANDLE_VALUE) {}
+ */
+
~cygheap_user ();
void set_name (const char *new_name);
@@ -289,5 +291,6 @@ void *__stdcall crealloc (void *, DWORD) __attribute__ ((regparm(2)));
void *__stdcall ccalloc (cygheap_types, DWORD, DWORD) __attribute__ ((regparm(3)));
char *__stdcall cstrdup (const char *) __attribute__ ((regparm(1)));
char *__stdcall cstrdup1 (const char *) __attribute__ ((regparm(1)));
+void __stdcall cfree_and_set (char *&, char * = NULL) __attribute__ ((regparm(2)));
void __stdcall cygheap_init ();
}
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 854e52585..ec5931acf 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -74,6 +74,8 @@ MTinterface _mtinterf;
bool NO_COPY _cygwin_testing;
unsigned NO_COPY _cygwin_testing_magic;
+char NO_COPY almost_null[1];
+
extern "C"
{
void *export_malloc (unsigned int);
@@ -703,9 +705,6 @@ dll_crt0_1 ()
{
char *new_argv0 = (char *) alloca (MAX_PATH);
cygwin_conv_to_posix_path (__argv[0], new_argv0);
- char *p = strchr (new_argv0, '\0') - 4;
- if (p > new_argv0 && strcasematch (p, ".exe"))
- *p = '\0';
__argv[0] = new_argv0;
}
}
@@ -718,7 +717,16 @@ dll_crt0_1 ()
cygheap->fdtab.stdio_init ();
/* Set up __progname for getopt error call. */
- __progname = __argv[0];
+ if (__argv[0] && (__progname = strrchr (__argv[0], '/')))
+ ++__progname;
+ else
+ __progname = __argv[0];
+ if (__progname)
+ {
+ char *cp = strchr (__progname, '\0') - 4;
+ if (cp > __progname && strcasematch (cp, ".exe"))
+ *cp = '\0';
+ }
/* Set new console title if appropriate. */
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 114fce7f0..052398a7f 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -759,7 +759,7 @@ struct spenv
__attribute__ ((regparm (3)));
};
-char env_dontadd[] = "";
+#define env_dontadd almost_null
/* Keep this list in upper case and sorted */
static NO_COPY spenv spenvs[] =
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index c89cf4c7b..d1bda79d8 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -23,10 +23,10 @@ details. */
#include "pinfo.h"
#include "sys/cygwin.h"
-#define PAGE_CNT(bytes) howmany(bytes,getpagesize())
+#define PAGE_CNT(bytes) howmany((bytes),getpagesize())
#define PGBITS (sizeof(DWORD)*8)
-#define MAPSIZE(pages) howmany(pages,PGBITS)
+#define MAPSIZE(pages) howmany((pages),PGBITS)
#define MAP_SET(n) (map_map_[(n)/PGBITS] |= (1L << ((n) % PGBITS)))
#define MAP_CLR(n) (map_map_[(n)/PGBITS] &= ~(1L << ((n) % PGBITS)))
@@ -315,7 +315,8 @@ list::match (__off64_t off, DWORD len)
{
for (int i = 0; i < nrecs; ++i)
if (off >= recs[i].get_offset ()
- && off + len <= recs[i].get_offset () + recs[i].get_size ())
+ && off + len <= recs[i].get_offset ()
+ + (PAGE_CNT (recs[i].get_size ()) * getpagesize ()))
return recs + i;
}
return NULL;
@@ -327,7 +328,8 @@ list::match (caddr_t addr, DWORD len, __off32_t start)
{
for (int i = start + 1; i < nrecs; ++i)
if (addr >= recs[i].get_address ()
- && addr + len <= recs[i].get_address () + recs[i].get_size ())
+ && addr + len <= recs[i].get_address ()
+ + (PAGE_CNT (recs[i].get_size ()) * getpagesize ()))
return i;
return -1;
}
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 65f06d90d..006a9b758 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1969,7 +1969,6 @@ seteuid32 (__uid32_t uid)
BOOL sav_impersonated, sav_token_is_internal_token;
BOOL process_ok, explicitly_created_token = FALSE;
struct passwd * pw_new;
- cygheap_user user;
PSID origpsid, psid2 = NO_SID;
debug_printf ("uid: %d myself->gid: %d", uid, myself->gid);
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 607e212f9..39fad36b4 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -399,7 +399,10 @@ pthread::create (void *(*func) (void *), pthread_attr *newattr,
this, CREATE_SUSPENDED, &thread_id);
if (!win32_obj_id)
- magic = 0;
+ {
+ thread_printf ("CreateThread failed: this %p LastError %E", this);
+ magic = 0;
+ }
else
{
InterlockedIncrement (&MT_INTERFACE->threadcount);
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index e1e907729..effcd5908 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -187,31 +187,26 @@ cuserid (char *src)
return src;
}
-char cygheap_user::homepath_env_buf[MAX_PATH + 1];
-char cygheap_user::homedrive_env_buf[3];
-char cygheap_user::userprofile_env_buf[MAX_PATH + 1];
-
const char *
cygheap_user::ontherange (homebodies what, struct passwd *pw)
{
LPUSER_INFO_3 ui = NULL;
WCHAR wuser[UNLEN + 1];
NET_API_STATUS ret;
+ char homepath_env_buf[MAX_PATH + 1];
+ char homedrive_env_buf[3];
+ char *newhomedrive = NULL;
+ char *newhomepath = NULL;
+
if (what == CH_HOME)
{
char *p;
if ((p = getenv ("HOMEDRIVE")))
- {
- memcpy (homedrive_env_buf, p, 2);
- homedrive = homedrive_env_buf;
- }
+ newhomedrive = p;
if ((p = getenv ("HOMEPATH")))
- {
- strcpy (homepath_env_buf, p);
- homepath = homepath_env_buf;
- }
+ newhomepath = p;
if ((p = getenv ("HOME")))
debug_printf ("HOME is already in the environment %s", p);
@@ -224,21 +219,20 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
setenv ("HOME", pw->pw_dir, 1);
debug_printf ("Set HOME (from /etc/passwd) to %s", pw->pw_dir);
}
- else if (homedrive && homepath)
+ else if (newhomedrive && newhomepath)
{
char home[MAX_PATH];
char buf[MAX_PATH + 1];
- strcpy (buf, homedrive);
- strcat (buf, homepath);
+ strcpy (buf, newhomedrive);
+ strcat (buf, newhomepath);
cygwin_conv_to_full_posix_path (buf, home);
setenv ("HOME", home, 1);
debug_printf ("Set HOME (from HOMEDRIVE/HOMEPATH) to %s", home);
}
}
- return NULL;
}
- if (homedrive == NULL || !homedrive[0])
+ if (homepath == NULL && newhomepath == NULL)
{
if (!pw)
pw = getpwnam (name ());
@@ -246,6 +240,7 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
cygwin_conv_to_full_win32_path (pw->pw_dir, homepath_env_buf);
else
{
+ homepath_env_buf[0] = homepath_env_buf[1] = '\0';
if (env_logsrv ())
{
WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3];
@@ -275,18 +270,26 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
if (homepath_env_buf[1] != ':')
{
- homedrive_env_buf[0] = homedrive_env_buf[1] = '\0';
- homepath = homepath_env_buf;
+ newhomedrive = almost_null;
+ newhomepath = homepath_env_buf;
}
else
{
homedrive_env_buf[0] = homepath_env_buf[0];
homedrive_env_buf[1] = homepath_env_buf[1];
- homepath = homepath_env_buf + 2;
+ homedrive_env_buf[2] = '\0';
+ newhomedrive = homedrive_env_buf;
+ newhomepath = homepath_env_buf + 2;
}
- homedrive = homedrive_env_buf;
}
+ if (newhomedrive)
+ cfree_and_set (homedrive, (newhomedrive == almost_null)
+ ? almost_null : cstrdup (newhomedrive));
+
+ if (newhomepath)
+ cfree_and_set (homepath, cstrdup (newhomepath));
+
switch (what)
{
case CH_HOMEDRIVE:
@@ -308,9 +311,10 @@ cygheap_user::env_logsrv ()
return NULL;
char logsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3];
- if (!get_logon_server (env_domain (), logsrv, NULL))
- return NULL;
- return plogsrv = cstrdup (logsrv);
+ cfree_and_set (plogsrv, almost_null);
+ if (get_logon_server (env_domain (), logsrv, NULL))
+ plogsrv = cstrdup (logsrv);
+ return plogsrv;
}
const char *
@@ -325,27 +329,30 @@ cygheap_user::env_domain ()
DWORD dlen = sizeof (userdomain);
SID_NAME_USE use;
+ cfree_and_set (winname, almost_null);
+ cfree_and_set (pdomain, almost_null);
if (!LookupAccountSid (NULL, sid (), username, &ulen,
userdomain, &dlen, &use))
+ __seterrno ();
+ else
{
- __seterrno ();
- return NULL;
+ winname = cstrdup (username);
+ pdomain = cstrdup (userdomain);
}
- if (winname)
- cfree (winname);
- winname = cstrdup (username);
- return pdomain = cstrdup (userdomain);
+ return pdomain;
}
const char *
cygheap_user::env_userprofile ()
{
+ char userprofile_env_buf[MAX_PATH + 1];
+ cfree_and_set (puserprof, almost_null);
/* FIXME: Should this just be setting a puserprofile like everything else? */
if (!strcasematch (env_name (), "SYSTEM")
&& get_registry_hive_path (sid (), userprofile_env_buf))
- return userprofile_env_buf;
+ puserprof = cstrdup (userprofile_env_buf);
- return NULL;
+ return puserprof;
}
const char *
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 4cfce5d4c..513d44863 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -288,6 +288,8 @@ extern bool cygwin_testing;
extern unsigned _cygwin_testing_magic;
extern HMODULE cygwin_hmodule;
+extern char almost_null[];
+
#define winsock2_active (wsadata.wVersion >= 512)
#define winsock_active (wsadata.wVersion < 512)
extern struct WSAData wsadata;