From owner-freebsd-questions Tue Apr 13 13:11:53 1999 Delivered-To: freebsd-questions@freebsd.org Received: from mailhub.scl.ameslab.gov (mailhub.scl.ameslab.gov [147.155.137.127]) by hub.freebsd.org (Postfix) with ESMTP id 6FFB014DA6 for ; Tue, 13 Apr 1999 13:11:48 -0700 (PDT) (envelope-from ghelmer@scl.ameslab.gov) Received: from demios.ether.scl.ameslab.gov ([147.155.137.54]) by mailhub.scl.ameslab.gov with esmtp (Exim 1.90 #1) id 10X9VQ-0001VP-00; Tue, 13 Apr 1999 15:10:00 -0500 Date: Tue, 13 Apr 1999 15:09:16 -0500 From: Guy Helmer To: GVB Cc: freebsd-questions@freebsd.org Subject: Re: lastlog/wtmp reporting incorrect info... In-Reply-To: <4.1.19990413101110.00b59e30@abused.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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