diff options
author | William Jon McCann <jmccann@redhat.com> | 2008-05-05 14:20:25 -0400 |
---|---|---|
committer | William Jon McCann <jmccann@redhat.com> | 2008-05-05 14:20:25 -0400 |
commit | 844de7d4b6d29d57a5425dcc7d0d3f6d4b005311 (patch) | |
tree | d59bf3cacfaac9630ec534c64a94cd8bef31f9f4 | |
parent | 8ec523138671a8fe93748a0b75adaaca96e2392e (diff) |
export login session id to the bus
-rw-r--r-- | data/ConsoleKit.conf | 2 | ||||
-rw-r--r-- | src/ck-manager.c | 9 | ||||
-rw-r--r-- | src/ck-session.c | 2 | ||||
-rw-r--r-- | src/ck-session.h | 6 | ||||
-rw-r--r-- | src/ck-session.xml | 3 | ||||
-rwxr-xr-x | src/test-method-access-policy | 13 | ||||
-rw-r--r-- | 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 @@ -64,6 +64,8 @@ <allow send_interface="org.freedesktop.ConsoleKit.Session" send_member="GetSeatId"/> <allow send_interface="org.freedesktop.ConsoleKit.Session" + send_member="GetLoginSessionId"/> + <allow send_interface="org.freedesktop.ConsoleKit.Session" send_member="GetSessionType"/> <allow send_interface="org.freedesktop.ConsoleKit.Session" send_member="GetUser"/> diff --git a/src/ck-manager.c b/src/ck-manager.c index df5a86a..0bcac88 100644 --- a/src/ck-manager.c +++ b/src/ck-manager.c @@ -1981,6 +1981,7 @@ ck_manager_get_session_for_cookie (CkManager *manager, _("Unable to get information about the calling process")); dbus_g_method_return_error (context, error); g_error_free (error); + g_debug ("CkManager: Unable to lookup caller info - failing"); return FALSE; } @@ -1999,10 +2000,14 @@ ck_manager_get_session_for_cookie (CkManager *manager, dbus_g_method_return_error (context, error); g_error_free (error); + + g_debug ("CkManager: Unable to lookup info for caller - failing"); + return FALSE; } /* FIXME: should we restrict this by uid? */ + ck_process_stat_free (stat); leader = g_hash_table_lookup (manager->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 @@ <method name="GetSeatId"> <arg name="sid" direction="out" type="o"/> </method> + <method name="GetLoginSessionId"> + <arg name="lsid" direction="out" type="s"/> + </method> <method name="GetSessionType"> <arg name="type" direction="out" type="s"/> </method> 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); |