Esempio n. 1
0
void key_handler( _SaganConfig *config )
{

  while(1) {

	int key; 

	key=getchar();
		   if ( key != 0 ) {
		   sagan_statistics(config);
		   }

	}
}
Esempio n. 2
0
void key_handler( void )
{

  while(1) {

	int key; 

	key=getchar();
		   if ( key != 0 ) {
		   sagan_statistics();
		   }

	}
}
Esempio n. 3
0
void sig_handler( _SaganSigArgs *args ) {

        sigset_t signal_set;
        int sig;

        for(;;) {
                /* wait for any and all signals */
                sigfillset( &signal_set );
                sigwait( &signal_set, &sig );


                switch( sig )
                {
		  /* exit */
		  case SIGQUIT:
		  case SIGINT:
		  case SIGTERM:
		  case SIGSEGV:
		  case SIGABRT:

                  sagan_log(args->config, 0, "\n\n[Received signal %d. Sagan version %s shutting down]-------\n", sig, VERSION);
		  sagan_statistics(args->config);

#if defined(HAVE_LIBMYSQLCLIENT_R) || defined(HAVE_LIBPQ)

		  /* last_cid != cid (has there been any alerts? */

		  if ( args->config->dbtype != 0 && counters->last_cid != counters-> cid ) record_last_cid(args->debug, args->config, counters);
#endif

#ifdef HAVE_LIBPRELUDE

/* This comment is from the Snort source code. "Sensor reporting to Prelude
   shall never go offline,  which is why we use the 
   PRELUDE_CLIENT_EXIT_STATUS_FAILURE.  */

if ( sagan_prelude_flag != 0 ) { 
prelude_client_destroy(preludeclient, PRELUDE_CLIENT_EXIT_STATUS_FAILURE);
prelude_deinit();
}

#endif

#ifdef HAVE_LIBDNET
if ( sagan_unified2_flag ) Unified2CleanExit(args->config); 
#endif

	        fflush(args->config->sagan_alert_stream);
	        fclose(args->config->sagan_alert_stream);             /* Close Sagan alert file */

       		fflush(args->config->sagan_log_stream);               /* Close the sagan.log */
        	fclose(args->config->sagan_log_stream);

                removelockfile(args->config);
                exit(0);
                break;

                 case SIGHUP:
                   pthread_mutex_lock(&sig_mutex);
   		   sagan_log(args->config, 0, "[Reloading Sagan version %s.]-------", VERSION);

		      /* Reset counters */
		   counters->refcount=0; counters->classcount=0; counters->rulecount=0; counters->ruletotal=0;
		   
		   /* Re-load everything */

		  load_config(args->debug, args->config);

                  pthread_mutex_unlock(&sig_mutex);
		  
		  sagan_log(args->config, 0, "Configuration reloaded.");
                  break;

		/* Signals to ignore */
	        case 17:		/* Child process has exited. */	
		case 28:		/* Terminal 'resize'/alarm. */
		break;

		case SIGUSR1:
		sagan_statistics(args->config); 
		break;

		default:
		sagan_log(args->config, 0, "[Received signal %d. Sagan doesn't know how to deal with]", sig);
                }
        }
}