[15216] in Athena Bugs
IRIX logname
daemon@ATHENA.MIT.EDU (Greg Hudson)
Tue Jun 24 19:41:53 1997
Date: Tue, 24 Jun 1997 19:41:48 -0400
From: Greg Hudson <ghudson@MIT.EDU>
To: bugs@MIT.EDU
/usr/bin/logname on IRIX doesn't understand DEAD_PROCESS utmp entries.
For example, my current telnet session to opus yields:
opus% /bin/logname
daemon
opus% tty
/dev/ttyq1
From trace output, we can tell that logname operates by reading
/var/adm/utmp (not, incidentally, utmpx). If we look at a dump of
that file, we find that the first ttyq1 entry is a DEAD_PROCESS entry
for daemon:
username id line pid type exit time
000,000,000,000 system boot 0 BOOT_TIME 000000,00 866655328
000,000,000,000 run-level 2 0 RUN_LVL 000050,83 866655328
lnsyscon 108,105,110,107 23 DEAD_PROCESS 000000,00 866655328
rc2 115,050,000,000 26 DEAD_PROCESS 000000,00 866655385
tcp 080,077,049,048 210 LOGIN_PROCESS 000000,00 866655344
LOGIN 113,048,000,000 ttyq0 553 LOGIN_PROCESS 000000,00 867193229
LOGIN 116,049,000,000 ttyd1 563 LOGIN_PROCESS 000000,00 866655385
daemon 113,049,000,000 ttyq1 11337 DEAD_PROCESS 000002,02 867193228
emhavens 113,051,000,000 ttyq3 10766 DEAD_PROCESS 000002,02 867190158
emhavens 113,050,000,000 ttyq2 10764 DEAD_PROCESS 000002,02 867190158
marc 113,052,000,000 ttyq4 22490 DEAD_PROCESS 000002,02 867009359
.telnet 116,110,049,048 /dev/ttyq1 9737 LOGIN_PROCESS 000000,00 866764160
ghudson 108,111,113,049 ttyq1 11494 USER_PROCESS 000000,00 867194721
.telnet 116,110,050,048 /dev/ttyq1 21186 LOGIN_PROCESS 000000,00 867001352
107,108,113,049 ttyq1 0 DEAD_PROCESS 000000,00 867001341
107,108,113,051 ttyq3 0 DEAD_PROCESS 000000,00 867006386
marc 113,053,000,000 ttyq5 22565 DEAD_PROCESS 000002,02 867011944
.telnet 116,110,051,048 /dev/ttyq3 9881 LOGIN_PROCESS 000000,00 867177539
ghudson 108,111,113,051 ttyq3 9994 DEAD_PROCESS 000000,00 867180496
.telnet 116,110,052,048 /dev/ttyq3 9994 LOGIN_PROCESS 000000,00 867180492
.telnet 116,110,053,048 /dev/ttyq1 11450 LOGIN_PROCESS 000000,00 867193944
.telnet 116,110,054,048 /dev/ttyq1 11494 LOGIN_PROCESS 000000,00 867194719
This bug should probably be reported to SGI if it's not fixed in some
6.x release. For reference, here is the dumputmp.c program I used to
generate the above utmp file dump:
#include <stdio.h>
#include <utmp.h>
static char *typestr(int type, char *buf);
int main()
{
FILE *fp;
struct utmp utmp;
char typebuf[100];
fp = fopen("/var/adm/utmp", "r");
if (!fp) {
perror("fopen");
return 1;
}
printf("username id line pid type "
"exit time\n\n");
while (fread(&utmp, sizeof(utmp), 1, fp) != 0) {
printf("%-8.8s %03d,%03d,%03d,%03d %-12.12s %5d %-13s %06u,%02u"
" %09lu\n",
utmp.ut_user, utmp.ut_id[0], utmp.ut_id[1],
utmp.ut_id[2], utmp.ut_id[3], utmp.ut_line,
(int) utmp.ut_pid, typestr(utmp.ut_type, typebuf),
utmp.ut_exit.e_termination, utmp.ut_exit.e_exit,
(unsigned long) utmp.ut_time);
}
return 0;
}
static char *typestr(int type, char *buf)
{
static char *types[] = { "EMPTY", "RUN_LVL", "BOOT_TIME", "OLD_TIME",
"NEW_TIME", "INIT_PROCESS", "LOGIN_PROCESS",
"USER_PROCESS", "DEAD_PROCESS", "ACCOUNTING" };
if (type >= 0 && type <= UTMAXTYPE) {
return types[type];
} else {
sprintf(buf, "%d", type);
return buf;
}
}