/* * Callback to load a cert/chain/key combo from a single PEM file. */ static void main_loadtgcrt(const char *filename, void *arg) { opts_t *opts = arg; cert_t *cert; char **names; cert = cert_new_load(filename); if (!cert) { log_err_printf("Failed to load cert and key from PEM file " "'%s'\n", filename); log_fini(); exit(EXIT_FAILURE); /* XXX */ } if (X509_check_private_key(cert->crt, cert->key) != 1) { log_err_printf("Cert does not match key in PEM file " "'%s':\n", filename); ERR_print_errors_fp(stderr); log_fini(); exit(EXIT_FAILURE); /* XXX */ } #ifdef DEBUG_CERTIFICATE log_dbg_printf("Loaded '%s':\n", filename); log_dbg_print_free(ssl_x509_to_str(cert->crt)); log_dbg_print_free(ssl_x509_to_pem(cert->crt)); #endif /* DEBUG_CERTIFICATE */ if (OPTS_DEBUG(opts)) { log_dbg_printf("Targets for '%s':", filename); } names = ssl_x509_names(cert->crt); for (char **p = names; *p; p++) { /* be deliberately vulnerable to NULL prefix attacks */ char *sep; if ((sep = strchr(*p, '!'))) { *sep = '\0'; } if (OPTS_DEBUG(opts)) { log_dbg_printf(" '%s'", *p); } cachemgr_tgcrt_set(*p, cert); free(*p); } if (OPTS_DEBUG(opts)) { log_dbg_printf("\n"); } free(names); cert_free(cert); }
static void all_fini(void) { // Make some effort to honnor any plugins destructor at exit doomer_stop(); // doomer_thread must not awake while we destroy parsers, plugins, and so on pkt_source_fini(); plugin_del_all(); // Since hook subscribers is not locked, we must kill sources before unregister plugins for (unsigned i = NB_ELEMS(initers); i > 0; ) { initers[--i].fini(); } # ifdef DELETE_ALL_AT_EXIT /* This is sometime usefull to clean all allocated ressources * at exit to help valgrind help us find memory leaks. */ ERR_free_strings(); # endif redim_array_fini(); hash_fini(); ref_fini(); mallocer_fini(); cli_fini(); ext_fini(); files_fini(); log_fini(); }
/* * called at exit */ static void cleanup(void) { log_notice("Exiting"); if(!intr) { /* We are not in the interrupt context */ if(md5ctxp != NULL) { free_MD5_CTX(md5ctxp); } if(pq != NULL) { off_t highwater = 0; size_t maxregions = 0; (void) pq_highwater(pq, &highwater, &maxregions); (void) pq_close(pq); pq = NULL; if(feed_close) (*feed_close)(ifd); ifd = -1; log_notice(" Queue usage (bytes):%8ld", (long)highwater); log_notice(" (nregions):%8ld", (long)maxregions); log_notice(" Duplicates rejected:%8lu", ndups); } (*prod_stats)(); (*feed_stats)(); } log_fini(); }
int main( const int argc, const char* const * argv) { int exitCode = 1; // Failure default int status = log_init(argv[0]); if (status) { (void) fprintf(stderr, "Couldn't initialize logging system\n"); } else { if (CUE_SUCCESS == CU_initialize_registry()) { CU_Suite* testSuite = CU_add_suite(__FILE__, setup, teardown); if (NULL != testSuite) { if (CU_ADD_TEST(testSuite, test_fq_new) && CU_ADD_TEST(testSuite, test_fq_shutdown) && CU_ADD_TEST(testSuite, test_write_then_read) && CU_ADD_TEST(testSuite, test_concurrency)) { CU_basic_set_mode(CU_BRM_VERBOSE); (void) CU_basic_run_tests(); } } exitCode = CU_get_number_of_tests_failed(); CU_cleanup_registry(); } } log_fini(); return exitCode; }
int main (int argc, char *argv[]) { int rc; zsock_t *zs; pthread_t tid; pthread_attr_t attr; flux_msg_t *msg; flux_sec_t *sec; int n; log_init (basename (argv[0])); if (argc != 1 && argc != 2) { fprintf (stderr, "Usage: tmunge [--fake]\n"); exit (1); } if (argc == 2) { if (!strcmp (argv[1], "--fake")) sec_typemask |= FLUX_SEC_FAKEMUNGE; else log_msg_exit ("unknown option %s", argv[1]); } if (!(sec = flux_sec_create (sec_typemask, NULL))) log_err_exit ("flux_sec_create"); if (flux_sec_comms_init (sec) < 0) log_err_exit ("flux_sec_comms_init: %s", flux_sec_errstr (sec)); if (!(zs = zsock_new_sub (uri, ""))) log_err_exit ("S: zsock_new_sub"); if (!(cs = zsock_new_pub (uri))) log_err_exit ("S: zsock_new_pub"); if ((rc = pthread_attr_init (&attr))) log_errn (rc, "S: pthread_attr_init"); if ((rc = pthread_create (&tid, &attr, thread, NULL))) log_errn (rc, "S: pthread_create"); /* Handle one client message. */ if (!(msg = flux_msg_recvzsock_munge (zs, sec))) log_err_exit ("S: flux_msg_recvzsock_munge: %s", flux_sec_errstr (sec)); //zmsg_dump (zmsg); if ((n = flux_msg_frames (msg)) != 4) log_err_exit ("S: expected 4 frames, got %d", n); flux_msg_destroy (msg); /* Wait for thread to terminate, then clean up. */ if ((rc = pthread_join (tid, NULL))) log_errn (rc, "S: pthread_join"); zsock_destroy (&zs); zsock_destroy (&cs); flux_sec_destroy (sec); log_fini (); return 0; }
int main( const int argc, const char* const * argv) { int exitCode = 1; if (log_init(argv[0])) { log_syserr("Couldn't initialize logging module"); exitCode = EXIT_FAILURE; } else { if (CUE_SUCCESS == CU_initialize_registry()) { CU_Suite* testSuite = CU_add_suite(__FILE__, setup, teardown); if (NULL != testSuite) { if (CU_ADD_TEST(testSuite, test_socketpair)) { CU_basic_set_mode(CU_BRM_VERBOSE); (void) CU_basic_run_tests(); } } exitCode = CU_get_number_of_tests_failed(); CU_cleanup_registry(); } log_fini(); } return exitCode; }
int main(int argc, char *argv[]) { int ret; config.logFilePath = DEFAULT_LOG_FILE_PATH; config.logLevel = INFO_LOG; parse_cmd_line(argc, argv); ret = load_config(); if(ret) { log_message(ERROR_LOG, "Loading configuration failed."); config_free(); return 1; } ret = initialize(); if(ret != 0) { log_message(ERROR_LOG, "initialize is failed."); config_free(); return 1; } ret = socks_proxy(); cachemgr_fini(); log_fini(); config_free(); return 0; }
int main (int argc, char *argv[]) { char *cmd; if (argc == 1) usage (); cmd = argv[1]; log_init (basename (argv[0])); if (!strcmp (cmd, "mt")) test_mt (argc - 2, argv + 2); else if (!strcmp (cmd, "selfmod")) test_selfmod (argc - 2, argv + 2); else if (!strcmp (cmd, "unwatch")) test_unwatch (argc - 2, argv + 2); else if (!strcmp (cmd, "unwatchloop")) test_unwatchloop (argc - 2, argv + 2); else if (!strcmp (cmd, "simulwatch")) test_simulwatch (argc - 2, argv + 2); else usage (); log_fini (); return 0; }
void NtProcessStartup( void ) { NTSTATUS r = 0; r = log_init(); dprintf( "hello world\n"); log_fini(); }
void cleanup(void) { if (ldmProxy != NULL) { lp_free(ldmProxy); ldmProxy = NULL; } log_fini(); }
/* * Called at exit. * This callback routine registered by atexit(). */ static void cleanup(void) { log_notice_q("exiting"); /* TODO: sign off */ log_fini(); }
void NtProcessStartup( void ) { log_init(); test_open_process(); test_open_process_param_size(); test_read_exception_port(); test_terminate_process(); log_fini(); }
void NtProcessStartup( void ) { log_init(); test_rtl_path(); test_file_open(); test_query_directory(); log_fini(); }
void cleanup (void) { if (pq) { (void) pq_close (pq); pq = NULL; } log_fini(); }
static void sig_handler (int s) { if (s == SIGINT) { fprintf (stdout, "Exit on INT\n\n"); /* this will call freectx */ flux_close (sig_flux_h); log_fini (); exit (0); } }
int main (int argc, char *argv[]) { flux_t h; int ch = 0; int rc = 0; char *cmd = NULL; const char *j = NULL; const char *ofn = NULL; const char *attr = NULL; const char *jcbstr = NULL; log_init ("flux-jstat"); while ((ch = getopt_long (argc, argv, OPTIONS, longopts, NULL)) != -1) { switch (ch) { case 'h': /* --help */ usage (0); break; case 'o': /* --testout */ ofn = xasprintf ("%s", optarg); break; default: usage (1); break; } } if (optind == argc) usage (1); if (!(h = flux_open (NULL, 0))) err_exit ("flux_open"); flux_log_set_facility (h, "jstat"); cmd = argv[optind++]; if (!strcmp ("notify", cmd)) rc = handle_notify_req (h, (const char *)ofn); else if (!strcmp ("query", cmd) && optind == argc - 2) { j = (const char *)(*(argv+optind)); attr = (const char *)(*(argv+optind+1)); rc = handle_query_req (h, strtol (j, NULL, 10), attr, ofn); } else if (!strcmp ("update", cmd) && optind == argc - 3) { j = (const char *)(*(argv+optind)); attr = (const char *)(*(argv+optind+1)); jcbstr = (const char *)(*(argv+optind+2)); rc = handle_update_req (h, strtol (j, NULL, 10), attr, jcbstr, ofn); } else usage (1); flux_close (h); log_fini (); return (!rc)? 0: 42; }
int main(void) { log_init(); log_set_level(LOG_DEBUG, NULL); log_set_file("cursor_check.log"); cursor_check(); log_fini(); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { flux_t h; int ch = 0; int64_t jobid = -1; char *sfn = NULL; char *cfn = NULL; wjctx_t *ctx = NULL; log_init ("flux-waitjob"); while ((ch = getopt_long (argc, argv, OPTIONS, longopts, NULL)) != -1) { switch (ch) { case 'h': /* --help */ usage (); break; case 's': /* --sync-start */ sfn = xstrdup (optarg); break; case 'c': /* --sync-complete */ cfn = xstrdup (optarg); break; default: usage (); break; } } if (optind == argc) usage (); jobid = strtol (argv[optind], NULL, 10); if (jobid <= 0) log_err_exit ("jobid must be a positive number"); else if (!(h = flux_open (NULL, 0))) log_err_exit ("flux_open"); ctx = getctx (h); if (sfn) ctx->start = sfn; if (cfn) ctx->complete = cfn; ctx->jobid = jobid; flux_log_set_appname (h, "waitjob"); wait_job_complete (h); flux_close (h); log_fini (); return 0; }
static void zipper_delete(zipper_t *zipper) { log_fini(); conf_destroy(zipper->config_); dns_server_delete(zipper->dns_server_); dns_client_delete(zipper->dns_client_); rule_store_destroy(zipper->rule_store_); ipstore_destroy(zipper->ip_store_); command_server_delete(zipper->command_server_); memorypool_delete(zipper->query_session_pool_); free(zipper); zrb_finalize_ruby_env(); }
int main (int argc, char *argv[]) { flux_t h; int ch; bool uopt = false; bool dopt = false; fmt_t fmt = FMT_RANGED; ns_t *ns; log_init ("flux-up"); while ((ch = getopt_long (argc, argv, OPTIONS, longopts, NULL)) != -1) { switch (ch) { case 'c': /* --comma */ fmt = FMT_COMMA; break; case 'n': /* --newline */ fmt = FMT_NEWLINE; break; case 'u': /* --up */ uopt = true; break; case 'd': /* --down */ dopt = true; break; default: usage (); break; } } if (optind != argc) usage (); if (!(h = flux_open (NULL, 0))) err_exit ("flux_open"); if (!(ns = ns_fromkvs (h))) ns = ns_guess (h); if (dopt) ns_print_down (ns, fmt); else if (uopt) ns_print_up (ns, fmt); else ns_print_all (ns, fmt); ns_destroy (ns); flux_close (h); log_fini (); return 0; }
int main (int argc, char *argv[]) { flux_t h; int ch; char *message = NULL; size_t len = 0; char *priority = "user.notice"; int level; char *facility; int e; log_init ("flux-logger"); while ((ch = getopt_long (argc, argv, OPTIONS, longopts, NULL)) != -1) { switch (ch) { case 'h': /* --help */ usage (); break; case 'p': /* --priority facility.level */ priority = optarg; break; default: usage (); break; } } if (optind == argc) usage (); if ((e = argz_create (argv + optind, &message, &len)) != 0) errn_exit (e, "argz_create"); argz_stringify (message, len, ' '); if (!(h = flux_open (NULL, 0))) err_exit ("flux_open"); if (parse_logstr (priority, &level, &facility) < 0) msg_exit ("bad priority argument"); flux_log_set_facility (h, facility); if (flux_log (h, level, "%s", message) < 0) err_exit ("flux_log"); flux_close (h); free (message); free (facility); log_fini (); return 0; }
int main(void) { log_init(); log_set_level(LOG_DEBUG, NULL); log_set_file("ip_addr_check.log"); ip_addr_check(); ip_addr_ctor_from_str_check(); ip_addr_routable_check(); broadcast_check(); scm_conv_check(); log_fini(); return EXIT_SUCCESS; }
int main(int argc, char** argv){ int rc = 0; if (log_init()){ printf("log_init() failed"); rc = 1; }else{ MYLOGMSG(LOG4C_PRIORITY_ERROR, "Hello World!"); /* Explicitly call the logging cleanup routine */ log_fini(); } return rc; }
void cleanup(void) { if (pq) { #if !USE_MMAP if (!pqeIsNone(pqeIndex)) (void)pqe_discard(pq, pqeIndex); #endif (void) pq_close(pq); pq = NULL; } log_fini(); }
static void cleanup(void) { log_notice("Exiting"); dump_stats(&stats); if(pq != NULL) { (void)pq_close(pq); pq = NULL; } log_fini(); }
int main (int argc, char *argv[]) { flux_t h; int ch; char *message = NULL; size_t len = 0; int severity = LOG_NOTICE; char *appname = "logger"; int e; log_init ("flux-logger"); while ((ch = getopt_long (argc, argv, OPTIONS, longopts, NULL)) != -1) { switch (ch) { case 'h': /* --help */ usage (); break; case 's': /* --severity LEVEL */ if ((severity = stdlog_string_to_severity (optarg)) < 0) log_msg_exit ("invalid severity: Use emerg|alert|crit|err|warning|notice|info|debug"); break; case 'n': /* --appname NAME */ appname = optarg; break; default: usage (); break; } } if (optind == argc) usage (); if ((e = argz_create (argv + optind, &message, &len)) != 0) log_errn_exit (e, "argz_create"); argz_stringify (message, len, ' '); if (!(h = flux_open (NULL, 0))) log_err_exit ("flux_open"); flux_log_set_appname (h, appname); flux_log (h, severity, "%s", message); flux_close (h); free (message); log_fini (); return 0; }
void NtProcessStartup( void ) { log_init(); test_NtAllocateVirtualMemory(); test_NtFreeVirtualMemory(); #if 0 test_alloc_free(); test_granularity(); test_chunksize(); test_prot_mem(); test_free_mem(); test_separate_alloc_single_free(); test_split_and_join(); test_commit_in_the_middle(); #endif log_fini(); }
int main(void) { log_init(); ext_init(); mallocer_init(); mutex_init(); log_set_level(LOG_DEBUG, NULL); log_set_file("mallocer_check.log"); malloc_check(); realloc_check(); mutex_fini(); mallocer_fini(); ext_fini(); log_fini(); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { int ch; flux_sec_t sec; bool force = false; bool plain = false; char *secdir; log_init ("flux-keygen"); while ((ch = getopt_long (argc, argv, OPTIONS, longopts, NULL)) != -1) { switch (ch) { case 'h': /* --help */ usage (); break; case 'f': /* --force */ force = true; break; case 'p': /* --plain */ plain = true; break; default: usage (); break; } } if (optind < argc) usage (); if (!(sec = flux_sec_create ())) err_exit ("flux_sec_create"); if (!(secdir = getenv ("FLUX_SEC_DIRECTORY"))) msg_exit ("FLUX_SEC_DIRECTORY is not set"); flux_sec_set_directory (sec, secdir); if (plain && flux_sec_enable (sec, FLUX_SEC_TYPE_PLAIN) < 0) msg_exit ("PLAIN security is not available"); if (flux_sec_keygen (sec, force, true) < 0) msg_exit ("%s", flux_sec_errstr (sec)); flux_sec_destroy (sec); log_fini (); return 0; }
/* * called at exit */ static void cleanup(void) { log_notice("Exiting"); if (done) { /* * We are not in the interrupt context, so these can be performed * safely. */ fl_closeAll(); if (pq) (void)pq_close(pq); if (!tvEqual(palt_last_insertion, TS_ZERO)) { timestampt now; (void)set_timestamp(&now); log_notice("Behind by %g s", d_diff_timestamp(&now, &palt_last_insertion)); if (stateWrite(&palt_last_insertion) < 0) { log_error("Couldn't save insertion-time of last processed " "data-product"); } } while (reap(-1, WNOHANG) > 0) /*EMPTY*/; } if(shmid != -1) { log_notice("Deleting shared segment."); shmctl(shmid, IPC_RMID, NULL); } if(semid != -1) { semctl(semid, 0, IPC_RMID); } log_fini(); }