~gotwig/indicator-pantheon-session/indicator-pantheon-session

« back to all changes in this revision

Viewing changes to debian/patches/01_polkit-1.patch

  • Committer: Bazaar Package Importer
  • Author(s): Ted Gould
  • Date: 2009-09-24 17:07:51 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090924170751-l7afnthkpri6diwd
Tags: 0.1.5-0ubuntu1
* Upstream release 0.1.5 (LP: #436223)
  * PolicyKit-1 support (LP: #418643)
  * GDM User list support (LP: #422052)
  * MissionControl5 support (LP: #427643)
  * Better locking of the screensaver (LP: #428115)
* debian/control: Adding in a libempathy-dev build dependency
  as it's now required by upstream.
* Removing patches 01_polkit-1.patch and 99_autoreconf.patch
  as they were merged upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
--- indicator-session-0.1.4/configure.ac        2009-09-22 09:12:00.000000000 +0200
2
 
+++ indicator-session-0.1.4.new/configure.ac    2009-09-22 09:11:42.000000000 +0200
3
 
@@ -28,6 +28,7 @@
4
 
 GTK_REQUIRED_VERSION=2.12
5
 
 INDICATOR_REQUIRED_VERSION=0.2.0
6
 
 DBUSMENUGTK_REQUIRED_VERSION=0.1.1
7
 
+POLKIT_REQUIRED_VERSION=0.92
8
 
 
9
 
 PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION
10
 
                           indicator >= $INDICATOR_REQUIRED_VERSION
11
 
@@ -53,7 +54,8 @@
12
 
 AC_SUBST(SESSIONERVICE_LIBS)
13
 
 
14
 
 PKG_CHECK_MODULES(GTKLOGOUTHELPER, gtk+-2.0 >= $GTK_REQUIRED_VERSION
15
 
-                                   polkit-gnome)
16
 
+                                   polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION)
17
 
+
18
 
 
19
 
 AC_SUBST(GTKLOGOUTHELPER_CFLAGS)
20
 
 AC_SUBST(GTKLOGOUTHELPER_LIBS)
21
 
diff -ur indicator-session-0.1.4/src/gtk-dialog/ck-pk-helper.c indicator-session-0.1.4.new/src/gtk-dialog/ck-pk-helper.c
22
 
--- indicator-session-0.1.4/src/gtk-dialog/ck-pk-helper.c       2009-09-22 09:12:00.000000000 +0200
23
 
+++ indicator-session-0.1.4.new/src/gtk-dialog/ck-pk-helper.c   2009-09-22 09:11:43.000000000 +0200
24
 
@@ -24,7 +24,7 @@
25
 
 #include <unistd.h>
26
 
 #include <glib.h>
27
 
 #include <dbus/dbus-glib.h>
28
 
-#include <polkit-gnome/polkit-gnome.h>
29
 
+#include <polkit/polkit.h>
30
 
 
31
 
 #include "logout-dialog.h"
32
 
 #include "ck-pk-helper.h"
33
 
@@ -170,67 +170,53 @@
34
 
                }
35
 
        }
36
 
 
37
 
-       PolKitResult polres;
38
 
+       PolkitAuthorizationResult *polres = NULL;
39
 
+       gboolean ret = FALSE;
40
 
        if (pk_can_do_action(pk_action, &polres)) {
41
 
-               if (polres == POLKIT_RESULT_YES) {
42
 
-                       return FALSE;
43
 
+               if (polkit_authorization_result_get_is_challenge (polres)) {
44
 
+                       ret = TRUE;
45
 
                }
46
 
-               return TRUE;
47
 
+               g_debug ("pk_require_auth(%s): authorized, is_challenge: %i", pk_action, ret);
48
 
+       } else {
49
 
+               g_debug ("pk_require_auth(%s): not authorized", pk_action);
50
 
+       }
51
 
+       if (polres) {
52
 
+               g_object_unref (polres);
53
 
        }
54
 
-       return FALSE;
55
 
+       return ret;
56
 
 }
57
 
 
58
 
 gboolean
59
 
-pk_can_do_action (const gchar    *action_id, PolKitResult * pol_result)
60
 
+pk_can_do_action (const gchar    *action_id, PolkitAuthorizationResult ** pol_result)
61
 
 {
62
 
-        PolKitGnomeContext *gnome_context;
63
 
-        PolKitAction *action;
64
 
-        PolKitCaller *caller;
65
 
-        DBusError dbus_error;
66
 
-        PolKitError *error;
67
 
-        PolKitResult result;
68
 
-
69
 
-        gnome_context = polkit_gnome_context_get (NULL);
70
 
-
71
 
-        if (gnome_context == NULL) {
72
 
-                return FALSE;
73
 
-        }
74
 
-
75
 
-        if (gnome_context->pk_tracker == NULL) {
76
 
-                return FALSE;
77
 
-        }
78
 
-
79
 
-        dbus_error_init (&dbus_error);
80
 
-        caller = polkit_tracker_get_caller_from_pid (gnome_context->pk_tracker,
81
 
-                                                     getpid (),
82
 
-                                                     &dbus_error);
83
 
-        dbus_error_free (&dbus_error);
84
 
-
85
 
-        if (caller == NULL) {
86
 
-                return FALSE;
87
 
-        }
88
 
-
89
 
-        action = polkit_action_new ();
90
 
-        if (!polkit_action_set_action_id (action, action_id)) {
91
 
-                polkit_action_unref (action);
92
 
-                polkit_caller_unref (caller);
93
 
-                return FALSE;
94
 
-        }
95
 
-
96
 
-        result = POLKIT_RESULT_UNKNOWN;
97
 
-        error = NULL;
98
 
-        result = polkit_context_is_caller_authorized (gnome_context->pk_context,
99
 
-                                                      action, caller, FALSE,
100
 
-                                                      &error);
101
 
-        if (polkit_error_is_set (error)) {
102
 
-                polkit_error_free (error);
103
 
-        }
104
 
-        polkit_action_unref (action);
105
 
-                polkit_caller_unref (caller);
106
 
+       PolkitAuthority *authority;
107
 
+       PolkitSubject *subject;
108
 
+       PolkitAuthorizationResult *result;
109
 
+       gboolean ret;
110
 
+
111
 
+       authority = polkit_authority_get();
112
 
+       if (!authority) {
113
 
+               g_warning ("Could not get PolicyKit authority instance");
114
 
+               return FALSE;
115
 
+       }
116
 
+       subject = polkit_unix_process_new (getpid());
117
 
 
118
 
-               if (pol_result != NULL) {
119
 
-                       *pol_result = result;
120
 
-               }
121
 
+       result = polkit_authority_check_authorization_sync (authority, subject, action_id, NULL, 0, NULL, NULL);
122
 
+       g_object_unref (authority);
123
 
 
124
 
-        return result != POLKIT_RESULT_NO && result != POLKIT_RESULT_UNKNOWN;
125
 
+       ret = FALSE;
126
 
+       if (result) {
127
 
+               ret = polkit_authorization_result_get_is_authorized (result) || 
128
 
+                     polkit_authorization_result_get_is_challenge (result);
129
 
+               g_debug ("pk_can_do_action(%s): %i", action_id, ret);
130
 
+       } else {
131
 
+               g_warning ("pk_can_do_action(%s): check_authorization returned NULL", action_id);
132
 
+       }
133
 
+       if (pol_result) {
134
 
+               *pol_result = result;
135
 
+       } else {
136
 
+               g_object_unref (result);
137
 
+       }
138
 
+       return ret;
139
 
+       
140
 
 }
141
 
diff -ur indicator-session-0.1.4/src/gtk-dialog/ck-pk-helper.h indicator-session-0.1.4.new/src/gtk-dialog/ck-pk-helper.h
142
 
--- indicator-session-0.1.4/src/gtk-dialog/ck-pk-helper.h       2009-09-22 09:12:00.000000000 +0200
143
 
+++ indicator-session-0.1.4.new/src/gtk-dialog/ck-pk-helper.h   2009-09-22 09:11:43.000000000 +0200
144
 
@@ -24,9 +24,9 @@
145
 
 #ifndef __CK_PK_HELPER_H__
146
 
 #define __CK_PK_HELPER_H__ 1
147
 
 
148
 
-#include <polkit-gnome/polkit-gnome.h>
149
 
+#include <polkit/polkit.h>
150
 
 
151
 
 gboolean pk_require_auth (LogoutDialogAction action);
152
 
-gboolean pk_can_do_action (const gchar *action_id, PolKitResult * pol_result);
153
 
+gboolean pk_can_do_action (const gchar *action_id, PolkitAuthorizationResult ** pol_result);
154
 
 
155
 
 #endif /* __CK_PK_HELPER__ */