gnome-control-center/gnome-control-center-fine-grained-tz-polkit.patch

98 lines
3.5 KiB
Diff
Raw Normal View History

commit 4300867b7bfc4f67a0e8b273aa7d2d13973ea7ac
Author: Vincent Untz <vuntz@gnome.org>
Date: Mon Mar 12 15:31:40 2012 +0100
datetime: Allow changing timezone without auth if action is allowed
As changing the time can have security implications, while changing the
timezone doesn't, it's not unusual to have a setup where
org.freedesktop.timedate1.set-timezone is allowed while other
time-related actions aren't.
Therefore, if org.freedesktop.timedate1.set-timezone is allowed, there's
no reason to require that the user unlocks the panel to enable him to
change the timezone.
https://bugzilla.gnome.org/show_bug.cgi?id=646185
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c
index d229e94..378e0cb 100644
--- a/panels/datetime/cc-datetime-panel.c
+++ b/panels/datetime/cc-datetime-panel.c
@@ -86,6 +86,7 @@ struct _CcDateTimePanelPrivate
GCancellable *cancellable;
GPermission *permission;
+ GPermission *permission_tz;
};
static void update_time (CcDateTimePanel *self);
@@ -164,6 +165,12 @@ cc_date_time_panel_dispose (GObject *object)
priv->permission = NULL;
}
+ if (priv->permission_tz)
+ {
+ g_object_unref (priv->permission_tz);
+ priv->permission_tz = NULL;
+ }
+
G_OBJECT_CLASS (cc_date_time_panel_parent_class)->dispose (object);
}
@@ -806,19 +813,33 @@ on_permission_changed (GPermission *permission,
gpointer data)
{
CcDateTimePanelPrivate *priv = CC_DATE_TIME_PANEL (data)->priv;
- gboolean allowed, using_ntp;
+ gboolean allowed, allowed_tz, using_ntp;
allowed = g_permission_get_allowed (permission);
+ allowed_tz = priv->permission_tz && g_permission_get_allowed (priv->permission_tz);
using_ntp = gtk_switch_get_active (GTK_SWITCH (W("network_time_switch")));
/* All the widgets but the lock button and the 24h setting */
- gtk_widget_set_sensitive (W("map-vbox"), allowed);
+ gtk_widget_set_sensitive (W("map-vbox"), allowed || allowed_tz);
gtk_widget_set_sensitive (W("hbox2"), allowed);
gtk_widget_set_sensitive (W("alignment2"), allowed);
update_widget_state_for_ntp (data, using_ntp);
}
static void
+on_permission_tz_changed (GPermission *permission,
+ GParamSpec *pspec,
+ gpointer data)
+{
+ CcDateTimePanelPrivate *priv = CC_DATE_TIME_PANEL (data)->priv;
+ gboolean allowed;
+
+ allowed = g_permission_get_allowed (permission) || g_permission_get_allowed (priv->permission);
+
+ gtk_widget_set_sensitive (W("map-vbox"), allowed);
+}
+
+static void
update_ntp_switch_from_system (CcDateTimePanel *self)
{
CcDateTimePanelPrivate *priv = self->priv;
@@ -1103,6 +1124,18 @@ cc_date_time_panel_init (CcDateTimePanel *self)
g_signal_connect (priv->permission, "notify",
G_CALLBACK (on_permission_changed), self);
on_permission_changed (priv->permission, NULL, self);
+
+ priv->permission_tz = polkit_permission_new_sync ("org.freedesktop.timedate1.set-timezone", NULL, NULL, NULL);
+ if (priv->permission_tz == NULL)
+ {
+ g_warning ("Your system does not have the '%s' PolicyKit files installed. Please check your installation",
+ "org.freedesktop.timedate1.set-timezone");
+ return;
+ }
+
+ g_signal_connect (priv->permission_tz, "notify",
+ G_CALLBACK (on_permission_tz_changed), self);
+ on_permission_tz_changed (priv->permission_tz, NULL, self);
}
void