static void tlm_manager_init (TlmManager *manager) { GError *error = NULL; TlmManagerPrivate *priv = TLM_MANAGER_PRIV (manager); priv->config = tlm_config_new (); priv->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); if (!priv->connection) { CRITICAL ("error getting system bus: %s", error->message); g_error_free (error); return; } priv->seats = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_object_unref); priv->account_plugin = NULL; priv->auth_plugins = NULL; manager->priv = priv; _load_accounts_plugin (manager, tlm_config_get_string_default (priv->config, TLM_CONFIG_GENERAL, TLM_CONFIG_GENERAL_ACCOUNTS_PLUGIN, "default")); _load_auth_plugins (manager); /* delete tlm runtime directory */ tlm_utils_delete_dir (TLM_DBUS_SOCKET_PATH); priv->dbus_observer = TLM_DBUS_OBSERVER (tlm_dbus_observer_new (manager, NULL, TLM_DBUS_ROOT_SOCKET_ADDRESS, getuid (), DBUS_OBSERVER_ENABLE_ALL)); }
int main (int argc, char *argv[]) { struct option opts[] = { { "file", required_argument, NULL, 'f' }, { "sessionid", required_argument, NULL, 's' }, { "help", no_argument, NULL, 'h' }, { 0, 0, NULL, 0 } }; int i, c; gchar *file = NULL; TlmLauncher launcher; gchar *address = NULL; TlmConfig *config = NULL; TlmProcessManager *proc_manager = NULL; const gchar *runtime_dir = NULL; gchar *sessionid = NULL; tlm_log_init("TLM_LAUNCHER"); while ((c = getopt_long (argc, argv, "f:s:h", opts, &i)) != -1) { switch(c) { case 'h': help(); return 0; case 'f': file = g_strdup (optarg); DBG("file found %s", file); break; case 's': sessionid = g_strdup (optarg); DBG("sessionid found %s", sessionid); break; } } if (!file) { /* FIXME: Load from configuration ??? */ help(); g_free (sessionid); return 0; } _tlm_launcher_init (&launcher); if (!(launcher.fp = fopen(file, "r"))) { WARN("Failed to open file '%s':%s", file, strerror(errno)); _tlm_launcher_deinit (&launcher); g_free (file); g_free (sessionid); return 0; } g_free (file); runtime_dir = g_getenv ("XDG_RUNTIME_DIR"); if (sessionid && runtime_dir) address = g_strdup_printf ("unix:path=%s/%s", runtime_dir, sessionid); else if (sessionid) address = g_strdup_printf ("unix:path=/run/user/%d/%s", getuid(), sessionid); else if (runtime_dir) address = g_strdup_printf ("unix:path=%s/%d", runtime_dir, getpid()); else address = g_strdup_printf ("unix:path=/run/user/%d/%d", getuid(), getpid()); config = tlm_config_new (); launcher.proc_manager = tlm_process_manager_new (config, address, getuid()); DBG ("Tlm launcher pid:%d, dbus addr: %s, sessionid: %s, runtimedir: %s\n", getpid(), address, sessionid, runtime_dir); g_free (sessionid); g_free (address); address = NULL; _tlm_launcher_process (&launcher); g_main_loop_run (launcher.loop); g_object_unref (config); _tlm_launcher_deinit (&launcher); tlm_log_close (NULL); return 0; }