Mail Archives: cygwin-developers/1999/09/11/14:16:38
>>> On 10 Sep 1999 19:00:29 +0900
>>> Kazuhiro Fujieda <fujieda AT jaist DOT ac DOT jp> said:
> Now, I came to realize it is not so bad idea that the uid become
> always DEFAULT_UID when there is no /etc/passwd. I couldn't,
> however, understand why the emulation code make the user name
> `Administrator' when GetUserNameA() fails.
So, I believe the following patch is meaningful.
Sat Sep 11 02:21:53 1999 Kazuhiro Fujieda (fujieda AT jaist DOT ac DOT jp)
* passwd.cc (read_etc_passwd): /etc/passwd emulation use
the user name `unknown' for an unknown user.
--- passwd.cc- Tue Aug 10 12:45:57 1999
+++ passwd.cc Sat Sep 11 02:21:53 1999
@@ -12,6 +12,7 @@ details. */
#include <pwd.h>
#include <stdio.h>
#include <errno.h>
+#include <unistd.h>
#include "winsup.h"
/* Read /etc/passwd only once for better performance. This is done
@@ -121,15 +122,9 @@ 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,
- DEFAULT_UID, DEFAULT_GID, getenv ("HOME") ?: "/");
+ snprintf (linebuf, sizeof (linebuf), "%s::%u:%u::%s:/bin/sh",
+ getlogin(), DEFAULT_UID, DEFAULT_GID,
+ getenv ("HOME") ?: "/");
add_pwd_line (linebuf);
}
passwd_in_memory_p = 1;
____
| AIST Kazuhiro Fujieda <fujieda AT jaist DOT ac DOT jp>
| HOKURIKU School of Information Science
o_/ 1990 Japan Advanced Institute of Science and Technology
- Raw text -