[unix-pc.general] getlogin

lenny@quincy.UUCP (Lenny Tropiano) (12/09/87)

On my UNIX PC I have noticed a problem occasionally with the
getlogin(3C) system call.  At certain times I have noticed
getlogin returning "LOGIN" or "rc" instead of the user's name
who is logged in.

I know what "LOGIN" and "rc" are, but why are they showing up
for a valid logged-in user?  This is quite strange...

--- piece of code ---

	char	*getlogin();

	printf("User is: %s\n", getlogin());

--- end piece of code ---

Any suggestions?  I have recreated the /etc/utmp, /etc/wtmp and
this hasn't cleared up the problem.  Sometimes it goes away
and other times it comes back.

						Thanks,
						Lenny
-- 
Lenny Tropiano                  UUCP:      ...uunet!godfre!quincy!lenny  -or-
American LP Systems, Inc.        ...cmcl2!phri!bc-cis!icus!quincy!lenny  -or-
1777-18 Veterans Memorial Hwy.   	          ...mtune!quincy!lenny  -or
Islandia, New York 11722     +1 516-582-5525 ...ihnp4!icus!quincy!lenny

lenny@icus.UUCP (Lenny Tropiano) (08/15/88)

In article <578@proxftl.UUCP> aaron@proxftl.UUCP (Aaron Zimmerman) writes:
|>I have a curious problem on my 3b1...
|>
...
|>$ who am i
|>aaron      w4           Aug 12 08:01
|>$ passwd
|>Changing password for LOGIN
|>Permission denied.
...

The problem occurs not in passwd (or the /etc/passwd file), but in the
getlogin(3C) function call.    This problem occurs if you use multiple
getty's on /dev/window, or you have something running on w1 when the
getty respawns for /dev/window.

The following example with show this:

lenny    + w1           Aug 14 20:05   .     4428  
root     + w4           Aug 14 21:51   .     5623  

(Note:  I'm logged in with two gettys, the current one is w4).

# tty
/dev/w4
# passwd
Changing password for lenny
New password: [...]

getlogin(3C) looks up the /dev/window login finding the first entry in
/etc/utmp it finds.  I maybe logged in on w4 as root, but getlogin thinks
I am logged in as lenny on w1.  In your case with user LOGIN, it found was a
LOGIN_PROCESS.	(A "getty" process waiting for login)

Something like:

LOGIN    + window       Aug 14 21:54   .     5880  
root     + w4           Aug 14 21:51   .     5623  

Those are the disadvantages in running multiple gettys, although having
the capability to login more than once is nice. (Something I'm working into
the window-manager I am rewriting).

-Lenny
-- 
Paper-net: Lenny Tropiano          | @-net:         lenny@icus.UUCP
           ICUS Software Systems   | !-net:      ...sbcs   \
           PO Box 1                |                boulder \
           Islip Terrace, NY 11752 |                talcott  !icus!lenny
Vocal-net: (516) 582-5525 [work]   |                pacbell /
           (516) 968-8576 [home]   |                hombre /
Telex-net: 154232428 ICUS          | Another-net:   attmail!icus!lenny

woods@gpu.utcs.toronto.edu (Greg Woods) (08/16/88)

In article <467@icus.UUCP> lenny@icus.UUCP (Lenny Tropiano) writes:
>In article <578@proxftl.UUCP> aaron@proxftl.UUCP (Aaron Zimmerman) writes:
>|>I have a curious problem on my 3b1...
>|>
>...
>|>$ who am i
>|>aaron      w4           Aug 12 08:01
>|>$ passwd
>|>Changing password for LOGIN
>|>Permission denied.
>...
>
>The problem occurs not in passwd (or the /etc/passwd file), but in the
>getlogin(3C) function call.    This problem occurs if you use multiple
>getty's on /dev/window, or you have something running on w1 when the
>getty respawns for /dev/window.

I've also had this problem with 386/ix, when a getty in the LOGIN state
dies abnormally.  A 'who -a' shows LOGIN and xyzzy both on the port, but
it gives an exit status for LOGIN.

I'd call this a bug (and I will bug-report it too).  The problem occurs
with any utility that calls getlogin(3C), including mail, etc.
-- 
						Greg Woods.

UUCP: utgpu!woods, utgpu!{ontmoh, ontmoh!ixpierre}!woods
VOICE: (416) 242-7572 [h]		LOCATION: Toronto, Ontario, Canada