policykit-gnome r39 - in trunk: data src
- From: davidz svn gnome org
- To: svn-commits-list gnome org
- Subject: policykit-gnome r39 - in trunk: data src
- Date: Fri, 18 Jul 2008 14:05:32 +0000 (UTC)
Author: davidz
Date: Fri Jul 18 14:05:32 2008
New Revision: 39
URL: http://svn.gnome.org/viewvc/policykit-gnome?rev=39&view=rev
Log:
add two gconf keys to control whether to check the "remember authz" by default
See
http://lists.freedesktop.org/archives/polkit-devel/2008-July/000022.html
and surrounding messages in that thread for details.
Modified:
trunk/data/polkit-gnome.schemas.in
trunk/src/polkit-gnome-auth-dialog.c
trunk/src/polkit-gnome-auth-dialog.h
trunk/src/polkit-gnome-manager.c
Modified: trunk/data/polkit-gnome.schemas.in
==============================================================================
--- trunk/data/polkit-gnome.schemas.in (original)
+++ trunk/data/polkit-gnome.schemas.in Fri Jul 18 14:05:32 2008
@@ -18,5 +18,43 @@
</locale>
</schema>
+ <schema>
+ <key>/schemas/desktop/gnome/policykit/auth_dialog_retain_authorization</key>
+ <applyto>/desktop/gnome/policykit/auth_dialog_retain_authorization</applyto>
+ <owner>policykit-gnome</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short>Whether the retain authorization check box is checked by default</short>
+ <long>
+ If set to true, then "retain authorization" check box (if present) is
+ checked by default in the authentication dialog unless the action
+ is mentioned in the
+ "/desktop/gnome/policykit/auth_dialog_retain_authorization_blacklist"
+ key.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/desktop/gnome/policykit/auth_dialog_retain_authorization_blacklist</key>
+ <applyto>/desktop/gnome/policykit/auth_dialog_retain_authorization_blacklist</applyto>
+ <owner>policykit-gnome</owner>
+ <type>list</type>
+ <list_type>string</list_type>
+ <default>[]</default>
+ <locale name="C">
+ <short>A list of actions where the "retain authorization" checkbox isn't checked by default</short>
+ <long>
+ A list of PolicyKit action where the "retain authorization"
+ checkbox isn't checked by default; this list is maintained
+ by the authentication dialog code itself. For example, if a
+ user unchecks the "retain authorization" check box for an
+ action and successfully obtains an authorization for the
+ action, the action will be added to this list.
+ </long>
+ </locale>
+ </schema>
+
</schemalist>
</gconfschemafile>
Modified: trunk/src/polkit-gnome-auth-dialog.c
==============================================================================
--- trunk/src/polkit-gnome-auth-dialog.c (original)
+++ trunk/src/polkit-gnome-auth-dialog.c Fri Jul 18 14:05:32 2008
@@ -34,6 +34,7 @@
#include <errno.h>
#include <libsexy/sexy.h>
#include <libgnomevfs/gnome-vfs-utils.h>
+#include <gconf/gconf-client.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
@@ -336,6 +337,63 @@
}
static void
+retain_checkbox_set_defaults (PolkitGnomeAuthDialog *auth_dialog, const char *action_id)
+{
+ gboolean retain_authorization;
+ GConfClient *client;
+ GError *error;
+ GSList *action_list, *l;
+
+ client = gconf_client_get_default ();
+ retain_authorization = TRUE;
+
+ if (client == NULL) {
+ g_warning ("Error getting GConfClient");
+ goto out;
+ }
+
+ error = NULL;
+ retain_authorization = gconf_client_get_bool (client, KEY_AUTH_DIALOG_RETAIN_AUTHORIZATION, &error);
+ if (error != NULL) {
+ g_warning ("Error getting key %s: %s",
+ KEY_AUTH_DIALOG_RETAIN_AUTHORIZATION,
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ /* check the blacklist */
+ if (!retain_authorization)
+ goto out;
+
+ action_list = gconf_client_get_list (client,
+ KEY_AUTH_DIALOG_RETAIN_AUTHORIZATION_BLACKLIST,
+ GCONF_VALUE_STRING,
+ &error);
+ if (error != NULL) {
+ g_warning ("Error getting key %s: %s",
+ KEY_AUTH_DIALOG_RETAIN_AUTHORIZATION_BLACKLIST,
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ for (l = action_list; l != NULL; l = l->next) {
+ const char *str = l->data;
+ if (strcmp (str, action_id) == 0) {
+ retain_authorization = FALSE;
+ break;
+ }
+ }
+ g_slist_foreach (action_list, (GFunc) g_free, NULL);
+ g_slist_free (action_list);
+
+out:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (auth_dialog->priv->keep_privilege_check_button),
+ retain_authorization);
+}
+
+static void
polkit_gnome_auth_dialog_set_action_id (PolkitGnomeAuthDialog *auth_dialog, const char *action_id)
{
char *str;
@@ -348,6 +406,8 @@
str = g_strdup_printf (_("Click to edit %s"), action_id);
gtk_widget_set_tooltip_markup (auth_dialog->priv->privilege_desc_label, str);
g_free (str);
+
+ retain_checkbox_set_defaults (auth_dialog, action_id);
}
static void
Modified: trunk/src/polkit-gnome-auth-dialog.h
==============================================================================
--- trunk/src/polkit-gnome-auth-dialog.h (original)
+++ trunk/src/polkit-gnome-auth-dialog.h Fri Jul 18 14:05:32 2008
@@ -25,6 +25,9 @@
G_BEGIN_DECLS
+#define KEY_AUTH_DIALOG_RETAIN_AUTHORIZATION "/desktop/gnome/policykit/auth_dialog_retain_authorization"
+#define KEY_AUTH_DIALOG_RETAIN_AUTHORIZATION_BLACKLIST "/desktop/gnome/policykit/auth_dialog_retain_authorization_blacklist"
+
#define POLKIT_GNOME_TYPE_AUTH_DIALOG (polkit_gnome_auth_dialog_get_type ())
#define POLKIT_GNOME_AUTH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), POLKIT_GNOME_TYPE_AUTH_DIALOG, PolkitGnomeAuthDialog))
#define POLKIT_GNOME_AUTH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), POLKIT_GNOME_TYPE_AUTH_DIALOG, PolkitGnomeAuthDialogClass))
Modified: trunk/src/polkit-gnome-manager.c
==============================================================================
--- trunk/src/polkit-gnome-manager.c (original)
+++ trunk/src/polkit-gnome-manager.c Fri Jul 18 14:05:32 2008
@@ -933,6 +933,76 @@
static PolKitGrant *grant = NULL;
static UserData *ud = NULL;
+static void
+add_to_blacklist (UserData *ud, const char *action_id)
+{
+ GSList *action_list, *l;
+ GConfClient *client;
+ GError *error;
+ gboolean never_retain_authorization;
+
+ client = gconf_client_get_default ();
+ if (client == NULL) {
+ g_warning ("Error getting GConfClient");
+ goto out;
+ }
+
+ error = NULL;
+ never_retain_authorization = !gconf_client_get_bool (client, KEY_AUTH_DIALOG_RETAIN_AUTHORIZATION, &error);
+ if (error != NULL) {
+ g_warning ("Error getting key %s: %s",
+ KEY_AUTH_DIALOG_RETAIN_AUTHORIZATION,
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ if (never_retain_authorization)
+ goto out;
+
+ error = NULL;
+ action_list = gconf_client_get_list (client,
+ KEY_AUTH_DIALOG_RETAIN_AUTHORIZATION_BLACKLIST,
+ GCONF_VALUE_STRING,
+ &error);
+ if (error != NULL) {
+ g_warning ("Error getting key %s: %s",
+ KEY_AUTH_DIALOG_RETAIN_AUTHORIZATION_BLACKLIST,
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ for (l = action_list; l != NULL; l = l->next) {
+ const char *str = l->data;
+ if (strcmp (str, action_id) == 0) {
+ /* already there */
+ goto done;
+ }
+ }
+
+ action_list = g_slist_append (action_list, g_strdup (action_id));
+
+ if (!gconf_client_set_list (client,
+ KEY_AUTH_DIALOG_RETAIN_AUTHORIZATION_BLACKLIST,
+ GCONF_VALUE_STRING,
+ action_list,
+ &error)) {
+ g_warning ("Error setting key %s: %s",
+ KEY_AUTH_DIALOG_RETAIN_AUTHORIZATION_BLACKLIST,
+ error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+
+done:
+ g_slist_foreach (action_list, (GFunc) g_free, NULL);
+ g_slist_free (action_list);
+
+out:
+ ;
+}
+
static gboolean
do_polkit_auth (PolKitContext *pk_context,
DBusConnection *system_bus_connection,
@@ -1081,6 +1151,16 @@
}
}
+ if (ud->gained_privilege) {
+ /* add to blacklist if the user unchecked the "remember authorization" check box */
+ if ((ud->remember_always &&
+ !polkit_gnome_auth_dialog_get_remember_always (POLKIT_GNOME_AUTH_DIALOG (ud->dialog))) ||
+ (ud->remember_session &&
+ !polkit_gnome_auth_dialog_get_remember_session (POLKIT_GNOME_AUTH_DIALOG (ud->dialog)))) {
+ add_to_blacklist (ud, action_id);
+ }
+ }
+
ret = ud->gained_privilege;
error:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]