Commit graph

4417 commits

Author SHA1 Message Date
Ralf Habacker
4d8a27701b Add cmake macro autoheaderchecks().
This macro prints out any include file defined as HAVE_..._H in the config
header template and not in the related cmake configure checks file.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=85418
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-05 13:52:57 +01:00
Ralf Habacker
8696bfdf07 Fix broken cmake HAVE_SOCKLEN_T type finding check.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=17289
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-05 08:14:24 +01:00
Simon McVittie
2d2b5af97d Add missing header for _dbus_sleep_milliseconds() (commit 43d2455) 2015-03-04 18:47:52 +00:00
Ralf Habacker
2c7abec29e Add test-fdpass to cmake build system.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=17289
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-04 18:43:54 +00:00
Simon McVittie
0d42526efa signal_handler: avoid signed/unsigned mismatch (-Wsign-compare)
We're ignoring the result of this write() to stderr anyway, because
if it failed... what would we do? Write to stderr? That wouldn't work
any better the second time :-)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=17289
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-03-04 18:41:15 +00:00
Ralf Habacker
08a75e07cb Enable -Wsign-compare for cmake builds.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=17289
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-03-04 18:41:01 +00:00
Simon McVittie
50bd76ac5b Autotools: enable -Wsign-compare and optionally -Werror=sign-compare
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=17289
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-03-04 18:40:53 +00:00
Simon McVittie
c3e345f15a fd-passing test: numbers of things are unsigned (-Wsign-compare)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=17289
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-03-04 18:40:47 +00:00
Simon McVittie
719829a41d _dbus_listen_systemd_sockets: fds are signed ints (-Wsign-compare)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=17289
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-03-04 18:40:39 +00:00
Simon McVittie
51a718c678 Use new _dbus_string_get_length_uint() to avoid another -Wsign-compare
DBusString's length is signed for historical reasons: the right type
would have been size_t or some other unsigned type. We have a *lot*
of callers of _dbus_string_get_length(), so it is not really desirable
to do a flag-day switch; but we know that the length is always in the
range [0, INT_MAX] that is common to int and unsigned int, so we can
safely add an unsigned accessor.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=17289
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-03-04 18:40:10 +00:00
Ralf Habacker
43d2455e19 Drop duplicated function tool_millisleep() and use dbus_sleep_milliseconds() instead.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89284
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-04 13:06:49 +01:00
Ralf Habacker
6588c65708 Fix warning 'conversion to ‘long unsigned int’ from ‘WriteResult’ may change the sign of the result [-Wsign-conversion]'.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89284
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-04 12:33:12 +01:00
Ralf Habacker
72549f316f Fix of 'warning: conversion to ‘dbus_bool_t‘ from ‘int‘ may change the sign of the result [-Wsign-conversion]'.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89284
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-04 12:32:53 +01:00
Ralf Habacker
0ee8a251ce Fix of 'warning: unused variable ‘result‘ [-Wunused-variable]'.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89284
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-04 12:32:53 +01:00
Ralf Habacker
50369c1219 Fix warning: conversion to 'DWORD' from 'int' may change the sign of the result [-Wsign-conversion].
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89284
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-04 12:32:53 +01:00
Ralf Habacker
d0fe556af1 Trivial -Wsign-compare fixes.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=17289
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-04 12:18:42 +01:00
Simon McVittie
073aa59f8c belatedly bump version for 1.9.15 2015-03-04 10:38:36 +00:00
Peter McCurdy
c701117672 Make all time values signed longs instead of a mix of signed and unsigned, to avoid compiler complaints.
check_timeout() tries to use some unsigned long variables to
perform some intermediate calculations, then has to cast
back to signed long. As it happens, there's no real chance
of overflowing a signed long (it'll only happen if the current
time is within 49.7 days of rolling over, at which point you're
already pretty doomed), so we can make the calculations a bit
simpler, and also avoid the mixed-signedness arithmetic we'd
otherwise need to do.

Bug: https://bugs.freedesktop.org/attachment.cgi?id=18494
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-03-04 09:56:40 +01:00
Ralf Habacker
dca6591fa2 Keep cmake defines GLIB_VERSION_... in sync with autotools.
This patch adds autotools related cmake macros autoinit() and autodefine().

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89284
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-03 16:37:32 +01:00
Simon McVittie
38e64d7571 prepare 1.9.14 2015-03-02 14:48:25 +00:00
Ralf Habacker
c803f0fbe1 Fix warning: 'the comparison will always evaluate as 'false' for the address of '....' will never be NULL [-Waddress]'
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89284
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-02 09:40:22 +01:00
Dimitri John Ledkov
57971f69ef Make include_dir non-existing directory, to not be an error.
Empty include directories were already not treated as failures.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89280
Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-25 15:59:24 +00:00
Simon McVittie
18c01b05b8 NEWS 2015-02-24 17:02:22 +00:00
Simon McVittie
6439ab73b3 monitor test: don't block in main context if we already have messages
Functions like become_monitor() sometimes iterate the main context,
which could leave us with unprocessed messages in f->monitored.
We need to drain that queue of unprocessed messages (setting flags
accordingly, which might meet the loop's exit condition or cause
a break) before we are willing to block in the main context again.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89222
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-24 17:00:26 +00:00
Simon McVittie
909762fd08 test_init: convert SIGALRM into SIGABRT so we leave a core dump on timeout
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89222
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-24 14:38:50 +00:00
Simon McVittie
c4279c1f37 NEWS 2015-02-24 13:43:17 +00:00
Ralf Habacker
267ec3b8ad dbus-monitor: Keep term 'dest' in --monitor output in sync with related watch expression.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88896
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
[smcv: rebase onto differently indented version of previous commit]
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-24 13:30:23 +00:00
Ralf Habacker
360a68eddd dbus-monitor: Add timestamp to --monitor mode.
Use cross platform function _dbus_get_real_time() for fetching current time.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88896
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
[smcv: use %ld to avoid needing casts; reinstate printing the timestamp;
libdbus-1 is sufficient now that fd.o#83115 is fixed; print timestamp for
non-literal dbus-send replies too]
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-24 13:29:45 +00:00
Ralf Habacker
e78bac35cc dbus-monitor: Keep parameter list of method returns in --monitor mode in sync with --profile mode.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88896
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-24 11:48:40 +00:00
Ralf Habacker
3c889c694d dbus-monitor: convert remaining hard tabs to 8 space.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88896
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-24 11:48:06 +00:00
Simon McVittie
c33996aaad Actually commit cmake changes for dbus-launch 2015-02-24 11:42:54 +00:00
Simon McVittie
160f5bb9d2 dbus-launch: if autolaunching, use XDG_RUNTIME_DIR/bus if available
This provides backwards-compatible autolaunching behaviour, as long
as dbus-launch inherits the XDG_RUNTIME_DIR (which it presumably did
if it's going to work at all, since it must also have inherited the
DISPLAY). In particular, we go through the motions of starting the
dbus-daemon, so that we can start the "babysitter" process that will
maintain the X11 window to store the bus address.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61301
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
[smcv: decorate _dbus_lookup_user_bus with DBUS_PRIVATE_EXPORT so we
can still call it after fixing fd.o#83115; update cmake to match Autotools]
2015-02-24 11:25:50 +00:00
Simon McVittie
71c11a9e48 dbus-launch: use libdbus to read the UUID
As a side benefit, this means that dbus-launch now understands
/etc/machine-id and not just /var/lib/dbus/machine-id.

Since machine_uuid comes out of libdbus allocated with dbus_malloc,
to avoid having to copy it from malloc-allocated to
dbus_malloc-allocated storage, it makes sense to change it to be
consistently dbus_malloc-allocated (particularly now that Bug #83115
has made use of internal symbols relatively painless). However, I'm
deliberately not changing the allocation model of any other strings
in dbus-launch right now; that's a larger yak-shaving exercise.
2015-02-24 11:16:13 +00:00
Simon McVittie
2a6cefbc3b Add dbus-update-activation-environment tool
If OS builders (distributions) have chosen to use the per-user bus,
this provides two possible modes of operation for compatibility with
existing X session startup hooks.

A legacy-free system can just upload DISPLAY, XAUTHORITY and possibly
DBUS_SESSION_BUS_ADDRESS into dbus-daemon's and systemd's activation
environments, similar to
http://cgit.freedesktop.org/systemd/systemd/tree/xorg/50-systemd-user.sh
installed by systemd (but unlike systemctl,
dbus-update-activation-environment works for traditional
D-Bus-activated services, not just for systemd services).

A system where compatibility is required for environment variables
exported by snippets in /etc/X11/xinit/xinitrc.d (in Red Hat derivatives,
Gentoo, etc.) or /etc/X11/Xsession.d (Debian derivatives) can upload
the entire environment of the X session, minus some selected environment
variables which are specific to a login session (notably XDG_SESSION_ID).

In Debian, I plan to put the former in a new dbus-user-session package
that enables a user-session-centric mode of operation for D-Bus,
and the latter in the existing dbus-x11 package, with the intention that
dbus-x11 eventually becomes a tool for change-averse setups or goes
away entirely.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61301
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-24 11:15:52 +00:00
Simon McVittie
263aca37ec Optionally install systemd user units for a per-user bus
The socket path used here, $XDG_RUNTIME_DIR/bus, does not match
what was used in user-session-units, but is what Lennart recommended
on fd.o #61303, and is also what kdbus will use for its bus proxy.

Installation of these units switches D-Bus to a different model of
the system: instead of considering each login session (approximately,
each password typed in) to be its own session, the user-session model
is that all concurrent logins by the same user form one large session.
This allows the same bus to be shared by a graphical session, cron jobs,
tty/ssh sessions, screen/tmux sessions and so on.

Because this is a different world-view, it is compile-time optional:
OS builders can choose which world their OS will live in. The default
is still the login-session model used in earlier D-Bus releases,
but might change to the user-session model in future. Explicit
configuration is recommended.

In OSs that support both models (either for sysadmin flexibility or as
a transitional measure), the OS builder should enable the user bus
units, but split them off into a dpkg binary package, RPM subpackage etc.;
the sysadmin can choose whether to enable the user-session model by
choosing whether to install that package.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61301
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-24 11:15:37 +00:00
Simon McVittie
614e5aa872 Add a regression test for connecting to XDG_RUNTIME_DIR/bus by default
This test requires the unix:runtime=yes sub-transport from Bug #61303.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61301
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-24 11:15:31 +00:00
Simon McVittie
b9de1f5ef0 On Unix platforms, try $XDG_RUNTIME_DIR/bus before default address
This is safe to do even on systems where there is a per-login-session
bus: the $XDG_RUNTIME_DIR/bus would just not exist there. This means
that OS builders can enable a per-user-session bus by merely providing
configuration to start it, without needing to rebuild the client library.

Based on a patch by Colin Walters, with these changes:

- factor out the actual XDG_RUNTIME_DIR bit into a function
- set error correctly on OOM
- do not try to use an XDG_RUNTIME_DIR/bus that belongs to a
  different uid or is not a socket
- escape the path if it contains inconvenient characters
- coding style adjustments

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61301
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-24 11:15:25 +00:00
Simon McVittie
326d342345 Add regression test for unix:runtime=yes
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61303
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-24 11:15:18 +00:00
Simon McVittie
e3f117e761 Add support for unix:runtime=yes as an address mode
This is not used by default, but can be configured by OS builders (or
regression-test environments) if desired.

If used, this listens on $XDG_RUNTIME_DIR/bus, or fails if $XDG_RUNTIME_DIR
is not set. Fallback behaviour is unnecessary, because it is already
possible to use a string of semicolon-separated addresses like
<listen>unix:runtime=yes;unix:tmpdir=/tmp</listen>, resulting in
listening on either $XDG_RUNTIME_DIR/bus or /tmp/something.

We use a non-abstract socket here, because that is desirable for
use with Linux containers: abstract sockets are attached to the
network namespace, whereas non-abstract sockets are part of the
filesystem and can be bind-mounted between domains if necessary.
The major advantage of abstract sockets is that they do not need
cleanup, but the specification of XDG_RUNTIME_DIR guarantees to
provide cleanup anyway.

Based on prior work by Simon McVittie, Colin Walters and Alexander
Larsson.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61303
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-24 11:14:46 +00:00
Simon McVittie
f6a2b907ec marshalling tests: fix an incorrect use of memcmp
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89243
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-24 11:14:31 +00:00
Simon McVittie
e554e1b4ba tests: reassure clang that oom() does in fact not return
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89243
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-24 11:14:02 +00:00
Simon McVittie
2ca78f51a9 tests: simplify Makefile.am now that libdbus is always dynamically linked
testutils_shared_if_possible_cppflags is now just a copy of AM_CPPFLAGS,
which is the default and does not need to be given explicitly, so
those lines can be removed.

Similarly, testutils_shared_if_possible_libs is just the
libdbus-testutils.la convenience library, so expand it and
remove the unnecessary variable.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83115
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-23 16:40:04 +00:00
Simon McVittie
6c433c0d50 Remove checks for dbus-glib from configure.ac
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83115
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-23 16:39:43 +00:00
Simon McVittie
7ec30ffa90 Add versioned symbol support to cmake build system for linux platforms to keep in sync with autotools.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83115
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-20 23:27:12 +01:00
Simon McVittie
6d9e1553c9 NEWS 2015-02-20 21:10:30 +00:00
Simon McVittie
be55374fb5 cmake: check for the necessary symbols for test-segfault.c
If we don't check for them, and you have core dumps enabled, then
running this test under cmake is really annoying, because it leaves
lots of core dumps none of which are actually a problem.

The equivalent Autotools change (which added the actual code that
this relies on) is commit ae50d46, from fd.o#83772.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83115
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-20 20:50:17 +00:00
Simon McVittie
c35d7d1eb7 Fix static linking with mingw
Now that we're normally linking libdbus-1 dynamically, we need to
use DBUS_STATIC_BUILD_CPPFLAGS in every Makefile that would normally
link it dynamically, but might link it statically if we are only
building static libraries.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83115
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-20 20:50:04 +00:00
Bertrand SIMONNET
57696a2e8a Link dbus-daemon and dbus-daemon-lauch-helper against libdbus
The shared can be used by dbus-daemon and dbus-daemon-launch-helper by exporting
the private symbols needed, reducing the size of dbus by about 500k.
The private symbols are exposed under the version
LIBDBUS_PRIVATE_@VERSION_NUMBER@.

[Altered by Simon McVittie and Ralf Habacker to clear up some
problematic linking.]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83115
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-20 20:49:45 +00:00
Simon McVittie
7d214f4d58 On Unix platforms with gcc (or compatible), hide non-exported symbols
This changes the Linux behaviour to match the default situation
on Windows: symbols without DBUS_EXPORT or DBUS_PRIVATE_EXPORT
decoration are internal to libdbus-1, and cannot be used by
other programs, even within the dbus source tree.

This means the compiler/linker can optimize calls to those functions
by avoiding indirection through the PLT, which should improve
performance a little. However, the primary purpose of doing this is
that it means developers building libdbus on Linux are considerably
less likely to break it on Windows by mistake.

I'm deliberately not adding -fvisbility=hidden in CMake because the
complexity of doing so is unnecessary: Autotools is the recommended
way to build dbus for Unix, and the one Unix developers are going
to use in practice, unless they are specifically checking that they
haven't broken the CMake build.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83115
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-20 20:49:41 +00:00
Simon McVittie
6bcf34d4c2 Add DBUS_PRIVATE_EXPORT decoration to symbols used by dbus-daemon or tests
The rules are:

* symbols in libdbus-1 with neither decoration are private to libdbus-1
* symbols in libdbus-1 with DBUS_EXPORT are public API
* symbols in libdbus-1 with DBUS_PRIVATE_EXPORT are private to the
  dbus source package, but may be used by other programs in the dbus
  source tree, including tests
* symbols in libdbus-internal must not have DBUS_EXPORT or
  DBUS_PRIVATE_EXPORT, and should be used by as few things as possible

Thanks to Ralf Habacker for his contributions to this rather
large commit.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83115
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-20 20:49:36 +00:00