int main (int argc, char *argv[]) { DBusGConnection *bus; DBusGProxy *proxy; MMManager *manager; GError *err = NULL; guint id; mm_options_parse (argc, argv); g_type_init (); setup_signals (); if (!mm_options_debug ()) logging_setup (); g_message ("ModemManager (version " MM_DIST_VERSION ") starting..."); bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err); if (!bus) { g_warning ("Could not get the system bus. Make sure " "the message bus daemon is running! Message: %s", err->message); g_error_free (err); return -1; } proxy = create_dbus_proxy (bus); if (!proxy) return -1; manager = mm_manager_new (bus); g_idle_add (start_manager, manager); loop = g_main_loop_new (NULL, FALSE); id = g_signal_connect (proxy, "destroy", G_CALLBACK (destroy_cb), loop); g_main_loop_run (loop); g_signal_handler_disconnect (proxy, id); mm_manager_shutdown (manager); /* Wait for all modems to be removed */ while (mm_manager_num_modems (manager)) { GMainContext *ctx = g_main_loop_get_context (loop); g_main_context_iteration (ctx, FALSE); g_usleep (50); } g_object_unref (manager); g_object_unref (proxy); dbus_g_connection_unref (bus); logging_shutdown (); return 0; }
/** * Ensure that at warning log level we DO log something via AM_LOG_WARNING. */ void test_log_warning_at_warning_level(void** state) { int result; const char* message = "Message written at WARNING level."; logging_setup(AM_LOG_LEVEL_WARNING); AM_LOG_WARNING(getpid(), message); sleep(5); result = validate_contains(log_file_name, message); logging_teardown(); assert_int_equal(result, 1); }
int complete_setup() { if (W.WasResetByWatchdog()) printf("Was reset by watchdog\n"); printf("Doing Logging Setup!\n"); int error = logging_setup(); if (error) return 1; printf("Doing Iridium Setup!\n"); iridiumSetup(); printf("Doing Internal Setup!\n"); internalStateSetup(); return 0; }
/** * Ensure that an impractically high log level we DO actually log text via AM_LOG_DEBUG. */ void test_log_debug_at_debug_level(void** state) { int result; const char* message = "Message written at DEBUG level."; srand(time(NULL)); logging_setup(AM_LOG_LEVEL_AUDIT_DENY); AM_LOG_DEBUG(getpid(), message); sleep(5); result = validate_contains(log_file_name, message); logging_teardown(); assert_int_equal(result, 1); }
int main(int argc, const char **argv) { int c, len; #ifdef HAVE_LIBPQ char *pass_replace = "--pg-pass=WITHHELD", *conninfo_replace = "--pg-connect=WITHHELD"; #endif oml_setup(&argc, argv); poptContext optCon = poptGetContext(NULL, argc, (const char**) argv, options, 0); while ((c = poptGetNextOpt(optCon)) >= 0) { switch (c) { case 'v': printf(V_STRING, VERSION); printf("OML Protocol V%d--%d\n", MIN_PROTOCOL_VERSION, MAX_PROTOCOL_VERSION); printf(COPYRIGHT); return 0; } } #ifdef HAVE_LIBPQ /* Cleanup command line to avoid showing credentials in ps(1) output, amongst * others. * * XXX: This is a poor man's security measure, as this creates a race * condition where, prior to doing the following, the credentials are still * visible to everybody. */ if (pg_pass || pg_conninfo) { for(c=1; c<argc; c++) { len = strlen(argv[c]); if(pg_pass && !strncmp(argv[c],"--pg-pass", 9)) { strncpy((char*)argv[c], pass_replace, len); ((char*)argv[c])[len] = 0; } if(pg_conninfo && !strncmp(argv[c],"--pg-connect", 12)) { strncpy((char*)argv[c], conninfo_replace, len); ((char*)argv[c])[len] = 0; } } } #endif /* HAVE_LIBPQ */ logging_setup (logfile_name, log_level); if (c < -1) { die ("%s: %s\n", poptBadOption (optCon, POPT_BADOPTION_NOALIAS), poptStrerror (c)); } loginfo(V_STRING, VERSION); loginfo("OML Protocol V%d--%d\n", MIN_PROTOCOL_VERSION, MAX_PROTOCOL_VERSION); loginfo(COPYRIGHT); eventloop_init(); eventloop_set_socket_timeout(socket_timeout); Socket* server_sock; server_sock = socket_server_new("server", NULL, listen_service, on_connect, NULL); if (!server_sock) { die ("Failed to create listening socket for service %s\n", listen_service); } drop_privileges (uidstr, gidstr); /* Important that this comes after drop_privileges(). */ if(database_setup_backend(dbbackend)) { die("Failed to setup database backend '%s'\n", dbbackend); } signal_setup(); hook_setup(); eventloop_run(); signal_cleanup(); hook_cleanup(); oml_cleanup(); oml_memreport(O_LOG_INFO); return 0; }