diff options
author | Havoc Pennington <hp@redhat.com> | 2003-05-04 03:22:46 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2003-05-04 03:22:46 +0000 |
commit | c0158234d046381a6bc8c004c82577576977d0d7 (patch) | |
tree | dd0c727dc8447837d06338083e7da6994431b667 | |
parent | f60d798c5001070718407febeac42b63ddac314f (diff) |
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.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | bus/dbus-daemon-1.1.in | 7 | ||||
-rw-r--r-- | bus/main.c | 2 | ||||
-rw-r--r-- | configure.in | 27 | ||||
-rw-r--r-- | dbus/dbus-watch.c | 11 | ||||
-rw-r--r-- | tools/Makefile.am | 8 | ||||
-rw-r--r-- | tools/dbus-launch.1 | 54 | ||||
-rw-r--r-- | tools/dbus-launch.c | 89 |
8 files changed, 204 insertions, 3 deletions
@@ -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 diff --git a/bus/dbus-daemon-1.1.in b/bus/dbus-daemon-1.1.in index b57d1d35..3339aebc 100644 --- a/bus/dbus-daemon-1.1.in +++ b/bus/dbus-daemon-1.1.in @@ -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 @@ -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); } diff --git a/configure.in b/configure.in index b26a87e0..b36aeba9 100644 --- a/configure.in +++ b/configure.in @@ -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} diff --git a/dbus/dbus-watch.c b/dbus/dbus-watch.c index 18044e49..55b182b2 100644 --- a/dbus/dbus-watch.c +++ b/dbus/dbus-watch.c @@ -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) diff --git a/tools/Makefile.am b/tools/Makefile.am index 868b5028..c33caae7 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -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 index 00000000..9342423d --- /dev/null +++ b/tools/dbus-launch.1 @@ -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 index 00000000..b21c7e9d --- /dev/null +++ b/tools/dbus-launch.c @@ -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; +} |