1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
3
* Copyright (C) 2008, 2009 Matthias Clasen <mclasen@redhat.com>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31
#include <sys/types.h>
35
#include <glib-object.h>
37
#include <dbus/dbus-glib.h>
38
#include <dbus/dbus-glib-lowlevel.h>
40
#include <polkit/polkit.h>
42
#define GCONF_ENABLE_INTERNALS
43
#include <gconf/gconf-client.h>
44
#include <gconf/gconf-engine.h>
46
#include "gconf-defaults.h"
47
#include "gconf-defaults-glue.h"
50
do_exit (gpointer user_data)
52
g_debug ("Exiting due to inactivity");
57
static guint timer_id = 0;
58
gboolean disable_killtimer = FALSE;
63
if (disable_killtimer)
67
g_source_remove (timer_id);
73
start_killtimer (void)
75
if (disable_killtimer)
79
g_debug ("Setting killtimer to 30 seconds...");
80
timer_id = g_timeout_add_seconds (30, do_exit, NULL);
84
static gint operations = 0;
87
start_operation (void)
102
struct GConfDefaultsPrivate
104
DBusGConnection *system_bus_connection;
105
DBusGProxy *system_bus_proxy;
106
PolkitAuthority *auth;
109
static void gconf_defaults_finalize (GObject *object);
111
G_DEFINE_TYPE (GConfDefaults, gconf_defaults, G_TYPE_OBJECT)
113
#define GCONF_DEFAULTS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCONF_TYPE_DEFAULTS, GConfDefaultsPrivate))
116
gconf_defaults_error_quark (void)
118
static GQuark ret = 0;
121
ret = g_quark_from_static_string ("gconf_defaults_error");
128
#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
131
gconf_defaults_error_get_type (void)
133
static GType etype = 0;
137
static const GEnumValue values[] =
139
ENUM_ENTRY (GCONF_DEFAULTS_ERROR_GENERAL, "GeneralError"),
140
ENUM_ENTRY (GCONF_DEFAULTS_ERROR_NOT_PRIVILEGED, "NotPrivileged"),
144
g_assert (GCONF_DEFAULTS_NUM_ERRORS == G_N_ELEMENTS (values) - 1);
146
etype = g_enum_register_static ("GConfDefaultsError", values);
154
gconf_defaults_constructor (GType type,
155
guint n_construct_properties,
156
GObjectConstructParam *construct_properties)
158
GConfDefaults *mechanism;
159
GConfDefaultsClass *klass;
161
klass = GCONF_DEFAULTS_CLASS (g_type_class_peek (GCONF_TYPE_DEFAULTS));
163
mechanism = GCONF_DEFAULTS (G_OBJECT_CLASS (gconf_defaults_parent_class)->constructor (
165
n_construct_properties,
166
construct_properties));
168
return G_OBJECT (mechanism);
176
static guint signals[LAST_SIGNAL] = { 0 };
179
gconf_defaults_class_init (GConfDefaultsClass *klass)
181
GObjectClass *object_class = G_OBJECT_CLASS (klass);
183
object_class->constructor = gconf_defaults_constructor;
184
object_class->finalize = gconf_defaults_finalize;
186
signals[SYSTEM_SET] = g_signal_new ("system-set",
187
G_OBJECT_CLASS_TYPE (object_class),
189
G_STRUCT_OFFSET (GConfDefaultsClass, system_set),
191
g_cclosure_marshal_VOID__BOXED,
192
G_TYPE_NONE, 1, G_TYPE_STRV);
194
g_type_class_add_private (klass, sizeof (GConfDefaultsPrivate));
196
dbus_g_object_type_install_info (GCONF_TYPE_DEFAULTS, &dbus_glib_gconf_defaults_object_info);
198
dbus_g_error_domain_register (GCONF_DEFAULTS_ERROR, NULL, GCONF_DEFAULTS_TYPE_ERROR);
203
gconf_defaults_init (GConfDefaults *mechanism)
205
mechanism->priv = GCONF_DEFAULTS_GET_PRIVATE (mechanism);
209
gconf_defaults_finalize (GObject *object)
211
GConfDefaults *mechanism;
213
g_return_if_fail (object != NULL);
214
g_return_if_fail (GCONF_IS_DEFAULTS (object));
216
mechanism = GCONF_DEFAULTS (object);
218
g_return_if_fail (mechanism->priv != NULL);
220
g_object_unref (mechanism->priv->auth);
221
g_object_unref (mechanism->priv->system_bus_proxy);
223
G_OBJECT_CLASS (gconf_defaults_parent_class)->finalize (object);
227
register_mechanism (GConfDefaults *mechanism)
229
GError *error = NULL;
231
mechanism->priv->auth = polkit_authority_get ();
234
mechanism->priv->system_bus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
235
if (mechanism->priv->system_bus_connection == NULL) {
237
g_critical ("error getting system bus: %s", error->message);
238
g_error_free (error);
243
dbus_g_connection_register_g_object (mechanism->priv->system_bus_connection, "/",
244
G_OBJECT (mechanism));
246
mechanism->priv->system_bus_proxy = dbus_g_proxy_new_for_name (mechanism->priv->system_bus_connection,
249
DBUS_INTERFACE_DBUS);
261
gconf_defaults_new (void)
266
object = g_object_new (GCONF_TYPE_DEFAULTS, NULL);
268
res = register_mechanism (GCONF_DEFAULTS (object));
270
g_object_unref (object);
274
return GCONF_DEFAULTS (object);
278
polkit_action_for_gconf_path (GConfDefaults *mechanism,
279
GList *action_descriptions,
280
const char *annotation_key,
286
PolkitActionDescription *action_description;
287
const gchar *annotation;
289
g_debug ("finding action for path '%s'", path);
290
prefix = g_strdup (path);
292
for (l = action_descriptions; l; l = l->next) {
293
action_description = l->data;
295
annotation = polkit_action_description_get_annotation (action_description, annotation_key);
296
if (g_strcmp0 (prefix, annotation) == 0) {
297
action = polkit_action_description_get_action_id (action_description);
298
g_debug ("action for prefix '%s': '%s'\n", prefix, action);
303
p = strrchr (prefix, '/');
305
if (p == NULL || p == prefix) {
320
throw_error (DBusGMethodInvocation *context,
329
va_start (args, format);
330
message = g_strdup_vprintf (format, args);
333
error = g_error_new (GCONF_DEFAULTS_ERROR,
336
dbus_g_method_return_error (context, error);
337
g_error_free (error);
341
typedef void (*AuthObtainedCallback) (GConfDefaults *mechanism,
342
DBusGMethodInvocation *context,
347
GConfDefaults *mechanism;
348
DBusGMethodInvocation *context;
352
AuthObtainedCallback auth_obtained_callback;
353
GAsyncReadyCallback check_auth_callback;
355
GDestroyNotify destroy;
356
PolkitSubject *subject;
361
check_auth_data_free (CheckAuthData *data)
363
g_object_unref (data->mechanism);
364
g_strfreev (data->actions);
366
data->destroy (data->user_data);
367
g_object_unref (data->subject);
371
static void check_next_action (CheckAuthData *data);
374
check_authorization_callback (PolkitAuthority *authority,
378
CheckAuthData *data = user_data;
379
PolkitAuthorizationResult *result;
381
gboolean is_authorized;
383
is_authorized = FALSE;
386
result = polkit_authority_check_authorization_finish (authority,
390
g_debug ("error checking action '%s'\n", error->message);
391
throw_error (data->context,
392
GCONF_DEFAULTS_ERROR_NOT_PRIVILEGED,
393
"Not Authorized: %s", error->message);
394
g_error_free (error);
397
if (polkit_authorization_result_get_is_authorized (result)) {
398
g_debug ("result for '%s': authorized\n",
399
data->actions[data->id]);
400
is_authorized = TRUE;
402
else if (polkit_authorization_result_get_is_challenge (result)) {
403
g_debug ("result for '%s': challenge\n",
404
data->actions[data->id]);
405
throw_error (data->context,
406
GCONF_DEFAULTS_ERROR_NOT_PRIVILEGED,
407
"Authorization is required");
410
g_debug ("result for '%s': not authorized\n",
411
data->actions[data->id]);
412
throw_error (data->context,
413
GCONF_DEFAULTS_ERROR_NOT_PRIVILEGED,
420
if (data->actions[data->id] == NULL)
421
data->auth_obtained_callback (data->mechanism,
425
check_next_action (data);
426
return; /* continue operation */
430
check_auth_data_free (data);
431
g_object_unref (result);
436
check_next_action (CheckAuthData *data)
438
g_debug ("checking action '%s'\n", data->actions[data->id]);
439
polkit_authority_check_authorization (data->mechanism->priv->auth,
441
data->actions[data->id],
445
data->check_auth_callback,
450
check_polkit_for_actions (GConfDefaults *mechanism,
451
DBusGMethodInvocation *context,
453
AuthObtainedCallback auth_obtained_callback,
455
GDestroyNotify destroy)
459
data = g_new0 (CheckAuthData, 1);
460
data->mechanism = g_object_ref (mechanism);
461
data->context = context;
462
data->actions = actions;
463
data->flags = POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION;
465
data->auth_obtained_callback = auth_obtained_callback;
466
data->check_auth_callback = (GAsyncReadyCallback)check_authorization_callback;
467
data->user_data = user_data;
468
data->destroy = destroy;
469
data->subject = polkit_system_bus_name_new (dbus_g_method_get_sender (context));
470
data->challenge = FALSE;
472
check_next_action (data);
476
gconf_address_for_caller (GConfDefaults *mechanism,
477
DBusGMethodInvocation *context,
481
DBusConnection *conn;
487
conn = dbus_g_connection_get_connection (mechanism->priv->system_bus_connection);
488
sender = dbus_g_method_get_sender (context);
490
dbus_error_init (&error);
491
uid = dbus_bus_get_unix_user (conn, sender, &error);
493
if (uid == (unsigned)-1) {
494
dbus_set_g_error (gerror, &error);
495
dbus_error_free (&error);
499
pwd = getpwuid (uid);
503
"Failed to get passwd information for uid %d", uid);
507
result = g_strconcat ("xml:merged:", pwd->pw_dir, "/.gconf", NULL);
512
path_is_excluded (const char *path,
513
const char **excludes)
517
for (i = 0; excludes && excludes[i]; i++) {
518
if (g_str_has_prefix (path, excludes[i]))
526
copy_tree (GConfClient *src,
528
GConfChangeSet *changes,
529
const char **excludes)
534
if (path_is_excluded (path, excludes))
537
list = gconf_client_all_entries (src, path, NULL);
538
for (l = list; l; l = l->next) {
540
if (!path_is_excluded (entry->key, excludes))
541
gconf_change_set_set (changes, entry->key, entry->value);
543
g_slist_foreach (list, (GFunc)gconf_entry_free, NULL);
546
list = gconf_client_all_dirs (src, path, NULL);
547
for (l = list; l; l = l->next)
548
copy_tree (src, (const char *)l->data, changes, excludes);
549
g_slist_foreach (list, (GFunc)g_free, NULL);
554
copy_entry (GConfClient *src,
556
GConfChangeSet *changes,
557
const char **excludes)
561
if (path_is_excluded (path, excludes))
564
value = gconf_client_get (src, path, NULL);
566
gconf_change_set_set (changes, path, value);
567
gconf_value_free (value);
571
typedef void (*ChangeSetCallback) (GConfDefaults *mechanism,
572
GConfChangeSet *changes,
577
GConfDefaults *mechanism;
578
DBusGMethodInvocation *context;
579
const char *dest_address;
584
ChangeSetCallback changeset_callback;
586
GDestroyNotify destroy;
590
copy_data_free (gpointer user_data)
592
CopyData *data = user_data;
594
g_object_unref (data->mechanism);
595
g_strfreev (data->includes);
596
g_strfreev (data->excludes);
597
g_strfreev (data->actions);
599
gconf_value_free (data->value);
601
data->destroy (data->user_data);
606
do_copy_authorized (GConfDefaults *mechanism,
607
DBusGMethodInvocation *context,
610
CopyData *data = user_data;
611
GConfClient *source = NULL;
612
GConfClient *dest = NULL;
613
GConfChangeSet *changes = NULL;
615
char *address = NULL;
620
engine = gconf_engine_get_local (data->dest_address, &error);
624
dest = gconf_client_get_for_engine (engine);
625
gconf_engine_unref (engine);
627
/* find the address to from the caller id */
628
address = gconf_address_for_caller (data->mechanism, data->context, &error);
632
engine = gconf_engine_get_local (address, &error);
636
source = gconf_client_get_for_engine (engine);
637
gconf_engine_unref (engine);
639
changes = gconf_change_set_new ();
642
g_assert (data->includes[1] == NULL);
643
g_assert (data->excludes == NULL);
645
gconf_change_set_set (changes, data->includes[0], data->value);
648
/* recursively copy each include, leaving out the excludes */
649
for (i = 0; data->includes[i]; i++) {
650
if (gconf_client_dir_exists (source, data->includes[i], NULL))
651
copy_tree (source, data->includes[i], changes, (const char **)data->excludes);
653
copy_entry (source, data->includes[i], changes, (const char **)data->excludes);
657
gconf_client_commit_change_set (dest, changes, FALSE, &error);
658
gconf_client_suggest_sync (dest, NULL);
660
if (data->changeset_callback) {
661
data->changeset_callback (data->mechanism, changes, data->user_data);
667
gconf_change_set_unref (changes);
669
g_object_unref (dest);
671
g_object_unref (source);
674
throw_error (data->context,
675
GCONF_DEFAULTS_ERROR_GENERAL,
676
"%s", error->message);
677
g_error_free (error);
680
dbus_g_method_return (data->context);
683
typedef void (*ActionsReadyCallback) (GConfDefaults *mechanism,
684
DBusGMethodInvocation *context,
686
AuthObtainedCallback auth_obtained_callback,
688
GDestroyNotify destroy);
692
GConfDefaults *mechanism;
693
DBusGMethodInvocation *context;
695
const char *default_action;
696
const char *annotation_key;
697
ActionsReadyCallback actions_ready_callback;
698
AuthObtainedCallback auth_obtained_callback;
700
GDestroyNotify destroy;
704
action_data_free (ActionData *data)
706
g_object_unref (data->mechanism);
707
g_strfreev (data->includes);
709
data->destroy (data->data);
714
actions_ready_cb (GObject *source,
718
ActionData *data = user_data;
719
GList *action_descriptions;
720
GError *error = NULL;
722
GHashTable *obtained;
728
action_descriptions = polkit_authority_enumerate_actions_finish (data->mechanism->priv->auth, res, &error);
731
throw_error (data->context,
732
GCONF_DEFAULTS_ERROR_GENERAL,
733
"Failed to get action descriptions: %s", error->message);
734
g_error_free (error);
735
action_data_free (data);
740
obtained = g_hash_table_new (g_str_hash, g_str_equal);
742
for (i = 0; data->includes[i]; i++) {
743
action = polkit_action_for_gconf_path (data->mechanism, action_descriptions, data->annotation_key, data->includes[i]);
744
if (action == NULL) {
745
g_debug ("using default action '%s' for path '%s'",
746
data->default_action, data->includes[i]);
747
action = data->default_action;
750
g_hash_table_insert (obtained, (gpointer)action, (gpointer)action);
752
actions = g_new0 (char *, g_hash_table_size (obtained) + 1);
753
g_hash_table_iter_init (&iter, obtained);
755
while (g_hash_table_iter_next (&iter, &key, &value)) {
756
actions[i] = g_strdup ((char *)key);
759
g_hash_table_destroy (obtained);
760
g_list_foreach (action_descriptions, (GFunc)g_object_unref, NULL);
761
g_list_free (action_descriptions);
763
data->actions_ready_callback (data->mechanism, data->context, actions, data->auth_obtained_callback, data->data, data->destroy);
765
data->destroy = NULL;
766
action_data_free (data);
770
do_copy (GConfDefaults *mechanism,
772
const gchar **includes,
773
const gchar **excludes,
775
DBusGMethodInvocation *context,
776
ChangeSetCallback changeset_callback,
778
GDestroyNotify destroy)
785
cdata = g_new0 (CopyData, 1);
786
cdata->mechanism = g_object_ref (mechanism);
787
cdata->context = context;
788
cdata->includes = g_strdupv ((gchar **)includes);
789
cdata->excludes = g_strdupv ((gchar **)excludes);
790
cdata->value = value;
791
cdata->actions = NULL;
792
cdata->changeset_callback = changeset_callback;
793
cdata->user_data = user_data;
794
cdata->destroy = destroy;
796
adata = g_new0 (ActionData, 1);
797
adata->mechanism = g_object_ref (mechanism);
798
adata->context = context;
799
adata->includes = g_strdupv ((gchar **)includes);
800
adata->actions_ready_callback = check_polkit_for_actions;
801
adata->auth_obtained_callback = do_copy_authorized;
803
adata->destroy = copy_data_free;
805
/* check privileges for each include */
807
adata->annotation_key = "org.gnome.gconf.defaults.set-mandatory.prefix";
808
adata->default_action = "org.gnome.gconf.defaults.set-mandatory";
809
cdata->dest_address = "xml:merged:" SYSGCONFDIR "/gconf.xml.mandatory";
812
adata->annotation_key = "org.gnome.gconf.defaults.set-system.prefix";
813
adata->default_action = "org.gnome.gconf.defaults.set-system";
814
cdata->dest_address = "xml:merged:" SYSGCONFDIR "/gconf.xml.system";
817
polkit_authority_enumerate_actions (mechanism->priv->auth,
824
append_key (GConfChangeSet *cs,
829
GPtrArray *keys = (GPtrArray *) user_data;
831
g_ptr_array_add (keys, (gpointer) key);
835
set_system_changes (GConfDefaults *mechanism,
836
GConfChangeSet *changes,
841
keys = g_ptr_array_new ();
842
gconf_change_set_foreach (changes, append_key, keys);
843
g_ptr_array_add (keys, NULL);
845
g_signal_emit (mechanism, signals[SYSTEM_SET], 0, keys->pdata);
847
g_ptr_array_free (keys, TRUE);
851
gconf_defaults_set_system (GConfDefaults *mechanism,
852
const char **includes,
853
const char **excludes,
854
DBusGMethodInvocation *context)
856
do_copy (mechanism, FALSE, includes, excludes, NULL, context, set_system_changes, NULL, NULL);
860
gconf_defaults_set_mandatory (GConfDefaults *mechanism,
861
const char **includes,
862
const char **excludes,
863
DBusGMethodInvocation *context)
865
do_copy (mechanism, TRUE, includes, excludes, NULL, context, NULL, NULL, NULL);
869
unset_tree (GConfClient *dest,
871
GConfChangeSet *changes,
872
const char **excludes)
877
if (path_is_excluded (path, excludes))
880
list = gconf_client_all_entries (dest, path, NULL);
881
for (l = list; l; l = l->next) {
883
if (!path_is_excluded (entry->key, excludes))
884
gconf_change_set_unset (changes, entry->key);
886
g_slist_foreach (list, (GFunc)gconf_entry_free, NULL);
889
list = gconf_client_all_dirs (dest, path, NULL);
890
for (l = list; l; l = l->next)
891
unset_tree (dest, (const char *)l->data, changes, excludes);
892
g_slist_foreach (list, (GFunc)g_free, NULL);
897
unset_entry (GConfClient *dest,
899
GConfChangeSet *changes,
900
const char **excludes)
902
if (path_is_excluded (path, excludes))
905
gconf_change_set_unset (changes, path);
909
unset_in_db (GConfDefaults *mechanism,
910
const gchar *address,
911
const gchar **includes,
912
const gchar **excludes,
916
GConfClient *dest = NULL;
917
GConfChangeSet *changes = NULL;
920
engine = gconf_engine_get_local (address, error);
924
dest = gconf_client_get_for_engine (engine);
925
gconf_engine_unref (engine);
927
changes = gconf_change_set_new ();
929
/* recursively copy each include, leaving out the excludes */
930
for (i = 0; includes[i]; i++) {
931
if (gconf_client_dir_exists (dest, includes[i], NULL))
932
unset_tree (dest, includes[i], changes, excludes);
934
unset_entry (dest, includes[i], changes, excludes);
937
gconf_client_commit_change_set (dest, changes, TRUE, error);
938
gconf_client_suggest_sync (dest, NULL);
942
g_object_unref (dest);
944
gconf_change_set_unref (changes);
949
GConfDefaults *mechanism;
950
DBusGMethodInvocation *context;
956
unset_data_free (gpointer user_data)
958
UnsetData *data = user_data;
960
g_object_unref (data->mechanism);
961
g_strfreev (data->includes);
962
g_strfreev (data->excludes);
967
do_unset_authorized (GConfDefaults *mechanism,
968
DBusGMethodInvocation *context,
971
UnsetData *data = user_data;
975
unset_in_db (mechanism, "xml:merged:" SYSGCONFDIR "/gconf.xml.mandatory",
976
(const gchar **)data->includes,
977
(const gchar **)data->excludes, &error);
980
throw_error (data->context,
981
GCONF_DEFAULTS_ERROR,
982
GCONF_DEFAULTS_ERROR_GENERAL,
983
"%s", error->message);
984
g_error_free (error);
987
dbus_g_method_return (data->context);
991
gconf_defaults_unset_mandatory (GConfDefaults *mechanism,
992
const char **includes,
993
const char **excludes,
994
DBusGMethodInvocation *context)
1001
udata = g_new0 (UnsetData, 1);
1002
udata->mechanism = g_object_ref (mechanism);
1003
udata->context = context;
1004
udata->includes = g_strdupv ((gchar **)includes);
1005
udata->excludes = g_strdupv ((gchar **)excludes);
1007
adata = g_new0 (ActionData, 1);
1008
adata->mechanism = g_object_ref (mechanism);
1009
adata->context = context;
1010
adata->includes = g_strdupv ((gchar **)includes);
1011
adata->auth_obtained_callback = do_unset_authorized;
1012
adata->data = udata;
1013
adata->destroy = unset_data_free;
1015
adata->annotation_key = "org.gnome.gconf.defaults.set-mandatory.prefix";
1016
adata->default_action = "org.gnome.gconf.defaults.set-mandatory";
1018
polkit_authority_enumerate_actions (mechanism->priv->auth,
1025
check_authorization_only_callback (PolkitAuthority *authority,
1029
CheckAuthData *data = user_data;
1030
PolkitAuthorizationResult *result;
1032
gboolean is_authorized;
1034
is_authorized = FALSE;
1037
result = polkit_authority_check_authorization_finish (authority,
1040
if (error != NULL) {
1041
g_debug ("error checking action '%s'\n", error->message);
1042
throw_error (data->context,
1043
GCONF_DEFAULTS_ERROR_NOT_PRIVILEGED,
1044
"Not Authorized: %s", error->message);
1045
g_error_free (error);
1049
if (polkit_authorization_result_get_is_authorized (result)) {
1050
g_debug ("result for '%s': authorized\n",
1051
data->actions[data->id]);
1052
is_authorized = TRUE;
1054
else if (polkit_authorization_result_get_is_challenge (result)) {
1055
g_debug ("result for '%s': challenge\n",
1056
data->actions[data->id]);
1057
is_authorized = TRUE;
1058
data->challenge = TRUE;
1061
g_debug ("result for '%s': not authorized\n",
1062
data->actions[data->id]);
1063
is_authorized = FALSE;
1067
if (is_authorized) {
1069
if (data->actions[data->id] == NULL) {
1072
result = data->challenge ? 1 : 2;
1073
g_debug ("return %d\n", result);
1074
dbus_g_method_return (data->context, result);
1077
check_next_action (data);
1078
return; /* continue operation */
1082
g_debug ("return 0\n");
1083
dbus_g_method_return (data->context, 0);
1087
check_auth_data_free (data);
1088
g_object_unref (result);
1093
check_permissions_only (GConfDefaults *mechanism,
1094
DBusGMethodInvocation *context,
1096
AuthObtainedCallback auth_obtained_callback,
1098
GDestroyNotify destroy)
1100
CheckAuthData *data;
1102
data = g_new0 (CheckAuthData, 1);
1103
data->mechanism = g_object_ref (mechanism);
1104
data->context = context;
1105
data->actions = actions;
1108
data->check_auth_callback = (GAsyncReadyCallback)check_authorization_only_callback;
1109
data->auth_obtained_callback = NULL;
1110
data->user_data = NULL;
1111
data->destroy = NULL;
1112
data->subject = polkit_system_bus_name_new (dbus_g_method_get_sender (context));
1113
data->challenge = FALSE;
1115
check_next_action (data);
1119
do_check (GConfDefaults *mechanism,
1121
const gchar **includes,
1122
DBusGMethodInvocation *context)
1128
adata = g_new0 (ActionData, 1);
1129
adata->mechanism = g_object_ref (mechanism);
1130
adata->context = context;
1131
adata->includes = g_strdupv ((gchar **)includes);
1132
adata->actions_ready_callback = check_permissions_only;
1133
adata->auth_obtained_callback = NULL;
1135
adata->destroy = NULL;
1138
adata->annotation_key = "org.gnome.gconf.defaults.set-mandatory.prefix";
1139
adata->default_action = "org.gnome.gconf.defaults.set-mandatory";
1142
adata->annotation_key = "org.gnome.gconf.defaults.set-system.prefix";
1143
adata->default_action = "org.gnome.gconf.defaults.set-system";
1146
polkit_authority_enumerate_actions (mechanism->priv->auth,
1153
gconf_defaults_can_set_system (GConfDefaults *mechanism,
1154
const char **includes,
1155
DBusGMethodInvocation *context)
1157
do_check (mechanism, FALSE, includes, context);
1161
gconf_defaults_can_set_mandatory (GConfDefaults *mechanism,
1162
const char **includes,
1163
DBusGMethodInvocation *context)
1165
do_check (mechanism, TRUE, includes, context);
1169
gconf_defaults_set_system_value (GConfDefaults *mechanism,
1172
DBusGMethodInvocation *context)
1175
const char *includes[] = { NULL, NULL };
1177
gvalue = gconf_value_decode (value);
1180
do_copy (mechanism, FALSE, includes, NULL, gvalue, context, set_system_changes, NULL, NULL);
1185
gconf_defaults_set_mandatory_value (GConfDefaults *mechanism,
1188
DBusGMethodInvocation *context)
1191
const char *includes[] = { NULL, NULL };
1193
gvalue = gconf_value_decode (value);
1196
do_copy (mechanism, TRUE, includes, NULL, gvalue, context, NULL, NULL, NULL);