[gvfs] Bug 583704 – undefined reference to `gdu_error_check_polkit_not_authorized'



commit 384b3a679e3cf5138ada51338d613df517e0658a
Author: David Zeuthen <davidz redhat com>
Date:   Tue Jun 2 11:18:45 2009 -0400

    Bug 583704 â?? undefined reference to `gdu_error_check_polkit_not_authorized'
    
    With the new polkit 1.0 version that gnome-disk-utility is now using,
    authorizations are obtained out-of-band. So we don't need to handle it
    here.
---
 monitor/gdu/Makefile.am  |   11 ++--
 monitor/gdu/ggduvolume.c |   89 +-----------------------------
 monitor/gdu/polkit.c     |  137 ----------------------------------------------
 monitor/gdu/polkit.h     |   44 ---------------
 4 files changed, 8 insertions(+), 273 deletions(-)

diff --git a/monitor/gdu/Makefile.am b/monitor/gdu/Makefile.am
index 10b80f3..a7671f0 100644
--- a/monitor/gdu/Makefile.am
+++ b/monitor/gdu/Makefile.am
@@ -10,7 +10,6 @@ gvfs_gdu_volume_monitor_SOURCES =			\
 	ggduvolume.c		ggduvolume.h		\
 	ggdumount.c		ggdumount.h		\
 	ggduvolumemonitor.c	ggduvolumemonitor.h	\
-	polkit.c		polkit.h		\
 	$(NULL)
 
 gvfs_gdu_volume_monitor_CFLAGS =		\
@@ -29,12 +28,12 @@ gvfs_gdu_volume_monitor_CFLAGS =		\
 gvfs_gdu_volume_monitor_LDFLAGS =	\
 	$(NULL)
 
-gvfs_gdu_volume_monitor_LDADD  =		     			      \
-	$(GLIB_LIBS)                                 			      \
-	$(GDU_LIBS)                                  			      \
+gvfs_gdu_volume_monitor_LDADD  =		     			      	\
+	$(GLIB_LIBS)                                 			      	\
+	$(GDU_LIBS)                                  			      	\
 	$(DBUS_LIBS)                                 				\
-	$(top_builddir)/common/libgvfscommon.la 			      \
-	$(top_builddir)/monitor/proxy/libgvfsproxyvolumemonitordaemon-noin.la \
+	$(top_builddir)/common/libgvfscommon.la 			      	\
+	$(top_builddir)/monitor/proxy/libgvfsproxyvolumemonitordaemon-noin.la 	\
 	$(NULL)
 
 remote_volume_monitorsdir = $(datadir)/gvfs/remote-volume-monitors
diff --git a/monitor/gdu/ggduvolume.c b/monitor/gdu/ggduvolume.c
index 871a1c5..8f75247 100644
--- a/monitor/gdu/ggduvolume.c
+++ b/monitor/gdu/ggduvolume.c
@@ -38,8 +38,6 @@
 /* for BUFSIZ */
 #include <stdio.h>
 
-#include "polkit.h"
-
 typedef struct MountOpData MountOpData;
 
 static void cancel_pending_mount_op (MountOpData *data);
@@ -725,102 +723,23 @@ static void
 mount_cb (GduDevice *device,
           gchar     *mount_point,
           GError    *error,
-          gpointer   user_data);
-
-static void
-mount_obtain_authz_cb (GObject *source_object,
-                       GAsyncResult *res,
-                       gpointer user_data)
+          gpointer   user_data)
 {
   MountOpData *data = user_data;
-  gboolean obtained_authz;
-  GError *error;
 
   /* if we've already aborted due to device removal / cancellation, just bail out */
   if (data->is_cancelled)
     goto bailout;
 
-  error = NULL;
-  obtained_authz = _obtain_authz_finish (res, &error);
-
-  if (!obtained_authz)
+  if (error != NULL)
     {
-      /* be quiet if the daemon is inhibited */
+      /* be quiet if the DeviceKit-disks daemon is inhibited */
       if (error->code == GDU_ERROR_INHIBITED)
         {
           error->domain = G_IO_ERROR;
           error->code = G_IO_ERROR_FAILED_HANDLED;
         }
       g_simple_async_result_set_from_error (data->simple, error);
-      g_simple_async_result_complete (data->simple);
-    }
-  else
-    {
-      gchar **mount_options;
-      /* got the authz, now try again */
-      mount_options = get_mount_options (data->device_to_mount);
-      gdu_device_op_filesystem_mount (data->device_to_mount, mount_options, mount_cb, data);
-      g_strfreev (mount_options);
-      goto out;
-    }
-
- bailout:
-  data->volume->pending_mount_op = NULL;
-  mount_op_data_unref (data);
-
- out:
-  ;
-}
-
-static void
-mount_cb (GduDevice *device,
-          gchar     *mount_point,
-          GError    *error,
-          gpointer   user_data)
-{
-  MountOpData *data = user_data;
-
-  /* if we've already aborted due to device removal / cancellation, just bail out */
-  if (data->is_cancelled)
-    goto bailout;
-
-  if (error != NULL)
-    {
-      PolKitAction *pk_action;
-      PolKitResult pk_result;
-
-      /* only attempt to show authentication dialog if we have a mount operation */
-      if (data->mount_operation != NULL && gdu_error_check_polkit_not_authorized (error,
-                                                                                  &pk_action,
-                                                                                  &pk_result))
-        {
-          if (pk_result != POLKIT_RESULT_NO && pk_result != POLKIT_RESULT_UNKNOWN)
-            {
-              const gchar *action_id;
-              /* try to obtain the authorization */
-              polkit_action_get_action_id (pk_action, (char **) &action_id);
-              _obtain_authz (action_id,
-                             data->cancellable,
-                             mount_obtain_authz_cb,
-                             data);
-              goto out;
-            }
-          else
-            {
-              g_simple_async_result_set_from_error (data->simple, error);
-            }
-          polkit_action_unref (pk_action);
-        }
-      else
-        {
-          /* be quiet if the daemon is inhibited */
-          if (error->code == GDU_ERROR_INHIBITED)
-            {
-              error->domain = G_IO_ERROR;
-              error->code = G_IO_ERROR_FAILED_HANDLED;
-            }
-          g_simple_async_result_set_from_error (data->simple, error);
-        }
       g_error_free (error);
     }
   else
@@ -834,8 +753,6 @@ mount_cb (GduDevice *device,
   data->volume->pending_mount_op = NULL;
   mount_op_data_unref (data);
 
- out:
-  ;
 }
 
 static void
diff --git a/monitor/gdu/polkit.c b/monitor/gdu/polkit.c
deleted file mode 100644
index 5c37ba6..0000000
--- a/monitor/gdu/polkit.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
-/* gvfs - extensions for gio
- *
- * Copyright (C) 2006-2009 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: David Zeuthen <davidz redhat com>
- */
-
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <gdbusutils.h>
-
-#include "polkit.h"
-
-static void
-_obtain_authz_cb (DBusMessage *reply,
-                  GError      *error,
-                  gpointer     user_data)
-{
-  GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data);
-  gboolean gained_authz;
-  DBusError derror;
-
-  if (error != NULL) {
-    g_simple_async_result_set_from_error (simple, error);
-    goto out;
-  }
-
-  dbus_error_init (&derror);
-  if (!dbus_message_get_args (reply,
-                              &derror,
-                              DBUS_TYPE_BOOLEAN, &gained_authz,
-                              DBUS_TYPE_INVALID))
-    {
-      /* no need to translate; this only happens if the auth agent is buggy */
-      g_simple_async_result_set_error (simple,
-                                       G_IO_ERROR,
-                                       G_IO_ERROR_FAILED,
-                                       "Error parsing reply for ObtainAuthorization(): %s: %s",
-                                       derror.name, derror.message);
-      dbus_error_free (&derror);
-      goto out;
-    }
-
-  if (!gained_authz && error == NULL)
-    {
-      /* no need to translate, is never shown */
-      g_simple_async_result_set_error (simple,
-                                       G_IO_ERROR,
-                                       G_IO_ERROR_FAILED_HANDLED,
-                                       "Didn't obtain authorization (bug in libgio user, it shouldn't display this error)");
-    }
-
- out:
-  g_simple_async_result_complete (simple);
-  g_object_unref (simple);
-}
-
-
-gboolean
-_obtain_authz_finish (GAsyncResult *res,
-                      GError       **error)
-{
-  GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
-
-  g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == _obtain_authz);
-
-  if (g_simple_async_result_propagate_error (simple, error))
-    return FALSE;
-  else
-    return TRUE;
-}
-
-void
-_obtain_authz (const gchar *action_id,
-               GCancellable *cancellable,
-               GAsyncReadyCallback callback,
-               gpointer user_data)
-{
-  DBusConnection *connection;
-  DBusMessage *message;
-  GSimpleAsyncResult *simple;
-  guint xid;
-  guint pid;
-  DBusError derror;
-
-  dbus_error_init (&derror);
-
-  /* this connection is already integrated and guaranteed to exist, see gvfsproxyvolumemonitordaemon.c */
-  connection = dbus_bus_get (DBUS_BUS_SESSION, &derror);
-
-  simple = g_simple_async_result_new (NULL,
-                                      callback,
-                                      user_data,
-                                      _obtain_authz);
-
-  message = dbus_message_new_method_call ("org.freedesktop.PolicyKit.AuthenticationAgent", /* bus name */
-                                          "/",                                             /* object */
-                                          "org.freedesktop.PolicyKit.AuthenticationAgent", /* interface */
-                                          "ObtainAuthorization");
-
-  xid = 0;
-  pid = getpid ();
-
-  dbus_message_append_args (message,
-                            DBUS_TYPE_STRING,
-                            &(action_id),
-                            DBUS_TYPE_UINT32,
-                            &(xid),
-                            DBUS_TYPE_UINT32,
-                            &(pid),
-                            DBUS_TYPE_INVALID);
-
-  _g_dbus_connection_call_async (connection,
-                                 message,
-                                 -1,
-                                 (GAsyncDBusCallback) _obtain_authz_cb,
-                                 simple);
-  dbus_message_unref (message);
-  dbus_connection_unref (connection);
-}
diff --git a/monitor/gdu/polkit.h b/monitor/gdu/polkit.h
deleted file mode 100644
index 4b26189..0000000
--- a/monitor/gdu/polkit.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
-/* gvfs - extensions for gio
- *
- * Copyright (C) 2006-2009 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: David Zeuthen <davidz redhat com>
- */
-
-
-#ifndef __POLKIT_H__
-#define __POLKIT_H__
-
-#include <glib-object.h>
-#include <gio/gio.h>
-#include <polkit/polkit.h>
-
-G_BEGIN_DECLS
-
-void _obtain_authz (const gchar        *action_id,
-                    GCancellable       *cancellable,
-                    GAsyncReadyCallback callback,
-                    gpointer            user_data);
-
-gboolean _obtain_authz_finish (GAsyncResult  *res,
-                               GError       **error);
-
-G_END_DECLS
-
-#endif /* __POLKIT_H__ */



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