Commit graph

18 commits

Author SHA1 Message Date
Simon McVittie
cd4e34408e dbus-launch-x11: print a window ID portably
On LP64 platforms, a Window is unsigned long.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-10-13 22:44:12 +01:00
Simon McVittie
8db5ca900f Be more const-correct
As a general design principle, strings that we aren't going to modify
should usually be const. When compiling with -Wwrite-strings, quoted
string constants are of type "const char *", causing compiler warnings
when they are assigned to char * variables.

Unfortunately, we need to add casts in a few places:

* _dbus_list_append(), _dbus_test_oom_handling() and similar generic
  "user-data" APIs take a void *, not a const void *, so we have
  to cast
* For historical reasons the execve() family of functions take a
  (char * const *), i.e. a constant pointer to an array of mutable
  strings, so again we have to cast
* _dbus_spawn_async_with_babysitter similarly takes a char **,
  although we can make it a little more const-correct by making it
  take (char * const *) like execve() does

This also incorporates a subsequent patch by Thomas Zimmermann to
put various string constants in static storage, which is a little
more efficient.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97357
2016-10-13 17:20:28 +01:00
Thomas Zimmermann
d0be2333d5 Fix warnings from compiler option '-Wshadow'
Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98192
2016-10-10 18:04:09 +01:00
Thiago Macieira
d64d5f996b Quote the DBUS_SESSION_BUS_ADDRESS variable in the shell file
Some D-Bus daemon versions set multiple addresses separated by semi-colon,
which breaks sourcing of the file.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=94746
Signed-off-by: Thiago Macieira <thiago@kde.org>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-06-30 13:51:20 +01:00
Simon McVittie
638828526a Fix spelling/grammatical mistakes detected by Debian's lintian(1)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=38284
Reviewed-by: Lennart Poettering <lennart@poettering.net>
2011-07-28 11:05:43 +01:00
Christian Dywan
916620ea96 Free session file early in dbus-launch
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=29881
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2011-01-05 14:55:42 +00:00
Christian Dywan
79b4e478d7 Check return value of XGetWindowProperty in x11_get_address
Reviewed-by: Thiago Macieira <thiago@kde.org>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=29881
2011-01-05 14:42:45 +00: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
Ralf Habacker
46df8b52d9 linux compile fix 2010-02-26 08:37:53 +01:00
Tobias Mueller
5baf2f856a Bug 21161 - Update the FSF address
No comment.

Signed-off-by: Colin Walters <walters@verbum.org>
2009-07-10 19:32:38 -04:00
Eamon Walsh
8f5c3e3c25 dbus-launch: use InputOnly X window
Working on SELinux policy for X, and came across this issue in dbus-launch:

Windows created for use as property/selection placeholders should be of
class InputOnly, since no drawing is ever done to them.

Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
Signed-off-by: Thiago Macieira <thiago@kde.org>
2009-03-20 09:08:37 +01:00
Colin Walters
193ebb7083 Make sure we call XFlush() on all code paths (FDO bug #15293) 2008-03-31 18:16:00 -04:00
Havoc Pennington
163555c7ab 2007-08-17 Havoc Pennington <hp@redhat.com>
* tools/dbus-launch-x11.c (set_address_in_x11): fix from Michael
	Lorenz to use long not int with XChangeProperty format 32

	* dbus/dbus-sysdeps-util-unix.c
	(_dbus_write_pid_to_file_and_pipe): factor this out, and use the
	same code in _dbus_become_daemon (where the parent writes the pid
	file and to the pid pipe) and in bus_context_new (where the daemon
	writes its own pid file and to its own pid pipe)

	* bus/bus.c (bus_context_new): close the pid pipe after we print
	to it. Also, don't write the pid to the pipe twice when we fork,
	someone reported this bug a long time ago.
2007-08-17 16:43:57 +00: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
Thiago Macieira
01b91ba121 * tools/dbus-launch-x11.c (get_session_file, init_x_atoms):
check if get_machine_uuid() returns NULL before proceeding any
        further: we can't init the X atoms or create a session file
        name if there is no machine ID.
	This solves a crash reported by some users if
        --exit-with-session was used without --autolaunch=<machine-id>
2006-10-26 17:34:49 +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