Mail Archives: cygwin-developers/1999/09/10/04:07:35
Hi!
KF> /etc/passwd emulation in passwd.cc generates an invalid entry of
KF> which uid is always 513 for any user on WinNT. Then, it use
KF> `Administrator' as the user name when GetUserNameA() fails. It
KF> seems a bit strange on Win9x.
KF> Fri Sep 10 03:49:22 1999 Kazuhiro Fujieda (fujieda AT jaist DOT ac DOT jp)
KF> * passwd.cc (read_etc_passwd): /etc/passwd emulation use the
KF> proper uid, and use `unknown' as the user name for an unknown user.
KF> -!- passwd.cc- Tue Aug 10 12:45:57 1999
KF> +++ passwd.cc Fri Sep 10 03:49:22 1999
KF> @@ -11,6 +11,7 @@ details. */
KF> #include <stdlib.h>
KF> #include <pwd.h>
KF> #include <stdio.h>
KF> +#include <unistd.h>
KF> #include <errno.h>
KF> #include "winsup.h"
KF> @@ -121,15 +122,9 @@ read_etc_passwd ()
KF> else
KF> {
KF> debug_printf ("Emulating /etc/passwd");
KF> - char user_name [ MAX_USER_NAME ];
KF> - DWORD user_name_len = MAX_USER_NAME;
KF> - if (! GetUserNameA (user_name, &user_name_len))
KF> - {
KF> - strncpy (user_name, "Administrator", MAX_USER_NAME);
KF> - debug_printf ("Failed to get current user name. %E");
KF> - }
KF> - snprintf (linebuf, sizeof (linebuf), "%s::%u:%u::%s:/bin/sh",
KF> user_name, - DEFAULT_UID, DEFAULT_GID, getenv ("HOME") ?:
KF> "/"); + snprintf (linebuf, sizeof (linebuf),
KF> "%s::%u:%u::%s:/bin/sh", + getlogin (), getuid (), DEFAULT_GID,
KF> + getenv ("HOME") ?: "/");
KF> add_pwd_line (linebuf);
KF> }
KF> passwd_in_memory_p = 1;
hmm. calling getuid() in /etc/passwd emulation code seems to be rather
strange, as long as getuid() use /etc/passwd to retrieve uid :)
So, actually getuid() will always return DEFAULT_UID :)
Egor. mailto:deo AT logos-m DOT ru ICQ 5165414 FidoNet 2:5020/496.19
- Raw text -