diff -Nru upower-0.99.16/debian/changelog upower-0.99.17/debian/changelog --- upower-0.99.16/debian/changelog 2022-02-26 09:43:19.000000000 +0000 +++ upower-0.99.17/debian/changelog 2022-03-09 18:59:13.000000000 +0000 @@ -1,3 +1,11 @@ +upower (0.99.17-1) unstable; urgency=medium + + * New upstream version 0.99.17 + * Drop patches, all applied upstream + * Remove unnecessary version constraints + + -- Michael Biebl Wed, 09 Mar 2022 19:59:13 +0100 + upower (0.99.16-2) unstable; urgency=medium * Cherry-pick FD handling fixes from upstream (Closes: #1006368) diff -Nru upower-0.99.16/debian/control upower-0.99.17/debian/control --- upower-0.99.16/debian/control 2022-02-26 09:43:19.000000000 +0000 +++ upower-0.99.17/debian/control 2022-03-09 18:59:13.000000000 +0000 @@ -7,11 +7,11 @@ Build-Depends: debhelper-compat (= 13), dh-exec, meson (>= 0.49.0), - gobject-introspection (>= 0.9.12-4~), + gobject-introspection, gtk-doc-tools, gettext (>= 0.19.8), - libgirepository1.0-dev (>= 0.10.7-1~), - libglib2.0-dev (>= 2.36), + libgirepository1.0-dev, + libglib2.0-dev (>= 2.56), libgudev-1.0-dev (>= 235) [linux-any], libimobiledevice-dev (>= 0.9.7) [linux-any], libkvm-dev [kfreebsd-any], @@ -62,7 +62,7 @@ Pre-Depends: ${misc:Pre-Depends}, Depends: ${misc:Depends}, ${shlibs:Depends}, -Recommends: upower (>> 0.99), +Recommends: upower, Description: abstraction for power management - shared library upower provides an interface to enumerate power sources on the system and control system-wide power management. Any application can access the diff -Nru upower-0.99.16/debian/patches/0001-linux-Set-FD-to-1-rather-than-0-when-closing-delay-i.patch upower-0.99.17/debian/patches/0001-linux-Set-FD-to-1-rather-than-0-when-closing-delay-i.patch --- upower-0.99.16/debian/patches/0001-linux-Set-FD-to-1-rather-than-0-when-closing-delay-i.patch 2022-02-26 09:43:19.000000000 +0000 +++ upower-0.99.17/debian/patches/0001-linux-Set-FD-to-1-rather-than-0-when-closing-delay-i.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -From: Benjamin Berg -Date: Fri, 25 Feb 2022 10:08:19 +0100 -Subject: linux: Set FD to -1 rather than 0 when closing delay inhibitor - -(cherry picked from commit 7192ff481bc46a257f44fb5625cbe97361cac140) ---- - src/linux/up-backend.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/linux/up-backend.c b/src/linux/up-backend.c -index e24e473..f46a88d 100644 ---- a/src/linux/up-backend.c -+++ b/src/linux/up-backend.c -@@ -746,9 +746,9 @@ up_backend_prepare_for_sleep (GDBusConnection *connection, - - if (will_sleep) { - up_daemon_pause_poll (backend->priv->daemon); -- if (backend->priv->logind_delay_inhibitor_fd > 0) { -+ if (backend->priv->logind_delay_inhibitor_fd >= 0) { - close (backend->priv->logind_delay_inhibitor_fd); -- backend->priv->logind_delay_inhibitor_fd = 0; -+ backend->priv->logind_delay_inhibitor_fd = -1; - } - return; - } diff -Nru upower-0.99.16/debian/patches/0002-input-Fix-FD-handling-and-let-input-stream-close-it.patch upower-0.99.17/debian/patches/0002-input-Fix-FD-handling-and-let-input-stream-close-it.patch --- upower-0.99.16/debian/patches/0002-input-Fix-FD-handling-and-let-input-stream-close-it.patch 2022-02-26 09:43:19.000000000 +0000 +++ upower-0.99.17/debian/patches/0002-input-Fix-FD-handling-and-let-input-stream-close-it.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -From: Benjamin Berg -Date: Fri, 25 Feb 2022 10:09:17 +0100 -Subject: input: Fix FD handling and let input stream close it - -The open() call needs to check against the FD being <0 for error -detection. Also, add a missing close in one of the error paths and -change the code to let the input stream close the FD when it is not -needed anymore. - -We still open() it manually just because we need to do an ioctl once. - -(cherry picked from commit 72469426b737f1398651efc360f62a86e3b2633b) ---- - src/linux/up-input.c | 18 ++++++++---------- - 1 file changed, 8 insertions(+), 10 deletions(-) - -diff --git a/src/linux/up-input.c b/src/linux/up-input.c -index ccd42c7..db96a9e 100644 ---- a/src/linux/up-input.c -+++ b/src/linux/up-input.c -@@ -37,7 +37,6 @@ struct _UpInput - - guint watched_switch; - int last_switch_state; -- int eventfp; - struct input_event event; - gsize offset; - GIOChannel *channel; -@@ -192,6 +191,7 @@ up_input_coldplug (UpInput *input, GUdevDevice *d) - glong bitmask[NBITS(SW_MAX)]; - gint num_bits; - GIOStatus status; -+ int eventfd; - - /* get sysfs path */ - native_path = up_input_get_device_sysfs_path (d); -@@ -243,23 +243,25 @@ up_input_coldplug (UpInput *input, GUdevDevice *d) - } - - /* open device file */ -- input->eventfp = open (device_file, O_RDONLY | O_NONBLOCK); -- if (input->eventfp <= 0) { -+ eventfd = open (device_file, O_RDONLY | O_NONBLOCK); -+ if (eventfd < 0) { - g_warning ("cannot open '%s': %s", device_file, strerror (errno)); - ret = FALSE; - goto out; - } - - /* get initial state */ -- if (ioctl (input->eventfp, EVIOCGSW(sizeof (bitmask)), bitmask) < 0) { -+ if (ioctl (eventfd, EVIOCGSW(sizeof (bitmask)), bitmask) < 0) { - g_warning ("ioctl EVIOCGSW on %s failed", native_path); -+ close(eventfd); - ret = FALSE; - goto out; - } - - /* create channel */ -- g_debug ("watching %s (%i)", device_file, input->eventfp); -- input->channel = g_io_channel_unix_new (input->eventfp); -+ g_debug ("watching %s (%i)", device_file, eventfd); -+ input->channel = g_io_channel_unix_new (eventfd); -+ g_io_channel_set_close_on_unref (input->channel, TRUE); - - /* set binary encoding */ - status = g_io_channel_set_encoding (input->channel, NULL, &error); -@@ -290,7 +292,6 @@ out: - static void - up_input_init (UpInput *input) - { -- input->eventfp = -1; - input->last_switch_state = -1; - } - -@@ -309,11 +310,8 @@ up_input_finalize (GObject *object) - - if (input->channel) { - g_io_channel_shutdown (input->channel, FALSE, NULL); -- input->eventfp = -1; - g_io_channel_unref (input->channel); - } -- if (input->eventfp >= 0) -- close (input->eventfp); - G_OBJECT_CLASS (up_input_parent_class)->finalize (object); - } - diff -Nru upower-0.99.16/debian/patches/0003-daemon-Initialize-FD-to-1-to-avoid-incorrect-close.patch upower-0.99.17/debian/patches/0003-daemon-Initialize-FD-to-1-to-avoid-incorrect-close.patch --- upower-0.99.16/debian/patches/0003-daemon-Initialize-FD-to-1-to-avoid-incorrect-close.patch 2022-02-26 09:43:19.000000000 +0000 +++ upower-0.99.17/debian/patches/0003-daemon-Initialize-FD-to-1-to-avoid-incorrect-close.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -From: Benjamin Berg -Date: Fri, 25 Feb 2022 10:11:01 +0100 -Subject: daemon: Initialize FD to -1 to avoid incorrect close - -Also add an assert that the FD is -1 when we are about to grab the -inhibitor. Previously, we would just set the value early enough before -trying to close the FD, overwriting the incorrect initialization. - -(cherry picked from commit 2f81d690148cd80909083e0390ba50fb1e431b39) ---- - src/up-daemon.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/src/up-daemon.c b/src/up-daemon.c -index da72ffe..738af99 100644 ---- a/src/up-daemon.c -+++ b/src/up-daemon.c -@@ -616,6 +616,8 @@ up_daemon_set_warning_level (UpDaemon *daemon, UpDeviceLevel warning_level) - - if (warning_level == UP_DEVICE_LEVEL_ACTION) { - if (daemon->priv->action_timeout_id == 0) { -+ g_assert (daemon->priv->critical_action_lock_fd == -1); -+ - g_debug ("About to take action in %d seconds", UP_DAEMON_ACTION_DELAY); - daemon->priv->critical_action_lock_fd = up_backend_inhibitor_lock_take (daemon->priv->backend, "Execute critical action", "block"); - daemon->priv->action_timeout_id = g_timeout_add_seconds (UP_DAEMON_ACTION_DELAY, -@@ -1120,6 +1122,8 @@ static void - up_daemon_init (UpDaemon *daemon) - { - daemon->priv = up_daemon_get_instance_private (daemon); -+ -+ daemon->priv->critical_action_lock_fd = -1; - daemon->priv->config = up_config_new (); - daemon->priv->power_devices = up_device_list_new (); - daemon->priv->display_device = up_device_new (); diff -Nru upower-0.99.16/debian/patches/series upower-0.99.17/debian/patches/series --- upower-0.99.16/debian/patches/series 2022-02-26 09:43:19.000000000 +0000 +++ upower-0.99.17/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -0001-linux-Set-FD-to-1-rather-than-0-when-closing-delay-i.patch -0002-input-Fix-FD-handling-and-let-input-stream-close-it.patch -0003-daemon-Initialize-FD-to-1-to-avoid-incorrect-close.patch diff -Nru upower-0.99.16/meson.build upower-0.99.17/meson.build --- upower-0.99.16/meson.build 2022-02-23 16:46:51.000000000 +0000 +++ upower-0.99.17/meson.build 2022-03-09 17:46:34.000000000 +0000 @@ -1,5 +1,5 @@ project('upower', 'c', - version: '0.99.16', + version: '0.99.17', license: 'GPLv2+', default_options: [ 'buildtype=debugoptimized', @@ -130,8 +130,8 @@ output += ' libdir: ' + get_option('libdir') output += ' libexecdir: ' + get_option('prefix') / get_option('libexecdir') output += ' bindir: ' + get_option('prefix') / get_option('bindir') -output += ' sbindir: ' + get_option('prefix') / get_option('datadir') -output += ' datadir: ' + get_option('prefix') / get_option('sbindir') +output += ' sbindir: ' + get_option('prefix') / get_option('sbindir') +output += ' datadir: ' + get_option('prefix') / get_option('datadir') output += ' sysconfdir: ' + get_option('sysconfdir') output += ' localstatedir: ' + get_option('prefix') / get_option('localstatedir') output += ' historydir: ' + historydir diff -Nru upower-0.99.16/NEWS upower-0.99.17/NEWS --- upower-0.99.16/NEWS 2022-02-23 16:46:51.000000000 +0000 +++ upower-0.99.17/NEWS 2022-03-09 17:46:34.000000000 +0000 @@ -1,3 +1,10 @@ +Version 0.99.17 +--------------- +Released: 2022-03-09 + +Bug fixes: +- Fix FD handling issues that may cause lid to not be detected + Version 0.99.16 --------------- Released: 2022-02-23 diff -Nru upower-0.99.16/src/linux/up-backend.c upower-0.99.17/src/linux/up-backend.c --- upower-0.99.16/src/linux/up-backend.c 2022-02-23 16:46:51.000000000 +0000 +++ upower-0.99.17/src/linux/up-backend.c 2022-03-09 17:46:34.000000000 +0000 @@ -746,9 +746,9 @@ if (will_sleep) { up_daemon_pause_poll (backend->priv->daemon); - if (backend->priv->logind_delay_inhibitor_fd > 0) { + if (backend->priv->logind_delay_inhibitor_fd >= 0) { close (backend->priv->logind_delay_inhibitor_fd); - backend->priv->logind_delay_inhibitor_fd = 0; + backend->priv->logind_delay_inhibitor_fd = -1; } return; } diff -Nru upower-0.99.16/src/linux/up-input.c upower-0.99.17/src/linux/up-input.c --- upower-0.99.16/src/linux/up-input.c 2022-02-23 16:46:51.000000000 +0000 +++ upower-0.99.17/src/linux/up-input.c 2022-03-09 17:46:34.000000000 +0000 @@ -37,7 +37,6 @@ guint watched_switch; int last_switch_state; - int eventfp; struct input_event event; gsize offset; GIOChannel *channel; @@ -192,6 +191,7 @@ glong bitmask[NBITS(SW_MAX)]; gint num_bits; GIOStatus status; + int eventfd; /* get sysfs path */ native_path = up_input_get_device_sysfs_path (d); @@ -243,23 +243,25 @@ } /* open device file */ - input->eventfp = open (device_file, O_RDONLY | O_NONBLOCK); - if (input->eventfp <= 0) { + eventfd = open (device_file, O_RDONLY | O_NONBLOCK); + if (eventfd < 0) { g_warning ("cannot open '%s': %s", device_file, strerror (errno)); ret = FALSE; goto out; } /* get initial state */ - if (ioctl (input->eventfp, EVIOCGSW(sizeof (bitmask)), bitmask) < 0) { + if (ioctl (eventfd, EVIOCGSW(sizeof (bitmask)), bitmask) < 0) { g_warning ("ioctl EVIOCGSW on %s failed", native_path); + close(eventfd); ret = FALSE; goto out; } /* create channel */ - g_debug ("watching %s (%i)", device_file, input->eventfp); - input->channel = g_io_channel_unix_new (input->eventfp); + g_debug ("watching %s (%i)", device_file, eventfd); + input->channel = g_io_channel_unix_new (eventfd); + g_io_channel_set_close_on_unref (input->channel, TRUE); /* set binary encoding */ status = g_io_channel_set_encoding (input->channel, NULL, &error); @@ -290,7 +292,6 @@ static void up_input_init (UpInput *input) { - input->eventfp = -1; input->last_switch_state = -1; } @@ -309,11 +310,8 @@ if (input->channel) { g_io_channel_shutdown (input->channel, FALSE, NULL); - input->eventfp = -1; g_io_channel_unref (input->channel); } - if (input->eventfp >= 0) - close (input->eventfp); G_OBJECT_CLASS (up_input_parent_class)->finalize (object); } diff -Nru upower-0.99.16/src/up-daemon.c upower-0.99.17/src/up-daemon.c --- upower-0.99.16/src/up-daemon.c 2022-02-23 16:46:51.000000000 +0000 +++ upower-0.99.17/src/up-daemon.c 2022-03-09 17:46:34.000000000 +0000 @@ -616,6 +616,8 @@ if (warning_level == UP_DEVICE_LEVEL_ACTION) { if (daemon->priv->action_timeout_id == 0) { + g_assert (daemon->priv->critical_action_lock_fd == -1); + g_debug ("About to take action in %d seconds", UP_DAEMON_ACTION_DELAY); daemon->priv->critical_action_lock_fd = up_backend_inhibitor_lock_take (daemon->priv->backend, "Execute critical action", "block"); daemon->priv->action_timeout_id = g_timeout_add_seconds (UP_DAEMON_ACTION_DELAY, @@ -1120,6 +1122,8 @@ up_daemon_init (UpDaemon *daemon) { daemon->priv = up_daemon_get_instance_private (daemon); + + daemon->priv->critical_action_lock_fd = -1; daemon->priv->config = up_config_new (); daemon->priv->power_devices = up_device_list_new (); daemon->priv->display_device = up_device_new ();