upstream_fix_issue_26.patch 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  1. diff -Nuar ConsoleKit2-0.9.3.orig/src/ck-manager.c ConsoleKit2-0.9.3/src/ck-manager.c
  2. --- ConsoleKit2-0.9.3.orig/src/ck-manager.c 2015-06-09 19:04:19.000000000 +0300
  3. +++ ConsoleKit2-0.9.3/src/ck-manager.c 2015-06-14 21:30:51.943744599 +0300
  4. @@ -2851,6 +2851,11 @@
  5. pid_t calling_pid = 0;
  6. char *cookie;
  7. + if (pid <= 1) {
  8. + throw_error (context, CK_MANAGER_ERROR_INVALID_INPUT, _("pid must be > 1"));
  9. + return TRUE;
  10. + }
  11. +
  12. manager = CK_MANAGER (ckmanager);
  13. sender = g_dbus_method_invocation_get_sender (context);
  14. diff -Nuar ConsoleKit2-0.9.3.orig/src/ck-session.c ConsoleKit2-0.9.3/src/ck-session.c
  15. --- ConsoleKit2-0.9.3.orig/src/ck-session.c 2015-05-18 06:43:04.000000000 +0300
  16. +++ ConsoleKit2-0.9.3/src/ck-session.c 2015-06-14 21:30:55.946744527 +0300
  17. @@ -55,7 +55,6 @@
  18. char *seat_id;
  19. char *login_session_id;
  20. - guint uid;
  21. GTimeVal creation_time;
  22. @@ -331,6 +330,11 @@
  23. g_return_val_if_fail (CK_IS_SESSION (cksession), FALSE);
  24. + if (console_kit_session_get_idle_hint (cksession) == FALSE) {
  25. + throw_error (context, CK_SESSION_ERROR_GENERAL, "idle since hint not set");
  26. + return TRUE;
  27. + }
  28. +
  29. date_str = g_time_val_to_iso8601 (&session->priv->idle_since_hint);
  30. console_kit_session_complete_get_idle_since_hint (cksession, context, date_str);
  31. @@ -386,7 +390,7 @@
  32. }
  33. /* only restrict this by UID for now */
  34. - if (session->priv->uid != calling_uid) {
  35. + if (console_kit_session_get_unix_user (cksession) != calling_uid) {
  36. throw_error (context, CK_SESSION_ERROR_INSUFFICIENT_PERMISSION, _("Only session owner may set idle hint state"));
  37. return TRUE;
  38. }
  39. @@ -836,7 +840,11 @@
  40. g_return_val_if_fail (CK_IS_SESSION (cksession), FALSE);
  41. - console_kit_session_complete_get_login_session_id (cksession, context, session->priv->login_session_id);
  42. + if (session->priv->login_session_id == NULL) {
  43. + throw_error (context, CK_SESSION_ERROR_FAILED, "no login session id");
  44. + } else {
  45. + console_kit_session_complete_get_login_session_id (cksession, context, session->priv->login_session_id);
  46. + }
  47. return TRUE;
  48. }
  49. @@ -1240,7 +1248,7 @@
  50. extra_env[n++] = g_strdup_printf ("CK_SESSION_TYPE=%s", console_kit_session_get_session_type (cksession));
  51. }
  52. extra_env[n++] = g_strdup_printf ("CK_SESSION_SEAT_ID=%s", session->priv->seat_id);
  53. - extra_env[n++] = g_strdup_printf ("CK_SESSION_USER_UID=%d", session->priv->uid);
  54. + extra_env[n++] = g_strdup_printf ("CK_SESSION_USER_UID=%d", console_kit_session_get_unix_user (cksession));
  55. if (console_kit_session_get_display_device (cksession) != NULL && strlen (console_kit_session_get_display_device (cksession)) > 0) {
  56. extra_env[n++] = g_strdup_printf ("CK_SESSION_DISPLAY_DEVICE=%s", console_kit_session_get_display_device (cksession));
  57. }
  58. @@ -1279,7 +1287,7 @@
  59. cksession = CONSOLE_KIT_SESSION (session);
  60. group_name = g_strdup_printf ("Session %s", session->priv->id);
  61. - g_key_file_set_integer (key_file, group_name, "uid", session->priv->uid);
  62. + g_key_file_set_integer (key_file, group_name, "uid", console_kit_session_get_unix_user (cksession));
  63. g_key_file_set_string (key_file,
  64. group_name,
  65. "seat",
  66. diff -Nuar ConsoleKit2-0.9.3.orig/src/test-fus ConsoleKit2-0.9.3/src/test-fus
  67. --- ConsoleKit2-0.9.3.orig/src/test-fus 1970-01-01 02:00:00.000000000 +0200
  68. +++ ConsoleKit2-0.9.3/src/test-fus 2015-06-14 21:31:08.768744297 +0300
  69. @@ -0,0 +1,69 @@
  70. +#!/usr/bin/env python
  71. +#
  72. +# Test fast-user-switch functionality
  73. +#
  74. +
  75. +import os
  76. +import sys
  77. +import gobject
  78. +import dbus
  79. +import dbus.glib
  80. +
  81. +def activate_reply (res):
  82. + print "session activated"
  83. +
  84. +def activate_error (e):
  85. + print str (e)
  86. +
  87. +def session_added_cb (ssid):
  88. + print "Session added: %s" % ssid
  89. +
  90. +def session_removed_cb (ssid):
  91. + print "Session removed: %s" % ssid
  92. +
  93. +def active_session_changed_cb (ssid):
  94. + print "Active session changed: %s" % ssid
  95. +
  96. +bus = dbus.SystemBus ()
  97. +
  98. +manager_obj = bus.get_object ('org.freedesktop.ConsoleKit', '/org/freedesktop/ConsoleKit/Manager')
  99. +
  100. +manager = dbus.Interface (manager_obj, 'org.freedesktop.ConsoleKit.Manager')
  101. +
  102. +current_ssid = manager.GetCurrentSession ()
  103. +current_session_obj = bus.get_object ('org.freedesktop.ConsoleKit', current_ssid)
  104. +current_session = dbus.Interface (current_session_obj, 'org.freedesktop.ConsoleKit.Session')
  105. +
  106. +sid = current_session.GetSeatId ()
  107. +if not sid:
  108. + print "Current session is not attached to a seat, no switching possible"
  109. + sys.exit ()
  110. +
  111. +seat_obj = bus.get_object ('org.freedesktop.ConsoleKit', sid)
  112. +seat = dbus.Interface (seat_obj, 'org.freedesktop.ConsoleKit.Seat')
  113. +seat.connect_to_signal ('SessionAdded', session_added_cb)
  114. +seat.connect_to_signal ('SessionRemoved', session_removed_cb)
  115. +seat.connect_to_signal ('ActiveSessionChanged', active_session_changed_cb)
  116. +
  117. +can_fus = seat.CanActivateSessions()
  118. +if can_fus:
  119. + print "The current seat supports session switching"
  120. +else:
  121. + print "The current seat does not support session switching"
  122. +
  123. +# Show a list of sessions on the current seat
  124. +sessions = seat.GetSessions ()
  125. +for ssid in sessions:
  126. + session_obj = bus.get_object ('org.freedesktop.ConsoleKit', ssid)
  127. + session = dbus.Interface (session_obj, 'org.freedesktop.ConsoleKit.Session')
  128. + uid = session.GetUser ()
  129. + print "Session %s user=%u" % (ssid, uid)
  130. +
  131. +# then pretend a session-ID is selected:
  132. +ssid = current_ssid
  133. +session_obj = bus.get_object ('org.freedesktop.ConsoleKit', ssid)
  134. +session = dbus.Interface (session_obj, 'org.freedesktop.ConsoleKit.Session')
  135. +session.Activate (reply_handler = activate_reply, error_handler = activate_error)
  136. +
  137. +mainloop = gobject.MainLoop ()
  138. +mainloop.run()
  139. diff -Nuar ConsoleKit2-0.9.3.orig/src/test-manager.c ConsoleKit2-0.9.3/src/test-manager.c
  140. --- ConsoleKit2-0.9.3.orig/src/test-manager.c 2015-06-08 10:14:14.000000000 +0300
  141. +++ ConsoleKit2-0.9.3/src/test-manager.c 2015-06-14 21:31:10.021744275 +0300
  142. @@ -277,7 +277,10 @@
  143. static gboolean
  144. validate_stuff ()
  145. {
  146. - gint fd;
  147. + gint fd;
  148. + GVariant *session_var = NULL, *close_var = NULL;
  149. + gboolean is_session_closed;
  150. + GError *error = NULL;
  151. print_reply (manager, "CanRestart");
  152. @@ -295,7 +298,7 @@
  153. fd = print_inhibit_reply (manager, "Inhibit");
  154. - print_reply (manager, "OpenSession");
  155. + session_var = print_method (manager, "OpenSession", g_variant_new ("()"));
  156. print_reply (manager, "GetSeats");
  157. @@ -317,8 +320,29 @@
  158. g_close (fd, NULL);
  159. }
  160. + /* test closing our session */
  161. + if (session_var != NULL) {
  162. + g_print ("calling CloseSession\t");
  163. + close_var = g_dbus_proxy_call_sync (manager, "CloseSession",
  164. + session_var,
  165. + G_DBUS_CALL_FLAGS_NONE, 3000, NULL, &error);
  166. + if (close_var == NULL) {
  167. + g_print ("returned NULL\t");
  168. + if (error)
  169. + g_print ("error %s", error->message);
  170. + }
  171. + }
  172. +
  173. + g_variant_get (close_var, "(b)", &is_session_closed);
  174. + g_print ("session closed? %s", is_session_closed ? "Closed" : "Not Closed");
  175. +
  176. g_print ("done printing stuff\n\n");
  177. + if (session_var)
  178. + g_variant_unref (session_var);
  179. + if (close_var)
  180. + g_variant_unref (close_var);
  181. +
  182. return TRUE;
  183. }
  184. diff -Nuar ConsoleKit2-0.9.3.orig/src/test-method-access-policy ConsoleKit2-0.9.3/src/test-method-access-policy
  185. --- ConsoleKit2-0.9.3.orig/src/test-method-access-policy 1970-01-01 02:00:00.000000000 +0200
  186. +++ ConsoleKit2-0.9.3/src/test-method-access-policy 2015-06-14 21:31:10.021744275 +0300
  187. @@ -0,0 +1,534 @@
  188. +#!/usr/bin/env python
  189. +#
  190. +# Test access to methods
  191. +#
  192. +
  193. +import os
  194. +import sys
  195. +import gobject
  196. +import dbus
  197. +import dbus.glib
  198. +
  199. +bus = dbus.SystemBus ()
  200. +
  201. +privileged = (os.geteuid () == 0)
  202. +if privileged:
  203. + print "Running privileged as uid=%d pid=%d" % (os.geteuid (), os.getpid ())
  204. +else:
  205. + print "Running unprivileged as uid=%d pid=%d" % (os.geteuid (), os.getpid ())
  206. +
  207. +print "Testing all public methods to check D-Bus policy"
  208. +
  209. +manager_obj = bus.get_object ('org.freedesktop.ConsoleKit', '/org/freedesktop/ConsoleKit/Manager')
  210. +manager = dbus.Interface (manager_obj, 'org.freedesktop.ConsoleKit.Manager')
  211. +
  212. +print "Testing Manager"
  213. +
  214. +print "Testing Manager.OpenSession:",
  215. +res = "PASS"
  216. +try:
  217. + cookie = manager.OpenSession ()
  218. +except dbus.exceptions.DBusException, e:
  219. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  220. + res = "FAIL"
  221. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  222. + res = "UKNOWN METHOD"
  223. +except:
  224. + pass
  225. +print "\t\t\t%s" % res
  226. +
  227. +print "Testing Manager.CloseSession:",
  228. +res = "PASS"
  229. +try:
  230. + manager.CloseSession (cookie)
  231. +except dbus.exceptions.DBusException, e:
  232. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  233. + res = "FAIL"
  234. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  235. + res = "UKNOWN METHOD"
  236. +except:
  237. + pass
  238. +print "\t\t\t%s" % res
  239. +
  240. +print "Testing Manager.OpenSessionWithParameters:",
  241. +res = "PASS"
  242. +try:
  243. + cookie = manager.OpenSessionWithParameters (dbus.Array([], signature = "sv"))
  244. + if not privileged:
  245. + res = "FAIL"
  246. +except dbus.exceptions.DBusException, e:
  247. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  248. + if privileged:
  249. + res = "FAIL"
  250. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  251. + res = "UKNOWN METHOD"
  252. +except:
  253. + pass
  254. +print "\t%s" % res
  255. +
  256. +print "Testing Manager.GetSeats:",
  257. +res = "PASS"
  258. +try:
  259. + manager.GetSeats ()
  260. +except dbus.exceptions.DBusException, e:
  261. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  262. + res = "FAIL"
  263. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  264. + res = "UKNOWN METHOD"
  265. +except:
  266. + pass
  267. +print "\t\t\t%s" % res
  268. +
  269. +print "Testing Manager.GetSessionForCookie:",
  270. +res = "PASS"
  271. +try:
  272. + manager.GetSessionForCookie (os.environ['XDG_SESSION_COOKIE'])
  273. +except dbus.exceptions.DBusException, e:
  274. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  275. + res = "FAIL"
  276. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  277. + res = "UKNOWN METHOD"
  278. +except:
  279. + pass
  280. +print "\t\t%s" % res
  281. +
  282. +print "Testing Manager.GetSessionForUnixProcess:",
  283. +res = "PASS"
  284. +try:
  285. + manager.GetSessionForUnixProcess (os.getpid ())
  286. +except dbus.exceptions.DBusException, e:
  287. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  288. + res = "FAIL"
  289. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  290. + res = "UKNOWN METHOD"
  291. +except:
  292. + pass
  293. +print "\t%s" % res
  294. +
  295. +print "Testing Manager.GetCurrentSession:",
  296. +res = "PASS"
  297. +try:
  298. + manager.GetCurrentSession ()
  299. +except dbus.exceptions.DBusException, e:
  300. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  301. + res = "FAIL"
  302. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  303. + res = "UKNOWN METHOD"
  304. +except:
  305. + pass
  306. +print "\t\t%s" % res
  307. +
  308. +print "Testing Manager.GetSessionsForUnixUser:",
  309. +res = "PASS"
  310. +try:
  311. + manager.GetSessionsForUnixUser (os.geteuid ())
  312. +except dbus.exceptions.DBusException, e:
  313. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  314. + res = "FAIL"
  315. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  316. + res = "UKNOWN METHOD"
  317. +except:
  318. + pass
  319. +print "\t%s" % res
  320. +
  321. +print "Testing Manager.GetSessionsForUser:",
  322. +res = "PASS"
  323. +try:
  324. + manager.GetSessionsForUser (os.geteuid ())
  325. +except dbus.exceptions.DBusException, e:
  326. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  327. + res = "FAIL"
  328. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  329. + res = "UKNOWN METHOD"
  330. +except:
  331. + pass
  332. +print "\t\t%s" % res
  333. +
  334. +print "Testing Manager.GetSystemIdleHint:",
  335. +res = "PASS"
  336. +try:
  337. + manager.GetSystemIdleHint ()
  338. +except dbus.exceptions.DBusException, e:
  339. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  340. + res = "FAIL"
  341. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  342. + res = "UKNOWN METHOD"
  343. +except:
  344. + pass
  345. +print "\t\t%s" % res
  346. +
  347. +print "Testing Manager.GetSystemIdleSinceHint:",
  348. +res = "PASS"
  349. +try:
  350. + manager.GetSystemIdleSinceHint ()
  351. +except dbus.exceptions.DBusException, e:
  352. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  353. + res = "FAIL"
  354. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  355. + res = "UKNOWN METHOD"
  356. +except:
  357. + pass
  358. +print "\t%s" % res
  359. +
  360. +# Test Seat Interface
  361. +print "Testing Seat"
  362. +
  363. +seat_obj = bus.get_object ('org.freedesktop.ConsoleKit', '/org/freedesktop/ConsoleKit/Seat1')
  364. +seat = dbus.Interface (seat_obj, 'org.freedesktop.ConsoleKit.Seat')
  365. +
  366. +print "Testing Seat.GetId:",
  367. +res = "PASS"
  368. +try:
  369. + seat.GetId ()
  370. +except dbus.exceptions.DBusException, e:
  371. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  372. + res = "FAIL"
  373. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  374. + res = "UKNOWN METHOD"
  375. +except:
  376. + pass
  377. +print "\t\t\t\t%s" % res
  378. +
  379. +print "Testing Seat.GetSessions:",
  380. +res = "PASS"
  381. +try:
  382. + seat.GetSessions ()
  383. +except dbus.exceptions.DBusException, e:
  384. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  385. + res = "FAIL"
  386. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  387. + res = "UKNOWN METHOD"
  388. +except:
  389. + pass
  390. +print "\t\t\t%s" % res
  391. +
  392. +print "Testing Seat.GetDevices:",
  393. +res = "PASS"
  394. +try:
  395. + seat.GetDevices ()
  396. +except dbus.exceptions.DBusException, e:
  397. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  398. + res = "FAIL"
  399. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  400. + res = "UKNOWN METHOD"
  401. +except:
  402. + pass
  403. +print "\t\t\t%s" % res
  404. +
  405. +print "Testing Seat.GetActiveSession:",
  406. +res = "PASS"
  407. +try:
  408. + seat.GetActiveSession ()
  409. +except dbus.exceptions.DBusException, e:
  410. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  411. + res = "FAIL"
  412. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  413. + res = "UKNOWN METHOD"
  414. +except:
  415. + pass
  416. +print "\t\t\t%s" % res
  417. +
  418. +print "Testing Seat.CanActivateSessions:",
  419. +res = "PASS"
  420. +try:
  421. + seat.CanActivateSessions ()
  422. +except dbus.exceptions.DBusException, e:
  423. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  424. + res = "FAIL"
  425. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  426. + res = "UKNOWN METHOD"
  427. +except:
  428. + pass
  429. +print "\t\t%s" % res
  430. +
  431. +print "Testing Seat.ActivateSession:",
  432. +res = "PASS"
  433. +try:
  434. + seat.ActivateSession ('/org/freedesktop/ConsoleKit/SessionN')
  435. +except dbus.exceptions.DBusException, e:
  436. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  437. + res = "FAIL"
  438. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  439. + res = "UKNOWN METHOD"
  440. +except:
  441. + pass
  442. +print "\t\t\t%s" % res
  443. +
  444. +# Test Session Interface
  445. +print "Testing Session"
  446. +
  447. +# create a new session so we can set props
  448. +cookie = manager.OpenSession ()
  449. +ssid = manager.GetSessionForCookie (cookie)
  450. +if not ssid:
  451. + print "Could not create a session to test"
  452. + sys.exit ()
  453. +
  454. +session_obj = bus.get_object ('org.freedesktop.ConsoleKit', ssid)
  455. +session = dbus.Interface (session_obj, 'org.freedesktop.ConsoleKit.Session')
  456. +
  457. +print "Testing Session.GetId:",
  458. +res = "PASS"
  459. +try:
  460. + session.GetId ()
  461. +except dbus.exceptions.DBusException, e:
  462. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  463. + res = "FAIL"
  464. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  465. + res = "UKNOWN METHOD"
  466. +except:
  467. + pass
  468. +print "\t\t\t\t%s" % res
  469. +
  470. +print "Testing Session.GetSeatId:",
  471. +res = "PASS"
  472. +try:
  473. + session.GetSeatId ()
  474. +except dbus.exceptions.DBusException, e:
  475. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  476. + res = "FAIL"
  477. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  478. + res = "UKNOWN METHOD"
  479. +except:
  480. + pass
  481. +print "\t\t\t%s" % res
  482. +
  483. +print "Testing Session.GetLoginSessionId:",
  484. +res = "PASS"
  485. +try:
  486. + session.GetLoginSessionId ()
  487. +except dbus.exceptions.DBusException, e:
  488. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  489. + res = "FAIL"
  490. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  491. + res = "UKNOWN METHOD"
  492. +except:
  493. + pass
  494. +print "\t\t%s" % res
  495. +
  496. +print "Testing Session.GetSessionType:",
  497. +res = "PASS"
  498. +try:
  499. + session.GetSessionType ()
  500. +except dbus.exceptions.DBusException, e:
  501. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  502. + res = "FAIL"
  503. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  504. + res = "UKNOWN METHOD"
  505. +except:
  506. + pass
  507. +print "\t\t%s" % res
  508. +
  509. +print "Testing Session.GetUser:",
  510. +res = "PASS"
  511. +try:
  512. + session.GetUser ()
  513. +except dbus.exceptions.DBusException, e:
  514. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  515. + res = "FAIL"
  516. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  517. + res = "UKNOWN METHOD"
  518. +except:
  519. + pass
  520. +print "\t\t\t%s" % res
  521. +
  522. +print "Testing Session.GetUnixUser:",
  523. +res = "PASS"
  524. +try:
  525. + session.GetUnixUser ()
  526. +except dbus.exceptions.DBusException, e:
  527. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  528. + res = "FAIL"
  529. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  530. + res = "UKNOWN METHOD"
  531. +except:
  532. + pass
  533. +print "\t\t\t%s" % res
  534. +
  535. +print "Testing Session.GetX11Display:",
  536. +res = "PASS"
  537. +try:
  538. + session.GetX11Display ()
  539. +except dbus.exceptions.DBusException, e:
  540. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  541. + res = "FAIL"
  542. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  543. + res = "UKNOWN METHOD"
  544. +except:
  545. + pass
  546. +print "\t\t\t%s" % res
  547. +
  548. +print "Testing Session.GetX11DisplayDevice:",
  549. +res = "PASS"
  550. +try:
  551. + session.GetX11DisplayDevice ()
  552. +except dbus.exceptions.DBusException, e:
  553. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  554. + res = "FAIL"
  555. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  556. + res = "UKNOWN METHOD"
  557. +except:
  558. + pass
  559. +print "\t\t%s" % res
  560. +
  561. +print "Testing Session.GetDisplayDevice:",
  562. +res = "PASS"
  563. +try:
  564. + session.GetDisplayDevice ()
  565. +except dbus.exceptions.DBusException, e:
  566. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  567. + res = "FAIL"
  568. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  569. + res = "UKNOWN METHOD"
  570. +except:
  571. + pass
  572. +print "\t\t%s" % res
  573. +
  574. +print "Testing Session.GetRemoteHostName:",
  575. +res = "PASS"
  576. +try:
  577. + session.GetRemoteHostName ()
  578. +except dbus.exceptions.DBusException, e:
  579. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  580. + res = "FAIL"
  581. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  582. + res = "UKNOWN METHOD"
  583. +except:
  584. + pass
  585. +print "\t\t%s" % res
  586. +
  587. +print "Testing Session.IsActive:",
  588. +res = "PASS"
  589. +try:
  590. + session.IsActive ()
  591. +except dbus.exceptions.DBusException, e:
  592. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  593. + res = "FAIL"
  594. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  595. + res = "UKNOWN METHOD"
  596. +except:
  597. + pass
  598. +print "\t\t\t%s" % res
  599. +
  600. +print "Testing Session.IsLocal:",
  601. +res = "PASS"
  602. +try:
  603. + session.IsLocal ()
  604. +except dbus.exceptions.DBusException, e:
  605. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  606. + res = "FAIL"
  607. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  608. + res = "UKNOWN METHOD"
  609. +except:
  610. + pass
  611. +print "\t\t\t%s" % res
  612. +
  613. +print "Testing Session.GetCreationTime:",
  614. +res = "PASS"
  615. +try:
  616. + session.GetCreationTime ()
  617. +except dbus.exceptions.DBusException, e:
  618. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  619. + res = "FAIL"
  620. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  621. + res = "UKNOWN METHOD"
  622. +except:
  623. + pass
  624. +print "\t\t%s" % res
  625. +
  626. +print "Testing Session.Activate:",
  627. +res = "PASS"
  628. +try:
  629. + session.Activate ()
  630. +except dbus.exceptions.DBusException, e:
  631. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  632. + res = "FAIL"
  633. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  634. + res = "UKNOWN METHOD"
  635. +except:
  636. + pass
  637. +print "\t\t\t%s" % res
  638. +
  639. +print "Testing Session.Lock:",
  640. +res = "PASS"
  641. +try:
  642. + session.Lock ()
  643. + if not privileged:
  644. + res = "FAIL"
  645. +except dbus.exceptions.DBusException, e:
  646. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  647. + if privileged:
  648. + res = "FAIL"
  649. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  650. + res = "UKNOWN METHOD"
  651. +except:
  652. + pass
  653. +print "\t\t\t\t%s" % res
  654. +
  655. +print "Testing Session.Unlock:",
  656. +res = "PASS"
  657. +try:
  658. + session.Unlock ()
  659. + if not privileged:
  660. + res = "FAIL"
  661. +except dbus.exceptions.DBusException, e:
  662. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  663. + if privileged:
  664. + res = "FAIL"
  665. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  666. + res = "UKNOWN METHOD"
  667. +except:
  668. + pass
  669. +print "\t\t\t%s" % res
  670. +
  671. +# Test session properties
  672. +
  673. +session_props = dbus.Interface (session_obj, 'org.freedesktop.DBus.Properties')
  674. +
  675. +print "Testing Properties.Get 'unix-user':",
  676. +res = "PASS"
  677. +try:
  678. + session_props.Get ('org.freedesktop.ConsoleKit.Session', "unix-user")
  679. + if not privileged:
  680. + res = "FAIL"
  681. +except dbus.exceptions.DBusException, e:
  682. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  683. + if privileged:
  684. + res = "FAIL"
  685. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  686. + res = "UKNOWN METHOD"
  687. +except:
  688. + pass
  689. +print "\t\t%s" % res
  690. +
  691. +print "Testing Properties.Get 'cookie':",
  692. +res = "PASS"
  693. +try:
  694. + session_props.Get ('org.freedesktop.ConsoleKit.Session', "cookie")
  695. + if not privileged:
  696. + res = "FAIL"
  697. +except dbus.exceptions.DBusException, e:
  698. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  699. + if privileged:
  700. + res = "FAIL"
  701. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  702. + res = "UKNOWN METHOD"
  703. +except:
  704. + pass
  705. +print "\t\t%s" % res
  706. +
  707. +print "Testing Properties.Set:",
  708. +res = "PASS"
  709. +try:
  710. + session_props.Set ('org.freedesktop.ConsoleKit.Session', "unix-user", 0)
  711. + if not privileged:
  712. + res = "FAIL"
  713. +except dbus.exceptions.DBusException, e:
  714. + if e.get_dbus_name () == "org.freedesktop.DBus.Error.AccessDenied":
  715. + if privileged:
  716. + res = "FAIL"
  717. + elif e.get_dbus_name () == "org.freedesktop.DBus.Error.UnknownMethod":
  718. + res = "UKNOWN METHOD"
  719. +except:
  720. + pass
  721. +print "\t\t\t%s" % res
  722. diff -Nuar ConsoleKit2-0.9.3.orig/src/test-session.c ConsoleKit2-0.9.3/src/test-session.c
  723. --- ConsoleKit2-0.9.3.orig/src/test-session.c 2015-05-18 06:43:04.000000000 +0300
  724. +++ ConsoleKit2-0.9.3/src/test-session.c 2015-06-14 21:31:12.560744229 +0300
  725. @@ -176,7 +176,7 @@
  726. open_session (void)
  727. {
  728. GDBusProxy *session;
  729. - GVariant *cookie_var, *session_var, *activate_var;
  730. + GVariant *cookie_var, *session_var, *activate_var, *close_var;
  731. GError *error = NULL;
  732. const gchar *path = NULL, *cookie = NULL;
  733. @@ -272,6 +272,20 @@
  734. }
  735. if (activate_var)
  736. g_variant_unref (activate_var);
  737. +
  738. + close_var = g_dbus_proxy_call_sync (manager, "CloseSession", g_variant_new ("(s)", cookie), G_DBUS_CALL_FLAGS_NONE, 3000, NULL, &error);
  739. + if (session_var == NULL) {
  740. + g_print ("returned NULL, is the daemon running?\t");
  741. +
  742. + if (error)
  743. + g_print ("error %s", error->message);
  744. +
  745. + g_print ("\n");
  746. + g_clear_error (&error);
  747. + return;
  748. + }
  749. + if (close_var)
  750. + g_variant_unref (close_var);
  751. }
  752. int