From 844de7d4b6d29d57a5425dcc7d0d3f6d4b005311 Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Mon, 5 May 2008 14:20:25 -0400 Subject: export login session id to the bus --- data/ConsoleKit.conf | 2 ++ src/ck-manager.c | 9 +++++++++ src/ck-session.c | 2 +- src/ck-session.h | 6 +++--- src/ck-session.xml | 3 +++ src/test-method-access-policy | 13 +++++++++++++ tools/list-sessions.c | 9 +++++++-- 7 files changed, 38 insertions(+), 6 deletions(-) diff --git a/data/ConsoleKit.conf b/data/ConsoleKit.conf index 70a0423..dbe29f8 100644 --- a/data/ConsoleKit.conf +++ b/data/ConsoleKit.conf @@ -63,6 +63,8 @@ send_member="GetId"/> + priv->leaders, cookie); @@ -2013,6 +2018,7 @@ ck_manager_get_session_for_cookie (CkManager *manager, _("Unable to find session for cookie")); dbus_g_method_return_error (context, error); g_error_free (error); + g_debug ("CkManager: Unable to lookup cookie for caller - failing"); return FALSE; } @@ -2024,11 +2030,14 @@ ck_manager_get_session_for_cookie (CkManager *manager, _("Unable to find session for cookie")); dbus_g_method_return_error (context, error); g_error_free (error); + g_debug ("CkManager: Unable to lookup session for cookie - failing"); return FALSE; } ck_session_get_id (session, &ssid, NULL); + g_debug ("CkManager: Found session '%s'", ssid); + dbus_g_method_return (context, ssid); g_free (ssid); diff --git a/src/ck-session.c b/src/ck-session.c index 8ba8791..dd4f13a 100644 --- a/src/ck-session.c +++ b/src/ck-session.c @@ -505,7 +505,7 @@ ck_session_get_login_session_id (CkSession *session, GError **error) { g_return_val_if_fail (CK_IS_SESSION (session), FALSE); - + g_debug ("Got: %s", session->priv->login_session_id); if (login_session_id != NULL) { *login_session_id = g_strdup (session->priv->login_session_id); } diff --git a/src/ck-session.h b/src/ck-session.h index 66ca705..c9ebd08 100644 --- a/src/ck-session.h +++ b/src/ck-session.h @@ -113,9 +113,6 @@ gboolean ck_session_set_remote_host_name (CkSession *se gboolean ck_session_set_session_type (CkSession *session, const char *type, GError **error); -gboolean ck_session_get_login_session_id (CkSession *session, - char **login_session_id, - GError **error); /* Exported methods */ @@ -144,6 +141,9 @@ gboolean ck_session_get_x11_display_device (CkSession *se gboolean ck_session_get_display_device (CkSession *session, char **display, GError **error); +gboolean ck_session_get_login_session_id (CkSession *session, + char **login_session_id, + GError **error); gboolean ck_session_get_session_type (CkSession *session, char **type, GError **error); diff --git a/src/ck-session.xml b/src/ck-session.xml index 5fc85d0..b42f30b 100644 --- a/src/ck-session.xml +++ b/src/ck-session.xml @@ -7,6 +7,9 @@ + + + diff --git a/src/test-method-access-policy b/src/test-method-access-policy index a950fc8..b206332 100755 --- a/src/test-method-access-policy +++ b/src/test-method-access-policy @@ -289,6 +289,19 @@ except: pass print "\t\t\t%s" % res +print "Testing Session.GetLoginSessionId:", +res = "PASS" +try: + session.GetLoginSessionId () +except dbus.exceptions.DBusException, e: + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied": + res = "FAIL" + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod": + res = "UKNOWN METHOD" +except: + pass +print "\t\t%s" % res + print "Testing Session.GetSessionType:", res = "PASS" try: diff --git a/tools/list-sessions.c b/tools/list-sessions.c index b883642..c320845 100644 --- a/tools/list-sessions.c +++ b/tools/list-sessions.c @@ -163,6 +163,7 @@ list_session (DBusGConnection *connection, int uid; char *realname; char *sid; + char *lsid; char *session_type; char *x11_display; char *x11_display_device; @@ -184,6 +185,7 @@ list_session (DBusGConnection *connection, } sid = NULL; + lsid = NULL; session_type = NULL; x11_display = NULL; x11_display_device = NULL; @@ -194,6 +196,7 @@ list_session (DBusGConnection *connection, get_int (proxy, "GetUnixUser", &uid); get_path (proxy, "GetSeatId", &sid); + get_string (proxy, "GetLoginSessionId", &lsid); get_string (proxy, "GetSessionType", &session_type); get_string (proxy, "GetX11Display", &x11_display); get_string (proxy, "GetX11DisplayDevice", &x11_display_device); @@ -216,7 +219,7 @@ list_session (DBusGConnection *connection, short_ssid = ssid + strlen (CK_PATH) + 1; } - printf ("%s:\n\tunix-user = '%d'\n\trealname = '%s'\n\tseat = '%s'\n\tsession-type = '%s'\n\tactive = %s\n\tx11-display = '%s'\n\tx11-display-device = '%s'\n\tdisplay-device = '%s'\n\tremote-host-name = '%s'\n\tis-local = %s\n\ton-since = '%s'", + printf ("%s:\n\tunix-user = '%d'\n\trealname = '%s'\n\tseat = '%s'\n\tsession-type = '%s'\n\tactive = %s\n\tx11-display = '%s'\n\tx11-display-device = '%s'\n\tdisplay-device = '%s'\n\tremote-host-name = '%s'\n\tis-local = %s\n\ton-since = '%s'\n\tlogin-session-id = '%s'", short_ssid, uid, realname, @@ -228,7 +231,8 @@ list_session (DBusGConnection *connection, display_device, remote_host_name, is_local ? "TRUE" : "FALSE", - creation_time); + creation_time, + lsid); if (idle_since_hint != NULL && idle_since_hint[0] != '\0') { printf ("\n\tidle-since-hint = '%s'", idle_since_hint); } @@ -239,6 +243,7 @@ list_session (DBusGConnection *connection, g_free (remote_host_name); g_free (realname); g_free (sid); + g_free (lsid); g_free (session_type); g_free (x11_display); g_free (x11_display_device); -- cgit