Commit graph

44 commits

Author SHA1 Message Date
Michel HERMIER
9a9b0e2736 Don't leak temporary fds pointing to /dev/null
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=56927
[commit message added -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2012-11-09 16:02:01 +00:00
Simon McVittie
6ec9900bc1 Revert "dbus-launch: add --exit-with-x11 option"
This reverts commit fcc656d430.
2012-06-27 11:31:22 +01:00
Simon McVittie
fcc656d430 dbus-launch: add --exit-with-x11 option
This is more suitable for distributions' Xsession scripts: it verifies
that X is already available, and so never results in an attempt to poll
stdin.

Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39197
2012-06-15 13:10:16 +01:00
Simon McVittie
1785b37e43 dbus-launch: if using X to define the session lifetime, do not poll stdin
dbus-launch --exit-with-session attempts to scope the session length
to various things:

- if DISPLAY points to an X server, exit when the X session ends
- if stdin is a terminal, exit when end-of-file is reached
- if both are true, exit when one of them happens, whichever is first
- if neither is true, fail

These are not particularly useful semantics: if the session is scoped to
the X session, then the terminal from which dbus-launch was launched
is irrelevant. This also causes practical problems when dbus-launch
consumes characters from the terminal from which it happens to have
been launched (some display managers, like slim and nodm, run users' X
sessions with stdin pointing to the terminal from which the init daemon
happens to have started the display manager during boot, usually tty1
on Linux).

Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39197
2012-06-15 13:09:58 +01:00
Simon McVittie
ab0cebd883 document how the various processes in dbus-launch interact
Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39197
2012-06-15 13:09:14 +01:00
Simon McVittie
cea055514a Check for X even if X11 autolaunching is disabled
DBUS_ENABLE_X11_AUTOLAUNCH obviously requires DBUS_BUILD_X11. However,
the converse is not true.

If DBUS_BUILD_X11 is defined, dbus-launch will be able to connect to
the X server to determine when the session ends; most distributors will
want this, but it can be disabled with the standard Autoconf option
--without-x.

If DBUS_ENABLE_X11_AUTOLAUNCH is *also* defined, dbus-launch and libdbus
will be willing to perform autolaunch. Again, most distributors will want
this, but it can be disabled with --disable-x11-autolaunch.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=19997
Reviewed-by: Colin Walters <walters@verbum.org>
2011-05-25 17:38:44 +01:00
Simon McVittie
c559ec0525 dbus-launch: pass_info: always free strings on OOM
This doesn't really do anything, because we're about to exit anyway, but
it placates static analysis tools.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=29881
Bug-NB: NB#180486
Reviewed-by: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
2011-05-25 16:13:19 +01:00
Christian Dywan
b1f947da1a Free envvar and args in pass_info in the oom case 2010-10-05 13:47:07 +01:00
Havoc Pennington
ade5c7ad33 fix some "unused result" warnings in dbus-launch and dbus-spawn
Needed to avoid -Werror
2010-09-06 19:30:42 +02:00
Marcus Brinkmann
dbecdeabb2 Consistently include <config.h> in all C source files and never in header files. 2010-03-19 20:11:48 +01:00
Sascha Silbe
9b2c196ef3 Bug 23977 - dbus-launch --exit-with-session not killing dbus-daemon on SIGINT
Handle SIGINT in the same way we handle SIGTERM.
2009-10-16 15:20:43 -04:00
Tobias Mueller
dc33f4f774 Bug 21161 - Update the FSF address
No comment.

Signed-off-by: Colin Walters <walters@verbum.org>
(cherry picked from commit 5baf2f856a)
2009-07-14 15:39:47 -04:00
Kjartan Maraas
eb3b99e7c6 Bug 19502 - Sparse warning cleanups
This patch makes various things that should be static static,
corrects some "return FALSE" where it should be NULL, etc.

Signed-off-by: Colin Walters <walters@verbum.org>
2009-05-06 12:51:18 -04:00
Tor Lillqvist
1000270072 [win32] Protect usage of SIGHUP with #ifdef
Signed-off-by: Colin Walters <walters@verbum.org>
2009-01-06 18:21:25 -05:00
Colin Walters
0bfc5e8d23 Check for X11 events before selecting (FDO bug #15293) 2008-03-31 18:20:07 -04:00
John (J5) Palmieri
46b48ac654 tools/dbus-launch.c: wrap X'ism in #ifdef so we can compile without X 2008-03-04 10:03:14 -05:00
John (J5) Palmieri
7d409700c3 fixes dbus-launch so the bus goes away when X does (Red Hat Bug #430412)
* tools/dbus-launch.c (main): set xdisplay = NULL
* Patch by Matthias Clasen <mclasen at redhat.com>
+
2008-02-21 12:02:58 -05:00
Sjoerd Simons
ed47b4502b Allow a normal session bus to be reused by applications using autolaunching
2007-11-23  Sjoerd Simons  <sjoerd@luon.net>

   * tools/dbus-launch.c: let both a normal dbus-launch and an
   autolaunched bus save their parameters in X11 if possible. This makes
   the autolaunch and non-autolaunch behaviour more similar. With the
   exception that on a normal launch there will always be a new session
   bus and not being able to save parameters is not fatal. This also
   enables to launch programs directly with autolaunch (not very usefull
   though).
2007-11-23 11:31:05 +01:00
Simon McVittie
35b00e3ab2 dbus-launch: convert C++-style comment to C-style, add {} for clarity 2007-10-11 10:17:17 +01:00
John (J5) Palmieri
7d9d3fc031 fd.o bug #12547 remove superfluous if
* also convert tabs to spaces
2007-10-03 16:43:22 -04:00
Havoc Pennington
d012387afe 2007-07-13 Havoc Pennington <hp@redhat.com>
* Add indent-tabs-mode: nil to all file headers.
2007-07-14 02:44:01 +00:00
Havoc Pennington
9362aac398 2007-03-11 Havoc Pennington <hp@redhat.com>
* tools/dbus-launch.c (do_close_stderr): fix C89 problem and
	formatting problem

	* Mostly fix the DBusPipe mess.
	- put line break after function return types
	- put space before parens
	- do not pass structs around by value
	- don't use dbus_strerror after calling supposedly cross-platform
	api
	- don't name pipe variables "fd"
	- abstract special fd numbers like -1 and 1
2007-03-12 22:52:40 +00:00
Thiago Macieira
4ceb86d29a * dbus/dbus-sysdeps-unix.c: capture the dbus-launch stderr
output and add it to the DBusError message we return.

	* tools/dbus-launch.1:
	* tools/dbus-launch.c: Add option --close-stderr to, well,
	close stderr before starting dbus-daemon.
2007-03-03 10:36:46 +00:00
John (J5) Palmieri
a107da8489 * tools/dbus-launch.c (main): run the dbus-daemon in the builddir
if tests are enabled and the DBUS_USE_TEST_BINARY env variable is set

* tools/run-with-tmp-session-bus.sh: set DBUS_USE_TEST_BINARY
  before we run dbus-launch

* configure.in: define TEST_BUS_BINARY to be the full path to
  dbus-daemon in the build root
2006-10-26 15:55:44 +00:00
Thiago Macieira
c6e066ff82 * tools/dbus-launch.c (main): make it complain and abort
execution in case an unknown option is given. Also, process
	the '--' argument as the end of arguments.
2006-10-01 22:21:30 +00:00
Havoc Pennington
10fe37f582 2006-10-01 Havoc Pennington <hp@redhat.com>
* tools/dbus-launch.c (print_variables): if no syntax is given,
	don't print something that's sort-of-half-sh-syntax, just print
	a plain key-value pairs thing.

	* tools/dbus-launch-x11.c: use machine ID rather than hostname for
	the local machine representation (but still have the hostname in
	the display). Remove the hostname from the display if it is
	localhost. Change session files to be named
	~/.dbus/session-bus/machine-display. Change X atoms to be
	underscore-prefixed so nobody whines about ICCCM compliance.
	Otherwise name them the same as the env variables.
	Change session file format to include key-value pairs and an
	explanatory comment. Keys are the same as the env variables.
	(set_address_in_x11): X property format can't depend on
	sizeof(pid_t) on a particular machine, fix to always be 32 bits

	* tools/dbus-launch.c: make --autolaunch take a machine id
	argument. If --autolaunch is used with a program to run, complain
	for now (but add a FIXME). Also, don't look for existing bus if
	there's a program to run (but add a FIXME).

	* dbus/dbus-sysdeps-unix.c (_dbus_get_autolaunch_address): pass
	machine uuid to dbus-launch (avoids linking dbus-launch to libdbus
	just to get this, and avoids duplicating uuid-reading code).

	* tools/dbus-launch.1: clarify various things
2006-10-01 20:05:39 +00:00
Havoc Pennington
d8155bf51b 2006-09-30 Havoc Pennington <hp@redhat.com>
* configure.in (LT_CURRENT, LT_AGE): increment current and age to
	reflect addition of interfaces.

	* doc/dbus-specification.xml: describe a new
	org.freedesktop.DBus.Peer.GetMachineId method

	* dbus/dbus-string.c (_dbus_string_skip_white_reverse): new function
	(_dbus_string_skip_white, _dbus_string_skip_blank): use new
	DBUS_IS_ASCII_BLANK, DBUS_IS_ASCII_WHITE macros and fix assertion
	at end of skip_white
	(_dbus_string_chop_white): new function

	* bus/connection.c (bus_connections_setup_connection): call
	dbus_connection_set_route_peer_messages.

	* dbus/dbus-connection.c
	(_dbus_connection_peer_filter_unlocked_no_update): modify to
	support a GetMachineId method.

	Also, support a new flag to let the bus pass peer methods through
	to apps on the bus, which can be set with
	dbus_connection_set_route_peer_messages.

	Finally, handle and return an error for anything unknown on the
	Peer interface, which will allow us to extend the Peer interface
	in the future without fear that we're now intercepting something
	apps were wanting to see.

	* tools/dbus-uuidgen.c: a thin wrapper around the functions in
	dbus/dbus-uuidgen.c

	* dbus/dbus-uuidgen.c: implement the bulk of the dbus-uuidgen
	binary here, since most of the code is already in libdbus

	* dbus/dbus-sysdeps.c (_dbus_read_local_machine_uuid): read the
	uuid from the system config file

	* dbus/dbus-internals.c (_dbus_generate_uuid, _dbus_uuid_encode)
	(_dbus_read_uuid_file_without_creating)
	(_dbus_create_uuid_file_exclusively, _dbus_read_uuid_file): new
	uuid-related functions, partly factored out from dbus-server.c

	* dbus/dbus-sysdeps.c (_dbus_error_from_errno): convert EEXIST to
	DBUS_ERROR_FILE_EXISTS instead of EEXIST

	* dbus/dbus-protocol.h (DBUS_ERROR_FILE_EXISTS): add file exists error

	* tools/dbus-cleanup-sockets.1: explain what the point of this
	thing is a bit more

	* autogen.sh (run_configure): add --config-cache to default
	configure args

	* dbus/dbus-internals.h (_DBUS_ASSERT_ERROR_IS_SET): disable the
	error set/clear assertions when DBUS_DISABLE_CHECKS is defined

	* tools/dbus-launch.c (main): if xdisplay hasn't been opened,
	don't try to save address, fixes crash in make check
2006-10-01 03:18:47 +00:00
Thiago Macieira
f6fa010403 * configure.in: add DBUS_BINDIR as a #define to C source code.
* tools/dbus-launch.c
	* tools/dbus-launch.h
	* tools/dbus-launch-x11.c:
	* tools/dbus-launch.1: Add the --autolaunch option to
	dbus-launch, which makes it scan for an existing session
	started with --autolaunch. With that option, it also creates
	an X11 window and saves the bus address and PID to it.

	* dbus/dbus-sysdeps.h:
	* dbus/dbus-sysdeps-unix.c (_dbus_get_autolaunch_address): Add
	a function that runs "dbus-launch --autolaunch" to retrieve
	the running D-Bus session address (or start one if none was running)

	* dbus/dbus-transport.c: Add the handler for the "autolaunch:"
        address protocol, which tries to get the running session from
        dbus-launch.

	* dbus/dbus-bus.c:
	* dbus/dbus-internals.h: Make "autolaunch:" be the default
	D-Bus session bus address.

	* dbus/dbus-connection.c: Fix horrible typo in error message.
2006-09-30 19:38:34 +00:00
John (J5) Palmieri
ee6964d6a0 * tools/dbus-launch.c: Add a sigterm handler (patch from Frederic Crozat
<fcrozat at mandriva dot com>)
2006-09-01 20:47:09 +00:00
John (J5) Palmieri
aaa432b064 * configure.in:
* tools/Makefile.am:
* tools/dbus-launch.c:
* bus/Makefile.am:
  allow --with-dbus-daemondir switch to be used to make the
  daemon install to a seperate bindir like /usr/libexec
  (patch from Brian Cameron <brian dot cameron at sun dot com)
2006-08-08 21:30:31 +00:00
John (J5) Palmieri
7652304bff * s/D-BUS/D-Bus/g 2006-08-03 20:34:36 +00:00
John (J5) Palmieri
385c443cc7 2006-02-13 John (J5) Palmieri <johnp@redhat.com>
* tools/dbus-launch.c: Fixed sh syntax output
2006-02-13 21:01:32 +00:00
John (J5) Palmieri
8fcc91bf0b 2006-02-10 John (J5) Palmieri <johnp@redhat.com>
* tools/dbus-launch.c: Fixed csh syntax output (Bug #5720)
2006-02-10 21:28:52 +00:00
John (J5) Palmieri
0ca96ec548 * dbus/dbus-auth.c, dbus/dbus-connection.c, dbus/dbus-keyring.c,
dbus/dbus-server-debug-pipe.c, glib/dbus-binding-tool-glib.c
  glib/dbus-glib-tool.c, glib/dbus-gparser.c, glib/dbus-gproxy.c
  test/test-segfault.c, test/test-utils.c,
  test/glib/test-dbus-glib.c, tools/dbus-cleanup-sockets.c
  tools/dbus-launch.c, tools/dbus-tree-view.c, tools/dbus-viewer.c:
  Various cleanup of dead code and compiler warnings (patch from
  Kjartan Maraas <kmaraas at gnome.org>)
2005-11-30 19:32:27 +00:00
Colin Walters
9f92ac0ef5 2005-07-12 Colin Walters <walters@verbum.org>
Patch from Jim Gettys <Jim.Gettys@hp.com>.

	* tools/dbus-launch.c: Include sys/select.h.
2005-07-12 21:09:54 +00:00
Havoc Pennington
2abdb13ebe 2005-01-18 Havoc Pennington <hp@redhat.com>
* rename dbus-daemon-1 to dbus-daemon throughout
2005-01-18 22:20:38 +00:00
Havoc Pennington
43605a6f4e 2004-08-09 Havoc Pennington <hp@redhat.com>
* COPYING: switch to Academic Free License version 2.1 instead of
	2.0, to resolve complaints about patent termination clause.
2004-08-10 03:07:01 +00:00
Richard Hult
a1df3040f2 2003-12-02 Richard Hult <richard@imendio.com>
* Update AFL version to 2.0 throughout the source files to reflect
	the update that was done a while ago.
2003-12-02 10:44:22 +00:00
Havoc Pennington
d6e1b2adb3 2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
	execute, not both
	(bus_connections_check_reply): use unlink, not remove_link, as we
	don't want to free the link; fixes double free mess

	* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
	where no reply was received

	* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
	fix a refcount leak

	* bus/signals.c (match_rule_matches): add special cases for the
	bus driver, so you can match on sender/destination for it.

	* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
	DBUS_PRINT_BACKTRACE is set

	* dbus/dbus-internals.c: add pid to assertion failure messages

	* dbus/dbus-connection.c: add message type code to the debug spew

	* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
	sender=foo not service=foo

	* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
	session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
	DBUS_ACTIVATION_ADDRESS instead

	* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
	DBUS_SYSTEM_BUS_ADDRESS if appropriate

	* bus/bus.c (bus_context_new): handle OOM copying bus type into
	context struct

	* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
	(dbus_message_iter_get_object_path_array): new function (half
	finished, disabled for the moment)

	* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
	DBUS_MESSAGE_TYPE_ERROR

	* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
	avoid redirecting stderr to /dev/null
	(babysit): close stdin if not doing the "exit_with_session" thing

	* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
	debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
	stdout/stdin, so things don't get confused

	* bus/system.conf.in: fix to allow replies, I modified .conf
	instead of .conf.in again.
2003-10-16 06:34:51 +00:00
Havoc Pennington
4097e94af3 2003-10-12 Havoc Pennington <hp@pobox.com>
Added test code that 1) starts an actual bus daemon and 2) uses
	DBusGProxy; fixed bugs that were revealed by the test. Lots
	more testing possible, but this is the basic framework.

	* glib/dbus-gproxy.c (dbus_gproxy_manager_unregister): remove
	empty proxy lists from the proxy list hash

	* dbus/dbus-message.c (dbus_message_iter_get_args_valist): add a
	couple of return_if_fail checks

	* dbus/dbus-pending-call.c (_dbus_pending_call_new): use dbus_new0
	to allocate, so everything is cleared to NULL as it should be.

	* glib/dbus-gmain.c (dbus_connection_setup_with_g_main): pass
	source as data to dbus_connection_set_timeout_functions() as the
	timeout functions expected

	* test/glib/run-test.sh: add a little script to start up a message
	bus and run tests using it

	* tools/dbus-launch.1: updates

	* tools/dbus-launch.c (main): add --config-file option

	* tools/dbus-launch.c (main): remove confusing else if (runprog)
	that could never be reached.

	* dbus/dbus-message.c (dbus_message_new_method_return)
	(dbus_message_new_error, dbus_message_new_signal): set the
	no-reply-expected flag on all these. Redundant, but may
	as well be consistent.
2003-10-12 05:59:39 +00:00
Havoc Pennington
2ad05d5ce4 2003-07-16 Havoc Pennington <hp@pobox.com>
* tools/dbus-launch.c (babysit): close stdout/stderr in the
	babysitter process, as suggested by Thomas Leonard, so
	an "eval `dbus-launch --exit-with-session`" will actually
	return
2003-07-17 01:53:42 +00:00
Colin Walters
fc5e3a06cf 2003-05-17 Colin Walters <walters@gnu.org>
* tools/dbus-send.c: Don't exit with an error code if --help was
	passed.  Default to using the session bus instead of the system
	one.

	* tools/dbus-launch.c: Ditto.

	* tools/dbus-monitor.c: Ditto.

	* tools/dbus-send.1: Update with new arguments.

	* tools/dbus-launch.c: Emit code to export variables.  New
	arguments -s and -c to specify shell syntax, and a bit of code to
	autodetect syntax.  Also, allow specifying a program to run.

	* tools/dbus-launch.1: Update with new arguments.

	* tools/dbus-send.1: Ditto.

	* tools/dbus-monitor.1: Ditto.
2003-05-18 02:39:47 +00:00
Havoc Pennington
df01c98cc7 2003-05-04 Havoc Pennington <hp@pobox.com>
* tools/dbus-launch.c: implement

	* bus/main.c (main), bus/bus.c (bus_context_new):
	implement --print-pid and --fork
2003-05-04 08:54:24 +00:00
Havoc Pennington
c0158234d0 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-04 03:22:46 +00:00