diff options
Diffstat (limited to 'src/krb5-auth-dialog.c')
-rw-r--r-- | src/krb5-auth-dialog.c | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/src/krb5-auth-dialog.c b/src/krb5-auth-dialog.c index 36387a9..a836480 100644 --- a/src/krb5-auth-dialog.c +++ b/src/krb5-auth-dialog.c @@ -572,6 +572,9 @@ main (int argc, char *argv[]) GtkWidget *dialog; GnomeClient *client; DBusGConnection *session; + DBusGProxy *bus_proxy; + guint request_name_reply; + unsigned int flags; GError *error = NULL; int run_auto = 0, run_always = 0; struct poptOption options[] = { @@ -589,21 +592,51 @@ main (int argc, char *argv[]) gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv, GNOME_PARAM_POPT_TABLE, options, - GNOME_PARAM_NONE); - - client = gnome_master_client (); - gnome_client_set_restart_style (client, GNOME_RESTART_ANYWAY); + GNOME_CLIENT_PARAM_SM_CONNECT, FALSE, GNOME_PARAM_NONE); /* Connect to the session bus so we get exit-on-disconnect semantics. */ session = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (session == NULL) { + g_error ("couldn't connect to session bus: %s", (error) ? error->message : "(null)"); + exit(1); + } + flags = DBUS_NAME_FLAG_DO_NOT_QUEUE; + bus_proxy = dbus_g_proxy_new_for_name (session, + "org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus"); + + if (!dbus_g_proxy_call (bus_proxy, + "RequestName", + &error, + G_TYPE_STRING, + "org.gnome.KrbAuthDialog", + G_TYPE_UINT, + flags, + G_TYPE_INVALID, + G_TYPE_UINT, + &request_name_reply, + G_TYPE_INVALID)) { + g_warning ("Failed to invoke RequestName: %s", + error->message); + } + g_clear_error (&error); + g_object_unref (bus_proxy); + + if (request_name_reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER + || request_name_reply == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER) + ; + else if (request_name_reply == DBUS_REQUEST_NAME_REPLY_EXISTS + || request_name_reply == DBUS_REQUEST_NAME_REPLY_IN_QUEUE) + exit(0); + else { + g_assert_not_reached(); + } if (run_always && !run_auto) { always_run++; } if (using_krb5 () || always_run) { - g_signal_connect (G_OBJECT (client), "die", - G_CALLBACK (gtk_main_quit), NULL); - g_set_application_name (_("Network Authentication")); #ifdef ENABLE_NETWORK_MANAGER |