Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Jan 1996 03:28:37 +0100 (MET)
From:      Åge Røbekk <aagero@aage.aage.priv.no>
To:        wosch@cs.tu-berlin.de
Cc:        freebsd-bugs@freebsd.org
Subject:   Re: getlogin() returns bogus username
Message-ID:  <199601170228.DAA02822@birk04.studby.uio.no>
In-Reply-To: <199601170122.CAA01429@localhost> (message from Wolfram Schneider on Wed, 17 Jan 1996 02:22:42 %2B0100)

next in thread | previous in thread | raw e-mail | index | archive | help

[Wolfram Schneider]

| $ man 5 passwd
|      While it is possible to have multiple entries with identical =
login names
|      and/or identical user id's, it is usually a mistake to do so.  =
Routines
|      that manipulate these files will often return only one of the =
multiple
|      entries, and that one by random selection.
|                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

| Ege Rxbekk writes:
| >getlogin() does sometimes return the wrong username, e.g.
| >
| >$ ./getlogin=20
| >getlogin: per-stia
| >$ id
| >uid=3D1000(aagero) gid=3D1000(aagero) =
groups=3D1000(aagero),0(wheel),2(kmem)
| >
| >That is, getlogin returns the same bogus name each time I call it. But
| >if I login to a new session, e.g. rlogin localhost, getlogin() returns
| >the same as getuid(). The user returned from getlogin is usually
| >logged in when this happens.

It sounds like you are suggesting I am using the same user id for the
two logins.

$ grep ^per-stia /etc/passwd
per-stia:*:1003:1003:Per-Stian =
Vatne:/usr/home/per-stia:/local/gnu/bin/bash
$ grep ^aagero /etc/passwd
aagero:*:1000:1000:=C5ge R=F8bekk,,,:/usr/home/aagero:/local/gnu/bin/bash

And getlogin() does not return "per-stia" as userid by random, when it
has first appeared, it remains throughout the entire session. That is,
each subsequent call to getlogin returns this id. This might be a
kernel case, since the getlogin call is a kernel function.

-aage



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199601170228.DAA02822>