* dcrt0.cc (initialize_env): Use colon for CYGWIN_DEBUG separator.

* grp.cc: Change most statics to NO_COPY throughout.
* passwd.cc: Ditto.
* pwdgrp.h: Change some BOOLs to bools.
(pwdgrp::pwdgrp): Remove unneeded constructor.
* passwd.cc: Change BOOL to bool throughout.
This commit is contained in:
Christopher Faylor 2003-01-17 18:05:32 +00:00
parent afa378e74a
commit e915243911
5 changed files with 40 additions and 43 deletions

View File

@ -1,3 +1,15 @@
2003-01-17 Christopher Faylor <cgf@redhat.com>
* dcrt0.cc (initialize_env): Use colon for CYGWIN_DEBUG separator.
* grp.cc: Change most statics to NO_COPY throughout.
* passwd.cc: Ditto.
2003-01-17 Christopher Faylor <cgf@redhat.com>
* pwdgrp.h: Change some BOOLs to bools.
(pwdgrp::pwdgrp): Remove unneeded constructor.
* passwd.cc: Change BOOL to bool throughout.
2003-01-17 Corinna Vinschen <corinna@vinschen.de> 2003-01-17 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Add strerror_r. * cygwin.din: Add strerror_r.

View File

@ -809,7 +809,7 @@ initial_env ()
len = GetModuleFileName (NULL, buf1, MAX_PATH); len = GetModuleFileName (NULL, buf1, MAX_PATH);
strlwr (buf1); strlwr (buf1);
strlwr (buf); strlwr (buf);
char *p = strchr (buf, '='); char *p = strchr (buf, ':');
if (!p) if (!p)
p = (char *) "gdb.exe -nw"; p = (char *) "gdb.exe -nw";
else else

View File

@ -29,18 +29,14 @@ details. */
/* Read /etc/group only once for better performance. This is done /* Read /etc/group only once for better performance. This is done
on the first call that needs information from it. */ on the first call that needs information from it. */
static struct __group32 *group_buf; /* group contents in memory */ static struct __group32 NO_COPY *group_buf; /* group contents in memory */
static int curr_lines; static int NO_COPY curr_lines;
static int max_lines; static int NO_COPY max_lines;
/* Position in the group cache */ /* Position in the group cache */
#ifdef _MT_SAFE
#define grp_pos _reent_winsup ()->_grp_pos #define grp_pos _reent_winsup ()->_grp_pos
#else
static int grp_pos = 0;
#endif
static pwdgrp gr; static pwdgrp NO_COPY gr;
static char * NO_COPY null_ptr; static char * NO_COPY null_ptr;
static int static int
@ -107,7 +103,7 @@ class group_lock
{ {
bool armed; bool armed;
static NO_COPY pthread_mutex_t mutex; static NO_COPY pthread_mutex_t mutex;
public: public:
group_lock (bool doit) group_lock (bool doit)
{ {
if (armed = doit) if (armed = doit)
@ -162,7 +158,7 @@ read_etc_group ()
debug_printf ("Completing /etc/group: %s", linebuf); debug_printf ("Completing /etc/group: %s", linebuf);
add_grp_line (linebuf); add_grp_line (linebuf);
} }
static char pretty_ls[] = "????????::-1:"; static char NO_COPY pretty_ls[] = "????????::-1:";
if (wincap.has_security ()) if (wincap.has_security ())
add_grp_line (pretty_ls); add_grp_line (pretty_ls);
} }
@ -185,7 +181,7 @@ internal_getgrsid (cygsid &sid)
} }
struct __group32 * struct __group32 *
internal_getgrgid (__gid32_t gid, BOOL check) internal_getgrgid (__gid32_t gid, bool check)
{ {
if (gr.isuninitialized () || (check && gr.isinitializing ())) if (gr.isuninitialized () || (check && gr.isinitializing ()))
read_etc_group (); read_etc_group ();
@ -197,7 +193,7 @@ internal_getgrgid (__gid32_t gid, BOOL check)
} }
struct __group32 * struct __group32 *
internal_getgrnam (const char *name, BOOL check) internal_getgrnam (const char *name, bool check)
{ {
if (gr.isuninitialized () || (check && gr.isinitializing ())) if (gr.isuninitialized () || (check && gr.isinitializing ()))
read_etc_group (); read_etc_group ();
@ -236,7 +232,7 @@ getgrgid32 (__gid32_t gid)
extern "C" struct __group16 * extern "C" struct __group16 *
getgrgid (__gid16_t gid) getgrgid (__gid16_t gid)
{ {
static struct __group16 g16; static struct __group16 g16; /* FIXME: thread-safe? */
return grp32togrp16 (&g16, getgrgid32 ((__gid32_t) gid)); return grp32togrp16 (&g16, getgrgid32 ((__gid32_t) gid));
} }
@ -250,7 +246,7 @@ getgrnam32 (const char *name)
extern "C" struct __group16 * extern "C" struct __group16 *
getgrnam (const char *name) getgrnam (const char *name)
{ {
static struct __group16 g16; static struct __group16 g16; /* FIXME: thread-safe? */
return grp32togrp16 (&g16, getgrnam32 (name)); return grp32togrp16 (&g16, getgrnam32 (name));
} }
@ -276,7 +272,7 @@ getgrent32 ()
extern "C" struct __group16 * extern "C" struct __group16 *
getgrent () getgrent ()
{ {
static struct __group16 g16; static struct __group16 g16; /* FIXME: thread-safe? */
return grp32togrp16 (&g16, getgrent32 ()); return grp32togrp16 (&g16, getgrent32 ());
} }

View File

@ -26,18 +26,14 @@ details. */
/* Read /etc/passwd only once for better performance. This is done /* Read /etc/passwd only once for better performance. This is done
on the first call that needs information from it. */ on the first call that needs information from it. */
static struct passwd *passwd_buf; /* passwd contents in memory */ static struct passwd NO_COPY *passwd_buf; /* passwd contents in memory */
static int curr_lines; static int NO_COPY curr_lines;
static int max_lines; static int NO_COPY max_lines;
static pwdgrp pr; static NO_COPY pwdgrp pr;
/* Position in the passwd cache */ /* Position in the passwd cache */
#ifdef _MT_SAFE
#define pw_pos _reent_winsup ()->_pw_pos #define pw_pos _reent_winsup ()->_pw_pos
#else
static int pw_pos = 0;
#endif
/* Remove a : terminated string from the buffer, and increment the pointer */ /* Remove a : terminated string from the buffer, and increment the pointer */
static char * static char *
@ -139,9 +135,8 @@ read_etc_passwd ()
if (!pr.load ("/etc/passwd", add_pwd_line)) if (!pr.load ("/etc/passwd", add_pwd_line))
debug_printf ("pr.load failed"); debug_printf ("pr.load failed");
static char linebuf[1024];
char strbuf[128] = ""; char strbuf[128] = "";
BOOL searchentry = TRUE; bool searchentry = true;
struct passwd *pw; struct passwd *pw;
if (wincap.has_security ()) if (wincap.has_security ())
@ -161,6 +156,7 @@ read_etc_passwd ()
myself->uid != (__uid32_t) pw->pw_uid && myself->uid != (__uid32_t) pw->pw_uid &&
!internal_getpwuid (myself->uid)))) !internal_getpwuid (myself->uid))))
{ {
char linebuf[1024];
(void) cygheap->user.ontherange (CH_HOME, NULL); (void) cygheap->user.ontherange (CH_HOME, NULL);
snprintf (linebuf, sizeof (linebuf), "%s:*:%lu:%lu:,%s:%s:/bin/sh", snprintf (linebuf, sizeof (linebuf), "%s:*:%lu:%lu:,%s:%s:/bin/sh",
cygheap->user.name (), cygheap->user.name (),
@ -198,10 +194,9 @@ internal_getpwsid (cygsid &sid)
} }
struct passwd * struct passwd *
internal_getpwuid (__uid32_t uid, BOOL check) internal_getpwuid (__uid32_t uid, bool check)
{ {
if (pr.isuninitialized () if (pr.isuninitialized () || (check && pr.isinitializing ()))
|| (check && pr.isinitializing ()))
read_etc_passwd (); read_etc_passwd ();
for (int i = 0; i < curr_lines; i++) for (int i = 0; i < curr_lines; i++)
@ -211,10 +206,9 @@ internal_getpwuid (__uid32_t uid, BOOL check)
} }
struct passwd * struct passwd *
internal_getpwnam (const char *name, BOOL check) internal_getpwnam (const char *name, bool check)
{ {
if (pr.isuninitialized () if (pr.isuninitialized () || (check && pr.isinitializing ()))
|| (check && pr.isinitializing ()))
read_etc_passwd (); read_etc_passwd ();
for (int i = 0; i < curr_lines; i++) for (int i = 0; i < curr_lines; i++)
@ -372,11 +366,7 @@ setpassent ()
extern "C" char * extern "C" char *
getpass (const char * prompt) getpass (const char * prompt)
{ {
#ifdef _MT_SAFE
char *pass=_reent_winsup ()->_pass; char *pass=_reent_winsup ()->_pass;
#else
static char pass[_PASSWORD_LEN];
#endif
struct termios ti, newti; struct termios ti, newti;
if (pr.isinitializing ()) if (pr.isinitializing ())

View File

@ -13,11 +13,11 @@ details. */
/* These functions are needed to allow searching and walking through /* These functions are needed to allow searching and walking through
the passwd and group lists */ the passwd and group lists */
extern struct passwd *internal_getpwsid (cygsid &); extern struct passwd *internal_getpwsid (cygsid &);
extern struct passwd *internal_getpwnam (const char *, BOOL = FALSE); extern struct passwd *internal_getpwnam (const char *, bool = FALSE);
extern struct passwd *internal_getpwuid (__uid32_t, BOOL = FALSE); extern struct passwd *internal_getpwuid (__uid32_t, bool = FALSE);
extern struct __group32 *internal_getgrsid (cygsid &); extern struct __group32 *internal_getgrsid (cygsid &);
extern struct __group32 *internal_getgrgid (__gid32_t gid, BOOL = FALSE); extern struct __group32 *internal_getgrgid (__gid32_t gid, bool = FALSE);
extern struct __group32 *internal_getgrnam (const char *, BOOL = FALSE); extern struct __group32 *internal_getgrnam (const char *, bool = FALSE);
extern struct __group32 *internal_getgrent (int); extern struct __group32 *internal_getgrent (int);
int internal_getgroups (int, __gid32_t *, cygsid * = NULL); int internal_getgroups (int, __gid32_t *, cygsid * = NULL);
@ -70,8 +70,7 @@ class pwdgrp
} }
public: public:
pwdgrp () : state (uninitialized) {} bool isinitializing ()
BOOL isinitializing ()
{ {
if (state <= initializing) if (state <= initializing)
state = initializing; state = initializing;
@ -80,7 +79,7 @@ public:
return state == initializing; return state == initializing;
} }
void operator = (pwdgrp_state nstate) { state = nstate; } void operator = (pwdgrp_state nstate) { state = nstate; }
BOOL isuninitialized () const { return state == uninitialized; } bool isuninitialized () const { return state == uninitialized; }
bool load (const char *posix_fname, void (* add_line) (char *)) bool load (const char *posix_fname, void (* add_line) (char *))
{ {