delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1999/09/09/15:51:22

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 AT sourceware DOT cygnus DOT com
Subject: /etc/passwd emulation
Mime-Version: 1.0 (generated by tm-edit 7.106)
From: Kazuhiro Fujieda <fujieda AT jaist DOT ac DOT jp>
Date: 10 Sep 1999 04:50:29 +0900
Message-ID: <s1sd7vrsw3e.fsf@jaist.ac.jp>
Lines: 44
X-Mailer: Gnus v5.3/Emacs 19.34

/etc/passwd emulation in passwd.cc generates an invalid entry of
which uid is always 513 for any user on WinNT.  Then, it use
`Administrator' as the user name when GetUserNameA() fails. It
seems a bit strange on Win9x.

Fri Sep 10 03:49:22 1999  Kazuhiro Fujieda (fujieda AT jaist DOT ac DOT jp)

	* passwd.cc (read_etc_passwd): /etc/passwd emulation use the proper
	uid, and use `unknown' as the user name for an unknown user.

--- passwd.cc-	Tue Aug 10 12:45:57 1999
+++ passwd.cc	Fri Sep 10 03:49:22 1999
@@ -11,6 +11,7 @@ details. */
 #include <stdlib.h>
 #include <pwd.h>
 #include <stdio.h>
+#include <unistd.h>
 #include <errno.h>
 #include "winsup.h"
 
@@ -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 (), getuid (), 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