[comp.sys.hp] question regarding how hpux uses /etc/utmp.

sundar@wheaties.ai.mit.edu (Sundar Narasimhan) (03/24/89)

Hi:
I am trying to port a finger program to the hp's (hpux version 6.2) and 
notice that the utmp file in the hp's often contains more entries than 
the number of users logged in. However, the "who" program distributed by hp 
seems to do the right thing. Since I dont have sources, could someone
explain the format (and other bits in hp's /etc/utmp file)? Also ut_host
is missing on the hp's, so where is this information kept, if it is saved
at all? 

This new finger program queries a database of users which we use for
creating password files, maintaining accounts etc.. and runs on a Sun
using yellow pages. I've noticed some problems with performance (the same 
program runs 10 times faster on the suns). I was therefore wondering if anyone
who has written network + nlist hacking code on hp350 series machines could 
explain this to me before I throw something heavier at it.. (is the network 
code just..slow?)  

-Sundar

ps. please send responses directly to me, since I dont read this newsgroup, 
and I doubt very many people are interested in these questions.

shankar@hpclscu.HP.COM (Shankar Unni) (03/28/89)

> I am trying to port a finger program to the hp's (hpux version 6.2) and 
> notice that the utmp file in the hp's often contains more entries than 
> the number of users logged in. However, the "who" program distributed by hp 
> seems to do the right thing. Since I dont have sources, could someone

Check the man page on utmp (4).

    struct           utmp {
         char     ut_user[8];     /* User login name */
         char     ut_id[4];       /* /etc/inittab id (usually line #) */
         char     ut_line[12];    /* device name (console, lnxx) */
         short    ut_pid; /* process id */
         short    ut_type;        /* type of entry */
         struct   exit_status {
              short           e_termination;  /* Process termination status */
              short           e_exit;         /* Process exit status */
                  } ut_exit;      /* The exit status of a process */
                                  /* marked as DEAD_PROCESS. */
         time_t   ut_time;        /* time entry was made */
    };

The field "ut_type" tells you what kind of an entry this is:

    /*  Definitions for ut_type  */
    #define   EMPTY           0
    /* ..... */
    #define   INIT_PROCESS    5     /* Process spawned by "init" */
    #define   LOGIN_PROCESS   6     /* A "getty" process waiting for login */
    #define   USER_PROCESS    7     /* A user process */
    #define   DEAD_PROCESS    8
    /* ... */
    
There are many more types: SysVish utmp's are cluttered with all kinds of
fascinating stuff. Read the man page for full details.

The ones you are interested in are the "USER_PROCESS" entries.
---
Shankar Unni.
HP Computer Language Lab.