Changeset 348

Show
Ignore:
Timestamp:
05/07/07 16:56:17 (2 years ago)
Author:
kindlund
Message:

Integrity checking was taking too long and the pretend run() thread dying code didn't work properly. Fixed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeyclient/branches/exp/kindlund-filesystem/etc/honeyclient.xml

    r340 r348  
    402402            </port> 
    403403            <datastore_path description="The absolute path to the parent directory, where all HoneyClient VM data is stored on the host server.  It is assumed that individual VM data is stored in separate subdirectories within this parent directory." default="/vm"> 
    404                 /vm 
     404                /vm/clones 
    405405            </datastore_path> 
    406406            <snapshot_path description="The absolute path to the directory that contains all snapshot data, associated with every HoneyClient VM." default="/vm/snapshots"> 
  • honeyclient/branches/exp/kindlund-filesystem/lib/HoneyClient/Agent.pm

    r347 r348  
    568568# When called from run(), this function takes in the corresponding 
    569569# Driver object; checks to see if there's a new entry within the 
    570 # driver's corresponding update queue; and dequeues the *first
    571 # entry in the queue, overwriting the Driver's state data 
     570# driver's corresponding update queue; and dequeues the *all
     571# entries in the queue, overwriting the Driver's state data 
    572572# accordingly. 
    573573# 
    574574# The external updateState() call adds new driver state into the queue, 
    575575# one entry per call.  The internal _update() function merges this 
    576 # driver state with the currently running driver, one merge 
    577 # operation per call.  In order words, a single call to _update() 
    578 # may *NOT* empty the corresponding Driver update queue completely 
    579 # -- only one entry within the queue will be dequeued per _update() 
     576# driver state with the currently running driver, merging everything 
     577# queued per call.  In order words, a single call to _update() 
     578# *WILL* empty the corresponding Driver update queue completely 
     579# -- all entries within the queue will be dequeued per _update() 
    580580# call made. 
    581581# 
     
    593593    my $queue = $driverUpdateQueues{$driverName}; 
    594594 
     595    # XXX: One possible DoS condition here; what if 
     596    # the manager keeps feeding updates to the Agent 
     597    # before the Agent has a chance to do any work? 
     598     
    595599    # If we have data in our driver specific queue... 
    596     if ($queue->pending) { 
     600    while ($queue->pending) { 
    597601 
    598602        # Update our driver state with the first entry 
     
    849853                    $data->{$driverName}->{'state'} = $driver; 
    850854 
    851                     if ($driver->isFinished() or $driverTargetsChanged) { 
    852                         # Thread is about to finish, set the ID back to undef. 
    853                         # This looks ugly, but setting it this early avoids the 
    854                         # potential race condition of when the run() thread is finished 
    855                         # and when updateState() checks for $driverData->{$driverName}->{'thread_id'} 
    856                         # to be set to undef. 
    857                         $data->{$driverName}->{'thread_id'} = undef; 
    858                     } 
    859  
    860855                    # Release lock on stored driver state. 
    861856                    _unlock($data); 
     
    863858                 
    864859                # TODO: Perform Integrity Check 
     860                my $isCompromised = 0; 
    865861                if (defined($integrity)) { 
    866862                    # For now, we update a scalar called 'is_compromised' within 
     
    871867                        scalar(@{$changes->{filesystem}})) { 
    872868                        print "Integrity Check: FAILED\n"; 
    873  
    874                         # Acquire lock on stored driver state. 
    875                         $data = _lock(); 
    876  
    877                         $data->{$driverName}->{'status'}->{'is_compromised'} = 1; 
    878  
    879                         # Release lock on stored driver state. 
    880                         _unlock($data); 
    881  
     869                        $isCompromised = 1; 
    882870                    } else { 
    883871                        print "Integrity Check: PASSED\n"; 
     
    888876                # DESTROY this reference, but don't kill any temporary files created. 
    889877                $integrity = undef; 
     878 
     879                # Update driver state one last time, before exiting. 
     880                 
     881                # Acquire lock on stored driver state. 
     882                $data = _lock(); 
     883                     
     884                # Check for any additional external driver updates. 
     885                $driver = _update($driver); 
     886 
     887                # Copy object data to shared memory. 
     888                $data->{$driverName}->{'next'} = $driver->next(); 
     889                $data->{$driverName}->{'status'} = $driver->status(); 
     890                $data->{$driverName}->{'status'}->{'is_compromised'} = $isCompromised; 
     891                $data->{$driverName}->{'state'} = $driver; 
     892  
     893                # Thread is about to finish, set the ID back to undef. 
     894                $data->{$driverName}->{'thread_id'} = undef; 
     895 
     896                # Release lock on stored driver state. 
     897                _unlock($data); 
    890898 
    891899                # XXX: Debugging, remove eventually.