Files
main/system/auth/ConsoleKit/files/upstream_fix_issue_26.patch
T
Ertuğrul Erata 5f3db543f5 mv ConsoleKit
2015-07-04 23:56:27 +03:00

777 lines
24 KiB
Diff

diff -Nuar ConsoleKit2-0.9.3.orig/src/ck-manager.c ConsoleKit2-0.9.3/src/ck-manager.c
--- ConsoleKit2-0.9.3.orig/src/ck-manager.c 2015-06-09 19:04:19.000000000 +0300
+++ ConsoleKit2-0.9.3/src/ck-manager.c 2015-06-14 21:30:51.943744599 +0300
@@ -2851,6 +2851,11 @@
pid_t calling_pid = 0;
char *cookie;
+ if (pid <= 1) {
+ throw_error (context, CK_MANAGER_ERROR_INVALID_INPUT, _("pid must be > 1"));
+ return TRUE;
+ }
+
manager = CK_MANAGER (ckmanager);
sender = g_dbus_method_invocation_get_sender (context);
diff -Nuar ConsoleKit2-0.9.3.orig/src/ck-session.c ConsoleKit2-0.9.3/src/ck-session.c
--- ConsoleKit2-0.9.3.orig/src/ck-session.c 2015-05-18 06:43:04.000000000 +0300
+++ ConsoleKit2-0.9.3/src/ck-session.c 2015-06-14 21:30:55.946744527 +0300
@@ -55,7 +55,6 @@
char *seat_id;
char *login_session_id;
- guint uid;
GTimeVal creation_time;
@@ -331,6 +330,11 @@
g_return_val_if_fail (CK_IS_SESSION (cksession), FALSE);
+ if (console_kit_session_get_idle_hint (cksession) == FALSE) {
+ throw_error (context, CK_SESSION_ERROR_GENERAL, "idle since hint not set");
+ return TRUE;
+ }
+
date_str = g_time_val_to_iso8601 (&session->priv->idle_since_hint);
console_kit_session_complete_get_idle_since_hint (cksession, context, date_str);
@@ -386,7 +390,7 @@
}
/* only restrict this by UID for now */
- if (session->priv->uid != calling_uid) {
+ if (console_kit_session_get_unix_user (cksession) != calling_uid) {
throw_error (context, CK_SESSION_ERROR_INSUFFICIENT_PERMISSION, _("Only session owner may set idle hint state"));
return TRUE;
}
@@ -836,7 +840,11 @@
g_return_val_if_fail (CK_IS_SESSION (cksession), FALSE);
- console_kit_session_complete_get_login_session_id (cksession, context, session->priv->login_session_id);
+ if (session->priv->login_session_id == NULL) {
+ throw_error (context, CK_SESSION_ERROR_FAILED, "no login session id");
+ } else {
+ console_kit_session_complete_get_login_session_id (cksession, context, session->priv->login_session_id);
+ }
return TRUE;
}
@@ -1240,7 +1248,7 @@
extra_env[n++] = g_strdup_printf ("CK_SESSION_TYPE=%s", console_kit_session_get_session_type (cksession));
}
extra_env[n++] = g_strdup_printf ("CK_SESSION_SEAT_ID=%s", session->priv->seat_id);
- extra_env[n++] = g_strdup_printf ("CK_SESSION_USER_UID=%d", session->priv->uid);
+ extra_env[n++] = g_strdup_printf ("CK_SESSION_USER_UID=%d", console_kit_session_get_unix_user (cksession));
if (console_kit_session_get_display_device (cksession) != NULL && strlen (console_kit_session_get_display_device (cksession)) > 0) {
extra_env[n++] = g_strdup_printf ("CK_SESSION_DISPLAY_DEVICE=%s", console_kit_session_get_display_device (cksession));
}
@@ -1279,7 +1287,7 @@
cksession = CONSOLE_KIT_SESSION (session);
group_name = g_strdup_printf ("Session %s", session->priv->id);
- g_key_file_set_integer (key_file, group_name, "uid", session->priv->uid);
+ g_key_file_set_integer (key_file, group_name, "uid", console_kit_session_get_unix_user (cksession));
g_key_file_set_string (key_file,
group_name,
"seat",
diff -Nuar ConsoleKit2-0.9.3.orig/src/test-fus ConsoleKit2-0.9.3/src/test-fus
--- ConsoleKit2-0.9.3.orig/src/test-fus 1970-01-01 02:00:00.000000000 +0200
+++ ConsoleKit2-0.9.3/src/test-fus 2015-06-14 21:31:08.768744297 +0300
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+#
+# Test fast-user-switch functionality
+#
+
+import os
+import sys
+import gobject
+import dbus
+import dbus.glib
+
+def activate_reply (res):
+ print "session activated"
+
+def activate_error (e):
+ print str (e)
+
+def session_added_cb (ssid):
+ print "Session added: %s" % ssid
+
+def session_removed_cb (ssid):
+ print "Session removed: %s" % ssid
+
+def active_session_changed_cb (ssid):
+ print "Active session changed: %s" % ssid
+
+bus = dbus.SystemBus ()
+
+manager_obj = bus.get_object ('org.freedesktop.ConsoleKit', '/org/freedesktop/ConsoleKit/Manager')
+
+manager = dbus.Interface (manager_obj, 'org.freedesktop.ConsoleKit.Manager')
+
+current_ssid = manager.GetCurrentSession ()
+current_session_obj = bus.get_object ('org.freedesktop.ConsoleKit', current_ssid)
+current_session = dbus.Interface (current_session_obj, 'org.freedesktop.ConsoleKit.Session')
+
+sid = current_session.GetSeatId ()
+if not sid:
+ print "Current session is not attached to a seat, no switching possible"
+ sys.exit ()
+
+seat_obj = bus.get_object ('org.freedesktop.ConsoleKit', sid)
+seat = dbus.Interface (seat_obj, 'org.freedesktop.ConsoleKit.Seat')
+seat.connect_to_signal ('SessionAdded', session_added_cb)
+seat.connect_to_signal ('SessionRemoved', session_removed_cb)
+seat.connect_to_signal ('ActiveSessionChanged', active_session_changed_cb)
+
+can_fus = seat.CanActivateSessions()
+if can_fus:
+ print "The current seat supports session switching"
+else:
+ print "The current seat does not support session switching"
+
+# Show a list of sessions on the current seat
+sessions = seat.GetSessions ()
+for ssid in sessions:
+ session_obj = bus.get_object ('org.freedesktop.ConsoleKit', ssid)
+ session = dbus.Interface (session_obj, 'org.freedesktop.ConsoleKit.Session')
+ uid = session.GetUser ()
+ print "Session %s user=%u" % (ssid, uid)
+
+# then pretend a session-ID is selected:
+ssid = current_ssid
+session_obj = bus.get_object ('org.freedesktop.ConsoleKit', ssid)
+session = dbus.Interface (session_obj, 'org.freedesktop.ConsoleKit.Session')
+session.Activate (reply_handler = activate_reply, error_handler = activate_error)
+
+mainloop = gobject.MainLoop ()
+mainloop.run()
diff -Nuar ConsoleKit2-0.9.3.orig/src/test-manager.c ConsoleKit2-0.9.3/src/test-manager.c
--- ConsoleKit2-0.9.3.orig/src/test-manager.c 2015-06-08 10:14:14.000000000 +0300
+++ ConsoleKit2-0.9.3/src/test-manager.c 2015-06-14 21:31:10.021744275 +0300
@@ -277,7 +277,10 @@
static gboolean
validate_stuff ()
{
- gint fd;
+ gint fd;
+ GVariant *session_var = NULL, *close_var = NULL;
+ gboolean is_session_closed;
+ GError *error = NULL;
print_reply (manager, "CanRestart");
@@ -295,7 +298,7 @@
fd = print_inhibit_reply (manager, "Inhibit");
- print_reply (manager, "OpenSession");
+ session_var = print_method (manager, "OpenSession", g_variant_new ("()"));
print_reply (manager, "GetSeats");
@@ -317,8 +320,29 @@
g_close (fd, NULL);
}
+ /* test closing our session */
+ if (session_var != NULL) {
+ g_print ("calling CloseSession\t");
+ close_var = g_dbus_proxy_call_sync (manager, "CloseSession",
+ session_var,
+ G_DBUS_CALL_FLAGS_NONE, 3000, NULL, &error);
+ if (close_var == NULL) {
+ g_print ("returned NULL\t");
+ if (error)
+ g_print ("error %s", error->message);
+ }
+ }
+
+ g_variant_get (close_var, "(b)", &is_session_closed);
+ g_print ("session closed? %s", is_session_closed ? "Closed" : "Not Closed");
+
g_print ("done printing stuff\n\n");
+ if (session_var)
+ g_variant_unref (session_var);
+ if (close_var)
+ g_variant_unref (close_var);
+
return TRUE;
}
diff -Nuar ConsoleKit2-0.9.3.orig/src/test-method-access-policy ConsoleKit2-0.9.3/src/test-method-access-policy
--- ConsoleKit2-0.9.3.orig/src/test-method-access-policy 1970-01-01 02:00:00.000000000 +0200
+++ ConsoleKit2-0.9.3/src/test-method-access-policy 2015-06-14 21:31:10.021744275 +0300
@@ -0,0 +1,534 @@
+#!/usr/bin/env python
+#
+# Test access to methods
+#
+
+import os
+import sys
+import gobject
+import dbus
+import dbus.glib
+
+bus = dbus.SystemBus ()
+
+privileged = (os.geteuid () == 0)
+if privileged:
+ print "Running privileged as uid=%d pid=%d" % (os.geteuid (), os.getpid ())
+else:
+ print "Running unprivileged as uid=%d pid=%d" % (os.geteuid (), os.getpid ())
+
+print "Testing all public methods to check D-Bus policy"
+
+manager_obj = bus.get_object ('org.freedesktop.ConsoleKit', '/org/freedesktop/ConsoleKit/Manager')
+manager = dbus.Interface (manager_obj, 'org.freedesktop.ConsoleKit.Manager')
+
+print "Testing Manager"
+
+print "Testing Manager.OpenSession:",
+res = "PASS"
+try:
+ cookie = manager.OpenSession ()
+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\t%s" % res
+
+print "Testing Manager.CloseSession:",
+res = "PASS"
+try:
+ manager.CloseSession (cookie)
+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\t%s" % res
+
+print "Testing Manager.OpenSessionWithParameters:",
+res = "PASS"
+try:
+ cookie = manager.OpenSessionWithParameters (dbus.Array([], signature = "sv"))
+ if not privileged:
+ res = "FAIL"
+except dbus.exceptions.DBusException, e:
+ if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
+ if privileged:
+ res = "FAIL"
+ elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
+ res = "UKNOWN METHOD"
+except:
+ pass
+print "\t%s" % res
+
+print "Testing Manager.GetSeats:",
+res = "PASS"
+try:
+ manager.GetSeats ()
+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\t%s" % res
+
+print "Testing Manager.GetSessionForCookie:",
+res = "PASS"
+try:
+ manager.GetSessionForCookie (os.environ['XDG_SESSION_COOKIE'])
+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 Manager.GetSessionForUnixProcess:",
+res = "PASS"
+try:
+ manager.GetSessionForUnixProcess (os.getpid ())
+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%s" % res
+
+print "Testing Manager.GetCurrentSession:",
+res = "PASS"
+try:
+ manager.GetCurrentSession ()
+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 Manager.GetSessionsForUnixUser:",
+res = "PASS"
+try:
+ manager.GetSessionsForUnixUser (os.geteuid ())
+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%s" % res
+
+print "Testing Manager.GetSessionsForUser:",
+res = "PASS"
+try:
+ manager.GetSessionsForUser (os.geteuid ())
+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 Manager.GetSystemIdleHint:",
+res = "PASS"
+try:
+ manager.GetSystemIdleHint ()
+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 Manager.GetSystemIdleSinceHint:",
+res = "PASS"
+try:
+ manager.GetSystemIdleSinceHint ()
+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%s" % res
+
+# Test Seat Interface
+print "Testing Seat"
+
+seat_obj = bus.get_object ('org.freedesktop.ConsoleKit', '/org/freedesktop/ConsoleKit/Seat1')
+seat = dbus.Interface (seat_obj, 'org.freedesktop.ConsoleKit.Seat')
+
+print "Testing Seat.GetId:",
+res = "PASS"
+try:
+ seat.GetId ()
+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\t\t%s" % res
+
+print "Testing Seat.GetSessions:",
+res = "PASS"
+try:
+ seat.GetSessions ()
+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\t%s" % res
+
+print "Testing Seat.GetDevices:",
+res = "PASS"
+try:
+ seat.GetDevices ()
+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\t%s" % res
+
+print "Testing Seat.GetActiveSession:",
+res = "PASS"
+try:
+ seat.GetActiveSession ()
+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\t%s" % res
+
+print "Testing Seat.CanActivateSessions:",
+res = "PASS"
+try:
+ seat.CanActivateSessions ()
+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 Seat.ActivateSession:",
+res = "PASS"
+try:
+ seat.ActivateSession ('/org/freedesktop/ConsoleKit/SessionN')
+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\t%s" % res
+
+# Test Session Interface
+print "Testing Session"
+
+# create a new session so we can set props
+cookie = manager.OpenSession ()
+ssid = manager.GetSessionForCookie (cookie)
+if not ssid:
+ print "Could not create a session to test"
+ sys.exit ()
+
+session_obj = bus.get_object ('org.freedesktop.ConsoleKit', ssid)
+session = dbus.Interface (session_obj, 'org.freedesktop.ConsoleKit.Session')
+
+print "Testing Session.GetId:",
+res = "PASS"
+try:
+ session.GetId ()
+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\t\t%s" % res
+
+print "Testing Session.GetSeatId:",
+res = "PASS"
+try:
+ session.GetSeatId ()
+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\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:
+ session.GetSessionType ()
+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.GetUser:",
+res = "PASS"
+try:
+ session.GetUser ()
+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\t%s" % res
+
+print "Testing Session.GetUnixUser:",
+res = "PASS"
+try:
+ session.GetUnixUser ()
+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\t%s" % res
+
+print "Testing Session.GetX11Display:",
+res = "PASS"
+try:
+ session.GetX11Display ()
+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\t%s" % res
+
+print "Testing Session.GetX11DisplayDevice:",
+res = "PASS"
+try:
+ session.GetX11DisplayDevice ()
+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.GetDisplayDevice:",
+res = "PASS"
+try:
+ session.GetDisplayDevice ()
+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.GetRemoteHostName:",
+res = "PASS"
+try:
+ session.GetRemoteHostName ()
+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.IsActive:",
+res = "PASS"
+try:
+ session.IsActive ()
+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\t%s" % res
+
+print "Testing Session.IsLocal:",
+res = "PASS"
+try:
+ session.IsLocal ()
+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\t%s" % res
+
+print "Testing Session.GetCreationTime:",
+res = "PASS"
+try:
+ session.GetCreationTime ()
+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.Activate:",
+res = "PASS"
+try:
+ session.Activate ()
+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\t%s" % res
+
+print "Testing Session.Lock:",
+res = "PASS"
+try:
+ session.Lock ()
+ if not privileged:
+ res = "FAIL"
+except dbus.exceptions.DBusException, e:
+ if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
+ if privileged:
+ res = "FAIL"
+ elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
+ res = "UKNOWN METHOD"
+except:
+ pass
+print "\t\t\t\t%s" % res
+
+print "Testing Session.Unlock:",
+res = "PASS"
+try:
+ session.Unlock ()
+ if not privileged:
+ res = "FAIL"
+except dbus.exceptions.DBusException, e:
+ if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
+ if privileged:
+ res = "FAIL"
+ elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
+ res = "UKNOWN METHOD"
+except:
+ pass
+print "\t\t\t%s" % res
+
+# Test session properties
+
+session_props = dbus.Interface (session_obj, 'org.freedesktop.DBus.Properties')
+
+print "Testing Properties.Get 'unix-user':",
+res = "PASS"
+try:
+ session_props.Get ('org.freedesktop.ConsoleKit.Session', "unix-user")
+ if not privileged:
+ res = "FAIL"
+except dbus.exceptions.DBusException, e:
+ if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
+ if privileged:
+ res = "FAIL"
+ elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
+ res = "UKNOWN METHOD"
+except:
+ pass
+print "\t\t%s" % res
+
+print "Testing Properties.Get 'cookie':",
+res = "PASS"
+try:
+ session_props.Get ('org.freedesktop.ConsoleKit.Session', "cookie")
+ if not privileged:
+ res = "FAIL"
+except dbus.exceptions.DBusException, e:
+ if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
+ if privileged:
+ res = "FAIL"
+ elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
+ res = "UKNOWN METHOD"
+except:
+ pass
+print "\t\t%s" % res
+
+print "Testing Properties.Set:",
+res = "PASS"
+try:
+ session_props.Set ('org.freedesktop.ConsoleKit.Session', "unix-user", 0)
+ if not privileged:
+ res = "FAIL"
+except dbus.exceptions.DBusException, e:
+ if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
+ if privileged:
+ res = "FAIL"
+ elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
+ res = "UKNOWN METHOD"
+except:
+ pass
+print "\t\t\t%s" % res
diff -Nuar ConsoleKit2-0.9.3.orig/src/test-session.c ConsoleKit2-0.9.3/src/test-session.c
--- ConsoleKit2-0.9.3.orig/src/test-session.c 2015-05-18 06:43:04.000000000 +0300
+++ ConsoleKit2-0.9.3/src/test-session.c 2015-06-14 21:31:12.560744229 +0300
@@ -176,7 +176,7 @@
open_session (void)
{
GDBusProxy *session;
- GVariant *cookie_var, *session_var, *activate_var;
+ GVariant *cookie_var, *session_var, *activate_var, *close_var;
GError *error = NULL;
const gchar *path = NULL, *cookie = NULL;
@@ -272,6 +272,20 @@
}
if (activate_var)
g_variant_unref (activate_var);
+
+ close_var = g_dbus_proxy_call_sync (manager, "CloseSession", g_variant_new ("(s)", cookie), G_DBUS_CALL_FLAGS_NONE, 3000, NULL, &error);
+ if (session_var == NULL) {
+ g_print ("returned NULL, is the daemon running?\t");
+
+ if (error)
+ g_print ("error %s", error->message);
+
+ g_print ("\n");
+ g_clear_error (&error);
+ return;
+ }
+ if (close_var)
+ g_variant_unref (close_var);
}
int