Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Apr 1999 15:09:16 -0500
From:      Guy Helmer <ghelmer@scl.ameslab.gov>
To:        GVB <gvbmail@tns.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: lastlog/wtmp reporting incorrect info...
Message-ID:  <Pine.SGI.4.05.9904131450540.26916-100000@demios.scl.ameslab.gov>
In-Reply-To: <4.1.19990413101110.00b59e30@abused.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 13 Apr 1999, GVB wrote:

> I just upgraded a 2.2.8 machine to 3.1 and I am having problems with what
> looks like wtmp and lastlog.  finger, w, and who are all reporting
> incorrect information about who is logged in, it is not updating correctly.
>  Is this a know problem during the upgrade process? What can I do to fix it.

The longer user names in 3.x affect the leftover 2.x wtmp and lastlog
files.  Maybe a Perl script like this would be able to convert 2.x wtmp
files to 3.x (no guarantees!  I haven't tried running it!).  Note that
your lastlog file is probably toasty -- you probably just need to "cp
/dev/null /var/log/lastlog" to clear it out.

#!/usr/bin/perl
#
# Usage: wtmp_convert /var/log/old-version2-wtmp /var/log/new-version3-wtmp
#
$wtmp2_template = 'A8 A8 A16 L';
$wtmp3_template = 'A8 A16 A16 L';
$wtmp2_struct_len = length(pack($wtmp2_template, '', '', '', 0));
$wtmp3_struct_len = length(pack($wtmp3_template, '', '', '', 0));

open(WTMP2, $ARGV[0]) || die "Error: couldn't open file $ARGV[0] : $!\n";
open(WTMP3, ">$ARGV[1]") || die "Error: couldn't open file $ARGV[1] : $!\n";

while (read(WTMP2, $wtmp2_buf, $wtmp2_struct_len) > 0) {
    $wtmp3_buf = pack($wtmp3_template, unpack($wtmp2_template, $wtmp2_buf));
    syswrite(WTMP3, $wtmp3_buf, $wtmp3_struct_len);
}
close(WTMP2);
close(WTMP3);
exit 0;

Guy Helmer, Ph.D. Candidate, Iowa State University Dept. of Computer Science 
Research Assistant, Ames Laboratory       ---         ghelmer@scl.ameslab.gov
Research Assistant, Dept. of Computer Science   ---   ghelmer@cs.iastate.edu
http://www.cs.iastate.edu/~ghelmer



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SGI.4.05.9904131450540.26916-100000>