Changeset 816
- Timestamp:
- 09/05/07 10:47:29 (1 year ago)
- Files:
-
- honeyclient/branches/exp/kindlund-dynamic_updates/lib/HoneyClient/Manager.pm (modified) (8 diffs)
- honeyclient/branches/exp/kindlund-dynamic_updates/lib/HoneyClient/Manager/VM.pm (modified) (3 diffs)
- honeyclient/branches/exp/kindlund-dynamic_updates/lib/HoneyClient/Manager/VM/Clone.pm (modified) (3 diffs)
- honeyclient/branches/exp/kindlund-dynamic_updates/t/honeyclient_manager.t (modified) (1 diff)
- honeyclient/branches/exp/kindlund-dynamic_updates/t/honeyclient_manager_vm_clone.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
honeyclient/branches/exp/kindlund-dynamic_updates/lib/HoneyClient/Manager.pm
r814 r816 239 239 use HoneyClient::Util::Config qw(getVar); 240 240 241 # Check if HoneyClient::DB support is enabled. 242 my $DB_ENABLE = getVar(name => "enable", 243 namespace => "HoneyClient::DB"); 244 245 if ($DB_ENABLE) { 246 # Make sure HoneyClient::DB::Fingerprint loads. 247 require_ok('HoneyClient::DB::Fingerprint'); 248 require HoneyClient::DB::Fingerprint; 249 } 250 241 251 # Make sure Storable loads. 242 252 BEGIN { use_ok('Storable', qw(nfreeze thaw)) or diag("Can't load Storable package. Check to make sure the package library is correctly listed within the path."); } … … 275 285 use HoneyClient::Manager::VM qw(); 276 286 277 # Check if DB support is enabled.287 # Check if HoneyClient::DB support is enabled. 278 288 our $DB_ENABLE = getVar(name => "enable", 279 289 namespace => "HoneyClient::DB"); 280 290 281 291 if ($DB_ENABLE) { 282 # Include DB Utility Library 283 # TODO: Include unit tests. 292 # Include HoneyClient::DB Utility Libraries 284 293 require HoneyClient::DB::Fingerprint; 285 294 } … … 325 334 326 335 # XXX: These will be migrated somewhere else, eventually. 327 our $vmStateTable = { };328 336 our $vmCloneConfig = undef; 329 our $stubVM = undef;330 our $stubAgent = undef;331 our $stubFW = undef;332 337 333 338 # This is a temporary, shared variable, used to print out the … … 336 341 # eventually. 337 342 our $globalAgentState = undef; 338 339 # This static variable may contain a filename that the Manager340 # would use to dump its entire state information, upon termination.341 # XXX: May want to change this format/usage, eventually.342 our $STATE_FILE = getVar(name => "manager_state");343 343 344 344 # Temporary variable, used to indicate to the fault handler whether … … 493 493 # Hence, rather than fight the VM daemon's natural self termination, 494 494 # we let the daemon die, but the create a new one, for the sole purpose 495 # of clean upup the clones.495 # of cleaning up the clones. 496 496 HoneyClient::Manager::VM->init(); 497 497 $LOG->info("Calling suspendVM(config => " . $vmCloneConfig . ")."); … … 502 502 } 503 503 504 # This variable may contain a filename that the Manager 505 # would use to dump its entire state information, upon termination. 504 506 # XXX: May want to change this format/usage, eventually. 507 my $STATE_FILE = getVar(name => "manager_state"); 508 505 509 if (length($STATE_FILE) > 0 && 506 510 defined($globalAgentState)) { … … 600 604 my ($class, %args) = @_; 601 605 606 my $stubVM = undef; 607 my $stubFW = undef; 608 my $stubAgent = undef; 602 609 my $som = undef; 603 610 my $ret = undef; … … 608 615 my $vmState = undef; 609 616 my $vmCompromised = 0; 617 my $vmStateTable = { }; 610 618 611 619 # Get a stub connection to the firewall. honeyclient/branches/exp/kindlund-dynamic_updates/lib/HoneyClient/Manager/VM.pm
r814 r816 307 307 use Carp (); 308 308 309 # XXX: Check this. 309 310 # Traps signals, allowing END: blocks to perform cleanup. 310 use sigtrap qw(die untrapped normal-signals error-signals);311 #use sigtrap qw(die untrapped normal-signals error-signals); 311 312 312 313 ####################################################################### … … 767 768 } 768 769 770 # XXX: Check this. 769 771 # Do not attempt to rejoin parent process tree, 770 772 # if any type of termination signal is received. 771 local $SIG{HUP} = sub { exit; };772 local $SIG{INT} = sub { exit; };773 local $SIG{QUIT} = sub { exit; };774 local $SIG{ABRT} = sub { exit; };775 local $SIG{PIPE} = sub { exit; };776 local $SIG{TERM} = sub { exit; };773 # local $SIG{HUP} = sub { exit; }; 774 # local $SIG{INT} = sub { exit; }; 775 # local $SIG{QUIT} = sub { exit; }; 776 # local $SIG{ABRT} = sub { exit; }; 777 # local $SIG{PIPE} = sub { exit; }; 778 # local $SIG{TERM} = sub { exit; }; 777 779 778 780 my $daemon = getServerHandle(address => $args{'address'}, … … 4776 4778 # Disconnect from the VMware Server / GSX host. 4777 4779 _disconnect(); 4780 4778 4781 } 4779 4782 honeyclient/branches/exp/kindlund-dynamic_updates/lib/HoneyClient/Manager/VM/Clone.pm
r814 r816 127 127 use Config; 128 128 use Carp (); 129 130 # XXX: Verify this. 131 # Traps signals, allowing END: blocks to perform cleanup. 132 #use sigtrap qw(die untrapped normal-signals error-signals); 133 use sigtrap qw(die untrapped normal-signals); 129 134 130 135 ####################################################################### … … 438 443 439 444 if (($OBJECT_COUNT >= 0) && defined($self->{'config'})) { 445 446 # Initialize a new handler, but suppress any initial connection errors. 447 $self->{'_vm_handle'} = getClientHandle(namespace => "HoneyClient::Manager::VM", 448 fault_handler => sub { die "ERROR"; }); 449 440 450 $LOG->info("Suspending clone VM (" . $self->{'config'} . ")."); 441 my $som = $self->{'_vm_handle'}->suspendVM(config => $self->{'config'}); 442 if (!$som->result()) { 451 my $som = undef; 452 eval { 453 $som = $self->{'_vm_handle'}->suspendVM(config => $self->{'config'}); 454 }; 455 456 # Reinitialize the VM daemon, in case it died from 457 # a CTRL-C or other forced termination. 458 unless(defined($som)) { 459 # Make sure the VM daemon was properly destroyed. 460 HoneyClient::Manager::VM->destroy(); 461 462 # Sleep a bit, in order for the terminated VM daemon to release 463 # its network bindings. 464 sleep(10); 465 466 # Reinitialize VM daemon. 467 HoneyClient::Manager::VM->init(); 468 469 # Reinitialize handler, with errors not suppressed. 470 $self->{'_vm_handle'} = getClientHandle(namespace => "HoneyClient::Manager::VM"); 471 472 # Call suspendVM one more time... 473 $som = $self->{'_vm_handle'}->suspendVM(config => $self->{'config'}); 474 } 475 476 if (!defined($som)) { 443 477 $LOG->error("Unable to suspend VM (" . $self->{'config'} . ")."); 444 478 } 479 445 480 } 446 481 … … 670 705 # Now, kill the VM daemon. 671 706 HoneyClient::Manager::VM->destroy(); 672 sleep (1 );707 sleep (10); 673 708 674 709 # Create a generic empty clone, with test state data. honeyclient/branches/exp/kindlund-dynamic_updates/t/honeyclient_manager.t
r814 r816 83 83 use HoneyClient::Util::Config qw(getVar); 84 84 85 # Check if HoneyClient::DB support is enabled. 86 my $DB_ENABLE = getVar(name => "enable", 87 namespace => "HoneyClient::DB"); 88 89 if ($DB_ENABLE) { 90 # Make sure HoneyClient::DB::Fingerprint loads. 91 require_ok('HoneyClient::DB::Fingerprint'); 92 require HoneyClient::DB::Fingerprint; 93 } 94 85 95 # Make sure Storable loads. 86 96 BEGIN { use_ok('Storable', qw(nfreeze thaw)) or diag("Can't load Storable package. Check to make sure the package library is correctly listed within the path."); } honeyclient/branches/exp/kindlund-dynamic_updates/t/honeyclient_manager_vm_clone.t
r814 r816 157 157 # Now, kill the VM daemon. 158 158 HoneyClient::Manager::VM->destroy(); 159 sleep (1 );159 sleep (10); 160 160 161 161 # Create a generic empty clone, with test state data.
