2003-05-03 Havoc Pennington <hp@pobox.com>
authorHavoc Pennington <hp@redhat.com>
Sun, 4 May 2003 03:22:46 +0000 (03:22 +0000)
committerHavoc Pennington <hp@redhat.com>
Sun, 4 May 2003 03:22:46 +0000 (03:22 +0000)
* dbus/dbus-watch.c (dbus_watch_handle): warn and return if a
watch is invalid when handled

* tools/Makefile.am, tools/dbus-launch.c, tools/dbus-launch.1: add
dbus-launch utility to launch the bus from a shell script.  Didn't
actually implement dbus-launch yet, it's just a placeholder still.

ChangeLog
bus/dbus-daemon-1.1.in
bus/main.c
configure.in
dbus/dbus-watch.c
tools/Makefile.am
tools/dbus-launch.1 [new file with mode: 0644]
tools/dbus-launch.c [new file with mode: 0644]

index d13a78d..ac82795 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,15 @@
 
 2003-05-03  Havoc Pennington  <hp@pobox.com>
 
+       * dbus/dbus-watch.c (dbus_watch_handle): warn and return if a
+       watch is invalid when handled
+
+       * tools/Makefile.am, tools/dbus-launch.c, tools/dbus-launch.1: add
+       dbus-launch utility to launch the bus from a shell script.  Didn't
+       actually implement dbus-launch yet, it's just a placeholder still.
+       
+2003-05-03  Havoc Pennington  <hp@pobox.com>
+
        * bus/Makefile.am, bus/dbus-daemon-1.1.in: man page for the
        daemon; also documents daemon config file, so replaces
        doc/config-file.txt. Corrected some stuff from config-file.txt in
index b57d1d3..3339aeb 100644 (file)
@@ -49,6 +49,13 @@ The per-session daemon is used for various interprocess communication
 among desktop applications (however, it is not tied to X or the GUI 
 in any way).
 
+.PP
+There is no way to cause the D-BUS daemon to reload its configuration
+file (HUP will not do so). The reason is that changing configuration
+would break the semantics expected by applications connected to the
+message bus. Thus, changing configuration would require kicking all
+apps off the bus; so you may as well just restart the daemon.
+
 .SH OPTIONS
 The following options are supported:
 .TP
index ef3f013..de78368 100644 (file)
@@ -47,7 +47,7 @@ signal_handler (int sig)
 static void
 usage (void)
 {
-  fprintf (stderr, "dbus-daemon-1 [--version] [--session] [--system] [--config-file=FILE] [--print-address[=descriptor]]\n");
+  fprintf (stderr, "dbus-daemon-1 [--version] [--session] [--system] [--config-file=FILE] [--print-address[=DESCRIPTOR]]\n");
   exit (1);
 }
 
index b26a87e..b36aeba 100644 (file)
@@ -438,6 +438,27 @@ dnl Qt flags
 AC_SUBST(DBUS_QT_CXXFLAGS)
 AC_SUBST(DBUS_QT_LIBS)
 
+### X11 detection
+AC_PATH_XTRA
+DBUS_X_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
+DBUS_X_CFLAGS="$X_CFLAGS"
+AC_SUBST(DBUS_X_CFLAGS)
+AC_SUBST(DBUS_X_LIBS)
+
+## for now enable_x11 just tracks have_x11, 
+## there's no --enable-x11
+if test x$no_x = xyes ; then
+   have_x11=no
+   enable_x11=no
+else
+   have_x11=yes
+   enable_x11=yes
+fi
+
+if test x$enable_x11 = xyes ; then
+   AC_DEFINE(DBUS_BUILD_X11,1,[Build X11-dependent code])
+fi
+
 ### Documentation
 
 AC_PATH_PROG(DOXYGEN, doxygen, no)
@@ -605,6 +626,11 @@ test/data/valid-service-files/debug-echo.service
 test/data/valid-service-files/debug-segfault.service
 ])
 
+### FIXME it's bizarre that have_qt and have_glib are used
+### instead of enable_ - should fix things so that enable 
+### is always whether it's enabled, and have is always whether 
+### it was found.
+
 dnl ==========================================================================
 echo "
                     D-BUS $VERSION
@@ -627,6 +653,7 @@ echo "
         Building checks:          ${enable_checks}
         Building Qt bindings:     ${have_qt}
         Building GLib bindings:   ${have_glib}
+        Building X11 code:        ${enable_x11}
         Building documentation:   ${enable_docs}
         Using XML parser:         ${with_xml}
         Init scripts style:       ${with_init_scripts}
index 18044e4..55b182b 100644 (file)
@@ -565,6 +565,17 @@ dbus_bool_t
 dbus_watch_handle (DBusWatch    *watch,
                    unsigned int  flags)
 {
+#ifndef DBUS_DISABLE_CHECKS
+  if (watch->fd < 0 || watch->flags == 0)
+    {
+      _dbus_warn ("%s: Watch is invalid, it should have been removed\n",
+                  _DBUS_FUNCTION_NAME);
+      return TRUE;
+    }
+#endif
+    
+  _dbus_return_val_if_fail (watch->fd >= 0 /* fails if watch was removed */, TRUE);
+  
   _dbus_watch_sanitize_condition (watch, &flags);
 
   if (flags == 0)
index 868b502..c33caae 100644 (file)
@@ -6,7 +6,7 @@ else
 GLIB_TOOLS=
 endif
 
-bin_PROGRAMS=dbus-send $(GLIB_TOOLS)
+bin_PROGRAMS=dbus-send $(GLIB_TOOLS) dbus-launch
 
 dbus_send_SOURCES=                             \
        dbus-send.c
@@ -14,8 +14,12 @@ dbus_send_SOURCES=                           \
 dbus_monitor_SOURCES=                          \
        dbus-monitor.c
 
+dbus_launch_SOURCES=                           \
+       dbus-launch.c
+
 dbus_send_LDADD= $(top_builddir)/dbus/libdbus-1.la
 dbus_monitor_LDADD= $(top_builddir)/glib/libdbus-glib-1.la
+dbus_launch_LDADD= $(top_builddir)/dbus/libdbus-1.la
 
-man_MANS = dbus-send.1 dbus-monitor.1
+man_MANS = dbus-send.1 dbus-monitor.1 dbus-launch.1
 EXTRA_DIST = $(man_MANS)
diff --git a/tools/dbus-launch.1 b/tools/dbus-launch.1
new file mode 100644 (file)
index 0000000..9342423
--- /dev/null
@@ -0,0 +1,54 @@
+.\" 
+.\" dbus-launch manual page.
+.\" Copyright (C) 2003 Red Hat, Inc.
+.\"
+.TH dbus-launch 1
+.SH NAME
+dbus-launch \- Utility to start a message bus from a shell script
+.SH SYNOPSIS
+.PP
+.B dbus-launch [\-\-version] [\-\-exit-with-session]
+
+.SH DESCRIPTION
+
+The \fIdbus-launch\fP command is used to start \fIdbus-daemon-1\fP
+from a shell script. It would normally be called from a user's login
+scripts. Unlike the daemon itself, \fIdbus-launch\fP exits, so
+backticks or the $() construct can be used to read information from
+\fIdbus-launch\fP. \fIdbus-launch\fP prints information about the
+launched daemon in KEY=VALUE format.
+
+.PP
+See http://www.freedesktop.org/software/dbus/ for more information
+about D-BUS. See also the man page for \fIdbus-daemon-1\fP.
+
+.PP
+Here is an example of how to use \fIdbus-launch\fP with an 
+sh-compatible shell:
+.nf
+
+  VARIABLES=`dbus-launch`
+  eval $VARIABLES
+  echo "D-BUS per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS"
+
+.fi
+
+.SH OPTIONS
+The following options are supported:
+.TP
+.I "--exit-with-session"
+If this option is provided, a persistent "babysitter" process will be 
+created that watches stdin for HUP and tries to connect to the X
+server. If this process gets a HUP on stdin or loses its X connection,
+it kills the message bus daemon.
+
+.TP
+.I "--version"
+Print the version of dbus-launch
+
+.SH AUTHOR
+See http://www.freedesktop.org/software/dbus/doc/AUTHORS
+
+.SH BUGS
+Please send bug reports to the D-BUS mailing list or bug tracker,
+see http://www.freedesktop.org/software/dbus/
diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c
new file mode 100644 (file)
index 0000000..b21c7e9
--- /dev/null
@@ -0,0 +1,89 @@
+/* -*- mode: C; c-file-style: "gnu" -*- */
+/* dbus-launch.c  dbus-launch utility
+ *
+ * Copyright (C) 2003 Red Hat, Inc.
+ *
+ * Licensed under the Academic Free License version 1.2
+ * 
+ * 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 of the License, 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
+ *
+ */
+#include <config.h>
+#include <dbus/dbus.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#ifdef DBUS_BUILD_X11
+#include <X11/Xlib.h>
+#endif
+
+static void
+usage (void)
+{
+  fprintf (stderr, "dbus-launch [--version] [--exit-with-session]\n");
+  exit (1);
+}
+
+static void
+version (void)
+{
+  printf ("D-BUS Message Bus Launcher %s\n"
+          "Copyright (C) 2003 Red Hat, Inc.\n"
+          "This is free software; see the source for copying conditions.\n"
+          "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
+          VERSION);
+  exit (0);
+}
+
+int
+main (int argc, char **argv)
+{
+  const char *prev_arg;
+  dbus_bool_t exit_with_session;
+  int i;  
+
+  exit_with_session = FALSE;
+  
+  prev_arg = NULL;
+  i = 1;
+  while (i < argc)
+    {
+      const char *arg = argv[i];
+      
+      if (strcmp (arg, "--help") == 0 ||
+          strcmp (arg, "-h") == 0 ||
+          strcmp (arg, "-?") == 0)
+        usage ();
+      else if (strcmp (arg, "--version") == 0)
+        version ();
+      else if (strcmp (arg, "--exit-with-session") == 0)
+        exit_with_session = TRUE;
+      else
+        usage ();
+      
+      prev_arg = arg;
+      
+      ++i;
+    }
+  
+  
+  
+  return 0;
+}