[gnome-settings-daemon] datetime: use a single policy kit action for configuring date and time



commit 6a0f8c1ac98b7f773ea8b8e386b8e3bac77bdc63
Author: Thomas Wood <thos gnome org>
Date:   Sat Jan 29 18:09:58 2011 +0000

    datetime: use a single policy kit action for configuring date and time
    
    A single action allows the user to authenticate only once to change any
    related date and time settings.

 plugins/datetime/gsd-datetime-mechanism.c          |   12 +++---
 ...nome.settingsdaemon.datetimemechanism.policy.in |   34 ++-----------------
 2 files changed, 10 insertions(+), 36 deletions(-)
---
diff --git a/plugins/datetime/gsd-datetime-mechanism.c b/plugins/datetime/gsd-datetime-mechanism.c
index f26baa1..e62d9d0 100644
--- a/plugins/datetime/gsd-datetime-mechanism.c
+++ b/plugins/datetime/gsd-datetime-mechanism.c
@@ -229,8 +229,9 @@ gsd_datetime_mechanism_new (void)
 }
 
 static gboolean
-_check_polkit_for_action (GsdDatetimeMechanism *mechanism, DBusGMethodInvocation *context, const char *action)
+_check_polkit_for_action (GsdDatetimeMechanism *mechanism, DBusGMethodInvocation *context)
 {
+        const char *action = "org.gnome.settingsdaemon.datetimemechanism.configure";
         const char *sender;
         GError *error;
         PolkitSubject *subject;
@@ -313,7 +314,7 @@ _set_time (GsdDatetimeMechanism  *mechanism,
 {
         GError *error;
 
-        if (!_check_polkit_for_action (mechanism, context, "org.gnome.settingsdaemon.datetimemechanism.settime"))
+        if (!_check_polkit_for_action (mechanism, context))
                 return FALSE;
 
         if (settimeofday (tv, NULL) != 0) {
@@ -545,7 +546,7 @@ gsd_datetime_mechanism_set_timezone (GsdDatetimeMechanism  *mechanism,
         reset_killtimer ();
         g_debug ("SetTimezone('%s') called", tz);
 
-        if (!_check_polkit_for_action (mechanism, context, "org.gnome.settingsdaemon.datetimemechanism.settimezone"))
+        if (!_check_polkit_for_action (mechanism, context))
                 return FALSE;
 
         error = NULL;
@@ -656,8 +657,7 @@ gsd_datetime_mechanism_set_hardware_clock_using_utc (GsdDatetimeMechanism  *mech
 
         error = NULL;
 
-        if (!_check_polkit_for_action (mechanism, context,
-                                       "org.gnome.settingsdaemon.datetimemechanism.configurehwclock"))
+        if (!_check_polkit_for_action (mechanism, context))
                 return FALSE;
 
         if (g_file_test ("/sbin/hwclock", 
@@ -741,7 +741,7 @@ gsd_datetime_mechanism_set_using_ntp  (GsdDatetimeMechanism    *mechanism,
 
         error = NULL;
 
-        if (!_check_polkit_for_action (mechanism, context, "org.gnome.clockapplet.mechanism.configurentp"))
+        if (!_check_polkit_for_action (mechanism, context))
                 return FALSE;
 
         cmd = g_strconcat ("/sbin/chkconfig --level 2345 ntpd ", using_ntp ? "on" : "off", NULL);
diff --git a/plugins/datetime/org.gnome.settingsdaemon.datetimemechanism.policy.in b/plugins/datetime/org.gnome.settingsdaemon.datetimemechanism.policy.in
index 6a480ce..2943c0d 100644
--- a/plugins/datetime/org.gnome.settingsdaemon.datetimemechanism.policy.in
+++ b/plugins/datetime/org.gnome.settingsdaemon.datetimemechanism.policy.in
@@ -8,40 +8,14 @@
   <vendor_url>http://www.gnome.org/</vendor_url>
   <icon_name>gnome-panel-clock</icon_name>
 
-  <action id="org.gnome.settingsdaemon.datetimemechanism.settimezone">
-    <_description>Change system time zone</_description>
-    <_message>Privileges are required to change the system time zone.</_message>
-    <defaults>
-      <allow_inactive>no</allow_inactive>
-      <allow_active>auth_self_keep</allow_active>
-    </defaults>
-  </action>
-
-  <action id="org.gnome.settingsdaemon.datetimemechanism.settime">
-    <_description>Change system time</_description>
-    <_message>Privileges are required to change the system time.</_message>
-    <defaults>
-      <allow_inactive>no</allow_inactive>
-      <allow_active>auth_admin_keep</allow_active>
-    </defaults>
-  </action>
-
-  <action id="org.gnome.settingsdaemon.datetimemechanism.configurehwclock">
-    <_description>Configure hardware clock</_description>
-    <_message>Privileges are required to configure the hardware clock.</_message>
+  <action id="org.gnome.settingsdaemon.datetimemechanism.configure">
+    <_description>Change system time and date settings</_description>
+    <_message>Privileges are required to configure time and date settings.</_message>
     <defaults>
+      <allow_any>no</allow_any>
       <allow_inactive>no</allow_inactive>
       <allow_active>auth_admin_keep</allow_active>
     </defaults>
   </action>
 
-  <action id="org.gnome.settingsdaemon.datetimemechanism.configurentp">
-    <_description>Configure network time</_description>
-    <_message>Privileges are required to configure network time.</_message>
-    <defaults>
-      <allow_inactive>no</allow_inactive>
-      <allow_active>auth_self_keep</allow_active>
-    </defaults>
-  </action>
-
 </policyconfig>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]