source: fixes wtmp so 'last' looks ok

Bill Selig - SysAdmin selig at golem.msfc.nasa.gov
Thu Nov 16 02:48:14 AEST 1989


About every 3-7 months here we have a case where the wtmp file gets scrod
and the output of the 'last' command looks REAL WIERD. This gets caused by
extra characters in the wtmp file. I have never figured out where this
comes from, but I did get aggravated enough the second time it happened to
write a bit of code to automatically fix the problem. I submit this to the
general community in case others have been hassled by this. 

Usage method is: fixwtmp infile [outfile]

It will read the infile, print to stdout the results of its analysis and
corrections, and optionally write to an output file. 

I typically do 

	'fixwtmp /var/adm/wtmp fw >results' 

followed by 

	'last -f fw' 

to check out the process. If the 'last' check looks ok, I copy (as root)
fw back to /var/adm/wtmp (making sure that no log{in,out}s have occured
since I started).

Ed's Note: placed in archives

FTP	Hostname : titan.rice.edu (128.42.30.1)
	Directory: sun-source
	Filename : fixwtmp.c

Archive Server Address: archive-server at rice.edu
Archive Server Command: get sun-source fixwtmp.c



More information about the Comp.sys.sun mailing list