Changeset 386

Show
Ignore:
Timestamp:
05/29/07 13:04:51 (1 year ago)
Author:
kindlund
Message:

Updated registry code to include intermediate cleanup of checkpoint operations (when temporary files are created).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeyclient/branches/exp/kindlund-filesystem/lib/HoneyClient/Agent/Integrity/Registry.pm

    r336 r386  
    442442            } 
    443443            delete($self->{_checkpoint_parsers}->{$hive}); 
     444        } 
     445    } 
     446} 
     447 
     448# Helper function, designed to cleanup temporary files created 
     449# by specified parsers. 
     450# 
     451# Inputs: HoneyClient::Agent::Integrity::Registry object, 
     452#         the hashtable collection of specified parsers 
     453# 
     454# Outputs: None. 
     455sub _cleanupParsers { 
     456    # Extract arguments. 
     457    my ($self, $parser_collection) = @_; 
     458 
     459    # Delete any temporary files created. 
     460    my $parser = undef; 
     461    my $fname = undef; 
     462    foreach my $hive (@{$self->{hives_to_check}}) { 
     463        $parser = $parser_collection->{$hive}; 
     464        if (defined($parser)) { 
     465            $fname = $parser->getFilename(); 
     466            if (defined($fname) && (-f $fname)) { 
     467                # XXX: Change this to debug, eventually. 
     468                $LOG->info("Deleting temporary '" . $hive . "' hive data in '" . 
     469                            $fname . "'."); 
     470                if (!unlink($fname)) { 
     471                    $LOG->fatal("Error: Unable to unlink '" . $hive . "' hive data in '" . $fname ."'."); 
     472                    Carp::croak("Error: Unable to unlink '" . $hive . "' hive data in '" . $fname ."'."); 
     473                } 
     474            } 
     475            delete($parser_collection->{$hive}); 
    444476        } 
    445477    } 
     
    14641496            $LOG->debug("Finished checking '" . $hive . "' hive."); 
    14651497        } 
     1498 
     1499        # Cleanup temporary files created by checkpointing. 
     1500        $self->_cleanupParsers($self->{_checkpoint_parsers}); 
    14661501    } 
    14671502