source: proiecte/PPPP/gdm/debian/patches/08_use_polkit_for_settings.patch @ 134

Last change on this file since 134 was 134, checked in by (none), 14 years ago

gdm sources with the modifications for webcam

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  
    3636#define DBUS_API_SUBJECT_TO_CHANGE
    3737#include <dbus/dbus-glib.h>
    3838#include <dbus/dbus-glib-lowlevel.h>
     39#include <polkit/polkit.h>
    3940
    4041#include "gdm-settings.h"
    4142#include "gdm-settings-glue.h"
     
    110111        return res;
    111112}
    112113
     114static void
     115unlock_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
     137gboolean
     138gdm_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
     151typedef struct
     152{
     153        GdmSettings *settings;
     154        DBusGMethodInvocation *context;
     155        gchar *key, *value;
     156} SetValueData;
     157
     158static void
     159set_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
    113198/*
    114199dbus-send --system --print-reply --dest=org.gnome.DisplayManager /org/gnome/DisplayManager/Settings org.gnome.DisplayManager.Settings.SetValue string:"xdmcp/Enable" string:"false"
    115200*/
     
    118203gdm_settings_set_value (GdmSettings *settings,
    119204                        const char  *key,
    120205                        const char  *value,
    121                         GError     **error)
     206                        DBusGMethodInvocation *context)
    122207{
    123         GError  *local_error;
    124         gboolean res;
    125 
     208        SetValueData *data;
     209   
    126210        g_return_val_if_fail (GDM_IS_SETTINGS (settings), FALSE);
    127211        g_return_val_if_fail (key != NULL, FALSE);
    128212
    129213        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;
    141230}
    142231
    143232static 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  
    2323#define __GDM_SETTINGS_H
    2424
    2525#include <glib-object.h>
     26#include <dbus/dbus-glib.h>
    2627
    2728G_BEGIN_DECLS
    2829
     
    7071                                                                 const char  *key,
    7172                                                                 char       **value,
    7273                                                                 GError     **error);
     74gboolean            gdm_settings_unlock                         (GdmSettings *settings,
     75                                                                 DBusGMethodInvocation *context);
    7376gboolean            gdm_settings_set_value                      (GdmSettings *settings,
    7477                                                                 const char  *key,
    7578                                                                 const char  *value,
    76                                                                  GError     **error);
     79                                                                 DBusGMethodInvocation *context);
    7780
    7881G_END_DECLS
    7982
  • 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  
    55      <arg name="key" direction="in" type="s"/>
    66      <arg name="value" direction="out" type="s"/>
    77    </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>
    812    <method name="SetValue">
     13      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
    914      <arg name="key" direction="in" type="s"/>
    1015      <arg name="value" direction="in" type="s"/>
    1116    </method>
  • configure.ac

    diff -Nur -x '*.orig' -x '*~' gdm-2.28.0/configure.ac gdm-2.28.0.new/configure.ac
    old new  
    4040dnl ---------------------------------------------------------------------------
    4141
    4242DBUS_GLIB_REQUIRED_VERSION=0.74
     43POLKIT_GOBJECT_REQUIRED_VERSION=0.92
    4344GLIB_REQUIRED_VERSION=2.15.4
    4445GTK_REQUIRED_VERSION=2.10.0
    4546PANGO_REQUIRED_VERSION=1.3.0
     
    6061
    6162PKG_CHECK_MODULES(COMMON,
    6263        dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
     64        polkit-gobject-1 >= $POLKIT_GOBJECT_REQUIRED_VERSION
    6365        gobject-2.0 >= $GLIB_REQUIRED_VERSION
    6466        gio-2.0 >= $GLIB_REQUIRED_VERSION
    6567)
     
    6870
    6971PKG_CHECK_MODULES(DAEMON,
    7072        dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
     73        polkit-gobject-1 >= $POLKIT_GOBJECT_REQUIRED_VERSION
    7174        gobject-2.0 >= $GLIB_REQUIRED_VERSION
    7275        gio-2.0 >= $GLIB_REQUIRED_VERSION
    7376        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  
    3434    <deny send_destination="org.gnome.DisplayManager"
    3535          send_interface="org.gnome.DisplayManager.LocalDisplayFactory"/>
    3636    <deny send_destination="org.gnome.DisplayManager"
    37           send_interface="org.gnome.DisplayManager.Settings"/>
    38     <deny send_destination="org.gnome.DisplayManager"
    3937          send_interface="org.gnome.DisplayManager.Slave"/>
    4038    <deny send_destination="org.gnome.DisplayManager"
    4139          send_interface="org.gnome.DisplayManager.Session"/>
     
    4442    <allow send_destination="org.gnome.DisplayManager"
    4543           send_interface="org.freedesktop.DBus.Introspectable"/>
    4644
     45    <!-- Controlled by PolicyKit -->
     46    <allow send_destination="org.gnome.DisplayManager"
     47           send_interface="org.gnome.DisplayManager.Settings"/>
     48
    4749    <allow send_destination="org.gnome.DisplayManager"
    4850           send_interface="org.gnome.DisplayManager.Display"
    4951           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  
    4545schemas_in_files = gdm.schemas.in
    4646schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
    4747
     48@INTLTOOL_POLICY_RULE@
     49
    4850gdm.schemas.in: $(srcdir)/gdm.schemas.in.in
    4951        sed     -e 's,[@]GDMPREFETCHCMD[@],$(GDMPREFETCHCMD),g' \
    5052                -e 's,[@]GDM_CUSTOM_CONF[@],$(GDM_CUSTOM_CONF),g' \
     
    7476                -e 's,[@]sbindir[@],$(sbindir),g' \
    7577                <$(srcdir)/gdm.schemas.in.in >gdm.schemas.in
    7678
     79polkitdir = $(datadir)/polkit-1/actions
     80polkit_in_files = gdm.policy.in
     81polkit_DATA = $(polkit_in_files:.policy.in=.policy)
     82check:
     83        $(POLKIT_POLICY_FILE_VALIDATE) $(polkit_DATA)
     84
    7785EXTRA_DIST =                    \
    7886        $(schemas_in_files)     \
    7987        $(schemas_DATA)         \
    8088        $(dbusconf_in_files)    \
     89        $(polkit_in_files)      \
    8190        gdm.schemas.in.in       \
    8291        gdm.conf-custom.in      \
    8392        Xsession.in             \
     
    100109        $(NULL)
    101110
    102111DISTCLEANFILES =                        \
    103         $(dbusconf_DATA)                        \
     112        $(dbusconf_DATA)                \
     113        $(polkit_DATA)                  \
    104114        gdm.schemas                     \
    105115        $(NULL)
    106116
  • 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  
    4949daemon/simple-slave-main.c
    5050daemon/test-session.c
    5151daemon/xdmcp-chooser-slave-main.c
     52data/gdm.policy.in
    5253data/gdm.schemas.in.in
    5354data/greeter-autostart/at-spi-registryd-wrapper.desktop.in.in
    5455data/greeter-autostart/gdm-simple-greeter.desktop.in.in
Note: See TracBrowser for help on using the repository browser.