! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Let polkit/systemd handle PowerOff/Restart
Status:
RESOLVED: FIXED
Product:
Xfce4-power-manager
Component:
General

Comments

Description Andreas Müller 2013-06-10 09:53:11 CEST
Created attachment 5065 
Add shutdown/reboot functionality for systemd

In a consolekit-free environment PowerOff stopped working. Patch atttached implements required functionality.
Comment 1 Guido Berhoerster 2013-08-08 12:12:03 CEST
Created attachment 5118 
support shutdown/reboot through logind

Your patch unnecessarily couples ENABLE_POLKIT with systemd support, users may want polkit support without systemd. Also systemd usage should be detected at runtime with ConsoleKit as a fallback rather than hardcoding at compile time so that distros can build with systemd support but still allow booting without systemd. Finally there are some typos in src/xfpm-systemd.h. Attached path fixes all of the above.
Comment 2 Yves-Alexis Perez editbugs 2013-10-24 23:06:45 CEST
Hi Nick,

can you comment on this bug (as well as bug #9335 and bug #9963, and maybe also the relevant bugs for xfce4-session?).
Comment 3 Yves-Alexis Perez editbugs 2013-10-25 10:31:32 CEST
Andreas,

it seems that the patch on https://build.opensuse.org/package/view_file/X11:xfce/xfce4-power-manager/xfce4-power-manager-systemd-shutdown-reboot-support.patch?expand=1 is still the original version, could you comment on the updated patch by Guido? (I'm trying to determine what should I import into Debian to have some slight systemd support in xfpm).

Thanks in advance!
Comment 4 Andreas Müller 2013-10-25 11:21:17 CEST
Without having tested Guido's patch (still using mine): I think it is much more flexible and we should use that.
Comment 5 Yves-Alexis Perez editbugs 2013-10-25 11:54:09 CEST
(In reply to Guido Berhoerster from comment #1)
> Created attachment 5118 
> support shutdown/reboot through logind
> 
> Your patch unnecessarily couples ENABLE_POLKIT with systemd support, users
> may want polkit support without systemd. Also systemd usage should be
> detected at runtime with ConsoleKit as a fallback rather than hardcoding at
> compile time so that distros can build with systemd support but still allow
> booting without systemd. Finally there are some typos in src/xfpm-systemd.h.
> Attached path fixes all of the above.

Actually, it seems that xfpm-systemd.h is completely missing from that patch.
Comment 6 Guido Berhoerster 2013-10-25 14:05:33 CEST
Created attachment 5201 
Add shutdown/reboot functionality for systemd

(In reply to Yves-Alexis Perez from comment #5)
> (In reply to Guido Berhoerster from comment #1)
> > Created attachment 5118 
> > support shutdown/reboot through logind
> > 
> > Your patch unnecessarily couples ENABLE_POLKIT with systemd support, users
> > may want polkit support without systemd. Also systemd usage should be
> > detected at runtime with ConsoleKit as a fallback rather than hardcoding at
> > compile time so that distros can build with systemd support but still allow
> > booting without systemd. Finally there are some typos in src/xfpm-systemd.h.
> > Attached path fixes all of the above.
> 
> Actually, it seems that xfpm-systemd.h is completely missing from that patch.

Stupid git, here is the version of the patch that the openSUSE package uses (with the leftover comments on top removed), sorry for the confusion.
Comment 7 Yves-Alexis Perez editbugs 2013-10-25 16:32:52 CEST
It seems I need to add:

+AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$systemd" = "xyes"])

to configure.ac[.in] (I patch 1.2.0 tarball)

Also, it doesn't seem to build here:

xfce4_power_manager-xfpm-manager.o: In function `xfpm_manager_shutdown':
/tmp/buildd/xfce4-power-manager-1.2.0/src/xfpm-manager.c:218: undefined reference to `xfpm_systemd_shutdown'
xfce4_power_manager-xfpm-manager.o: In function `xfpm_manager_start':
/tmp/buildd/xfce4-power-manager-1.2.0/src/xfpm-manager.c:545: undefined reference to `xfpm_systemd_new'
xfce4_power_manager-xfpm-power.o: In function `xfpm_power_dbus_reboot':
/tmp/buildd/xfce4-power-manager-1.2.0/src/xfpm-power.c:1753: undefined reference to `xfpm_systemd_reboot'
xfce4_power_manager-xfpm-power.o: In function `xfpm_power_dbus_shutdown':
/tmp/buildd/xfce4-power-manager-1.2.0/src/xfpm-power.c:1720: undefined reference to `xfpm_systemd_shutdown'
xfce4_power_manager-xfpm-power.o: In function `xfpm_power_init':
/tmp/buildd/xfce4-power-manager-1.2.0/src/xfpm-power.c:1399: undefined reference to `xfpm_systemd_new'
collect2: error: ld returned 1 exit status

maybe because of --as-needed (will redo a build with verbose rules).
Comment 8 Yves-Alexis Perez editbugs 2013-10-25 16:41:39 CEST
Here's the link command:

libtool: link: gcc -I.. -I../common -I../libdbus -DLOCALEDIR=\"/usr/share/locale\" -DG_LOG_DOMAIN=\"xfce4-power-manager\" -DSYSCONFDIR=\"/etc\" -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -pthread -I/usr/include/xfce4/libxfce4ui-1 -I/usr/include/gtk-2.0 -I/usr/include/xfce4 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/libdrm -I/usr/include/harfbuzz -I/usr/include/xfce4/xfconf-0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -pthread -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libpng12 -pthread -I/usr/include/polkit-1 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIE -pie -Wl,-z -Wl,relro -Wl,-z -Wl,now -Wl,-z -Wl,defs -Wl,--as-needed -Wl,-O1 -o xfce4-power-manager xfce4_power_manager-xfpm-enum-types.o xfce4_power_manager-xfpm-marshal.o xfce4_power_manager-xfpm-main.o xfce4_power_manager-xfpm-manager.o xfce4_power_manager-xfpm-power.o xfce4_power_manager-xfpm-power-common.o xfce4_power_manager-xfpm-battery.o xfce4_power_manager-xfpm-xfconf.o xfce4_power_manager-xfpm-disks.o xfce4_power_manager-xfpm-console-kit.o xfce4_power_manager-egg-idletime.o xfce4_power_manager-xfpm-backlight.o xfce4_power_manager-xfpm-dpms.o xfce4_power_manager-xfpm-button.o xfce4_power_manager-xfpm-network-manager.o xfce4_power_manager-xfpm-inhibit.o xfce4_power_manager-xfpm-notify.o xfce4_power_manager-xfpm-polkit.o xfce4_power_manager-xfpm-errors.o -pthread  ../common/.libs/libxfpmcommon.a ../libdbus/.libs/libxfpmdbus.a -lgthread-2.0 -lxfce4ui-1 -lgtk-x11-2.0 -lxfce4util -lgdk-x11-2.0 -latk-1.0 -lpangoft2-1.0 -lpangocairo-1.0 /usr/lib/x86_64-linux-gnu/libcairo.so -lpango-1.0 -lfontconfig /usr/lib/x86_64-linux-gnu/libfreetype.so -lxfconf-0 -ldbus-glib-1 -ldbus-1 -lnotify -lgdk_pixbuf-2.0 -lpolkit-gobject-1 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lXrandr -lXext -lX11 -lm -pthread
Comment 9 Guido Berhoerster 2013-10-25 19:35:18 CEST
(In reply to Yves-Alexis Perez from comment #8)
> Here's the link command:
> 
> libtool: link: gcc -I.. -I../common -I../libdbus
> -DLOCALEDIR=\"/usr/share/locale\" -DG_LOG_DOMAIN=\"xfce4-power-manager\"
> -DSYSCONFDIR=\"/etc\" -I/usr/include/glib-2.0
> -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -pthread
> -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
> -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include
> -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
> -pthread -I/usr/include/xfce4/libxfce4ui-1 -I/usr/include/gtk-2.0
> -I/usr/include/xfce4 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include
> -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0
> -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/
> -I/usr/include/freetype2 -I/usr/include/glib-2.0
> -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1
> -I/usr/include/libpng12 -I/usr/include/libdrm -I/usr/include/harfbuzz
> -I/usr/include/xfce4/xfconf-0 -I/usr/include/dbus-1.0
> -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/glib-2.0
> -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -pthread
> -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0
> -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libpng12
> -pthread -I/usr/include/polkit-1 -I/usr/include/glib-2.0
> -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -g -O2 -fPIE -fstack-protector
> --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIE -pie -Wl,-z
> -Wl,relro -Wl,-z -Wl,now -Wl,-z -Wl,defs -Wl,--as-needed -Wl,-O1 -o
> xfce4-power-manager xfce4_power_manager-xfpm-enum-types.o
> xfce4_power_manager-xfpm-marshal.o xfce4_power_manager-xfpm-main.o
> xfce4_power_manager-xfpm-manager.o xfce4_power_manager-xfpm-power.o
> xfce4_power_manager-xfpm-power-common.o xfce4_power_manager-xfpm-battery.o
> xfce4_power_manager-xfpm-xfconf.o xfce4_power_manager-xfpm-disks.o
> xfce4_power_manager-xfpm-console-kit.o xfce4_power_manager-egg-idletime.o
> xfce4_power_manager-xfpm-backlight.o xfce4_power_manager-xfpm-dpms.o
> xfce4_power_manager-xfpm-button.o xfce4_power_manager-xfpm-network-manager.o
> xfce4_power_manager-xfpm-inhibit.o xfce4_power_manager-xfpm-notify.o
> xfce4_power_manager-xfpm-polkit.o xfce4_power_manager-xfpm-errors.o -pthread
> ../common/.libs/libxfpmcommon.a ../libdbus/.libs/libxfpmdbus.a -lgthread-2.0
> -lxfce4ui-1 -lgtk-x11-2.0 -lxfce4util -lgdk-x11-2.0 -latk-1.0 -lpangoft2-1.0
> -lpangocairo-1.0 /usr/lib/x86_64-linux-gnu/libcairo.so -lpango-1.0
> -lfontconfig /usr/lib/x86_64-linux-gnu/libfreetype.so -lxfconf-0
> -ldbus-glib-1 -ldbus-1 -lnotify -lgdk_pixbuf-2.0 -lpolkit-gobject-1
> -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lXrandr -lXext -lX11 -lm -pthread

I don't see xfce4_power_manager-xfpm-systemd.o, have you run xdt-autogen before building since the Makefile.am has been modified?
Comment 10 Yves-Alexis Perez editbugs 2013-10-25 20:52:49 CEST
(In reply to Guido Berhoerster from comment #9)> 
> I don't see xfce4_power_manager-xfpm-systemd.o, have you run xdt-autogen
> before building since the Makefile.am has been modified?

Yes (I can provide a complete build log if needed)
Comment 11 Guido Berhoerster 2013-10-25 21:09:09 CEST
(In reply to Yves-Alexis Perez from comment #10)
> (In reply to Guido Berhoerster from comment #9)> 
> > I don't see xfce4_power_manager-xfpm-systemd.o, have you run xdt-autogen
> > before building since the Makefile.am has been modified?
> 
> Yes (I can provide a complete build log if needed)

Yes, that might help. You can also take a look and compare with our build log at https://build.opensuse.org/package/rawlog/X11:xfce/xfce4-power-manager/openSUSE_Factory/x86_64
Comment 12 Yves-Alexis Perez editbugs 2013-10-25 21:11:06 CEST
Created attachment 5202 
xfpm build log

(In reply to Guido Berhoerster from comment #11)
> (In reply to Yves-Alexis Perez from comment #10)
> > (In reply to Guido Berhoerster from comment #9)> 
> > > I don't see xfce4_power_manager-xfpm-systemd.o, have you run xdt-autogen
> > > before building since the Makefile.am has been modified?
> > 
> > Yes (I can provide a complete build log if needed)
> 
> Yes, that might help. You can also take a look and compare with our build
> log at
> https://build.opensuse.org/package/rawlog/X11:xfce/xfce4-power-manager/
> openSUSE_Factory/x86_64

Actually I can't (it requires a username).
Comment 13 Guido Berhoerster 2013-10-26 00:02:00 CEST
(In reply to Yves-Alexis Perez from comment #12)
> Created attachment 5202 
> xfpm build log
> 
> (In reply to Guido Berhoerster from comment #11)
> > (In reply to Yves-Alexis Perez from comment #10)
> > > (In reply to Guido Berhoerster from comment #9)> 
> > > > I don't see xfce4_power_manager-xfpm-systemd.o, have you run xdt-autogen
> > > > before building since the Makefile.am has been modified?
> > > 
> > > Yes (I can provide a complete build log if needed)

So the configure check works, SYSTEMD_CFLAGS/SYSTEMD_LIBS makefile macros are set, the HAVE_SYSTEMD macro seems defined, only xfpm-systemd.c does not seem to be added to the sources in src/Makefile, not sure why that would be.

> > Yes, that might help. You can also take a look and compare with our build
> > log at
> > https://build.opensuse.org/package/rawlog/X11:xfce/xfce4-power-manager/
> > openSUSE_Factory/x86_64
> 
> Actually I can't (it requires a username).

OK, see  http://pastebin.com/raw.php?i=xBUSCyWq
Comment 14 Eric Koegel editbugs 2014-01-12 10:53:45 CET
Created attachment 5306 
Add shutdown/reboot functionality for systemd (Bug 10167)

I've created a git formatted patch combining Andreas' and
Guido's work. Guido, I noticed one spot in your patch where
it calls:

+#ifdef HAVE_SYSTEMD
+    if ( LOGIND_RUNNING () )
+	xfpm_systemd_reboot (power->priv->systemd, error);
+#else
     xfpm_console_kit_reboot (power->priv->console, error);
+#endif

Which I changed to:

+#ifdef HAVE_SYSTEMD
+   if ( LOGIND_RUNNING () )
+        xfpm_systemd_reboot (power->priv->systemd, error);
+    else
+#endif
     xfpm_console_kit_reboot (power->priv->console, error);

Is that what was intended?
Comment 15 Guido Berhoerster 2014-01-12 11:05:22 CET
(In reply to Eric Koegel from comment #14)
> Created attachment 5306 
> Add shutdown/reboot functionality for systemd (Bug 10167)
> 
> I've created a git formatted patch combining Andreas' and
> Guido's work. Guido, I noticed one spot in your patch where
> it calls:
> 
> +#ifdef HAVE_SYSTEMD
> +    if ( LOGIND_RUNNING () )
> +	xfpm_systemd_reboot (power->priv->systemd, error);
> +#else
>      xfpm_console_kit_reboot (power->priv->console, error);
> +#endif
> 
> Which I changed to:
> 
> +#ifdef HAVE_SYSTEMD
> +   if ( LOGIND_RUNNING () )
> +        xfpm_systemd_reboot (power->priv->systemd, error);
> +    else
> +#endif
>      xfpm_console_kit_reboot (power->priv->console, error);
> 
> Is that what was intended?

Yes.

BTW, since this does runtime detection of logind should we drop the HAVE_SYSTEMD ifdefs and build-time detection by autoconf?
Comment 16 Eric Koegel editbugs 2014-01-13 11:27:24 CET
Created attachment 5311 
Add shutdown/reboot functionality for systemd (runtime checks only)

This patch eliminates the compile time checks. It
uses xfpm's polkit helper functions to avoid bringing
in another library. Let me know if this works as expected.
Comment 17 Marc MAURICE 2014-02-21 22:22:30 CET
Seems to work great on my Manjaro (archlinux like) system !

Thanks, with that patch I can poweroff my system just by pressing the power button.

This was working in xubuntu, but not in Manjaro... probably because consolekit is missing in Manjaro (systemd instead).
Comment 19 Eric Koegel editbugs 2014-04-12 17:31:46 CEST
Marking resolved.

Bug #10167

Reported by:
Andreas Müller
Reported on: 2013-06-10
Last modified on: 2014-04-12

People

Assignee:
Ali Abdallah
CC List:
6 users

Version

Attachments

Additional information