Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com To: cygwin-developers Subject: Re: /etc/passwd emulation References: <1503 DOT 990910 AT logos-m DOT ru> Mime-Version: 1.0 (generated by tm-edit 7.106) Content-Type: text/plain; charset=US-ASCII From: Kazuhiro Fujieda Date: 12 Sep 1999 03:16:12 +0900 In-Reply-To: Kazuhiro Fujieda's message of 10 Sep 1999 19:00:29 +0900 Message-ID: Lines: 49 X-Mailer: Gnus v5.3/Emacs 19.34 >>> On 10 Sep 1999 19:00:29 +0900 >>> Kazuhiro Fujieda 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 #include #include +#include #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 | HOKURIKU School of Information Science o_/ 1990 Japan Advanced Institute of Science and Technology