GMainLoop *main_loop;
gboolean is_plugind_up;
+ gboolean unref_in_down_cb;
+
/* Signals */
- guint signal_response;
- guint signal_response_final;
- guint signal_store;
- guint signal_error;
- guint signal_user_action_required;
- guint signal_refreshed;
- guint signal_status_changed;
+ gulong signal_response;
+ gulong signal_response_final;
+ gulong signal_store;
+ gulong signal_error;
+ gulong signal_user_action_required;
+ gulong signal_refreshed;
+ gulong signal_status_changed;
};
G_END_DECLS
argv[2] = g_strdup(plugin_type);
ret = g_spawn_async_with_pipes (NULL, argv, NULL,
G_SPAWN_DO_NOT_REAP_CHILD, NULL,
- NULL, &cpid, &cin_fd, &cout_fd, &cerr_fd, &error);
+ NULL, &cpid, &cin_fd, &cout_fd, NULL, &error);
g_strfreev (argv);
if (ret == FALSE || (kill(cpid, 0) != 0)) {
- DBG ("failed to start plugind: error %s(%d)", error->message, ret);
+ DBG ("failed to start plugind: error %s(%d)",
+ error ? error->message : "(null)", ret);
if (error) g_error_free (error);
return NULL;
}
WARN ("Unable to redirect stdin to /dev/null");
}
- gint out_fd = dup(1);
+ out_fd = dup(1);
- if (out_fd == -1) {
- WARN ("Failed to dup stdout : %s(%d)", strerror(errno), errno);
- out_fd = 1;
- }
- if(!freopen("/dev/null", "r+", stdout)) {
- WARN ("Unable to redirect stdout to /dev/null");
- }
- err_fd = dup(2);
- if (err_fd == -1) {
- WARN ("Failed to dup stderr : %s(%d)", strerror(errno), errno);
- err_fd = 2;
- }
- if (!freopen("/dev/null", "r+", stderr)) {
- WARN ("Unable to redirect stderr to /dev/null");
- }
+ /* Reattach stderr to stdout */
+ dup2 (2, 1);
#if !GLIB_CHECK_VERSION (2, 36, 0)
g_type_init ();
opt_context = g_option_context_new ("<plugin_path> <plugin_name>");
g_option_context_set_summary (opt_context, "gSSO helper plugin daemon");
g_option_context_add_main_entries (opt_context, opt_entries, NULL);
+ g_option_context_set_ignore_unknown_options (opt_context, TRUE);
g_option_context_parse (opt_context, &argc, &argv, &error);
g_option_context_free (opt_context);
- if (error || !plugin_args || !plugin_args[0] || !plugin_args[1]) {
+ if (error) {
+ WARN ("Error in arguments parsing: %s", error->message);
+ g_error_free (error);
+ }
+ if (!plugin_args || !plugin_args[0] || !plugin_args[1]) {
+ WARN ("plugin path or plugin type missing");
+ if (write (out_fd, "0", sizeof(char)) == -1)
+ WARN ("Unable to write down notification to stdout");
- if (error) g_error_free (error);
+ if (in_fd != 0) close (in_fd);
+ if (out_fd != 1) close (out_fd);
- if (err_fd != 2) close (err_fd);
if (plugin_args) g_strfreev(plugin_args);
- close (in_fd);
- close (out_fd);
return -1;
}
out_fd);
g_strfreev(plugin_args);
if (_daemon == NULL) {
- close (in_fd);
- close (out_fd);
+ if (write (out_fd, "0", sizeof(char)) == -1)
+ WARN ("Unable to write down notification to stdout");
- if (err_fd != 2) close (err_fd);
+ if (in_fd != 0) close (in_fd);
+ if (out_fd != 1) close (out_fd);
return -1;
}