2fe47a3c9f
no longer needed according to Michael Bunk. Patch from Michael Biebl.
71 lines
1.9 KiB
Plaintext
71 lines
1.9 KiB
Plaintext
/*
|
|
* utmpdump Simple program to dump UTMP and WTMP files in
|
|
* raw format, so they can be examined.
|
|
*
|
|
* Version: @(#)utmpdump.c 13-Aug-1996 1.00 miquels@cistron.nl
|
|
*
|
|
* This file is part of the sysvinit suite,
|
|
* Copyright (C) 1991-1996 Miquel van Smoorenburg.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <utmp.h>
|
|
#include <time.h>
|
|
|
|
void dump(fp)
|
|
FILE *fp;
|
|
{
|
|
struct utmp ut;
|
|
int f;
|
|
time_t tm;
|
|
|
|
while (fread(&ut, sizeof(struct utmp), 1, fp) == 1) {
|
|
for(f = 0; f < 12; f++) if (ut.ut_line[f] == ' ') ut.ut_line[f] = '_';
|
|
for(f = 0; f < 8; f++) if (ut.ut_name[f] == ' ') ut.ut_name[f] = '_';
|
|
tm = ut.ut_time;
|
|
printf("[%d] [%05d] [%-4.4s] [%-8.8s] [%-12.12s] [%-15.15s]\n",
|
|
ut.ut_type, ut.ut_pid, ut.ut_id, ut.ut_user,
|
|
ut.ut_line, 4 + ctime(&tm));
|
|
}
|
|
}
|
|
|
|
int main(argc, argv)
|
|
int argc;
|
|
char **argv;
|
|
{
|
|
int f;
|
|
FILE *fp;
|
|
|
|
if (argc < 2) {
|
|
argc = 2;
|
|
argv[1] = UTMP_FILE;
|
|
}
|
|
|
|
for(f = 1; f < argc; f++) {
|
|
if (strcmp(argv[f], "-") == 0) {
|
|
printf("Utmp dump of stdin\n");
|
|
dump(stdin);
|
|
} else if ((fp = fopen(argv[f], "r")) != NULL) {
|
|
printf("Utmp dump of %s\n", argv[f]);
|
|
dump(fp);
|
|
fclose(fp);
|
|
} else
|
|
perror(argv[f]);
|
|
}
|
|
return(0);
|
|
}
|