diff options
-rw-r--r-- | BUGS | 2 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | Makefile.in | 3 | ||||
-rw-r--r-- | README | 25 | ||||
-rw-r--r-- | config.h.in | 9 | ||||
-rwxr-xr-x | configure | 76 | ||||
-rw-r--r-- | configure.ac | 12 | ||||
-rw-r--r-- | defaults/Makefile.in | 1 | ||||
-rw-r--r-- | docs/FAQ | 2 | ||||
-rw-r--r-- | docs/Makefile.in | 1 | ||||
-rw-r--r-- | settings/Makefile.in | 1 | ||||
-rw-r--r-- | themes/Default/Makefile.in | 1 | ||||
-rw-r--r-- | themes/Makefile.in | 1 | ||||
-rw-r--r-- | xfce4-session.spec.in | 5 | ||||
-rw-r--r-- | xfce4-session/Makefile.am | 4 | ||||
-rw-r--r-- | xfce4-session/Makefile.in | 32 | ||||
-rw-r--r-- | xfce4-session/shutdown.c | 288 | ||||
-rw-r--r-- | xfce4-session/xfsm-shutdown-helper.c | 307 | ||||
-rw-r--r-- | xfce4-session/xfsm-shutdown-helper.h | 50 | ||||
-rw-r--r-- | xfce4-session/xfsm-util.c | 12 | ||||
-rw-r--r-- | xfce4-session/xfsm-util.h | 2 | ||||
-rw-r--r-- | xfce4-shutdown/Makefile.am | 18 | ||||
-rw-r--r-- | xfce4-shutdown/main.c | 305 | ||||
-rw-r--r-- | xfce4-shutdown/xfce4-shutdown.1 | 30 | ||||
-rw-r--r-- | xfsm-shutdown-helper/Makefile.am | 11 | ||||
-rw-r--r-- | xfsm-shutdown-helper/Makefile.in (renamed from xfce4-shutdown/Makefile.in) | 184 | ||||
-rw-r--r-- | xfsm-shutdown-helper/main.c | 153 |
27 files changed, 954 insertions, 583 deletions
@@ -4,3 +4,5 @@ * Make the logout dialog icon themable through GtkIconTheme * Fix leftover Xinerama bugs in XfsmSplashScreen. + +* Make the shutdown stipple themable? diff --git a/Makefile.am b/Makefile.am index 78cf71f5..91aad99b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,7 @@ SUBDIRS = \ settings \ themes \ xfce4-session \ - xfce4-shutdown + xfsm-shutdown-helper configdir = $(sysconfdir)/xdg/xfce4-session config_DATA = xfce4-session.rc diff --git a/Makefile.in b/Makefile.in index cc469499..b6dfa306 100644 --- a/Makefile.in +++ b/Makefile.in @@ -163,6 +163,7 @@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ +SUDO = @SUDO@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XFCE_MCS_MANAGER_CFLAGS = @XFCE_MCS_MANAGER_CFLAGS@ @@ -223,7 +224,7 @@ SUBDIRS = \ settings \ themes \ xfce4-session \ - xfce4-shutdown + xfsm-shutdown-helper configdir = $(sysconfdir)/xdg/xfce4-session config_DATA = xfce4-session.rc @@ -1,17 +1,16 @@ -Session manager for the XFce desktop environment. - -Using xfce4-shutdown: ---------------------- -In order to use xfce4-shutdown with xfce4-session to reboot/halt the computer, -you have two options: - - a) make $sbindir/xfce4-shutdown setuid to root and add the users - that you want to allow to reboot/halt to the file - $sysconfdir/xfce4/shutdown.allow - - b) install sudo(8) and allow the users to execute /sbin/poweroff, - /sbin/halt and/or /sbin/reboot. +Session manager for the Xfce desktop environment. How to start the session manager: --------------------------------- See the sample xinitrc file in $sysconfdir/xfce4/xinitrc.xfce4-session. + + +Shutting down your computer using the session manager: +------------------------------------------------------ +Since 4.1.5, the session manager supports only sudo(8)-based shutdown, other +method can be added by packagers if desired, just replace XfsmShutdownHelper +with your code. To be able to shutdown the computer, you must be listed +in the systems sudoers file, in particular, you must be allowed to execute +$libexecdir/xfsm-shutdown-helper as user root (where $libexecdir is the +libexec subdir in the prefix you installed xfce4-session, for example +/usr/local/libexec). diff --git a/config.h.in b/config.h.in index 4df8c766..7a2f2f12 100644 --- a/config.h.in +++ b/config.h.in @@ -87,15 +87,15 @@ /* Define to 1 if you have the <sys/param.h> header file. */ #undef HAVE_SYS_PARAM_H +/* Define to 1 if you have the <sys/resource.h> header file. */ +#undef HAVE_SYS_RESOURCE_H + /* Define to 1 if you have the <sys/stat.h> header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the <sys/types.h> header file. */ #undef HAVE_SYS_TYPES_H -/* Define to 1 if you have the <sys/utsname.h> header file. */ -#undef HAVE_SYS_UTSNAME_H - /* Define to 1 if you have the <sys/wait.h> header file. */ #undef HAVE_SYS_WAIT_H @@ -135,6 +135,9 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* path to sudo */ +#undef SUDO_CMD + /* Version number of package */ #undef VERSION @@ -1,7 +1,7 @@ #! /bin/sh # From configure.ac Id: configure.ac,v 1.44 2004/05/18 22:41:20 benny Exp . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for xfce4-session 4.1.5. +# Generated by GNU Autoconf 2.59 for xfce4-session 4.1.6. # # Report bugs to <xfce4-dev@xfce.org>. # @@ -429,8 +429,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='xfce4-session' PACKAGE_TARNAME='xfce4-session' -PACKAGE_VERSION='4.1.5' -PACKAGE_STRING='xfce4-session 4.1.5' +PACKAGE_VERSION='4.1.6' +PACKAGE_STRING='xfce4-session 4.1.6' PACKAGE_BUGREPORT='xfce4-dev@xfce.org' # Factoring default headers for most tests. @@ -470,7 +470,7 @@ ac_includes_default="\ # include <unistd.h> #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP build build_cpu build_vendor build_os host host_cpu host_vendor host_os LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS LIBX11_CFLAGS LIBX11_LDFLAGS LIBX11_LIBS LIBSM_CFLAGS LIBSM_LDFLAGS LIBSM_LIBS GETTEXT_PACKAGE USE_NLS MSGFMT GMSGFMT XGETTEXT CATALOGS CATOBJEXT DATADIRNAME GMOFILES INSTOBJEXT INTLLIBS PO_IN_DATADIR_TRUE PO_IN_DATADIR_FALSE POFILES POSUB MKINSTALLDIRS localedir PKG_CONFIG LIBXFCE4UTIL_CFLAGS LIBXFCE4UTIL_LIBS LIBXFCE4UTIL_REQUIRED_VERSION LIBXFCE4MCS_CLIENT_CFLAGS LIBXFCE4MCS_CLIENT_LIBS LIBXFCE4MCS_CLIENT_REQUIRED_VERSION LIBXFCEGUI4_CFLAGS LIBXFCEGUI4_LIBS LIBXFCEGUI4_REQUIRED_VERSION XFCE_MCS_MANAGER_CFLAGS XFCE_MCS_MANAGER_LIBS XFCE_MCS_MANAGER_REQUIRED_VERSION XFCE_MCS_MANAGER_PLUGINSDIR LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP build build_cpu build_vendor build_os host host_cpu host_vendor host_os LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS LIBX11_CFLAGS LIBX11_LDFLAGS LIBX11_LIBS LIBSM_CFLAGS LIBSM_LDFLAGS LIBSM_LIBS GETTEXT_PACKAGE USE_NLS MSGFMT GMSGFMT XGETTEXT CATALOGS CATOBJEXT DATADIRNAME GMOFILES INSTOBJEXT INTLLIBS PO_IN_DATADIR_TRUE PO_IN_DATADIR_FALSE POFILES POSUB MKINSTALLDIRS localedir PKG_CONFIG LIBXFCE4UTIL_CFLAGS LIBXFCE4UTIL_LIBS LIBXFCE4UTIL_REQUIRED_VERSION LIBXFCE4MCS_CLIENT_CFLAGS LIBXFCE4MCS_CLIENT_LIBS LIBXFCE4MCS_CLIENT_REQUIRED_VERSION LIBXFCEGUI4_CFLAGS LIBXFCEGUI4_LIBS LIBXFCEGUI4_REQUIRED_VERSION XFCE_MCS_MANAGER_CFLAGS XFCE_MCS_MANAGER_LIBS XFCE_MCS_MANAGER_REQUIRED_VERSION XFCE_MCS_MANAGER_PLUGINSDIR SUDO LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -959,7 +959,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures xfce4-session 4.1.5 to adapt to many kinds of systems. +\`configure' configures xfce4-session 4.1.6 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1029,7 +1029,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of xfce4-session 4.1.5:";; + short | recursive ) echo "Configuration of xfce4-session 4.1.6:";; esac cat <<\_ACEOF @@ -1187,7 +1187,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -xfce4-session configure 4.1.5 +xfce4-session configure 4.1.6 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -1206,7 +1206,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by xfce4-session $as_me 4.1.5, which was +It was created by xfce4-session $as_me 4.1.6, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1545,7 +1545,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -XFSM_VERSION=4.1.5 +XFSM_VERSION=4.1.6 am__api_version="1.8" ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do @@ -20527,7 +20527,7 @@ done for ac_header in errno.h fcntl.h limits.h signal.h stdarg.h sys/param.h \ - sys/utsname.h sys/wait.h time.h unistd.h + sys/resource.h sys/wait.h time.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then @@ -24367,6 +24367,53 @@ echo "${ECHO_T}yes" >&6 fi +# Extract the first word of "sudo", so it can be a program name with args. +set dummy sudo; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_SUDO+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $SUDO in + [\\/]* | ?:[\\/]*) + ac_cv_path_SUDO="$SUDO" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_SUDO="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +SUDO=$ac_cv_path_SUDO + +if test -n "$SUDO"; then + echo "$as_me:$LINENO: result: $SUDO" >&5 +echo "${ECHO_T}$SUDO" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +if test x"$SUDO" != x""; then + +cat >>confdefs.h <<_ACEOF +#define SUDO_CMD "$SUDO" +_ACEOF + +fi + echo "$as_me:$LINENO: checking for custom 'poweroff' command" >&5 echo $ECHO_N "checking for custom 'poweroff' command... $ECHO_C" >&6 @@ -24428,7 +24475,7 @@ fi echo "$as_me:$LINENO: result: $with_reboot" >&5 echo "${ECHO_T}$with_reboot" >&6 - ac_config_files="$ac_config_files Makefile xfce4-session.spec defaults/Makefile docs/Makefile po/Makefile.in settings/Makefile themes/Makefile themes/Default/Makefile xfce4-session/Makefile xfce4-shutdown/Makefile" + ac_config_files="$ac_config_files Makefile xfce4-session.spec defaults/Makefile docs/Makefile po/Makefile.in settings/Makefile themes/Makefile themes/Default/Makefile xfce4-session/Makefile xfsm-shutdown-helper/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure @@ -24826,7 +24873,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by xfce4-session $as_me 4.1.5, which was +This file was extended by xfce4-session $as_me 4.1.6, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -24889,7 +24936,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -xfce4-session config.status 4.1.5 +xfce4-session config.status 4.1.6 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" @@ -25009,7 +25056,7 @@ do "themes/Makefile" ) CONFIG_FILES="$CONFIG_FILES themes/Makefile" ;; "themes/Default/Makefile" ) CONFIG_FILES="$CONFIG_FILES themes/Default/Makefile" ;; "xfce4-session/Makefile" ) CONFIG_FILES="$CONFIG_FILES xfce4-session/Makefile" ;; - "xfce4-shutdown/Makefile" ) CONFIG_FILES="$CONFIG_FILES xfce4-shutdown/Makefile" ;; + "xfsm-shutdown-helper/Makefile" ) CONFIG_FILES="$CONFIG_FILES xfsm-shutdown-helper/Makefile" ;; "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; @@ -25205,6 +25252,7 @@ s,@XFCE_MCS_MANAGER_CFLAGS@,$XFCE_MCS_MANAGER_CFLAGS,;t t s,@XFCE_MCS_MANAGER_LIBS@,$XFCE_MCS_MANAGER_LIBS,;t t s,@XFCE_MCS_MANAGER_REQUIRED_VERSION@,$XFCE_MCS_MANAGER_REQUIRED_VERSION,;t t s,@XFCE_MCS_MANAGER_PLUGINSDIR@,$XFCE_MCS_MANAGER_PLUGINSDIR,;t t +s,@SUDO@,$SUDO,;t t s,@LIBOBJS@,$LIBOBJS,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t CEOF diff --git a/configure.ac b/configure.ac index 984f706f..f2d73408 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ dnl dnl Version information m4_define([xfsm_version_major], [4]) m4_define([xfsm_version_minor], [1]) -m4_define([xfsm_version_micro], [5]) +m4_define([xfsm_version_micro], [6]) m4_define([xfsm_version], [xfsm_version_major.xfsm_version_minor.xfsm_version_micro]) dnl Initialize autoconf @@ -41,7 +41,7 @@ dnl check for standard header files AC_HEADER_STDC AC_CHECK_FUNCS([mkdir clearenv sigaction strdup]) AC_CHECK_HEADERS([errno.h fcntl.h limits.h signal.h stdarg.h sys/param.h \ - sys/utsname.h sys/wait.h time.h unistd.h]) + sys/resource.h sys/wait.h time.h unistd.h]) dnl Check for X11 installed BM_LIBX11_REQUIRE @@ -70,6 +70,12 @@ XFCE_MCS_PLUGIN([XFCE_MCS_MANAGER], [4.1.0]) dnl Check for debugging support BM_DEBUG_SUPPORT +dnl check for sudo +AC_PATH_PROG([SUDO], [sudo]) +if test x"$SUDO" != x""; then + AC_DEFINE_UNQUOTED([SUDO_CMD], ["$SUDO"], [path to sudo]) +fi + dnl dnl arguments to set shutdown commands dnl @@ -114,5 +120,5 @@ settings/Makefile themes/Makefile themes/Default/Makefile xfce4-session/Makefile -xfce4-shutdown/Makefile +xfsm-shutdown-helper/Makefile ]) diff --git a/defaults/Makefile.in b/defaults/Makefile.in index 2f2fdf2e..17382e79 100644 --- a/defaults/Makefile.in +++ b/defaults/Makefile.in @@ -137,6 +137,7 @@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ +SUDO = @SUDO@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XFCE_MCS_MANAGER_CFLAGS = @XFCE_MCS_MANAGER_CFLAGS@ @@ -17,7 +17,7 @@ Session manager FAQ: 2) Question: What do I need to do in order to use xfce4-session as session manager - with XFce4? + with Xfce4? Answer: If you have a recent xfce-utils (post 20030708) then xfce4-session diff --git a/docs/Makefile.in b/docs/Makefile.in index c96e2440..40f4a3a8 100644 --- a/docs/Makefile.in +++ b/docs/Makefile.in @@ -133,6 +133,7 @@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ +SUDO = @SUDO@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XFCE_MCS_MANAGER_CFLAGS = @XFCE_MCS_MANAGER_CFLAGS@ diff --git a/settings/Makefile.in b/settings/Makefile.in index 9e9315a8..27614511 100644 --- a/settings/Makefile.in +++ b/settings/Makefile.in @@ -159,6 +159,7 @@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ +SUDO = @SUDO@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XFCE_MCS_MANAGER_CFLAGS = @XFCE_MCS_MANAGER_CFLAGS@ diff --git a/themes/Default/Makefile.in b/themes/Default/Makefile.in index f8eb060b..68fde0cd 100644 --- a/themes/Default/Makefile.in +++ b/themes/Default/Makefile.in @@ -137,6 +137,7 @@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ +SUDO = @SUDO@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XFCE_MCS_MANAGER_CFLAGS = @XFCE_MCS_MANAGER_CFLAGS@ diff --git a/themes/Makefile.in b/themes/Makefile.in index e48bfdca..b5f8589e 100644 --- a/themes/Makefile.in +++ b/themes/Makefile.in @@ -142,6 +142,7 @@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ +SUDO = @SUDO@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XFCE_MCS_MANAGER_CFLAGS = @XFCE_MCS_MANAGER_CFLAGS@ diff --git a/xfce4-session.spec.in b/xfce4-session.spec.in index cff53900..e5d38a7b 100644 --- a/xfce4-session.spec.in +++ b/xfce4-session.spec.in @@ -35,10 +35,9 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root) %doc AUTHORS COPYING ChangeLog ChangeLog.pre-xfce-devel NEWS README TODO %{_sysconfdir}/xfce4/ -%{_datadir}/xfce4/splash/ +%{_datadir}/themes/ %{_datadir}/locale/ %{_mandir}/man1/* %{_bindir}/* -%{_sbindir}/* %{_libdir}/xfce4/mcs-plugins/ - +%{_libexecdir}/xfsm-shutdown-helper diff --git a/xfce4-session/Makefile.am b/xfce4-session/Makefile.am index 01af748d..e5e7e1ea 100644 --- a/xfce4-session/Makefile.am +++ b/xfce4-session/Makefile.am @@ -23,6 +23,8 @@ xfce4_session_SOURCES = \ xfsm-manager.h \ xfsm-properties.c \ xfsm-properties.h \ + xfsm-shutdown-helper.c \ + xfsm-shutdown-helper.h \ xfsm-splash-screen.c \ xfsm-splash-screen.h \ xfsm-splash-theme.c \ @@ -38,7 +40,7 @@ xfce4_session_CFLAGS = \ @LIBXFCE4MCS_CLIENT_CFLAGS@ \ @LIBXFCEGUI4_CFLAGS@ \ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \ - -DSHUTDOWN_COMMAND=\"$(sbindir)/xfce4-shutdown\" + -DXFSM_SHUTDOWN_HELPER=\"$(libexecdir)/xfsm-shutdown-helper\" xfce4_session_LDADD = \ @LIBSM_LDFLAGS@ \ diff --git a/xfce4-session/Makefile.in b/xfce4-session/Makefile.in index 796fb218..7ca421b1 100644 --- a/xfce4-session/Makefile.in +++ b/xfce4-session/Makefile.in @@ -61,6 +61,7 @@ am_xfce4_session_OBJECTS = xfce4_session-ice-layer.$(OBJEXT) \ xfce4_session-xfsm-global.$(OBJEXT) \ xfce4_session-xfsm-manager.$(OBJEXT) \ xfce4_session-xfsm-properties.$(OBJEXT) \ + xfce4_session-xfsm-shutdown-helper.$(OBJEXT) \ xfce4_session-xfsm-splash-screen.$(OBJEXT) \ xfce4_session-xfsm-splash-theme.$(OBJEXT) \ xfce4_session-xfsm-startup.$(OBJEXT) \ @@ -80,6 +81,7 @@ am__depfiles_maybe = depfiles @AMDEP_TRUE@ ./$(DEPDIR)/xfce4_session-xfsm-global.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/xfce4_session-xfsm-manager.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/xfce4_session-xfsm-properties.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/xfce4_session-xfsm-splash-screen.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/xfce4_session-xfsm-splash-theme.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/xfce4_session-xfsm-startup.Po \ @@ -185,6 +187,7 @@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ +SUDO = @SUDO@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XFCE_MCS_MANAGER_CFLAGS = @XFCE_MCS_MANAGER_CFLAGS@ @@ -260,6 +263,8 @@ xfce4_session_SOURCES = \ xfsm-manager.h \ xfsm-properties.c \ xfsm-properties.h \ + xfsm-shutdown-helper.c \ + xfsm-shutdown-helper.h \ xfsm-splash-screen.c \ xfsm-splash-screen.h \ xfsm-splash-theme.c \ @@ -275,7 +280,7 @@ xfce4_session_CFLAGS = \ @LIBXFCE4MCS_CLIENT_CFLAGS@ \ @LIBXFCEGUI4_CFLAGS@ \ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \ - -DSHUTDOWN_COMMAND=\"$(sbindir)/xfce4-shutdown\" + -DXFSM_SHUTDOWN_HELPER=\"$(libexecdir)/xfsm-shutdown-helper\" xfce4_session_LDADD = \ @LIBSM_LDFLAGS@ \ @@ -370,6 +375,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfce4_session-xfsm-global.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfce4_session-xfsm-manager.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfce4_session-xfsm-properties.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfce4_session-xfsm-splash-screen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfce4_session-xfsm-splash-theme.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfce4_session-xfsm-startup.Po@am__quote@ @@ -639,6 +645,30 @@ xfce4_session-xfsm-properties.lo: xfsm-properties.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -c -o xfce4_session-xfsm-properties.lo `test -f 'xfsm-properties.c' || echo '$(srcdir)/'`xfsm-properties.c +xfce4_session-xfsm-shutdown-helper.o: xfsm-shutdown-helper.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -MT xfce4_session-xfsm-shutdown-helper.o -MD -MP -MF "$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Tpo" -c -o xfce4_session-xfsm-shutdown-helper.o `test -f 'xfsm-shutdown-helper.c' || echo '$(srcdir)/'`xfsm-shutdown-helper.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Tpo" "$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Po"; else rm -f "$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xfsm-shutdown-helper.c' object='xfce4_session-xfsm-shutdown-helper.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Po' tmpdepfile='$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -c -o xfce4_session-xfsm-shutdown-helper.o `test -f 'xfsm-shutdown-helper.c' || echo '$(srcdir)/'`xfsm-shutdown-helper.c + +xfce4_session-xfsm-shutdown-helper.obj: xfsm-shutdown-helper.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -MT xfce4_session-xfsm-shutdown-helper.obj -MD -MP -MF "$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Tpo" -c -o xfce4_session-xfsm-shutdown-helper.obj `if test -f 'xfsm-shutdown-helper.c'; then $(CYGPATH_W) 'xfsm-shutdown-helper.c'; else $(CYGPATH_W) '$(srcdir)/xfsm-shutdown-helper.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Tpo" "$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Po"; else rm -f "$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xfsm-shutdown-helper.c' object='xfce4_session-xfsm-shutdown-helper.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Po' tmpdepfile='$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -c -o xfce4_session-xfsm-shutdown-helper.obj `if test -f 'xfsm-shutdown-helper.c'; then $(CYGPATH_W) 'xfsm-shutdown-helper.c'; else $(CYGPATH_W) '$(srcdir)/xfsm-shutdown-helper.c'; fi` + +xfce4_session-xfsm-shutdown-helper.lo: xfsm-shutdown-helper.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -MT xfce4_session-xfsm-shutdown-helper.lo -MD -MP -MF "$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Tpo" -c -o xfce4_session-xfsm-shutdown-helper.lo `test -f 'xfsm-shutdown-helper.c' || echo '$(srcdir)/'`xfsm-shutdown-helper.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Tpo" "$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Plo"; else rm -f "$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xfsm-shutdown-helper.c' object='xfce4_session-xfsm-shutdown-helper.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.Plo' tmpdepfile='$(DEPDIR)/xfce4_session-xfsm-shutdown-helper.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -c -o xfce4_session-xfsm-shutdown-helper.lo `test -f 'xfsm-shutdown-helper.c' || echo '$(srcdir)/'`xfsm-shutdown-helper.c + xfce4_session-xfsm-splash-screen.o: xfsm-splash-screen.c @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -MT xfce4_session-xfsm-splash-screen.o -MD -MP -MF "$(DEPDIR)/xfce4_session-xfsm-splash-screen.Tpo" -c -o xfce4_session-xfsm-splash-screen.o `test -f 'xfsm-splash-screen.c' || echo '$(srcdir)/'`xfsm-splash-screen.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfce4_session-xfsm-splash-screen.Tpo" "$(DEPDIR)/xfce4_session-xfsm-splash-screen.Po"; else rm -f "$(DEPDIR)/xfce4_session-xfsm-splash-screen.Tpo"; exit 1; fi diff --git a/xfce4-session/shutdown.c b/xfce4-session/shutdown.c index 7797ffcf..0b2cf574 100644 --- a/xfce4-session/shutdown.c +++ b/xfce4-session/shutdown.c @@ -44,11 +44,22 @@ #include <xfce4-session/shutdown.h> #include <xfce4-session/xfsm-global.h> #include <xfce4-session/xfsm-fadeout.h> +#include <xfce4-session/xfsm-shutdown-helper.h> #include <xfce4-session/xfsm-util.h> #define BORDER 6 +static XfsmShutdownHelper *shutdown_helper = NULL; + + +static void +entry_activate_cb (GtkWidget *entry, GtkDialog *dialog) +{ + gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); +} + + /* */ gboolean @@ -70,18 +81,35 @@ shutdownDialog(gint *shutdownType, gboolean *saveSession) GtkWidget *radio_reboot; GtkWidget *radio_halt; GtkWidget *checkbox; + GtkWidget *entry_vbox; + GtkWidget *entry; GtkWidget *hidden; + GtkWidget *ok_button; + GtkWidget *cancel_button; gboolean saveonexit; gboolean autosave; gint monitor; gint result; XfceRc *rc; + /* XXX - move to other module?! */ + GdkPixmap *saved = NULL; + GdkGC *saved_gc = NULL; + int saved_x, saved_y; + int saved_w, saved_h; + g_return_val_if_fail(saveSession != NULL, FALSE); g_return_val_if_fail(shutdownType != NULL, FALSE); - rc = xfsm_open_config (FALSE); + /* destroy any previously running shutdown helper first */ + if (shutdown_helper != NULL) + { + xfsm_shutdown_helper_destroy (shutdown_helper); + shutdown_helper = NULL; + } + /* load configuration */ + rc = xfsm_open_config (FALSE); xfce_rc_set_group (rc, "General"); saveonexit = xfce_rc_read_bool_entry (rc, "SaveOnExit", TRUE); autosave = xfce_rc_read_bool_entry (rc, "AutoSave", FALSE); @@ -137,10 +165,10 @@ shutdownDialog(gint *shutdownType, gboolean *saveSession) gtk_window_set_decorated (GTK_WINDOW (dialog), FALSE); } - gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL); - gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, - GTK_RESPONSE_OK); + cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL); + ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, + GTK_RESPONSE_OK); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL); gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); @@ -149,23 +177,19 @@ shutdownDialog(gint *shutdownType, gboolean *saveSession) dbox = GTK_DIALOG(dialog)->vbox; - /* */ hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(dbox), hbox, TRUE, TRUE, BORDER); gtk_widget_show(hbox); - /* */ image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, TRUE, BORDER); gtk_widget_show(image); - /* */ vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, BORDER); gtk_widget_show(vbox); - /* */ label = gtk_label_new(_("What do you want to do next?")); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, BORDER); gtk_widget_show(label); @@ -190,7 +214,6 @@ shutdownDialog(gint *shutdownType, gboolean *saveSession) gtk_box_pack_start (GTK_BOX (radio_vbox), radio_halt, FALSE, FALSE, 0); gtk_widget_show (radio_halt); - /* */ if (!autosave) { checkbox = gtk_check_button_new_with_mnemonic( @@ -223,17 +246,39 @@ shutdownDialog(gint *shutdownType, gboolean *saveSession) xfsm_splash_theme_destroy (theme); } + /* connect to the shutdown helper */ + shutdown_helper = xfsm_shutdown_helper_spawn (); + if (shutdown_helper == NULL) + { + gtk_widget_set_sensitive (radio_reboot, FALSE); + gtk_widget_set_sensitive (radio_halt, FALSE); + } + + /* save portion of the root window covered by the dialog */ + if (!accessibility && shutdown_helper != NULL) + { + GdkWindow *root; + + gtk_window_get_position (GTK_WINDOW (dialog), &saved_x, &saved_y); + gtk_window_get_size (GTK_WINDOW (dialog), &saved_w, &saved_h); + + root = gdk_screen_get_root_window (screen); + saved = gdk_pixmap_new (GDK_DRAWABLE (root), saved_w, saved_h, -1); + saved_gc = gdk_gc_new (GDK_DRAWABLE (saved)); + gdk_gc_set_function (saved_gc, GDK_COPY); + gdk_gc_set_subwindow (saved_gc, TRUE); + + gdk_draw_drawable (GDK_DRAWABLE (saved), saved_gc, GDK_DRAWABLE (root), + saved_x, saved_y, 0, 0, saved_w, saved_h); + } + /* need to realize the dialog first! */ gtk_widget_show_now (dialog); + gtk_widget_grab_focus (ok_button); /* Grab Keyboard and Mouse pointer */ if (!accessibility) - { - gdk_pointer_grab (dialog->window, TRUE, 0, NULL, NULL, GDK_CURRENT_TIME); - gdk_keyboard_grab (dialog->window, FALSE, GDK_CURRENT_TIME); - XSetInputFocus (GDK_DISPLAY (), GDK_WINDOW_XWINDOW (dialog->window), - RevertToParent, CurrentTime); - } + xfsm_window_grab_input (GTK_WINDOW (dialog)); /* run the logout dialog */ result = gtk_dialog_run (GTK_DIALOG(dialog)); @@ -249,6 +294,127 @@ shutdownDialog(gint *shutdownType, gboolean *saveSession) *shutdownType = SHUTDOWN_HALT; } + gtk_widget_hide (dialog); + + /* ask password */ + if (result == GTK_RESPONSE_OK && *shutdownType != SHUTDOWN_LOGOUT + && xfsm_shutdown_helper_need_password (shutdown_helper)) + { + GdkWindow *root; + + root = gdk_screen_get_root_window (screen); + + /* clear the area occupied by the dialog first */ + if (!accessibility) + { + gdk_draw_drawable (GDK_DRAWABLE (root), saved_gc, GDK_DRAWABLE(saved), + 0, 0, saved_x, saved_y, saved_w, saved_h); + } + + gtk_container_remove (GTK_CONTAINER (vbox), radio_vbox); + + entry_vbox = gtk_vbox_new (FALSE, BORDER); + gtk_box_pack_start (GTK_BOX (vbox), entry_vbox, TRUE, TRUE, 0); + gtk_widget_show (entry_vbox); + + gtk_image_set_from_stock (GTK_IMAGE (image), + GTK_STOCK_DIALOG_AUTHENTICATION, + GTK_ICON_SIZE_DIALOG); + + gtk_label_set_text (GTK_LABEL (label), _("Please enter your password:")); + + entry = gtk_entry_new (); + gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); + gtk_box_pack_start (GTK_BOX (entry_vbox), entry, TRUE, TRUE, 0); + g_signal_connect (G_OBJECT (entry), "activate", + G_CALLBACK (entry_activate_cb), dialog); + gtk_widget_show (entry); + + /* center dialog on target monitor */ + xfsm_center_window_on_screen (GTK_WINDOW (dialog), screen, monitor); + + /* again, save the area below the dialog */ + if (!accessibility) + { + g_object_unref (G_OBJECT (saved)); + + gtk_window_get_position (GTK_WINDOW (dialog), &saved_x, &saved_y); + gtk_window_get_size (GTK_WINDOW (dialog), &saved_w, &saved_h); + + saved = gdk_pixmap_new (GDK_DRAWABLE (root), saved_w, saved_h, -1); + gdk_draw_drawable (GDK_DRAWABLE (saved), saved_gc, GDK_DRAWABLE(root), + saved_x, saved_y, 0, 0, saved_w, saved_h); + } + + gtk_widget_show_now (dialog); + gtk_widget_grab_focus (entry); + + /* Grab Keyboard and Mouse pointer */ + if (!accessibility) + xfsm_window_grab_input (GTK_WINDOW (dialog)); + + result = gtk_dialog_run (GTK_DIALOG (dialog)); + + if (result == GTK_RESPONSE_OK) + { + const gchar *pw = gtk_entry_get_text (GTK_ENTRY (entry)); + + if (!xfsm_shutdown_helper_send_password (shutdown_helper, pw)) + { + gtk_widget_hide (dialog); + + /* clear the area occupied by the dialog first */ + if (!accessibility) + { + gdk_draw_drawable (GDK_DRAWABLE (root), saved_gc, + GDK_DRAWABLE(saved), 0, 0, + saved_x, saved_y, saved_w, saved_h); + } + + gtk_image_set_from_stock (GTK_IMAGE (image), + GTK_STOCK_DIALOG_ERROR, + GTK_ICON_SIZE_DIALOG); + + gtk_label_set_text (GTK_LABEL (label), + _("<b>An error occured</b>")); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + + gtk_container_remove (GTK_CONTAINER ( + GTK_DIALOG (dialog)->action_area), cancel_button); + gtk_container_remove (GTK_CONTAINER ( + GTK_DIALOG (dialog)->action_area), ok_button); + + gtk_container_remove (GTK_CONTAINER (entry_vbox), entry); + + gtk_dialog_add_button (GTK_DIALOG (dialog), + GTK_STOCK_CLOSE, + GTK_RESPONSE_CANCEL); + + label = gtk_label_new (_("Either the password you entered is " + "invalid, or the system administrator " + "disallows shutting down this computer " + "with your user account.")); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_box_pack_start (GTK_BOX (entry_vbox), label, TRUE, TRUE, 0); + gtk_widget_show (label); + + /* center dialog on target monitor */ + xfsm_center_window_on_screen (GTK_WINDOW (dialog), screen, + monitor); + + gtk_widget_show_now (dialog); + + /* Grab Keyboard and Mouse pointer */ + if (!accessibility) + xfsm_window_grab_input (GTK_WINDOW (dialog)); + + gtk_dialog_run (GTK_DIALOG (dialog)); + + result = GTK_RESPONSE_CANCEL; + } + } + } + gtk_widget_destroy(dialog); gtk_widget_destroy(hidden); @@ -257,17 +423,21 @@ shutdownDialog(gint *shutdownType, gboolean *saveSession) { xfsm_fadeout_destroy (fadeout); + if (saved != NULL) + { + g_object_unref (G_OBJECT (saved_gc)); + g_object_unref (G_OBJECT (saved)); + } + gdk_x11_ungrab_server (); gdk_pointer_ungrab (GDK_CURRENT_TIME); gdk_keyboard_ungrab (GDK_CURRENT_TIME); gdk_flush (); } - /* - * run an iteration through the main loop to give the - * confirm dialog time to disappear - */ - g_main_context_iteration (NULL, TRUE); + /* process all pending events first */ + while (gtk_events_pending ()) + g_main_context_iteration (NULL, FALSE); /* * remember the current settings. @@ -290,60 +460,38 @@ shutdownDialog(gint *shutdownType, gboolean *saveSession) gint shutdown(gint type) { - gchar *command; - gchar *fallback; - gchar *buf; - GError *error; - gint status; - - error = NULL; - fallback = NULL; - - switch (type) { - case SHUTDOWN_REBOOT: - command = g_strdup_printf("%s reboot", SHUTDOWN_COMMAND); - break; - - case SHUTDOWN_HALT: - command = g_strdup_printf("%s poweroff", SHUTDOWN_COMMAND); - fallback = g_strdup_printf("%s halt", SHUTDOWN_COMMAND); - break; - - default: - return(EXIT_SUCCESS); - } + gboolean result; -again: - if (!g_spawn_command_line_sync(command, NULL, &buf, &status, &error)) { - if (fallback != NULL) - goto try_fallback; + if (type == SHUTDOWN_LOGOUT) + return EXIT_SUCCESS; - xfce_err(_("The following error occured while trying to " - "shutdown the computer:\n\n%s"), error->message); - g_error_free(error); - g_free(command); - return(EXIT_FAILURE); - } + if (shutdown_helper == NULL) + { + g_warning ("No shutdown helper attached!"); + return EXIT_FAILURE; + } - if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { - if (fallback != NULL) - goto try_fallback; + if (type == SHUTDOWN_HALT) + { + result = xfsm_shutdown_helper_send_command (shutdown_helper, + XFSM_SHUTDOWN_POWEROFF); + } + else + { + result = xfsm_shutdown_helper_send_command (shutdown_helper, + XFSM_SHUTDOWN_REBOOT); + } - xfce_err(_( - "The following error occured while trying to " - "shutdown the computer:\n\n%s"), buf); - g_free(command); - return(EXIT_FAILURE); - } + xfsm_shutdown_helper_destroy (shutdown_helper); + shutdown_helper = NULL; - g_free(command); - return(EXIT_SUCCESS); + if (!result) + { + /* XXX - graphical feedback ?! */ + g_warning ("Failed to perform shutdown action!"); + return EXIT_FAILURE; + } -try_fallback: - /* try using fallback command */ - g_free(command); - command = fallback; - fallback = NULL; - goto again; + return EXIT_SUCCESS; } diff --git a/xfce4-session/xfsm-shutdown-helper.c b/xfce4-session/xfsm-shutdown-helper.c new file mode 100644 index 00000000..80b74c8d --- /dev/null +++ b/xfce4-session/xfsm-shutdown-helper.c @@ -0,0 +1,307 @@ +/* $Id$ */ +/*- + * Copyright (c) 2003-2004 Benedikt Meurer <benny@xfce.org> + * 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_SYS_RESOURCE_H +#include <sys/resource.h> +#endif +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif + +#ifdef HAVE_MEMORY_H +#include <memory.h> +#endif +#include <stdio.h> +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef HAVE_SIGNAL_H +#include <signal.h> +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#include <libxfce4util/libxfce4util.h> + +#include <xfce4-session/xfsm-shutdown-helper.h> + + +struct _XfsmShutdownHelper +{ + FILE *infile; + FILE *outfile; + gboolean need_password; +}; + + +XfsmShutdownHelper* +xfsm_shutdown_helper_spawn (void) +{ +#if defined(SUDO_CMD) + XfsmShutdownHelper *helper; + int parent_pipe[2]; + int child_pipe[2]; + struct rlimit rlp; + char buf[15]; + int result; + pid_t pid; + int n; + + helper = g_new0 (XfsmShutdownHelper, 1); + + result = pipe (parent_pipe); + if (result < 0) + goto error0; + + result = pipe (child_pipe); + if (result < 0) + goto error1; + + pid = fork (); + if (pid < 0) + { + goto error2; + } + else if (pid == 0) + { + /* setup signals */ + signal (SIGPIPE, SIG_DFL); + + /* setup environment */ + xfce_setenv ("LC_ALL", "C", TRUE); + xfce_setenv ("LANG", "C", TRUE); + xfce_setenv ("LANGUAGE", "C", TRUE); + + /* setup the 3 standard file handles */ + dup2 (child_pipe[0], STDIN_FILENO); + dup2 (parent_pipe[1], STDOUT_FILENO); + dup2 (parent_pipe[1], STDERR_FILENO); + + /* Close all other file handles */ + getrlimit (RLIMIT_NOFILE, &rlp); + for (n = 0; n < (int) rlp.rlim_cur; ++n) + { + if (n != STDIN_FILENO && n != STDOUT_FILENO && n != STDERR_FILENO) + close (n); + } + + /* execute sudo with the helper */ + execl (SUDO_CMD, "sudo", "-H", "-S", "-p", + "XFSM_SUDO_PASS ", "--", XFSM_SHUTDOWN_HELPER, NULL); + _exit (127); + } + + close (parent_pipe[1]); + + /* read sudo/helper answer */ + n = read (parent_pipe[0], buf, 15); + if (n < 15) + goto error2; + + helper->infile = fdopen (parent_pipe[0], "r"); + if (helper->infile == NULL) + goto error2; + + helper->outfile = fdopen (child_pipe[1], "w"); + if (helper->outfile == NULL) + goto error3; + + if (memcmp (buf, "XFSM_SUDO_PASS ", 15) == 0) + { + helper->need_password = TRUE; + } + else if (memcmp (buf, "XFSM_SUDO_DONE ", 15) == 0) + { + helper->need_password = FALSE; + } + else + goto error3; + + close (parent_pipe[1]); + close (child_pipe[0]); + + return helper; + +error3: + if (helper->infile != NULL) + fclose (helper->infile); + if (helper->outfile != NULL) + fclose (helper->outfile); + +error2: + close (child_pipe[0]); + close (child_pipe[1]); + +error1: + close (parent_pipe[0]); + close (parent_pipe[1]); + +error0: + g_free (helper); + return NULL; +#else + /* won't work without sudo */ + return NULL; +#endif +} + + +gboolean +xfsm_shutdown_helper_need_password (const XfsmShutdownHelper *helper) +{ + return helper->need_password; +} + + +gboolean +xfsm_shutdown_helper_send_password (XfsmShutdownHelper *helper, + const gchar *password) +{ + char buffer[1024]; + ssize_t result; + size_t failed; + size_t length; + size_t bytes; + int fd; + + g_return_val_if_fail (helper != NULL, FALSE); + g_return_val_if_fail (password != NULL, FALSE); + g_return_val_if_fail (helper->need_password, FALSE); + + g_snprintf (buffer, 1024, "%s\n", password); + length = strlen (buffer); + bytes = fwrite (buffer, 1, length, helper->outfile); + fflush (helper->outfile); + bzero (buffer, length); + + if (bytes != length) + { + fprintf (stderr, "Failed to write password (bytes=%u, length=%u)\n", + bytes, length); + return FALSE; + } + + if (ferror (helper->outfile)) + { + fprintf (stderr, "Pipe error\n"); + return FALSE; + } + + fd = fileno (helper->infile); + + for (failed = length = 0;;) + { + result = read (fd, buffer + length, 256 - length); + + if (result < 0) + { + perror ("read"); + return FALSE; + } + else if (result == 0) + { + if (++failed > 20) + return FALSE; + continue; + } + else if (result + length >= 1024) + { + fprintf (stderr, "Too much output from sudo!\n"); + return FALSE; + } + + length += result; + buffer[length] = 0; + + if (length >= 15) + { + if (strncmp (buffer + (length - 15), "XFSM_SUDO_PASS ", 15) == 0) + { + return FALSE; + } + else if (strncmp (buffer + (length - 15), "XFSM_SUDO_DONE ", 15) == 0) + { + helper->need_password = FALSE; + break; + } + } + } + + return TRUE; +} + + +gboolean +xfsm_shutdown_helper_send_command (XfsmShutdownHelper *helper, + XfsmShutdownCommand command) +{ + static char *command_table[] = { "POWEROFF", "REBOOT" }; + char response[256]; + + g_return_val_if_fail (helper != NULL, FALSE); + g_return_val_if_fail (!helper->need_password, FALSE); + + fprintf (helper->outfile, "%s\n", command_table[command]); + fflush (helper->outfile); + + if (ferror (helper->outfile)) + { + fprintf (stderr, "Error sending command to helper\n"); + return FALSE; + } + + if (fgets (response, 256, helper->infile) == NULL) + { + fprintf (stderr, "No response from helper\n"); + return FALSE; + } + + if (strncmp (response, "SUCCEED", 7) != 0) + { + fprintf (stderr, "Command failed\n"); + return FALSE; + } + + return TRUE; +} + + +void +xfsm_shutdown_helper_destroy (XfsmShutdownHelper *helper) +{ + g_return_if_fail (helper != NULL); + + if (helper->infile != NULL) + fclose (helper->infile); + if (helper->outfile != NULL) + fclose (helper->outfile); + g_free (helper); +} + + diff --git a/xfce4-session/xfsm-shutdown-helper.h b/xfce4-session/xfsm-shutdown-helper.h new file mode 100644 index 00000000..b2e055d4 --- /dev/null +++ b/xfce4-session/xfsm-shutdown-helper.h @@ -0,0 +1,50 @@ +/* $Id$ */ +/*- + * Copyright (c) 2003-2004 Benedikt Meurer <benny@xfce.org> + * 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. + */ + +#ifndef __XFSM_SHUTDOWN_HELPER_H__ +#define __XFSM_SHUTDOWN_HELPER_H__ + +#include <glib.h> + + +typedef enum +{ + XFSM_SHUTDOWN_POWEROFF = 0, + XFSM_SHUTDOWN_REBOOT = 1, +} XfsmShutdownCommand; + + +typedef struct _XfsmShutdownHelper XfsmShutdownHelper; + + +XfsmShutdownHelper *xfsm_shutdown_helper_spawn (void); + +gboolean xfsm_shutdown_helper_need_password (const XfsmShutdownHelper *helper); + +gboolean xfsm_shutdown_helper_send_password (XfsmShutdownHelper *helper, + const gchar *password); + +gboolean xfsm_shutdown_helper_send_command (XfsmShutdownHelper *helper, + XfsmShutdownCommand command); + +void xfsm_shutdown_helper_destroy (XfsmShutdownHelper *helper); + +#endif /* !__XFSM_SHUTDOWN_HELPER_H__ */ diff --git a/xfce4-session/xfsm-util.c b/xfce4-session/xfsm-util.c index 491b5bc0..9b76eee5 100644 --- a/xfce4-session/xfsm-util.c +++ b/xfce4-session/xfsm-util.c @@ -331,6 +331,18 @@ xfsm_window_add_border (GtkWindow *window) } +void +xfsm_window_grab_input (GtkWindow *window) +{ + GdkWindow *xwindow = GTK_WIDGET (window)->window; + + gdk_pointer_grab (xwindow, TRUE, 0, NULL, NULL, GDK_CURRENT_TIME); + gdk_keyboard_grab (xwindow, FALSE, GDK_CURRENT_TIME); + XSetInputFocus (GDK_DISPLAY (), GDK_WINDOW_XWINDOW (xwindow), + RevertToParent, CurrentTime); +} + + XfceRc* xfsm_open_config (gboolean readonly) { diff --git a/xfce4-session/xfsm-util.h b/xfce4-session/xfsm-util.h index 1375bc05..f5cc6567 100644 --- a/xfce4-session/xfsm-util.h +++ b/xfce4-session/xfsm-util.h @@ -55,6 +55,8 @@ gboolean xfsm_strv_equal (gchar **a, gchar **b); void xfsm_window_add_border (GtkWindow *window); +void xfsm_window_grab_input (GtkWindow *window); + XfceRc *xfsm_open_config (gboolean readonly); G_END_DECLS; diff --git a/xfce4-shutdown/Makefile.am b/xfce4-shutdown/Makefile.am deleted file mode 100644 index 053ece63..00000000 --- a/xfce4-shutdown/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -man_MANS = xfce4-shutdown.1 - -EXTRA_DIST = \ - $(man_MANS) - -sbin_PROGRAMS = xfce4-shutdown - -xfce4_shutdown_SOURCES = \ - main.c - -xfce4_shutdown_CFLAGS = \ - @LIBXFCE4UTIL_CFLAGS@ \ - -DPATH_SHUTDOWNALLOW=\"$(sysconfdir)/xfce4/shutdown.allow\" - -xfce4_shutdown_LDADD = \ - @LIBXFCE4UTIL_LIBS@ - - diff --git a/xfce4-shutdown/main.c b/xfce4-shutdown/main.c deleted file mode 100644 index 59f78a17..00000000 --- a/xfce4-shutdown/main.c +++ /dev/null @@ -1,305 +0,0 @@ -/* $Id$ */ -/*- - * Copyright (c) 2003-2004 Benedikt Meurer <benny@xfce.org> - * 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_SYS_STAT_H -#include <sys/stat.h> -#endif -#ifdef HAVE_SYS_WAIT_H -#include <sys/wait.h> -#endif - -#include <ctype.h> -#ifdef HAVE_ERRNO_H -#include <errno.h> -#endif -#ifdef HAVE_LIMITS_H -#include <limits.h> -#endif -#ifdef HAVE_SIGNAL_H -#include <signal.h> -#endif -#include <stdio.h> -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif -#ifdef HAVE_STRING_H -#include <string.h> -#endif -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - -#include <libxfce4util/libxfce4util.h> - -/* - * Check if a user is allowed to issue shutdown commands (when running - * setuid to root) - */ -gboolean -checkUser(const gchar *action) -{ - gchar buffer[LINE_MAX]; - const gchar *username; - const gchar *u; - FILE *fp; - gchar *p; - - g_return_val_if_fail(action != NULL, FALSE); - - if ((username = g_get_user_name()) == NULL) - return(FALSE); - - if ((fp = fopen(PATH_SHUTDOWNALLOW, "r")) == NULL) - return(FALSE); - - while (fgets(buffer, LINE_MAX, fp) != NULL) { - /* skip leading white space */ - for (p = buffer; isspace(*p); p++); - - /* ignore comments and empty lines */ - if (*p == '#' || *p == '\n' || *p == '\0') - continue; - - /* */ - for (u = username; *u != '\0'; ) - if (*u++ != *p++) - break; - - if (*u == '\0' && (*p == '\0' || isspace(*p))) { - /* ok, we found him, he's ok */ - (void)fclose(fp); - return(TRUE); - } - } - - (void)fclose(fp); - return(FALSE); -} - -/* - */ -gboolean -sudo(const gchar *action) -{ - gboolean result; - gchar *command; - gchar **argv; - gchar **envp; - GError *err; - gint status; - gint argc; - -again: - err = NULL; -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) - if (strcmp (action, "poweroff") == 0) - command = g_strdup ("sudo -S -u root /sbin/shutdown -p now"); - else if (strcmp (action, "halt") == 0) - command = g_strdup ("sudo -S -u root /sbin/shutdown -h now"); - else - command = g_strdup ("sudo -S -u root /sbin/shutdown -r now"); -#else - command = g_strdup_printf("sudo -S -u root /sbin/%s", action); -#endif - - result = g_shell_parse_argv (command, &argc, &argv, &err); - - if (result) - { - envp = g_new0 (gchar *, 1); - - result = g_spawn_sync (NULL, argv, envp, - G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | - G_SPAWN_STDERR_TO_DEV_NULL, - NULL, NULL, NULL, NULL, &status, &err); - - g_strfreev (envp); - g_strfreev (argv); - } - - g_free(command); - - if (!result) - { - g_error_free (err); - - if (strcmp (action, "poweroff") == 0) - { - action = "halt"; - goto again; - } - - return FALSE; - } - - return (WIFEXITED (status) && WEXITSTATUS (status) == 0); -} - -#ifdef HAVE_SIGPROCMASK -static void -block_signals (void) -{ - sigset_t set; - - sigemptyset (&set); - sigaddset (&set, SIGHUP); - sigaddset (&set, SIGINT); - /*sigaddset (&set, SIGKILL);*/ - - sigprocmask (SIG_BLOCK, &set, NULL); -} -#endif - -/* - */ -int -main(int argc, char **argv) -{ - struct stat sb; - char *action; - - /* */ - if (argc != 2) { - fprintf(stderr, _("Usage: %s <action>\n"), *argv); - return(EXIT_FAILURE); - } - - action = argv[1]; - - /* */ - if (strcmp(action, "halt") && strcmp(action, "poweroff") && - strcmp(action, "reboot")) { - fprintf(stderr, _("%s: Unknown action %s\n"), action, *argv); - return(EXIT_FAILURE); - } - -#ifdef HAVE_SETSID - setsid (); -#endif - -#ifdef HAVE_SIGPROCMASK - block_signals (); -#endif - - /* XXX - get rid of the shutdown.allow and replace it w/ something - * more convenient! - */ - if (geteuid() == 0) { - if (stat(PATH_SHUTDOWNALLOW, &sb) < 0) { - fprintf(stderr, "Unable to stat file %s: %s\n", - PATH_SHUTDOWNALLOW, g_strerror(errno)); - return(EXIT_FAILURE); - } - - if (sb.st_uid != 0) { - fprintf(stderr, "%s is not owned by root", - PATH_SHUTDOWNALLOW); - return(FALSE); - } - - /* - * Ok, we are running as root (or setuid to root), so lets - * try to do it the simple way - */ - if (getuid() && !checkUser(action)) { - fprintf(stderr, _( - "You are not allowed to execute the action \"%s\".\n" - "Ask your system adminitrator to add you to the list\n" - "of people allowed to execute shutdown actions, by\n" - "adding your username to the file %s.\n"), action, - PATH_SHUTDOWNALLOW); - return(EXIT_FAILURE); - } - - /* - * XXX - I wonder if this is actually a good idea. - * - bm, 20040110 - */ -#if defined(POWEROFF_CMD) || defined(HALT_CMD) || defined(REBOOT_CMD) -#ifdef HAVE_CLEARENV - clearenv(); -#endif - xfce_setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin", 1); - xfce_setenv("IFS", " \t\n", 1); -#endif - - /* Ok, lets get this box down */ - if (!strcmp(action, "poweroff")) { -#ifdef POWEROFF_CMD - if (g_spawn_command_line_sync(POWEROFF_CMD, NULL, NULL, NULL, NULL)) - return(EXIT_SUCCESS); -#endif - - /* Ok, now the dirty way */ - execl("/sbin/poweroff", "poweroff", NULL); - execl("/sbin/halt", "halt", "-p", NULL); - /* FALLTHROUGH */ - } - - if (!strcmp(action, "reboot")) { -#ifdef REBOOT_CMD - if(g_spawn_command_line_sync(REBOOT_CMD, NULL, NULL, NULL, NULL)) - return(EXIT_SUCCESS); -#endif - execl("/sbin/reboot", "reboot", NULL); - /* FALLTHROUGH */ - } - -#ifdef HALT_CMD - if(g_spawn_command_line_sync(HALT_CMD, NULL, NULL, NULL, NULL)) - return(EXIT_SUCCESS); -#endif - execl("/sbin/halt", "halt", NULL); - - fprintf(stderr, _( - "Unable to shutdown this box. Please check your\n" - "installation, or contact your system administrator\n" - "and report the problem.\n")); - return(EXIT_FAILURE); - } - - /* try using sudo (should not return) */ - if (sudo(action)) { -#if 0 - /* - * Ok, sudo returned indicating success, that means, the - * system is about to go down, so idle a bit - */ - for (;;) - sleep(1); -#else - /* better return to caller here */ - return(EXIT_SUCCESS); -#endif - } - - fprintf(stderr, _( - "Got no way to shutdown the system. You should ask\n" - "your system administrator to either add your account\n" - "name to %s or to install sudo(8) and grant\n" - "you the right execute reboot and halt commands.\n"), - PATH_SHUTDOWNALLOW); - return(EXIT_FAILURE); -} diff --git a/xfce4-shutdown/xfce4-shutdown.1 b/xfce4-shutdown/xfce4-shutdown.1 deleted file mode 100644 index 65ec966d..00000000 --- a/xfce4-shutdown/xfce4-shutdown.1 +++ /dev/null @@ -1,30 +0,0 @@ -.TH xfce4-shutdown 1 "Dec 13, 2003" -.SH NAME -xfce4-shutdown \- System shutdown command used by xfce4-session(1) -.SH SYNOPSIS -.B xfce4-shutdown -.RI <action> -.br -.SH DESCRIPTION -This manual page documents briefly the -.B xfce4-shutdown -command. -.PP -The \fBxfce4-shutdown\fP is used by \fBxfce4-session\fP to either halt, -poweroff or reboot the system upon logout. For this to work, the users -that are allowed to stop the system need to be allowed to do so -via the \fBsudo\fP program or \fBxfce4-shutdown\fP needs to be setuid -root and the users listed in the file /etc/xfce4/shutdown.allow. - -.SH OPTIONS -\fBxfce4-shutdown\fP takes the action to execute as it's sole argument. -The value is one of "halt", "poweroff" or "reboot". - -.SH AUTHOR -\fBxfce4-shutdown\fP is written by Benedikt Meurer -<benedikt.meurer@unix-ag.uni-siegen.de> as part of the XFce project. -This manual page was written by Oliver M. Bolzer <oliver@debian.org>. - -.SH SEE ALSO -.BR xfce4-session(1) - diff --git a/xfsm-shutdown-helper/Makefile.am b/xfsm-shutdown-helper/Makefile.am new file mode 100644 index 00000000..2f5cfbaa --- /dev/null +++ b/xfsm-shutdown-helper/Makefile.am @@ -0,0 +1,11 @@ +libexec_PROGRAMS = \ + xfsm-shutdown-helper + +xfsm_shutdown_helper_SOURCES = \ + main.c + +xfsm_shutdown_helper_CFLAGS = \ + $(LIBXFCE4UTIL_CFLAGS) + +xfsm_shutdown_helper_LDFLAGS = \ + $(LIBXFCE4UTIL_LIBS) diff --git a/xfce4-shutdown/Makefile.in b/xfsm-shutdown-helper/Makefile.in index f09fc26e..27e0d08c 100644 --- a/xfce4-shutdown/Makefile.in +++ b/xfsm-shutdown-helper/Makefile.in @@ -14,7 +14,7 @@ @SET_MAKE@ -SOURCES = $(xfce4_shutdown_SOURCES) +SOURCES = $(xfsm_shutdown_helper_SOURCES) srcdir = @srcdir@ top_srcdir = @top_srcdir@ @@ -37,8 +37,8 @@ NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : host_triplet = @host@ -sbin_PROGRAMS = xfce4-shutdown$(EXEEXT) -subdir = xfce4-shutdown +libexec_PROGRAMS = xfsm-shutdown-helper$(EXEEXT) +subdir = xfsm-shutdown-helper DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/X11.m4 \ @@ -49,16 +49,16 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = -am__installdirs = $(DESTDIR)$(sbindir) $(DESTDIR)$(man1dir) -sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM) -PROGRAMS = $(sbin_PROGRAMS) -am_xfce4_shutdown_OBJECTS = xfce4_shutdown-main.$(OBJEXT) -xfce4_shutdown_OBJECTS = $(am_xfce4_shutdown_OBJECTS) -xfce4_shutdown_DEPENDENCIES = +am__installdirs = $(DESTDIR)$(libexecdir) +libexecPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(libexec_PROGRAMS) +am_xfsm_shutdown_helper_OBJECTS = xfsm_shutdown_helper-main.$(OBJEXT) +xfsm_shutdown_helper_OBJECTS = $(am_xfsm_shutdown_helper_OBJECTS) +xfsm_shutdown_helper_LDADD = $(LDADD) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles -@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/xfce4_shutdown-main.Po +@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/xfsm_shutdown_helper-main.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \ @@ -67,11 +67,8 @@ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \ CCLD = $(CC) LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(xfce4_shutdown_SOURCES) -DIST_SOURCES = $(xfce4_shutdown_SOURCES) -man1dir = $(mandir)/man1 -NROFF = nroff -MANS = $(man_MANS) +SOURCES = $(xfsm_shutdown_helper_SOURCES) +DIST_SOURCES = $(xfsm_shutdown_helper_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -160,6 +157,7 @@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ +SUDO = @SUDO@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XFCE_MCS_MANAGER_CFLAGS = @XFCE_MCS_MANAGER_CFLAGS@ @@ -213,19 +211,14 @@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ -man_MANS = xfce4-shutdown.1 -EXTRA_DIST = \ - $(man_MANS) - -xfce4_shutdown_SOURCES = \ +xfsm_shutdown_helper_SOURCES = \ main.c -xfce4_shutdown_CFLAGS = \ - @LIBXFCE4UTIL_CFLAGS@ \ - -DPATH_SHUTDOWNALLOW=\"$(sysconfdir)/xfce4/shutdown.allow\" +xfsm_shutdown_helper_CFLAGS = \ + $(LIBXFCE4UTIL_CFLAGS) -xfce4_shutdown_LDADD = \ - @LIBXFCE4UTIL_LIBS@ +xfsm_shutdown_helper_LDFLAGS = \ + $(LIBXFCE4UTIL_LIBS) all: all-am @@ -240,9 +233,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign xfce4-shutdown/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign xfsm-shutdown-helper/Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign xfce4-shutdown/Makefile + $(AUTOMAKE) --foreign xfsm-shutdown-helper/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ @@ -260,37 +253,37 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -install-sbinPROGRAMS: $(sbin_PROGRAMS) +install-libexecPROGRAMS: $(libexec_PROGRAMS) @$(NORMAL_INSTALL) - $(mkdir_p) $(DESTDIR)$(sbindir) - @list='$(sbin_PROGRAMS)'; for p in $$list; do \ + $(mkdir_p) $(DESTDIR)$(libexecdir) + @list='$(libexec_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ || test -f $$p1 \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f || exit 1; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(libexecPROGRAMS_INSTALL) $$p $(DESTDIR)$(libexecdir)/$$f"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(libexecPROGRAMS_INSTALL) $$p $(DESTDIR)$(libexecdir)/$$f || exit 1; \ else :; fi; \ done -uninstall-sbinPROGRAMS: +uninstall-libexecPROGRAMS: @$(NORMAL_UNINSTALL) - @list='$(sbin_PROGRAMS)'; for p in $$list; do \ + @list='$(libexec_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " rm -f $(DESTDIR)$(sbindir)/$$f"; \ - rm -f $(DESTDIR)$(sbindir)/$$f; \ + echo " rm -f $(DESTDIR)$(libexecdir)/$$f"; \ + rm -f $(DESTDIR)$(libexecdir)/$$f; \ done -clean-sbinPROGRAMS: - @list='$(sbin_PROGRAMS)'; for p in $$list; do \ +clean-libexecPROGRAMS: + @list='$(libexec_PROGRAMS)'; for p in $$list; do \ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ echo " rm -f $$p $$f"; \ rm -f $$p $$f ; \ done -xfce4-shutdown$(EXEEXT): $(xfce4_shutdown_OBJECTS) $(xfce4_shutdown_DEPENDENCIES) - @rm -f xfce4-shutdown$(EXEEXT) - $(LINK) $(xfce4_shutdown_LDFLAGS) $(xfce4_shutdown_OBJECTS) $(xfce4_shutdown_LDADD) $(LIBS) +xfsm-shutdown-helper$(EXEEXT): $(xfsm_shutdown_helper_OBJECTS) $(xfsm_shutdown_helper_DEPENDENCIES) + @rm -f xfsm-shutdown-helper$(EXEEXT) + $(LINK) $(xfsm_shutdown_helper_LDFLAGS) $(xfsm_shutdown_helper_OBJECTS) $(xfsm_shutdown_helper_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -298,7 +291,7 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfce4_shutdown-main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfsm_shutdown_helper-main.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @@ -324,29 +317,29 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< -xfce4_shutdown-main.o: main.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_shutdown_CFLAGS) $(CFLAGS) -MT xfce4_shutdown-main.o -MD -MP -MF "$(DEPDIR)/xfce4_shutdown-main.Tpo" -c -o xfce4_shutdown-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfce4_shutdown-main.Tpo" "$(DEPDIR)/xfce4_shutdown-main.Po"; else rm -f "$(DEPDIR)/xfce4_shutdown-main.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='xfce4_shutdown-main.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/xfce4_shutdown-main.Po' tmpdepfile='$(DEPDIR)/xfce4_shutdown-main.TPo' @AMDEPBACKSLASH@ +xfsm_shutdown_helper-main.o: main.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfsm_shutdown_helper_CFLAGS) $(CFLAGS) -MT xfsm_shutdown_helper-main.o -MD -MP -MF "$(DEPDIR)/xfsm_shutdown_helper-main.Tpo" -c -o xfsm_shutdown_helper-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfsm_shutdown_helper-main.Tpo" "$(DEPDIR)/xfsm_shutdown_helper-main.Po"; else rm -f "$(DEPDIR)/xfsm_shutdown_helper-main.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='xfsm_shutdown_helper-main.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/xfsm_shutdown_helper-main.Po' tmpdepfile='$(DEPDIR)/xfsm_shutdown_helper-main.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_shutdown_CFLAGS) $(CFLAGS) -c -o xfce4_shutdown-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfsm_shutdown_helper_CFLAGS) $(CFLAGS) -c -o xfsm_shutdown_helper-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c -xfce4_shutdown-main.obj: main.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_shutdown_CFLAGS) $(CFLAGS) -MT xfce4_shutdown-main.obj -MD -MP -MF "$(DEPDIR)/xfce4_shutdown-main.Tpo" -c -o xfce4_shutdown-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfce4_shutdown-main.Tpo" "$(DEPDIR)/xfce4_shutdown-main.Po"; else rm -f "$(DEPDIR)/xfce4_shutdown-main.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='xfce4_shutdown-main.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/xfce4_shutdown-main.Po' tmpdepfile='$(DEPDIR)/xfce4_shutdown-main.TPo' @AMDEPBACKSLASH@ +xfsm_shutdown_helper-main.obj: main.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfsm_shutdown_helper_CFLAGS) $(CFLAGS) -MT xfsm_shutdown_helper-main.obj -MD -MP -MF "$(DEPDIR)/xfsm_shutdown_helper-main.Tpo" -c -o xfsm_shutdown_helper-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfsm_shutdown_helper-main.Tpo" "$(DEPDIR)/xfsm_shutdown_helper-main.Po"; else rm -f "$(DEPDIR)/xfsm_shutdown_helper-main.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='xfsm_shutdown_helper-main.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/xfsm_shutdown_helper-main.Po' tmpdepfile='$(DEPDIR)/xfsm_shutdown_helper-main.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_shutdown_CFLAGS) $(CFLAGS) -c -o xfce4_shutdown-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfsm_shutdown_helper_CFLAGS) $(CFLAGS) -c -o xfsm_shutdown_helper-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi` -xfce4_shutdown-main.lo: main.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_shutdown_CFLAGS) $(CFLAGS) -MT xfce4_shutdown-main.lo -MD -MP -MF "$(DEPDIR)/xfce4_shutdown-main.Tpo" -c -o xfce4_shutdown-main.lo `test -f 'main.c' || echo '$(srcdir)/'`main.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfce4_shutdown-main.Tpo" "$(DEPDIR)/xfce4_shutdown-main.Plo"; else rm -f "$(DEPDIR)/xfce4_shutdown-main.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='xfce4_shutdown-main.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/xfce4_shutdown-main.Plo' tmpdepfile='$(DEPDIR)/xfce4_shutdown-main.TPlo' @AMDEPBACKSLASH@ +xfsm_shutdown_helper-main.lo: main.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfsm_shutdown_helper_CFLAGS) $(CFLAGS) -MT xfsm_shutdown_helper-main.lo -MD -MP -MF "$(DEPDIR)/xfsm_shutdown_helper-main.Tpo" -c -o xfsm_shutdown_helper-main.lo `test -f 'main.c' || echo '$(srcdir)/'`main.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfsm_shutdown_helper-main.Tpo" "$(DEPDIR)/xfsm_shutdown_helper-main.Plo"; else rm -f "$(DEPDIR)/xfsm_shutdown_helper-main.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='xfsm_shutdown_helper-main.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/xfsm_shutdown_helper-main.Plo' tmpdepfile='$(DEPDIR)/xfsm_shutdown_helper-main.TPlo' @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_shutdown_CFLAGS) $(CFLAGS) -c -o xfce4_shutdown-main.lo `test -f 'main.c' || echo '$(srcdir)/'`main.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfsm_shutdown_helper_CFLAGS) $(CFLAGS) -c -o xfsm_shutdown_helper-main.lo `test -f 'main.c' || echo '$(srcdir)/'`main.c mostlyclean-libtool: -rm -f *.lo @@ -357,51 +350,6 @@ clean-libtool: distclean-libtool: -rm -f libtool uninstall-info-am: -install-man1: $(man1_MANS) $(man_MANS) - @$(NORMAL_INSTALL) - $(mkdir_p) $(DESTDIR)$(man1dir) - @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ - l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ - for i in $$l2; do \ - case "$$i" in \ - *.1*) list="$$list $$i" ;; \ - esac; \ - done; \ - for i in $$list; do \ - if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ - else file=$$i; fi; \ - ext=`echo $$i | sed -e 's/^.*\\.//'`; \ - case "$$ext" in \ - 1*) ;; \ - *) ext='1' ;; \ - esac; \ - inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ - inst=`echo $$inst | sed -e 's/^.*\///'`; \ - inst=`echo $$inst | sed '$(transform)'`.$$ext; \ - echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \ - $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \ - done -uninstall-man1: - @$(NORMAL_UNINSTALL) - @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ - l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ - for i in $$l2; do \ - case "$$i" in \ - *.1*) list="$$list $$i" ;; \ - esac; \ - done; \ - for i in $$list; do \ - ext=`echo $$i | sed -e 's/^.*\\.//'`; \ - case "$$ext" in \ - 1*) ;; \ - *) ext='1' ;; \ - esac; \ - inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ - inst=`echo $$inst | sed -e 's/^.*\///'`; \ - inst=`echo $$inst | sed '$(transform)'`.$$ext; \ - echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \ - rm -f $(DESTDIR)$(man1dir)/$$inst; \ - done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ @@ -478,9 +426,9 @@ distdir: $(DISTFILES) done check-am: all-am check: check-am -all-am: Makefile $(PROGRAMS) $(MANS) +all-am: Makefile $(PROGRAMS) installdirs: - $(mkdir_p) $(DESTDIR)$(sbindir) $(DESTDIR)$(man1dir) + $(mkdir_p) $(DESTDIR)$(libexecdir) install: install-am install-exec: install-exec-am install-data: install-data-am @@ -507,7 +455,7 @@ maintainer-clean-generic: @echo "it deletes files that may require special tools to rebuild." clean: clean-am -clean-am: clean-generic clean-libtool clean-sbinPROGRAMS \ +clean-am: clean-generic clean-libexecPROGRAMS clean-libtool \ mostlyclean-am distclean: distclean-am @@ -526,13 +474,13 @@ info: info-am info-am: -install-data-am: install-man +install-data-am: -install-exec-am: install-sbinPROGRAMS +install-exec-am: install-libexecPROGRAMS install-info: install-info-am -install-man: install-man1 +install-man: installcheck-am: @@ -554,22 +502,20 @@ ps: ps-am ps-am: -uninstall-am: uninstall-info-am uninstall-man uninstall-sbinPROGRAMS - -uninstall-man: uninstall-man1 +uninstall-am: uninstall-info-am uninstall-libexecPROGRAMS .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-sbinPROGRAMS ctags distclean \ + clean-libexecPROGRAMS clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-exec \ - install-exec-am install-info install-info-am install-man \ - install-man1 install-sbinPROGRAMS install-strip installcheck \ + install-exec-am install-info install-info-am \ + install-libexecPROGRAMS install-man install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags uninstall uninstall-am uninstall-info-am uninstall-man \ - uninstall-man1 uninstall-sbinPROGRAMS + tags uninstall uninstall-am uninstall-info-am \ + uninstall-libexecPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/xfsm-shutdown-helper/main.c b/xfsm-shutdown-helper/main.c new file mode 100644 index 00000000..917e1c57 --- /dev/null +++ b/xfsm-shutdown-helper/main.c @@ -0,0 +1,153 @@ +/* $Id$ */ +/*- + * Copyright (c) 2003-2004 Benedikt Meurer <benny@xfce.org> + * 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. + * + * XXX - since this program is executed with root permissions, it may not + * be a good idea to trust glib!! + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef HAVE_SYS_WAIT_H +#include <sys/wait.h> +#endif + +#ifdef HAVE_MEMORY_H +#include <memory.h> +#endif +#ifdef HAVE_SIGNAL_H +#include <signal.h> +#endif +#include <stdio.h> +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#include <glib.h> + +/* XXX */ +#ifdef POWEROFF_CMD +#undef POWEROFF_CMD +#endif +#ifdef REBOOT_CMD +#undef REBOOT_CMD +#endif + +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +#define POWEROFF_CMD "/sbin/shutdown -p now" +#define REBOOT_CMD "/sbin/shutdown -r now" +#else +#define POWEROFF_CMD "/sbin/shutdown -h now" +#define REBOOT_CMD "/sbin/shutdown -r now" +#endif + + +static gboolean +run (const gchar *command) +{ +#if defined(HAVE_SIGPROCMASK) + sigset_t sigset; +#endif + gboolean result; + gchar **argv; + gchar **envp; + GError *err; + gint status; + gint argc; + +#if defined(HAVE_SETSID) + setsid (); +#endif + +#if defined (HAVE_SIGPROCMASK) + sigemptyset (&sigset); + sigaddset (&sigset, SIGHUP); + sigaddset (&sigset, SIGINT); + sigprocmask (SIG_BLOCK, &sigset, NULL); +#endif + + result = g_shell_parse_argv (command, &argc, &argv, &err); + + if (result) + { + envp = g_new0 (gchar *, 1); + + result = g_spawn_sync (NULL, argv, envp, + G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | + G_SPAWN_STDERR_TO_DEV_NULL, + NULL, NULL, NULL, NULL, &status, &err); + + g_strfreev (envp); + g_strfreev (argv); + } + + if (!result) + { + g_error_free (err); + return FALSE; + } + + return (WIFEXITED (status) && WEXITSTATUS (status) == 0); +} + + +int +main (int argc, char **argv) +{ + gboolean succeed = FALSE; + char action[1024]; + + /* display banner */ + fprintf (stdout, "XFSM_SUDO_DONE "); + fflush (stdout); + + if (fgets (action, 1024, stdin) == NULL) + { + fprintf (stdout, "FAILED\n"); + return EXIT_FAILURE; + } + + if (strncasecmp (action, "POWEROFF", 8) == 0) + { + succeed = run (POWEROFF_CMD); + } + else if (strncasecmp (action, "REBOOT", 6) == 0) + { + succeed = run (REBOOT_CMD); + } + + if (succeed) + { + fprintf (stdout, "SUCCEED\n"); + return EXIT_SUCCESS; + } + + fprintf (stdout, "FAILED\n"); + return EXIT_FAILURE; +} + + |