summaryrefslogtreecommitdiffstats
path: root/polkit-fix.patch
blob: 2d074459ce601e3604525e9b112e1c2abe782716 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
diff -up gnome-panel-2.21.92/applets/clock/set-timezone.c.polkit-fix gnome-panel-2.21.92/applets/clock/set-timezone.c
--- gnome-panel-2.21.92/applets/clock/set-timezone.c.polkit-fix	2008-03-03 12:10:34.000000000 -0500
+++ gnome-panel-2.21.92/applets/clock/set-timezone.c	2008-03-03 12:10:50.000000000 -0500
@@ -75,6 +75,40 @@ get_system_bus (void)
         return bus;
 }
 
+static gboolean
+pk_io_watch_have_data (GIOChannel *channel, GIOCondition condition, gpointer user_data)
+{
+        int fd;
+        PolKitContext *pk_context = user_data;
+        fd = g_io_channel_unix_get_fd (channel);
+        polkit_context_io_func (pk_context, fd);
+        return TRUE;
+}
+
+static int 
+pk_io_add_watch_fn (PolKitContext *pk_context, int fd)
+{
+        guint id = 0;
+        GIOChannel *channel;
+        channel = g_io_channel_unix_new (fd);
+        if (channel == NULL)
+                goto out;
+        id = g_io_add_watch (channel, G_IO_IN, pk_io_watch_have_data, pk_context);
+        if (id == 0) {
+                g_io_channel_unref (channel);
+                goto out;
+        }
+        g_io_channel_unref (channel);
+out:
+        return id;
+}
+
+static void 
+pk_io_remove_watch_fn (PolKitContext *pk_context, int watch_id)
+{
+        g_source_remove (watch_id);
+}
+
 static PolKitContext *
 get_pk_context (void)
 {
@@ -82,6 +116,9 @@ get_pk_context (void)
 
 	if (pk_context == NULL) {
 		pk_context = polkit_context_new ();
+//                polkit_context_set_io_watch_functions (pk_context,
+//                                                       pk_io_add_watch_fn,
+//                                                       pk_io_remove_watch_fn);
 		if (!polkit_context_init (pk_context, NULL)) {
 			polkit_context_unref (pk_context);
 			pk_context = NULL;
@@ -126,22 +163,19 @@ can_do (const gchar *pk_action_id)
         pk_result = polkit_context_can_caller_do_action (pk_context, pk_action, pk_caller);
 
 	switch (pk_result) {
-        default:
         case POLKIT_RESULT_UNKNOWN:
         case POLKIT_RESULT_NO:
  		res = 0;
 		break;
-        case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH:
-        case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION:
-        case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS:
-        case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
-        case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
-        case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
-		res = 1;
-		break;
         case POLKIT_RESULT_YES:
 		res = 2;
 		break;
+        default:
+                /* This covers all the POLKIT_RESULT_ONLY_VIA_[SELF|ADMIN]_AUTH_* cases as more of these
+                 * may be added in the future.
+                 */
+		res = 1;
+		break;
 	}
 	
 out:
diff -up gnome-panel-2.21.92/applets/clock/clock.c.polkit-fix gnome-panel-2.21.92/applets/clock/clock.c
--- gnome-panel-2.21.92/applets/clock/clock.c.polkit-fix	2008-03-03 12:10:23.000000000 -0500
+++ gnome-panel-2.21.92/applets/clock/clock.c	2008-03-03 12:10:45.000000000 -0500
@@ -2266,11 +2266,15 @@ clock_migrate_to_26 (ClockData *clock)
 	else if (hourformat == 24)
 		clock->format = CLOCK_FORMAT_24;
 
-	panel_applet_gconf_set_string (PANEL_APPLET (clock->applet),
-				       KEY_FORMAT,
-				       gconf_enum_to_string (format_type_enum_map,
-							     clock->format),
-				       NULL);
+	/* It's still possible that we have none of the old keys, in which case
+	 * we're not migrating from 2.6, but the config is simply wrong. So
+	 * don't set the format key in this case. */
+	if (clock->format != CLOCK_FORMAT_INVALID)
+		panel_applet_gconf_set_string (PANEL_APPLET (clock->applet),
+					       KEY_FORMAT,
+					       gconf_enum_to_string (format_type_enum_map,
+								     clock->format),
+					       NULL);
 }
 
 static void