Skip to content
Snippets Groups Projects
Commit e47e89d0 authored by Natanael Copa's avatar Natanael Copa
Browse files

main/upower: add fixes fom upstream

This fixes segfault in xfsettingsd
parent 723ca9ec
No related merge requests found
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=upower
pkgver=0.99.4
pkgrel=1
pkgrel=2
pkgdesc="Power Management Services"
url="http://upower.freedesktop.org"
arch="all"
......@@ -13,6 +13,9 @@ makedepends="linux-headers gtk+-dev libgudev-dev libusb-dev polkit-dev dbus-glib
source="http://upower.freedesktop.org/releases/upower-$pkgver.tar.xz
lib-Fix-memory-leak-in-up_client_get_devices.patch
linux-Fix-possible-double-free.patch
daemon-fix-get_critical_action.patch
lib-add-propererror-and-cancellable-handling-to-UpClient.patch
"
_builddir="$srcdir"/$pkgname-$pkgver
......@@ -41,10 +44,16 @@ package() {
md5sums="78800e1ac7f92b24aabdf433e38f75d2 upower-0.99.4.tar.xz
e2f1d7810337b9c7dd559bda4b88cfea lib-Fix-memory-leak-in-up_client_get_devices.patch
48ab7a1f497b8628f0a836aa4e3bd1f1 linux-Fix-possible-double-free.patch"
48ab7a1f497b8628f0a836aa4e3bd1f1 linux-Fix-possible-double-free.patch
15ae9162959c6221c6d8c72c486e1299 daemon-fix-get_critical_action.patch
09a93187fd2ff4f4c8e69c7bef73bb4e lib-add-propererror-and-cancellable-handling-to-UpClient.patch"
sha256sums="9ca325a6ccef505529b268ebbbd9becd0ce65a65f6ac7ee31e2e5b17648037b0 upower-0.99.4.tar.xz
8c62939c1850f4c3b7ee32b5b79496155c03cd1371e7cad26ecfc1e0643f9851 lib-Fix-memory-leak-in-up_client_get_devices.patch
069e4407b775a28bbf987d145e0d0659dcae4b85e3b9a45a0a3aef0cee23f426 linux-Fix-possible-double-free.patch"
069e4407b775a28bbf987d145e0d0659dcae4b85e3b9a45a0a3aef0cee23f426 linux-Fix-possible-double-free.patch
30c9e7587bd63f75d50f50f93bf97d9a80fc76f5ce875080487de04b2538beb4 daemon-fix-get_critical_action.patch
3b6c8b324bf8dcf9da0bad833f27d4c040c4d9acdc3aa261f0a0c9da2258a7bc lib-add-propererror-and-cancellable-handling-to-UpClient.patch"
sha512sums="b3fdee5ccf5f4d0c69e227f543272f6952119132814e27bc8f112716b8d36b5e07741a87bcf02203e80ef910cad9ddffa1adecb338c9a9aaa5e1038b62be07f3 upower-0.99.4.tar.xz
d18e4c6119e32297f612fa110e01de342381f38c8be42d4fd5322eb17a2cb172c1cb8bf09e0a25e0ef6b76edb82b6748c9c8fd02f44341f51ecd09141ea432fd lib-Fix-memory-leak-in-up_client_get_devices.patch
13656064551a9b9e40fe3560098319182e980d2ab48134959f9f642a6c42cb0283b3bd00052ef26834ffea5c3a2108b66fd127e165b2167a43064ccd4ba526b0 linux-Fix-possible-double-free.patch"
13656064551a9b9e40fe3560098319182e980d2ab48134959f9f642a6c42cb0283b3bd00052ef26834ffea5c3a2108b66fd127e165b2167a43064ccd4ba526b0 linux-Fix-possible-double-free.patch
9f2718c7fb7ea77d07fe463d3eecae14e40cc2da71c500e2d747c52bbe2f645632cd7ee8289a7f1b8b252b3eb9d5d568ddcd74e00e5fd9985861514895847006 daemon-fix-get_critical_action.patch
678298e420ce0eb8f9ca65ca0806b856b4d7f3634a70a029dcb9a391a457dcb91b2a5c8bbe7f3054e45a36f33458daedb10e6be11e970bd818ecf42e3587a76e lib-add-propererror-and-cancellable-handling-to-UpClient.patch"
From 28cee8e2845b094488c337c4ecfa84ada0b6be60 Mon Sep 17 00:00:00 2001
From: Martin Pitt <martin.pitt@ubuntu.com>
Date: Tue, 23 Feb 2016 09:51:07 +0100
Subject: daemon: fix get_critical_action()
Fix copy&paste error from e7e9156f that called the wrong _complete_ function
for up_daemon_get_critical_action().
https://bugs.freedesktop.org/show_bug.cgi?id=94262
diff --git a/src/up-daemon.c b/src/up-daemon.c
index be14cbe..e95f904 100644
--- a/src/up-daemon.c
+++ b/src/up-daemon.c
@@ -435,8 +435,8 @@ up_daemon_get_critical_action (UpExportedDaemon *skeleton,
GDBusMethodInvocation *invocation,
UpDaemon *daemon)
{
- up_exported_daemon_complete_get_display_device (skeleton, invocation,
- up_backend_get_critical_action (daemon->priv->backend));
+ up_exported_daemon_complete_get_critical_action (skeleton, invocation,
+ up_backend_get_critical_action (daemon->priv->backend));
return TRUE;
}
--
cgit v0.10.2
From 932a6a39e35754be571e1274aec4730fd42dba13 Mon Sep 17 00:00:00 2001
From: Martin Pitt <martin.pitt@ubuntu.com>
Date: Wed, 18 May 2016 09:22:43 +0200
Subject: lib: Add proper error and cancellable handling to UpClient
constructor
A GObject's _init() should never fail or block, but this is currently the case
as up_client_init() connects to upowerd on D-Bus. Convert this to the GInitable
interface and provide a new constructor up_client_new_full() which accepts a
GCancellable and GError, so that clients can do proper error handling
and reporting.
This changes up_client_new() to return NULL when connecting to upowerd fails.
This provides a more well-defined behaviour in this case as clients can check
for this and our methods stop segfaulting as they have checks like
g_return_val_if_fail (UP_IS_CLIENT (client), ...)
Previously we returned a valid object, but trying to call any method on it
segfaulted due to the NULL D-Bus proxy, so client code had no chance to check
whether the UpClient object was really valid.
https://bugs.freedesktop.org/show_bug.cgi?id=95350
diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c
index 5b2218f..adc0b9b 100644
--- a/libupower-glib/up-client.c
+++ b/libupower-glib/up-client.c
@@ -39,9 +39,10 @@
#include "up-daemon-generated.h"
#include "up-device.h"
-static void up_client_class_init (UpClientClass *klass);
-static void up_client_init (UpClient *client);
-static void up_client_finalize (GObject *object);
+static void up_client_class_init (UpClientClass *klass);
+static void up_client_initable_iface_init (GInitableIface *iface);
+static void up_client_init (UpClient *client);
+static void up_client_finalize (GObject *object);
#define UP_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_CLIENT, UpClientPrivate))
@@ -73,7 +74,8 @@ enum {
static guint signals [UP_CLIENT_LAST_SIGNAL] = { 0 };
static gpointer up_client_object = NULL;
-G_DEFINE_TYPE (UpClient, up_client, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_CODE (UpClient, up_client, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE(G_TYPE_INITABLE, up_client_initable_iface_init))
/**
* up_client_get_devices:
@@ -434,11 +436,10 @@ up_client_class_init (UpClientClass *klass)
* up_client_init:
* @client: This class instance
*/
-static void
-up_client_init (UpClient *client)
+static gboolean
+up_client_initable_init (GInitable *initable, GCancellable *cancellable, GError **error)
{
- GError *error = NULL;
-
+ UpClient *client = UP_CLIENT (initable);
client->priv = UP_CLIENT_GET_PRIVATE (client);
/* connect to main interface */
@@ -446,13 +447,10 @@ up_client_init (UpClient *client)
G_DBUS_PROXY_FLAGS_NONE,
"org.freedesktop.UPower",
"/org/freedesktop/UPower",
- NULL,
- &error);
- if (client->priv->proxy == NULL) {
- g_warning ("Couldn't connect to proxy: %s", error->message);
- g_error_free (error);
- return;
- }
+ cancellable,
+ error);
+ if (client->priv->proxy == NULL)
+ return FALSE;
/* all callbacks */
g_signal_connect (client->priv->proxy, "device-added",
@@ -461,6 +459,23 @@ up_client_init (UpClient *client)
G_CALLBACK (up_device_removed_cb), client);
g_signal_connect (client->priv->proxy, "notify",
G_CALLBACK (up_client_notify_cb), client);
+
+ return TRUE;
+}
+
+static void
+up_client_initable_iface_init (GInitableIface *iface)
+{
+ iface->init = up_client_initable_init;
+}
+
+/*
+ * up_client_init:
+ * @client: This class instance
+ */
+static void
+up_client_init (UpClient *client)
+{
}
/*
@@ -482,23 +497,52 @@ up_client_finalize (GObject *object)
}
/**
- * up_client_new:
+ * up_client_new_full:
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
*
- * Creates a new #UpClient object.
+ * Creates a new #UpClient object. If connecting to upowerd on D-Bus fails,
+ % this returns %NULL and sets @error.
*
- * Return value: a new UpClient object.
+ * Return value: a new UpClient object, or %NULL on failure.
*
- * Since: 0.9.0
+ * Since: 0.99.5
**/
UpClient *
-up_client_new (void)
+up_client_new_full (GCancellable *cancellable, GError **error)
{
if (up_client_object != NULL) {
g_object_ref (up_client_object);
} else {
- up_client_object = g_object_new (UP_TYPE_CLIENT, NULL);
- g_object_add_weak_pointer (up_client_object, &up_client_object);
+ up_client_object = g_initable_new (UP_TYPE_CLIENT, cancellable, error, NULL);
+ if (up_client_object)
+ g_object_add_weak_pointer (up_client_object, &up_client_object);
}
return UP_CLIENT (up_client_object);
}
+/**
+ * up_client_new:
+ *
+ * Creates a new #UpClient object. If connecting to upowerd on D-Bus fails,
+ * this returns %NULL and prints out a warning with the error message.
+ * Consider using up_client_new_full() instead which allows you to handle errors
+ * and cancelling long operations yourself.
+ *
+ * Return value: a new UpClient object, or %NULL on failure.
+ *
+ * Since: 0.9.0
+ **/
+UpClient *
+up_client_new (void)
+{
+ GError *error = NULL;
+ UpClient *client;
+ client = up_client_new_full (NULL, &error);
+ if (client == NULL) {
+ g_warning ("Couldn't connect to proxy: %s", error->message);
+ g_error_free (error);
+ }
+ return client;
+}
+
diff --git a/libupower-glib/up-client.h b/libupower-glib/up-client.h
index 79c2d9e..5b9af3c 100644
--- a/libupower-glib/up-client.h
+++ b/libupower-glib/up-client.h
@@ -72,6 +72,7 @@ typedef struct
/* general */
GType up_client_get_type (void);
UpClient *up_client_new (void);
+UpClient *up_client_new_full (GCancellable *cancellable, GError **error);
/* sync versions */
UpDevice * up_client_get_display_device (UpClient *client);
--
cgit v0.10.2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment