delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1999/09/11/14:16:38

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-developers-unsubscribe-archive-cygwin-developers=delorie DOT com AT sourceware DOT cygnus DOT com>
List-Subscribe: <mailto:cygwin-developers-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-developers-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
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 <cygwin-developers AT sourceware DOT cygnus DOT com>
Subject: Re: /etc/passwd emulation
References: <1503 DOT 990910 AT logos-m DOT ru> <s1s7llzrsqq DOT fsf AT jaist DOT ac DOT jp>
Mime-Version: 1.0 (generated by tm-edit 7.106)
From: Kazuhiro Fujieda <fujieda AT jaist DOT ac DOT jp>
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: <s1s4sh1s49f.fsf@jaist.ac.jp>
Lines: 49
X-Mailer: Gnus v5.3/Emacs 19.34

>>> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019