source:
proiecte/PPPP/gdm/debian/patches/08_use_polkit_for_settings.patch
@
141
Last change on this file since 141 was 134, checked in by , 14 years ago | |
---|---|
File size: 12.5 KB |
-
common/gdm-settings.c
# # Description: Add PolicyKit support to GDM settings D-Bus interface # Ubuntu: https://bugs.launchpad.net/ubuntu/+source/gdm/+bug/395299 # Upstream: http://bugzilla.gnome.org/show_bug.cgi?id=587750 # diff -Nur -x '*.orig' -x '*~' gdm-2.28.0/common/gdm-settings.c gdm-2.28.0.new/common/gdm-settings.c
old new 36 36 #define DBUS_API_SUBJECT_TO_CHANGE 37 37 #include <dbus/dbus-glib.h> 38 38 #include <dbus/dbus-glib-lowlevel.h> 39 #include <polkit/polkit.h> 39 40 40 41 #include "gdm-settings.h" 41 42 #include "gdm-settings-glue.h" … … 110 111 return res; 111 112 } 112 113 114 static void 115 unlock_auth_cb (PolkitAuthority *authority, 116 GAsyncResult *result, 117 DBusGMethodInvocation *context) 118 { 119 PolkitAuthorizationResult *auth_result; 120 GError *error = NULL; 121 122 auth_result = polkit_authority_check_authorization_finish (authority, result, &error); 123 124 if (!auth_result) 125 dbus_g_method_return_error (context, error); 126 else { 127 dbus_g_method_return (context, 128 polkit_authorization_result_get_is_authorized (auth_result)); 129 } 130 131 if (auth_result) 132 g_object_unref (auth_result); 133 if (error) 134 g_error_free (error); 135 } 136 137 gboolean 138 gdm_settings_unlock (GdmSettings *settings, 139 DBusGMethodInvocation *context) 140 { 141 polkit_authority_check_authorization (polkit_authority_get (), 142 polkit_system_bus_name_new (dbus_g_method_get_sender (context)), 143 "org.gnome.displaymanager.settings.write", 144 NULL, 145 POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, 146 NULL, 147 (GAsyncReadyCallback) unlock_auth_cb, 148 context); 149 } 150 151 typedef struct 152 { 153 GdmSettings *settings; 154 DBusGMethodInvocation *context; 155 gchar *key, *value; 156 } SetValueData; 157 158 static void 159 set_value_auth_cb (PolkitAuthority *authority, 160 GAsyncResult *result, 161 SetValueData *data) 162 { 163 PolkitAuthorizationResult *auth_result; 164 GError *error = NULL; 165 166 auth_result = polkit_authority_check_authorization_finish (authority, result, &error); 167 168 if (!auth_result) 169 dbus_g_method_return_error (data->context, error); 170 else { 171 if (polkit_authorization_result_get_is_authorized (auth_result)) { 172 gboolean result; 173 174 result = gdm_settings_backend_set_value (data->settings->priv->backend, 175 data->key, 176 data->value, 177 &error); 178 if (result) 179 dbus_g_method_return (data->context); 180 else 181 dbus_g_method_return_error (data->context, error); 182 } 183 else { 184 error = g_error_new (DBUS_GERROR_REMOTE_EXCEPTION, 0, "Not authorized"); 185 dbus_g_method_return_error (data->context, error); 186 } 187 } 188 189 if (auth_result) 190 g_object_unref (auth_result); 191 if (error) 192 g_error_free (error); 193 g_free (data->key); 194 g_free (data->value); 195 g_free (data); 196 } 197 113 198 /* 114 199 dbus-send --system --print-reply --dest=org.gnome.DisplayManager /org/gnome/DisplayManager/Settings org.gnome.DisplayManager.Settings.SetValue string:"xdmcp/Enable" string:"false" 115 200 */ … … 118 203 gdm_settings_set_value (GdmSettings *settings, 119 204 const char *key, 120 205 const char *value, 121 GError **error)206 DBusGMethodInvocation *context) 122 207 { 123 GError *local_error; 124 gboolean res; 125 208 SetValueData *data; 209 126 210 g_return_val_if_fail (GDM_IS_SETTINGS (settings), FALSE); 127 211 g_return_val_if_fail (key != NULL, FALSE); 128 212 129 213 g_debug ("Setting value %s", key); 130 131 local_error = NULL; 132 res = gdm_settings_backend_set_value (settings->priv->backend, 133 key, 134 value, 135 &local_error); 136 if (! res) { 137 g_propagate_error (error, local_error); 138 } 139 140 return res; 214 215 /* Authorize with PolicyKit */ 216 data = g_malloc (sizeof(SetValueData)); 217 data->settings = settings; 218 data->context = context; 219 data->key = g_strdup(key); 220 data->value = g_strdup(value); 221 polkit_authority_check_authorization (polkit_authority_get (), 222 polkit_system_bus_name_new (dbus_g_method_get_sender (context)), 223 "org.gnome.displaymanager.settings.write", 224 NULL, 225 POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, 226 NULL, 227 (GAsyncReadyCallback) set_value_auth_cb, 228 data); 229 return TRUE; 141 230 } 142 231 143 232 static gboolean -
common/gdm-settings.h
diff -Nur -x '*.orig' -x '*~' gdm-2.28.0/common/gdm-settings.h gdm-2.28.0.new/common/gdm-settings.h
old new 23 23 #define __GDM_SETTINGS_H 24 24 25 25 #include <glib-object.h> 26 #include <dbus/dbus-glib.h> 26 27 27 28 G_BEGIN_DECLS 28 29 … … 70 71 const char *key, 71 72 char **value, 72 73 GError **error); 74 gboolean gdm_settings_unlock (GdmSettings *settings, 75 DBusGMethodInvocation *context); 73 76 gboolean gdm_settings_set_value (GdmSettings *settings, 74 77 const char *key, 75 78 const char *value, 76 GError **error);79 DBusGMethodInvocation *context); 77 80 78 81 G_END_DECLS 79 82 -
common/gdm-settings.xml
diff -Nur -x '*.orig' -x '*~' gdm-2.28.0/common/gdm-settings.xml gdm-2.28.0.new/common/gdm-settings.xml
old new 5 5 <arg name="key" direction="in" type="s"/> 6 6 <arg name="value" direction="out" type="s"/> 7 7 </method> 8 <method name="Unlock"> 9 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> 10 <arg name="is_unlocked" direction="out" type="b"/> 11 </method> 8 12 <method name="SetValue"> 13 <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> 9 14 <arg name="key" direction="in" type="s"/> 10 15 <arg name="value" direction="in" type="s"/> 11 16 </method> -
configure.ac
diff -Nur -x '*.orig' -x '*~' gdm-2.28.0/configure.ac gdm-2.28.0.new/configure.ac
old new 40 40 dnl --------------------------------------------------------------------------- 41 41 42 42 DBUS_GLIB_REQUIRED_VERSION=0.74 43 POLKIT_GOBJECT_REQUIRED_VERSION=0.92 43 44 GLIB_REQUIRED_VERSION=2.15.4 44 45 GTK_REQUIRED_VERSION=2.10.0 45 46 PANGO_REQUIRED_VERSION=1.3.0 … … 60 61 61 62 PKG_CHECK_MODULES(COMMON, 62 63 dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION 64 polkit-gobject-1 >= $POLKIT_GOBJECT_REQUIRED_VERSION 63 65 gobject-2.0 >= $GLIB_REQUIRED_VERSION 64 66 gio-2.0 >= $GLIB_REQUIRED_VERSION 65 67 ) … … 68 70 69 71 PKG_CHECK_MODULES(DAEMON, 70 72 dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION 73 polkit-gobject-1 >= $POLKIT_GOBJECT_REQUIRED_VERSION 71 74 gobject-2.0 >= $GLIB_REQUIRED_VERSION 72 75 gio-2.0 >= $GLIB_REQUIRED_VERSION 73 76 hal -
data/gdm.conf.in
diff -Nur -x '*.orig' -x '*~' gdm-2.28.0/data/gdm.conf.in gdm-2.28.0.new/data/gdm.conf.in
old new 34 34 <deny send_destination="org.gnome.DisplayManager" 35 35 send_interface="org.gnome.DisplayManager.LocalDisplayFactory"/> 36 36 <deny send_destination="org.gnome.DisplayManager" 37 send_interface="org.gnome.DisplayManager.Settings"/>38 <deny send_destination="org.gnome.DisplayManager"39 37 send_interface="org.gnome.DisplayManager.Slave"/> 40 38 <deny send_destination="org.gnome.DisplayManager" 41 39 send_interface="org.gnome.DisplayManager.Session"/> … … 44 42 <allow send_destination="org.gnome.DisplayManager" 45 43 send_interface="org.freedesktop.DBus.Introspectable"/> 46 44 45 <!-- Controlled by PolicyKit --> 46 <allow send_destination="org.gnome.DisplayManager" 47 send_interface="org.gnome.DisplayManager.Settings"/> 48 47 49 <allow send_destination="org.gnome.DisplayManager" 48 50 send_interface="org.gnome.DisplayManager.Display" 49 51 send_member="GetId"/> -
data/gdm.policy.in
diff -Nur -x '*.orig' -x '*~' gdm-2.28.0/data/gdm.policy.in gdm-2.28.0.new/data/gdm.policy.in
old new 1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE policyconfig PUBLIC 3 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN" 4 "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd"> 5 <policyconfig> 6 <vendor>The GNOME Project</vendor> 7 <vendor_url>http://www.gnome.org/</vendor_url> 8 <icon_name>gdm</icon_name> 9 10 <action id="org.gnome.displaymanager.settings.write"> 11 <_description>Change login screen configuration</_description> 12 <_message>Privileges are required to change the login screen configuration.</_message> 13 <defaults> 14 <allow_inactive>no</allow_inactive> 15 <allow_active>auth_admin_keep</allow_active> 16 </defaults> 17 </action> 18 </policyconfig> -
data/Makefile.am
diff -Nur -x '*.orig' -x '*~' gdm-2.28.0/data/Makefile.am gdm-2.28.0.new/data/Makefile.am
old new 45 45 schemas_in_files = gdm.schemas.in 46 46 schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) 47 47 48 @INTLTOOL_POLICY_RULE@ 49 48 50 gdm.schemas.in: $(srcdir)/gdm.schemas.in.in 49 51 sed -e 's,[@]GDMPREFETCHCMD[@],$(GDMPREFETCHCMD),g' \ 50 52 -e 's,[@]GDM_CUSTOM_CONF[@],$(GDM_CUSTOM_CONF),g' \ … … 74 76 -e 's,[@]sbindir[@],$(sbindir),g' \ 75 77 <$(srcdir)/gdm.schemas.in.in >gdm.schemas.in 76 78 79 polkitdir = $(datadir)/polkit-1/actions 80 polkit_in_files = gdm.policy.in 81 polkit_DATA = $(polkit_in_files:.policy.in=.policy) 82 check: 83 $(POLKIT_POLICY_FILE_VALIDATE) $(polkit_DATA) 84 77 85 EXTRA_DIST = \ 78 86 $(schemas_in_files) \ 79 87 $(schemas_DATA) \ 80 88 $(dbusconf_in_files) \ 89 $(polkit_in_files) \ 81 90 gdm.schemas.in.in \ 82 91 gdm.conf-custom.in \ 83 92 Xsession.in \ … … 100 109 $(NULL) 101 110 102 111 DISTCLEANFILES = \ 103 $(dbusconf_DATA) \ 112 $(dbusconf_DATA) \ 113 $(polkit_DATA) \ 104 114 gdm.schemas \ 105 115 $(NULL) 106 116 -
po/POTFILES.in
diff -Nur -x '*.orig' -x '*~' gdm-2.28.0/po/POTFILES.in gdm-2.28.0.new/po/POTFILES.in
old new 49 49 daemon/simple-slave-main.c 50 50 daemon/test-session.c 51 51 daemon/xdmcp-chooser-slave-main.c 52 data/gdm.policy.in 52 53 data/gdm.schemas.in.in 53 54 data/greeter-autostart/at-spi-registryd-wrapper.desktop.in.in 54 55 data/greeter-autostart/gdm-simple-greeter.desktop.in.in
Note: See TracBrowser
for help on using the repository browser.