delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1999/09/10/04:07:35

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
Date: Fri, 10 Sep 1999 12:05:13 +0400
From: Egor Duda <deo AT logos-m DOT ru>
X-Mailer: The Bat! (v1.029) S/N A0F2A05A
Reply-To: Egor Duda <deo AT logos-m DOT ru>
Organization: DEO
Message-ID: <1503.990910@logos-m.ru>
To: cygwin-developers <cygwin-developers AT sourceware DOT cygnus DOT com>
CC: Kazuhiro Fujieda <fujieda AT jaist DOT ac DOT jp>
Subject: /etc/passwd emulation
Mime-Version: 1.0

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 -


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