diff options
author | Benedikt Meurer <benny@xfce.org> | 2006-08-14 20:36:17 +0000 |
---|---|---|
committer | Benedikt Meurer <benny@xfce.org> | 2006-08-14 20:36:17 +0000 |
commit | 001ac1534d69c7a9f86c7ba280c4e16a2d937cd7 (patch) | |
tree | e217acf5565e4c01c099b85ebe71968249426bc2 | |
parent | 71be0325d405b50628bae367a0f90bc43c10ac53 (diff) | |
download | xfce4-session-001ac1534d69c7a9f86c7ba280c4e16a2d937cd7.tar.gz |
2006-08-14 Benedikt Meurer <benny@xfce.org>
* xfce4-session/main.c: Reap child processes to avoid sudo zombies
when cancelling the logout dialog. Bug #2088.
* xfce4-session/xfsm-shutdown-helper-hal.c, AUTHORS, NEWS, README,
configure.in.in, xfce4-session/Makefile.am: Add support for HAL
to shutdown/reboot the computer, based on the Xubuntu patch by
Jani Monoses <jani@ubuntu.com>. Bug #2046.
(Old svn revision: 22759)
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | README | 6 | ||||
-rw-r--r-- | configure.in.in | 9 | ||||
-rw-r--r-- | xfce4-session/Makefile.am | 4 | ||||
-rw-r--r-- | xfce4-session/main.c | 18 | ||||
-rw-r--r-- | xfce4-session/xfsm-shutdown-helper-hal.c | 124 |
8 files changed, 173 insertions, 3 deletions
@@ -3,5 +3,6 @@ Oliver M. Bolzer <oliver@debian.org> Francois Le Clainche <fleclainche@wanadoo.fr> Maarten Boekhold <boekhold@emirates.net.ae> Brian Tarricone <kelnos@xfce.org> +Jani Monoses <jani@ubuntu.com> Parts of the code were copied from gnome-session and ksmserver. @@ -1,3 +1,12 @@ +2006-08-14 Benedikt Meurer <benny@xfce.org> + + * xfce4-session/main.c: Reap child processes to avoid sudo zombies + when cancelling the logout dialog. Bug #2088. + * xfce4-session/xfsm-shutdown-helper-hal.c, AUTHORS, NEWS, README, + configure.in.in, xfce4-session/Makefile.am: Add support for HAL + to shutdown/reboot the computer, based on the Xubuntu patch by + Jani Monoses <jani@ubuntu.com>. Bug #2046. + 2006-08-12 Benedikt Meurer <benny@xfce.org> * xfce4-tips/main.c(main): Fake a session id, so the session manager @@ -1,3 +1,8 @@ +4.3.90.3svn +=========== +- Add support for HAL to shutdown/reboot the computer. Must be enabled + explicitly using --with-shutdown-style=hal to configure/autogen.sh. + 4.3.90.2 ======== - Update dialogs to use the new XfceTitledDialog. @@ -17,6 +17,12 @@ that file): myuser myhost=/usr/local/libexec/xfsm-shutdown-helper +Starting with xfce4-session 4.3.90.3 it is also possible to use HAL to +shutdown/reboot the computer. Therefore pass --with-shutdown-style=hal +to configure/autogen.sh and be sure to have D-BUS 0.34 or above (including +the development files) installed and hald running. You will also need to +allow users to shutdown the computer using HAL (see your system documentation +for details here). Legacy session management: diff --git a/configure.in.in b/configure.in.in index c965d9ce..de3b0972 100644 --- a/configure.in.in +++ b/configure.in.in @@ -123,10 +123,10 @@ fi dnl Check for shutdown method AC_ARG_WITH([shutdown-style], -AC_HELP_STRING([--with-shutdown-style=auto/none/sudo], [Shutdown style]), +AC_HELP_STRING([--with-shutdown-style=auto/none/hal/sudo], [Shutdown style]), [with_shutdown=$withval], [with_shutdown=auto]) AC_MSG_CHECKING([what shutdown style should be used]) -if test x"$with_shutdown" != x"sudo" -a x"$with_shutdown" != x"none"; then +if test x"$with_shutdown" != x"sudo" -a x"$with_shutdown" != x"hal" -a x"$with_shutdown" != x"none"; then with_shutdown="sudo" fi AC_DEFINE_UNQUOTED([XFSM_SHUTDOWN_HELPER_IMPL_C], @@ -134,6 +134,11 @@ AC_DEFINE_UNQUOTED([XFSM_SHUTDOWN_HELPER_IMPL_C], [Shutdown helper implementation]) AC_MSG_RESULT([$with_shutdown]) +dnl Check for dbus for hal support +if test x"$with_shutdown" = x"hal"; then + XDT_CHECK_PACKAGE([DBUS], [dbus-1], [0.34]) +fi + dnl dnl arguments to set shutdown commands dnl diff --git a/xfce4-session/Makefile.am b/xfce4-session/Makefile.am index dcad6959..2cfe604f 100644 --- a/xfce4-session/Makefile.am +++ b/xfce4-session/Makefile.am @@ -47,6 +47,8 @@ xfce4_session_CFLAGS = \ @LIBX11_CFLAGS@ \ @LIBXFCE4MCS_CLIENT_CFLAGS@ \ @LIBXFCEGUI4_CFLAGS@ \ + @DBUS_CFLAGS@ \ + -DDBUS_API_SUBJECT_TO_CHANGE \ -DLIBDIR=\"$(libdir)\" \ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \ -DSYSCONFDIR=\"$(sysconfdir)\" \ @@ -60,6 +62,7 @@ xfce4_session_LDADD = \ @LIBX11_LIBS@ \ @LIBXFCE4MCS_CLIENT_LIBS@ \ @LIBXFCEGUI4_LIBS@ \ + @DBUS_LIBS@ \ @GNOME_LIBS@ xfce4_session_DEPENDENCIES = \ @@ -75,5 +78,6 @@ EXTRA_DIST = \ chooser-icon.png \ xfsm-shutdown-helper-none.c \ xfsm-shutdown-helper-redhat.c \ + xfsm-shutdown-helper-hal.c \ xfsm-shutdown-helper-sudo.c diff --git a/xfce4-session/main.c b/xfce4-session/main.c index b9693bd7..b400da63 100644 --- a/xfce4-session/main.c +++ b/xfce4-session/main.c @@ -23,6 +23,13 @@ #include <config.h> #endif +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#ifdef HAVE_SYS_WAIT_H +#include <sys/wait.h> +#endif + #ifdef HAVE_ERRNO_H #include <errno.h> #endif @@ -222,6 +229,14 @@ initialize (int argc, char **argv) } +static void +sigchld (gint signo) +{ + gint status; + wait (&status); +} + + int main (int argc, char **argv) { @@ -230,8 +245,9 @@ main (int argc, char **argv) xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); - /* stupid, damn f*ck*ng stupid linux! */ + /* install required signal handlers */ signal (SIGPIPE, SIG_IGN); + signal (SIGCHLD, sigchld); gtk_init (&argc, &argv); diff --git a/xfce4-session/xfsm-shutdown-helper-hal.c b/xfce4-session/xfsm-shutdown-helper-hal.c new file mode 100644 index 00000000..e885a843 --- /dev/null +++ b/xfce4-session/xfsm-shutdown-helper-hal.c @@ -0,0 +1,124 @@ +/* $Id$ */ +/*- + * Copyright (c) 2006 Jani Monoses <jani@ubuntu.com> + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif + +#include <dbus/dbus.h> + +#include <xfce4-session/xfsm-shutdown-helper.h> + + + +#define HAL_DBUS_SERVICE "org.freedesktop.Hal" +#define HAL_ROOT_COMPUTER "/org/freedesktop/Hal/devices/computer" +#define HAL_DBUS_INTERFACE_POWER "org.freedesktop.Hal.Device.SystemPowerManagement" + + + +struct _XfsmShutdownHelper +{ + gint dummy; +}; + + +XfsmShutdownHelper* +xfsm_shutdown_helper_spawn (void) +{ + return g_new0 (XfsmShutdownHelper, 1); +} + + +gboolean +xfsm_shutdown_helper_need_password (const XfsmShutdownHelper *helper) +{ + return FALSE; +} + + +gboolean +xfsm_shutdown_helper_send_password (XfsmShutdownHelper *helper, + const gchar *password) +{ + return TRUE; +} + + +static gboolean +hal_dbus_power_command(XfsmShutdownCommand command) +{ + DBusConnection *connection; + DBusMessage *method; + DBusMessage *result; + const gchar *methodname; + DBusError derror; + + if (command == XFSM_SHUTDOWN_REBOOT) + methodname = "Reboot"; + else + methodname = "Shutdown"; + + dbus_error_init (&derror); + connection = dbus_bus_get (DBUS_BUS_SYSTEM, &derror); + if (connection == NULL) + { + dbus_error_free (&derror); + return FALSE; + } + + method = dbus_message_new_method_call (HAL_DBUS_SERVICE, + HAL_ROOT_COMPUTER, + HAL_DBUS_INTERFACE_POWER, + methodname); + result = dbus_connection_send_with_reply_and_block (connection, method, 2000, &derror); + dbus_message_unref (method); + + if (result == NULL) + { + dbus_error_free (&derror); + return FALSE; + } + + dbus_message_unref (result); + return TRUE; +} + + +gboolean +xfsm_shutdown_helper_send_command (XfsmShutdownHelper *helper, + XfsmShutdownCommand command) +{ + return hal_dbus_power_command (command); +} + + +void +xfsm_shutdown_helper_destroy (XfsmShutdownHelper *helper) +{ + g_free (helper); +} + + |