Subject: Re: CVS commit: src/usr.bin/who
To: None <>
From: Christos Zoulas <>
List: current-users
Date: 09/20/2006 19:51:06
In article <>,
Tom Spindler  <> wrote:
>> On Sep 20,  2:53pm, (Hubert Feyrer) wrote:
>> -- Subject: Re: CVS commit: src/usr.bin/who
>> | On Wed, 20 Sep 2006, Elad Efrat wrote:
>> | > While it is noble that it cares, I think we can safely deprecate it,
>> | > keeping the config file and the parser for compliance.
>> | 
>> | No - it's a nice example of how to allow users to run a program only at 
>> | several times.
>> | 
>> | I didn't know that the who-sources are used in other places when I 
>> | committed the change to who(1). I'll have a look within the next few days 
>> | (I'm mostly offline right now).
>> Lots of things use it (everything that needs utmp). I meant to move it
>> to libutil, but I am not happy with the API yet.
>I was looking at some of the various programs that use utmpentry.h,
>and some of the things they do are... not obvious.
>The (obvious/small) code fragment
>	struct utmpx *u; int nusers;
>        for (nusers = 0; NULL != (u = getutxent());) {
>                if (*u->ut_name) nusers++;
>        }
>gives a different number of users than who(1) does. Without descending
>too far into madness^Wthe who(1) code, how are its (or rpc.rusersd)
>criteria different than what utmpx keeps track of?

Well, the above code probably not what you want.  It will return more
"users" than you think, because:

	1. there are more kinds of entries in utmpx. You probably only
	   want USER_PROCESS.
	2. Some programs just set the type to DEAD_PROCESS, and don't
	   clear the user name (which is nice) when they un-registrer.

>For that matter, there's a whole bunch of #ifdef SUPPORT_UTMP and
>#ifdef SUPPORT_UTMPX code in who.c; are they really needed?

The madness is caused by programs that don't support utmpx and register only
with utmp. I am pretty sure that there are not any left in src, but there
are in pkgsrc. The utmpentry API tries to compensate for that by merging
the utmp and utmpx entries if but SUPPORT_UTMP and SUPPORT_UTMPX are there.