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:
authorChristopher Faylor <me@cgf.cx>2001-01-28 08:51:15 +0300
committerChristopher Faylor <me@cgf.cx>2001-01-28 08:51:15 +0300
commit2a6fc028badee6ab9a4df2b1b395dbb701d965fb (patch)
tree22d3b565c2f57907367012419b1c63765043d05d /winsup/cygwin/passwd.cc
parent022ce214de829810a9ddd1a747be03ac95185bb1 (diff)
Throughout, change 'cygwin_shared.mount' to 'mount_table'.
* child_info.h (child_info): Move shared_h, console_h to cygheap. Add mount_h. * cygheap.h (init_cygheap): Add shared_h, console_h. * cygheap.cc (init_cheap): Initialize heap at a fixed location after the shared memory regions. Initialize cygheap->user name here. * dcrt0.cc (dll_crt0_1): Call getpagesize () to initialize constants. Remove cygheap_init since it is done in shared_init now. (_dll_crt0): Initialize mount_h, remove shared_h and console_h initialization. * fhandler_console.cc (console_shared_h): Eliminate. (get_tty_stuff): Use cygheap->console_h rather than console_shared_h. * heap.cc (heap_init): Use page size constant calculated earlier in initialization. * shared.cc: Eliminate cygwin_shared_h. Add cygwin_mount_h. (mount_table_init): New function for initializing a user mount table. (open_shared_file_map): Use constant for shared memory region. Initialize cygheap and mount table here. (open_shared): Improve debugging output. (shared_info::initialize): Eliminate call to mount.init. (shared_terminate): Use cygheap->shared_h. Close cygwin_mount_h. (open_shared_file_map): Eliminate. * shared_info.h (mount_info): Add a version field. (shared_align_past): New macro for calculating location for shared memory regions. * sigproc.cc (init_child_info): Eliminate shared_h, console_h. * spawn.cc (spawn_guts): Pass on cygwin_mount_h iff not a different user. * syscalls.cc (system_info): New global holding system memory defaults. (getpagesize): Use system_info. * uinfo.cc (internal_getlogin): Only fill in user name if nonexistent. * winsup.h: Declare system_info. * passwd.cc (read_etc_passwd): Use cygheap->user.name () rather than retrieving the name again.
Diffstat (limited to 'winsup/cygwin/passwd.cc')
-rw-r--r--winsup/cygwin/passwd.cc33
1 files changed, 13 insertions, 20 deletions
diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc
index 797fb5375..21c3e786d 100644
--- a/winsup/cygwin/passwd.cc
+++ b/winsup/cygwin/passwd.cc
@@ -42,7 +42,7 @@ static pwd_state passwd_state = uninitialized;
/* 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
@@ -92,7 +92,7 @@ parse_pwd (struct passwd &res, char *buf)
if (mybuf[--len] == '\n')
mybuf[len] = '\0';
- res.pw_name = strlwr(grab_string (&mybuf));
+ res.pw_name = strlwr (grab_string (&mybuf));
res.pw_passwd = grab_string (&mybuf);
res.pw_uid = grab_int (&mybuf);
res.pw_gid = grab_int (&mybuf);
@@ -140,14 +140,7 @@ read_etc_passwd ()
else
{
debug_printf ("Emulating /etc/passwd");
- char user_name [ MAX_USER_NAME ];
- DWORD user_name_len = MAX_USER_NAME;
- if (! GetUserNameA (user_name, &user_name_len))
- {
- strncpy (user_name, "Administrator", MAX_USER_NAME);
- debug_printf ("Failed to get current user name. %E");
- }
- snprintf (linebuf, sizeof (linebuf), "%s::%u:%u::%s:/bin/sh", user_name,
+ snprintf (linebuf, sizeof (linebuf), "%s::%u:%u::%s:/bin/sh", cygheap->user.name (),
DEFAULT_UID, DEFAULT_GID, getenv ("HOME") ?: "/");
add_pwd_line (linebuf);
passwd_state = emulated;
@@ -180,7 +173,7 @@ search_for (uid_t uid, const char *name)
request for the current user. */
if (passwd_state != loaded
|| (!name && uid == myself->uid)
- || (name && strcasematch(name, cygheap->user.name ())))
+ || (name && strcasematch (name, cygheap->user.name ())))
return default_pw;
return NULL;
@@ -190,7 +183,7 @@ extern "C" struct passwd *
getpwuid (uid_t uid)
{
if (passwd_state == uninitialized)
- read_etc_passwd();
+ read_etc_passwd ();
return search_for (uid, 0);
}
@@ -199,7 +192,7 @@ extern "C" struct passwd *
getpwnam (const char *name)
{
if (passwd_state == uninitialized)
- read_etc_passwd();
+ read_etc_passwd ();
return search_for (0, name);
}
@@ -208,7 +201,7 @@ extern "C" struct passwd *
getpwent (void)
{
if (passwd_state == uninitialized)
- read_etc_passwd();
+ read_etc_passwd ();
if (pw_pos < curr_lines)
return passwd_buf + pw_pos++;
@@ -220,7 +213,7 @@ extern "C" struct passwd *
getpwduid (uid_t)
{
if (passwd_state == uninitialized)
- read_etc_passwd();
+ read_etc_passwd ();
return NULL;
}
@@ -229,7 +222,7 @@ extern "C" void
setpwent (void)
{
if (passwd_state == uninitialized)
- read_etc_passwd();
+ read_etc_passwd ();
pw_pos = 0;
}
@@ -238,7 +231,7 @@ extern "C" void
endpwent (void)
{
if (passwd_state == uninitialized)
- read_etc_passwd();
+ read_etc_passwd ();
pw_pos = 0;
}
@@ -247,7 +240,7 @@ extern "C" int
setpassent ()
{
if (passwd_state == uninitialized)
- read_etc_passwd();
+ read_etc_passwd ();
return 0;
}
@@ -256,14 +249,14 @@ extern "C" char *
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;
if (passwd_state == uninitialized)
- read_etc_passwd();
+ read_etc_passwd ();
if (fdtab.not_open (0))
{