diff options
author | drochner <drochner> | 2007-04-11 20:25:38 +0000 |
---|---|---|
committer | drochner <drochner> | 2007-04-11 20:25:38 +0000 |
commit | 2476df667e1be5b0aa218e764877f32a39047f6b (patch) | |
tree | 350abcc47cf6893f212c7bd2f60da5a7e84e8990 /x11 | |
parent | 61e8952c9b9e79ae81621c04a90bbe8cb556a2e7 (diff) | |
download | pkgsrc-2476df667e1be5b0aa218e764877f32a39047f6b.tar.gz |
update to 2.18.0
This moves this pkg to the new stable gnome branch, too much to list here.
pkgsrc note: automatic dbus startup doesn't work well, it seems to
conflict with another dbus autostart. Better start the session with
"dbus-launch". gdm-2.18 will take care of that.
Diffstat (limited to 'x11')
-rw-r--r-- | x11/gnome-session/Makefile | 16 | ||||
-rw-r--r-- | x11/gnome-session/PLIST | 14 | ||||
-rw-r--r-- | x11/gnome-session/distinfo | 15 | ||||
-rw-r--r-- | x11/gnome-session/patches/patch-aa | 43 | ||||
-rw-r--r-- | x11/gnome-session/patches/patch-ab | 10 | ||||
-rw-r--r-- | x11/gnome-session/patches/patch-ac | 38 | ||||
-rw-r--r-- | x11/gnome-session/patches/patch-ad | 34 | ||||
-rw-r--r-- | x11/gnome-session/patches/patch-ae | 366 |
8 files changed, 38 insertions, 498 deletions
diff --git a/x11/gnome-session/Makefile b/x11/gnome-session/Makefile index 806f8c96960..2a0b7d72206 100644 --- a/x11/gnome-session/Makefile +++ b/x11/gnome-session/Makefile @@ -1,10 +1,9 @@ -# $NetBSD: Makefile,v 1.81 2007/03/21 12:05:55 wiz Exp $ +# $NetBSD: Makefile,v 1.82 2007/04/11 20:25:38 drochner Exp $ # -DISTNAME= gnome-session-2.16.2 -PKGREVISION= 1 +DISTNAME= gnome-session-2.18.0 CATEGORIES= x11 gnome -MASTER_SITES= ${MASTER_SITE_GNOME:=sources/gnome-session/2.16/} +MASTER_SITES= ${MASTER_SITE_GNOME:=sources/gnome-session/2.18/} SITES.gnome-splash-2.16.0.png= ${MASTER_SITE_LOCAL:=gnome-splash/} EXTRACT_SUFX= .tar.bz2 DISTFILES= ${DISTNAME}${EXTRACT_SUFX} gnome-splash-2.16.0.png @@ -56,15 +55,16 @@ BUILDLINK_DEPMETHOD.libXt?= build .include "../../x11/libSM/buildlink3.mk" .include "../../x11/libX11/buildlink3.mk" .include "../../x11/libXt/buildlink3.mk" +.include "../../graphics/hicolor-icon-theme/buildlink3.mk" post-extract: - ${MV} ${WRKSRC}/gnome-session/gnome-splash.png \ - ${WRKSRC}/gnome-session/gnome-splash-orig.png + ${MV} ${WRKSRC}/data/gnome-splash.png \ + ${WRKSRC}/data/gnome-splash-orig.png ${CP} ${DISTDIR}/gnome-splash-2.16.0.png \ - ${WRKSRC}/gnome-session/gnome-splash.png + ${WRKSRC}/data/gnome-splash.png post-install: - ${INSTALL_DATA} ${WRKSRC}/gnome-session/gnome-splash-orig.png \ + ${INSTALL_DATA} ${WRKSRC}/data/gnome-splash-orig.png \ ${PREFIX}/share/pixmaps/splash/gnome-splash-orig.png .include "../../mk/bsd.pkg.mk" diff --git a/x11/gnome-session/PLIST b/x11/gnome-session/PLIST index 9e68566419d..991616f32cb 100644 --- a/x11/gnome-session/PLIST +++ b/x11/gnome-session/PLIST @@ -1,4 +1,4 @@ -@comment $NetBSD: PLIST,v 1.15 2006/09/15 15:18:16 jmmv Exp $ +@comment $NetBSD: PLIST,v 1.16 2007/04/11 20:25:38 drochner Exp $ bin/gnome-session bin/gnome-session-properties bin/gnome-session-remove @@ -12,7 +12,11 @@ man/man5/default.session.5 share/applications/session-properties.desktop share/gconf/schemas/gnome-session.schemas share/gnome/default.session -share/gnome/default.wm +share/icons/hicolor/16x16/apps/session-properties.png +share/icons/hicolor/22x22/apps/session-properties.png +share/icons/hicolor/24x24/apps/session-properties.png +share/icons/hicolor/32x32/apps/session-properties.png +share/icons/hicolor/scalable/apps/session-properties.svg share/locale/af/LC_MESSAGES/gnome-session-2.0.mo share/locale/am/LC_MESSAGES/gnome-session-2.0.mo share/locale/ar/LC_MESSAGES/gnome-session-2.0.mo @@ -98,6 +102,12 @@ share/pixmaps/splash/gnome-splash-orig.png share/pixmaps/splash/gnome-splash.png @dirrm share/pixmaps/splash @comment in xdg-dirs: @dirrm share/pixmaps +@comment in hicolor-icon-theme: @dirrm share/icons/hicolor/scalable/apps +@comment in hicolor-icon-theme: @dirrm share/icons/hicolor/32x32/apps +@comment in hicolor-icon-theme: @dirrm share/icons/hicolor/24x24/apps +@comment in hicolor-icon-theme: @dirrm share/icons/hicolor/22x22/apps +@comment in hicolor-icon-theme: @dirrm share/icons/hicolor/16x16/apps +@comment in hicolor-icon-theme: @dirrm share/icons/hicolor @comment in gnome2-dirs: @dirrm share/gnome @comment in GConf2: @dirrm share/gconf/schemas @comment in xdg-dirs: @dirrm share/applications diff --git a/x11/gnome-session/distinfo b/x11/gnome-session/distinfo index f788e2d7f46..7b4a09cacfb 100644 --- a/x11/gnome-session/distinfo +++ b/x11/gnome-session/distinfo @@ -1,13 +1,10 @@ -$NetBSD: distinfo,v 1.29 2006/11/28 22:17:24 drochner Exp $ +$NetBSD: distinfo,v 1.30 2007/04/11 20:25:38 drochner Exp $ -SHA1 (gnome-session-2.16.2.tar.bz2) = 37cbad34ce329c2109e5336bfe83a26f8ef44987 -RMD160 (gnome-session-2.16.2.tar.bz2) = aedb9906c7968080b5e5db044097c9294112d09a -Size (gnome-session-2.16.2.tar.bz2) = 681853 bytes +SHA1 (gnome-session-2.18.0.tar.bz2) = ab01a84f9ad78db85028192698cd1d6157fd8163 +RMD160 (gnome-session-2.18.0.tar.bz2) = c12e91cb49cd8314f9dbca69981fe93f65ece9fb +Size (gnome-session-2.18.0.tar.bz2) = 707392 bytes SHA1 (gnome-splash-2.16.0.png) = 0d321be84c5668a2c0fecb494edc820d6b74ee9d RMD160 (gnome-splash-2.16.0.png) = 28667abaaef6ac20dde9f4101554a5043b4f9c96 Size (gnome-splash-2.16.0.png) = 36601 bytes -SHA1 (patch-aa) = 3a7bac87c0031ea73bf313d3a2dcb983b83d7cbf -SHA1 (patch-ab) = 7287c9f0a921f2dfe28373027a4f3564d58e5ac8 -SHA1 (patch-ac) = 315fc1edf2cb23bd6cd895604a78eee6b3e0e6ca -SHA1 (patch-ad) = 42aa7867f6b660e5eb4b59eb5d74a97a38078fe5 -SHA1 (patch-ae) = a1e2996e9c8ffa8afdc92e60172d9baee285e1a6 +SHA1 (patch-aa) = 817579fb223f59e5d86fd041585a714f9262cf89 +SHA1 (patch-ab) = b274bbe433151383ee0f2117dd2fb5746920be75 diff --git a/x11/gnome-session/patches/patch-aa b/x11/gnome-session/patches/patch-aa index 98d8fa162ca..b8136c0f4c8 100644 --- a/x11/gnome-session/patches/patch-aa +++ b/x11/gnome-session/patches/patch-aa @@ -1,42 +1,13 @@ -$NetBSD: patch-aa,v 1.7 2006/04/01 17:36:41 jmmv Exp $ +$NetBSD: patch-aa,v 1.8 2007/04/11 20:25:38 drochner Exp $ -http://bugzilla.gnome.org/show_bug.cgi?id=336237 -The GONFTOOL_CMD change does not belong to the bug report! - ---- gnome-session/Makefile.in.orig 2006-03-13 21:53:02.000000000 +0100 +--- gnome-session/Makefile.in.orig 2007-03-12 19:59:22.000000000 +0100 +++ gnome-session/Makefile.in -@@ -65,7 +65,7 @@ am__objects_1 = egg-screen-exec.$(OBJEXT - am_gnome_session_OBJECTS = manager.$(OBJEXT) ice.$(OBJEXT) \ - main.$(OBJEXT) prop.$(OBJEXT) save.$(OBJEXT) command.$(OBJEXT) \ - remote.$(OBJEXT) logout.$(OBJEXT) splash-widget.$(OBJEXT) \ -- gsm-xrandr.$(OBJEXT) gsm-keyring.$(OBJEXT) gsm-gsd.$(OBJEXT) \ -+ gsm-xrandr.$(OBJEXT) gsm-dbus.$(OBJEXT) gsm-keyring.$(OBJEXT) gsm-gsd.$(OBJEXT) \ - gsm-protocol.$(OBJEXT) gsm-remote-desktop.$(OBJEXT) \ - gsm-sound.$(OBJEXT) gsm-at-startup.$(OBJEXT) \ - gsm-multiscreen.$(OBJEXT) gsm-typebuiltins.$(OBJEXT) \ -@@ -323,7 +323,7 @@ INCLUDES = \ - -DREBOOT_COMMAND=\""$(REBOOT_COMMAND)\"" \ - -DHALT_COMMAND=\""$(HALT_COMMAND)\"" \ +@@ -309,7 +309,7 @@ INCLUDES = \ + -DGNOME_KEYRING_DAEMON=\""$(GNOME_KEYRING_DAEMON)"\" \ + -DGNOME_ICONDIR=\""$(datadir)/pixmaps\"" \ -DRSH_COMMAND=\""$(RSH_COMMAND)\"" \ - -DGCONFTOOL_CMD=\""$(GCONFTOOL)\"" \ + -DGCONFTOOL_CMD=\""$(REAL_GCONFTOOL)\"" \ -DDEFAULTDIR="\"$(defaultdir)\"" \ - -DESD_SERVER="\"$(ESD_SERVER)\"" - -@@ -386,6 +386,8 @@ gnome_session_SOURCES = \ - splash-widget.h \ - gsm-xrandr.c \ - gsm-xrandr.h \ -+ gsm-dbus.c \ -+ gsm-dbus.h \ - gsm-keyring.c \ - gsm-keyring.h \ - gsm-gsd.c \ -@@ -602,6 +604,7 @@ distclean-compile: - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gsm-client-list.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gsm-client-row.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gsm-gsd.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gsm-dbus.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gsm-keyring.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gsm-multiscreen.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gsm-protocol.Po@am__quote@ + -DESD_SERVER="\"$(ESD_SERVER)\"" \ + -DAT_SPI_REGISTRYD_DIR="\"$(AT_SPI_REGISTRYD_DIR)\"" diff --git a/x11/gnome-session/patches/patch-ab b/x11/gnome-session/patches/patch-ab index 2228c4ceef7..a82b0127bdc 100644 --- a/x11/gnome-session/patches/patch-ab +++ b/x11/gnome-session/patches/patch-ab @@ -1,12 +1,12 @@ -$NetBSD: patch-ab,v 1.4 2005/01/11 12:36:24 jmmv Exp $ +$NetBSD: patch-ab,v 1.5 2007/04/11 20:25:38 drochner Exp $ ---- configure.orig 2004-10-12 17:57:32.000000000 +0200 +--- configure.orig 2007-03-12 19:59:01.000000000 +0100 +++ configure -@@ -24686,6 +24686,7 @@ case "$GNOME_SESSION_LIBS" in +@@ -26374,6 +26374,7 @@ case "$GNOME_SESSION_LIBS" in GNOME_HAVE_SM=no ;; esac +GNOME_HAVE_SM=yes - echo "$as_me:$LINENO: result: $GNOME_HAVE_SM" >&5 - echo "${ECHO_T}$GNOME_HAVE_SM" >&6 + { echo "$as_me:$LINENO: result: $GNOME_HAVE_SM" >&5 + echo "${ECHO_T}$GNOME_HAVE_SM" >&6; } if test "$GNOME_HAVE_SM" = no ; then diff --git a/x11/gnome-session/patches/patch-ac b/x11/gnome-session/patches/patch-ac deleted file mode 100644 index bc131c3455a..00000000000 --- a/x11/gnome-session/patches/patch-ac +++ /dev/null @@ -1,38 +0,0 @@ -$NetBSD: patch-ac,v 1.9 2006/11/28 22:17:24 drochner Exp $ - ---- gnome-session/main.c.orig 2006-11-20 00:24:40.000000000 +0100 -+++ gnome-session/main.c -@@ -43,6 +43,7 @@ - #include "command.h" - #include "splash-widget.h" - #include "util.h" -+#include "gsm-dbus.h" - #include "gsm-sound.h" - #include "gsm-gsd.h" - #include "gsm-proxy.h" -@@ -336,6 +337,7 @@ main (int argc, char *argv[]) - char **versions; - GConfClient *gconf_client; - GOptionContext *goption_context; -+ gboolean dbus_daemon_owner; - - if (getenv ("GSM_VERBOSE_DEBUG")) - gsm_set_verbose (TRUE); -@@ -420,6 +422,7 @@ main (int argc, char *argv[]) - fprintf (stderr, "SESSION_MANAGER=%s\n", getenv ("SESSION_MANAGER")); - gnome_window_icon_set_default_from_file (GNOME_ICONDIR"/gnome-session.png"); - -+ dbus_daemon_owner = gsm_dbus_daemon_start (); - - /* Make sure children see the right value for DISPLAY. This is - useful if --display was specified on the command line. */ -@@ -506,6 +509,9 @@ main (int argc, char *argv[]) - - gsm_keyring_daemon_stop (); - -+ if (dbus_daemon_owner) -+ gsm_dbus_daemon_stop (); -+ - g_object_unref (gconf_client); - gsm_shutdown_gconfd (); - diff --git a/x11/gnome-session/patches/patch-ad b/x11/gnome-session/patches/patch-ad deleted file mode 100644 index 5034aee73cb..00000000000 --- a/x11/gnome-session/patches/patch-ad +++ /dev/null @@ -1,34 +0,0 @@ -$NetBSD: patch-ad,v 1.3 2006/04/01 17:36:41 jmmv Exp $ - -http://bugzilla.gnome.org/show_bug.cgi?id=336237 - ---- /dev/null 2006-04-01 19:01:40.000000000 +0200 -+++ gnome-session/gsm-dbus.h 2006-04-01 19:02:57.000000000 +0200 -@@ -0,0 +1,27 @@ -+/* gsm-dbus.h - Handle the dbus-daemon process. -+ * -+ * Copyright (c) 2006 Julio M. Merino Vidal <jmmv@NetBSD.org> -+ * -+ * 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 GSM_DBUS_H -+#define GSM_DBUS_H -+ -+gboolean gsm_dbus_daemon_start (void); -+void gsm_dbus_daemon_stop (void); -+ -+#endif /* GSM_DBUS_H */ diff --git a/x11/gnome-session/patches/patch-ae b/x11/gnome-session/patches/patch-ae deleted file mode 100644 index 5b159543c80..00000000000 --- a/x11/gnome-session/patches/patch-ae +++ /dev/null @@ -1,366 +0,0 @@ -$NetBSD: patch-ae,v 1.4 2006/04/02 11:07:28 jmmv Exp $ - -http://bugzilla.gnome.org/show_bug.cgi?id=336237 - ---- gnome-session/gsm-dbus.c.orig 2006-04-02 12:32:32.000000000 +0200 -+++ gnome-session/gsm-dbus.c -@@ -0,0 +1,359 @@ -+/* gsm-dbus.c - Handle the dbus-daemon process. -+ * -+ * Copyright (c) 2006 Julio M. Merino Vidal <jmmv@NetBSD.org> -+ * -+ * 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. -+ */ -+ -+#if HAVE_CONFIG_H -+#include "config.h" -+#endif -+ -+#include <sys/wait.h> -+ -+#include <errno.h> -+#include <limits.h> -+#include <signal.h> -+#include <stdlib.h> -+#include <unistd.h> -+ -+#include <glib.h> -+#include <glib/gprintf.h> -+ -+#include "gsm-dbus.h" -+ -+static pid_t dbus_daemon_pid = 0; -+ -+static gboolean have_dbus_daemon (void); -+static gboolean have_running_instance (void); -+static int read_line (int, char *, ssize_t); -+static void start_child (int, int); -+static void start_parent (int, int, pid_t); -+ -+/* --------------------------------------------------------------------- -+ * PUBLIC INTERFACE -+ * --------------------------------------------------------------------- */ -+ -+/* -+ * Starts the dbus-daemon if not already running and attaches it to the -+ * current environment by defining DBUS_SESSION_BUS_ADDRESS. Returns -+ * true if we launch a new dbus-daemon so that we know if we have to call -+ * gsm_dbus_daemon_stop later on or not. -+ * -+ * This function can only be called if dbus-daemon is not already running -+ * (i.e., if gnome-session is starting up or if gsm_dbus_daemon_stop was -+ * previously called). -+ */ -+gboolean -+gsm_dbus_daemon_start (void) -+{ -+ int address_pipe[2]; -+ int pid_pipe[2]; -+ pid_t tmp_pid; -+ -+ g_assert (dbus_daemon_pid == 0); -+ -+ if (have_running_instance ()) -+ return FALSE; -+ if (! have_dbus_daemon ()) -+ return FALSE; -+ -+ /* -+ * At this point, dbus-daemon is not running for the current session -+ * and the binary exists. Spawn it. -+ */ -+ -+ if (pipe (address_pipe) == -1) -+ { -+ g_printerr ("Cannot create address pipe for dbus-daemon\n"); -+ return FALSE; -+ } -+ -+ if (pipe (pid_pipe) == -1) -+ { -+ close (address_pipe[0]); -+ close (address_pipe[1]); -+ g_printerr ("Cannot create pid pipe for dbus-daemon\n"); -+ return FALSE; -+ } -+ -+ tmp_pid = fork (); -+ if (tmp_pid == -1) -+ { -+ close (address_pipe[0]); -+ close (address_pipe[1]); -+ close (pid_pipe[0]); -+ close (pid_pipe[1]); -+ g_printerr ("Cannot create child process for dbus-daemon\n"); -+ return FALSE; -+ } -+ else if (tmp_pid == 0) -+ { -+ close (address_pipe[0]); -+ close (pid_pipe[0]); -+ start_child (address_pipe[1], pid_pipe[1]); -+ /* NOTREACHED */ -+ } -+ else -+ { -+ close (address_pipe[1]); -+ close (pid_pipe[1]); -+ start_parent (address_pipe[0], pid_pipe[0], tmp_pid); -+ } -+ -+ g_assert (dbus_daemon_pid != 0); -+ return TRUE; -+} -+ -+/* -+ * Stops the running dbus-daemon. Can only be called if we own the process; -+ * i.e., if gsm_dbus_daemon_start returned true. -+ */ -+void -+gsm_dbus_daemon_stop (void) -+{ -+ g_assert (dbus_daemon_pid != 0); -+ -+ if (kill (dbus_daemon_pid, SIGTERM) == -1) -+ g_printerr ("Failed to kill dbus-daemon (pid %d)\n", -+ dbus_daemon_pid); -+ else -+ { -+ dbus_daemon_pid = 0; -+ g_unsetenv ("DBUS_SESSION_BUS_ADDRESS"); -+ } -+} -+ -+/* --------------------------------------------------------------------- -+ * PRIVATE FUNCTIONS -+ * --------------------------------------------------------------------- */ -+ -+/* -+ * Check whether the dbus-daemon binary is in the path and raise an -+ * appropriate error message if it is not. -+ */ -+static gboolean -+have_dbus_daemon (void) -+{ -+ gboolean result; -+ gchar *file_name; -+ -+ file_name = g_find_program_in_path ("dbus-daemon"); -+ if (file_name == NULL) -+ g_printerr ("Cannot locate dbus-daemon\n"); -+ result = file_name != NULL; -+ g_free (file_name); -+ -+ return result; -+} -+ -+/* -+ * Check whether there is a dbus-daemon session instance currently running -+ * (not spawned by us). If there is, do nothing and return TRUE. -+ */ -+static gboolean -+have_running_instance (void) -+{ -+ const gchar *address_str; -+ -+ g_assert (dbus_daemon_pid == 0); -+ -+ address_str = g_getenv ("DBUS_SESSION_BUS_ADDRESS"); -+ return address_str != NULL; -+} -+ -+/* -+ * Reads a single line from the given file descriptor and stores it in the -+ * buffer pointed to by 'buf'. -+ * -+ * After finding the first new line character, the function returns. This -+ * is to avoid reading dbus' pid multiple times from its file descriptor. -+ */ -+static int -+read_line (int fd, char *buf, ssize_t bufsize) -+{ -+ gboolean discard, done; -+ ssize_t bytes; -+ -+ bytes = 0; -+ discard = FALSE; -+ done = FALSE; -+ do -+ { -+ ssize_t i, result; -+ -+ result = read (fd, &buf[bytes], bufsize - bytes); -+ if (result < 0) -+ return -1; -+ else if (result > 0 && !discard) -+ { -+ if (bytes + result < bufsize) -+ bytes += result; -+ else -+ bytes = bufsize - 1; -+ } -+ else -+ done = TRUE; -+ -+ for (i = 0; !discard && i < bytes; i++) -+ if (buf[i] == '\n') -+ { -+ buf[i] = '\0'; -+ discard = TRUE; -+ } -+ } -+ while (!done); -+ -+ g_assert (bytes >= 0 && bytes < bufsize); -+ buf[bytes] = '\0'; -+ -+ return bytes; -+} -+ -+/* -+ * Code run by the child process after the fork to launch dbus-demon. -+ * -+ * As the child, this execs dbus-daemon, connecting it to the appropriate -+ * file descriptors. -+ */ -+static void -+start_child (int address_fd, int pid_fd) -+{ -+ gchar address_str[16]; -+ gchar pid_str[16]; -+ int fd; -+ long open_max; -+ -+ open_max = sysconf (_SC_OPEN_MAX); -+ for (fd = 0; fd < open_max; fd++) -+ { -+ if (fd != STDIN_FILENO && fd != STDOUT_FILENO && fd != STDERR_FILENO && -+ fd != address_fd && fd != pid_fd) -+ close (fd); -+ } -+ -+ g_snprintf (address_str, sizeof (address_str), "%d", address_fd); -+ g_snprintf (pid_str, sizeof (pid_str), "%d", pid_fd); -+ -+ execlp ("dbus-daemon", -+ "dbus-daemon", -+ "--fork", -+ "--print-address", address_str, -+ "--print-pid", pid_str, -+ "--session", -+ NULL); -+ -+ g_printerr ("Could not launch dbus-daemon\n"); -+ -+ exit (EXIT_FAILURE); -+} -+ -+/* -+ * Code run by the parent process after the fork to launch dbus-demon. -+ * -+ * As the parent, this waits until dbus-daemon forks itself again and -+ * fetches its address and pid to later take its ownership. -+ */ -+static void -+start_parent (int address_fd, int pid_fd, pid_t child) -+{ -+ char address_str[256]; -+ char pid_str[256]; -+ char *tmp_ep; -+ int exitstat; -+ unsigned long tmp_num; -+ ssize_t bytes; -+ -+ g_assert (child > 0); -+ -+ /* -+ * dbus-daemon --fork causes our child process to exit prematurely -+ * because it is not the real daemon. See if it worked correctly -+ * and clean it up to avoid a zombie. -+ * -+ * Life could be much easier if dbus-daemon had a --no-fork flag. -+ * But, as it hasn't it, we cannot assume that it will not fork, -+ * because we have no control over its configuration file. -+ */ -+ if (waitpid (child, &exitstat, 0) == -1) -+ { -+ close (address_fd); -+ close (pid_fd); -+ -+ g_printerr ("Failed to get dbus-daemon status\n"); -+ return; -+ } -+ if (!WIFEXITED (exitstat) || WEXITSTATUS (exitstat) != EXIT_SUCCESS) -+ { -+ close (address_fd); -+ close (pid_fd); -+ -+ g_printerr ("dbus-daemon exited unexpectedly\n"); -+ return; -+ } -+ -+ /* -+ * Fetch dbus-daemon address. -+ */ -+ bytes = read_line (address_fd, address_str, sizeof (address_str)); -+ if (bytes == -1 || bytes == 0) -+ { -+ close (address_fd); -+ close (pid_fd); -+ -+ g_printerr ("Failed to get dbus-daemon's address\n"); -+ return; -+ } -+ -+ /* -+ * Fetch dbus-daemon pid. -+ */ -+ bytes = read_line (pid_fd, pid_str, sizeof (pid_str)); -+ if (bytes == -1 || bytes == 0) -+ { -+ close (address_fd); -+ close (pid_fd); -+ -+ g_printerr ("Failed to get dbus-daemon's pid\n"); -+ return; -+ } -+ -+ close (address_fd); -+ close (pid_fd); -+ -+ /* -+ * Convert the string printed in pid_fd to a pid value. Do the usual -+ * strtoul dance to check for a valid number. -+ */ -+ errno = 0; -+ tmp_num = strtoul(pid_str, &tmp_ep, 10); -+ if (pid_str[0] == '\0' || *tmp_ep != '\0') -+ { -+ g_printerr ("dbus-daemon pid invalid (not a number)\n"); -+ return; -+ } -+ if (errno == ERANGE && tmp_num == ULONG_MAX) -+ { -+ g_printerr ("dbus-daemon pid invalid (out of range)\n"); -+ return; -+ } -+ dbus_daemon_pid = tmp_num; -+ -+ /* -+ * All right! Tell our future children about the new born dbus-daemon. -+ */ -+ g_setenv ("DBUS_SESSION_BUS_ADDRESS", address_str, TRUE); -+} |