123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777 |
- 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
|