#!/usr/local/bin/perl
# written by Dave Barr <barr@pop.psu.edu>
#
# Date: Thu, 10 Mar 1994 17:17:43 -0500
# From: David Barr <barr@pop.psu.edu>
#	I noticed that the fingerd program doesn't ever deleted
# entries in the userdata file if the accounts are deleted.  Perhaps
# it could go through and expire 'stale' entries when fingerd starts up.
#	In the meantime, I hacked up a little perl script which does it.
 
# first, slurp in the password file into an assoc

while (($name,$passwd,$uid,$gid,$q,$c,$gcos,$rest) = getpwent) {
	$uid{$name}=$uid;
}

# next, slurp in the finger user database and merge in last login time

open(USERDATA,"/usr/local/etc/packet2ascii </usr/local/lib/finger/userdata|");
open(USEROUT,"|/usr/local/etc/ascii2packet >/usr/local/lib/finger/userdata.new");

while (<USERDATA>) {
	($n,$rest)=split(/~/);
	if ($uid{$n} ne undef) {
		print USEROUT;
	}
}

close(USERDATA);
close(USEROUT);

# you need to then just mv the file if all went well and start fingerd.
