This is the mail archive of the cygwin-developers@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

/etc/passwd emulation


/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@jaist.ac.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@jaist.ac.jp>
  | HOKURIKU  School of Information Science
o_/ 1990      Japan Advanced Institute of Science and Technology

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]