void start_plugins_one (void) { plugin_system_init (); vfs_set_lookup_func (lookup_transport); for (int i = 0; i < PLUGIN_TYPE_GENERAL; i ++) start_plugins (i); }
int CommonRender::restart_playback() { delete_vconsole(); create_modules(); build_virtual_console(); start_plugins(); done = 0; interrupt = 0; last_playback = 0; restart_plugins = 0; return 0; }
int main(int argc, char *argv[]) { mrp_context_t *ctx; ctx = create_context(); setup_signals(ctx); create_ruleset(ctx); parse_cmdline(ctx, argc, argv); load_configuration(ctx); start_plugins(ctx); load_ruleset(ctx); prepare_ruleset(ctx); setup_logging(ctx); daemonize(ctx); run_mainloop(ctx); stop_plugins(ctx); cleanup_context(ctx); return 0; }
int main(int argc, char *argv[]) { lnode *conf; struct sigaction sa; int i; #ifndef DEBUG /* Make sure we are root */ if (getuid() != 0) { fprintf(stderr, "You must be root to run this program.\n"); return 4; } #endif set_aumessage_mode(MSG_SYSLOG, DBG_YES); /* Register sighandlers */ sa.sa_flags = 0; sigemptyset(&sa.sa_mask); /* Ignore all signals by default */ sa.sa_handler = SIG_IGN; for (i=1; i<NSIG; i++) sigaction(i, &sa, NULL); /* Set handler for the ones we care about */ sa.sa_handler = term_handler; sigaction(SIGTERM, &sa, NULL); sa.sa_handler = hup_handler; sigaction(SIGHUP, &sa, NULL); sa.sa_handler = alarm_handler; sigaction(SIGALRM, &sa, NULL); sa.sa_handler = child_handler; sigaction(SIGCHLD, &sa, NULL); /* move stdin to its own fd */ if (argc == 3 && strcmp(argv[1], "--input") == 0) audit_fd = open(argv[2], O_RDONLY); else audit_fd = dup(0); if (audit_fd < 0) { syslog(LOG_ERR, "Failed setting up input, exiting"); return 1; } /* Make all descriptors point to dev null */ i = open("/dev/null", O_RDWR); if (i >= 0) { if (dup2(0, i) < 0 || dup2(1, i) < 0 || dup2(2, i) < 0) { syslog(LOG_ERR, "Failed duping /dev/null %s, exiting", strerror(errno)); return 1; } close(i); } else { syslog(LOG_ERR, "Failed opening /dev/null %s, exiting", strerror(errno)); return 1; } if (fcntl(audit_fd, F_SETFD, FD_CLOEXEC) < 0) { syslog(LOG_ERR, "Failed protecting input %s, exiting", strerror(errno)); return 1; } /* init the daemon's config */ if (load_config(&daemon_config, config_file)) return 6; load_plugin_conf(&plugin_conf); /* if no plugins - exit */ if (plist_count(&plugin_conf) == 0) { syslog(LOG_ERR, "No plugins found, exiting"); return 0; } /* Plugins are started with the auditd priority */ i = start_plugins(&plugin_conf); /* Now boost priority to make sure we are getting time slices */ if (daemon_config.priority_boost != 0) { errno = 0; (void) nice((int)-daemon_config.priority_boost); if (errno) { syslog(LOG_ERR, "Cannot change priority (%s)", strerror(errno)); /* Stay alive as this is better than stopping */ } } /* Let the queue initialize */ init_queue(daemon_config.q_depth); syslog(LOG_NOTICE, "audispd initialized with q_depth=%d and %d active plugins", daemon_config.q_depth, i); /* Tell it to poll the audit fd */ if (add_event(audit_fd, process_inbound_event) < 0) { syslog(LOG_ERR, "Cannot add event, exiting"); return 1; } /* Create inbound thread */ pthread_create(&inbound_thread, NULL, inbound_thread_main, NULL); /* Start event loop */ while (event_loop()) { hup = 0; reconfigure(); } /* Tell plugins we are going down */ signal_plugins(SIGTERM); /* Cleanup builtin plugins */ destroy_af_unix(); destroy_syslog(); /* Give it 5 seconds to clear the queue */ alarm(5); pthread_join(inbound_thread, NULL); /* Release configs */ plist_first(&plugin_conf); conf = plist_get_cur(&plugin_conf); while (conf) { free_pconfig(conf->p); conf = plist_next(&plugin_conf); } plist_clear(&plugin_conf); /* Cleanup the queue */ destroy_queue(); free_config(&daemon_config); return 0; }
void start_plugins_two (void) { for (int i = PLUGIN_TYPE_GENERAL; i < PLUGIN_TYPES; i ++) start_plugins (i); }
int main(int argc, char *argv[]) { GPtrArray *plugin_array = g_ptr_array_new(); GOptionContext *ctx = g_option_context_new(" target port"); signal(SIGPIPE, signal_callback_handler); int plugin_num = enumerate_plugins(SYSLOG_NG_PATH_LOGGEN_PLUGIN_DIR, plugin_array, ctx); DEBUG("%d plugin successfuly loaded\n",plugin_num); /* create sub group for file reader functions */ GOptionGroup *group = g_option_group_new("file-reader", "file-reader", "Show options", NULL, NULL); g_option_group_add_entries(group, get_file_reader_options()); g_option_context_add_group(ctx, group); GError *error = NULL; if (!g_option_context_parse(ctx, &argc, &argv, &error)) { ERROR("option parsing failed: %s\n", error->message); g_ptr_array_free(plugin_array,TRUE); if (error) g_error_free(error); return 1; } /* debug option defined by --debug command line option */ set_debug_level(debug); if (argc>=3) { global_plugin_option.target = g_strdup(argv[1]); global_plugin_option.port = g_strdup(argv[2]); } else if (argc>=2) { global_plugin_option.target = g_strdup(argv[1]); global_plugin_option.port = NULL; } else { global_plugin_option.target = NULL; global_plugin_option.port = NULL; DEBUG("no port and address specified"); } DEBUG("target=%s port=%s\n",global_plugin_option.target,global_plugin_option.port); if (global_plugin_option.message_length > MAX_MESSAGE_LENGTH) { ERROR("warning: defined message length (%d) is too big. truncated to (%d)\n",global_plugin_option.message_length, MAX_MESSAGE_LENGTH); global_plugin_option.message_length = MAX_MESSAGE_LENGTH; } read_from_file = init_file_reader(global_plugin_option.active_connections); if (read_from_file < 0) { ERROR("error while opening input file. exit.\n"); return 1; } message_counter_lock = g_mutex_new(); init_logline_generator(plugin_array); init_csv_statistics(); if (start_plugins(plugin_array) > 0) { wait_all_plugin_to_finish(plugin_array); stop_plugins(plugin_array); } close_file_reader(global_plugin_option.active_connections); if (message_counter_lock) g_mutex_free(message_counter_lock); g_free((gpointer)global_plugin_option.target); g_free((gpointer)global_plugin_option.port); g_ptr_array_free(plugin_array,TRUE); g_free(thread_stat_count_last); g_free(thread_stat_count); return 0; }