Commit graph

944 commits

Author SHA1 Message Date
Simon McVittie
46e2759883 name-test: also switch to AM_TESTS_ENVIRONMENT here
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89846
2015-04-16 13:06:26 +01:00
Simon McVittie
bb4b586d7c Change syntax of AM_TESTS_ENVIRONMENT to what the Automake docs prefer
On closer inspection of Automake docs, this is how AM_TESTS_ENVIRONMENT
is actually meant to work; the parallel test driver is even less
compatible with the old serial test driver than I'd realised :-(

Also, according to <http://www.unix.com/man-page/POSIX/1posix/export>,
"export FOO=bar" is actually required functionality for POSIX shells,
and is not a bashism. The Autoconf documentation mentions Solaris 10
as an example of somewhere this doesn't work... but at this point
I'd prefer to say "compiling dbus requires a POSIX shell".

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89846
2015-04-16 13:06:21 +01:00
Simon McVittie
4e29ece664 Depend on Automake 1.13 so we can use the correct AM_TESTS_ENVIRONMENT
Since Automake 1.13 (released December 2012) the correct way for a
maintainer to specify environment variables has been
AM_TESTS_ENVIRONMENT, with TESTS_ENVIRONMENT reserved for the user.
That doesn't work in older Automake, so drop support for such old
versions.

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89846
2015-04-16 13:06:19 +01:00
Simon McVittie
03da0fefd7 installed-tests: don't set DBUS_TEST_HOME which is misleading
It doesn't do anything - the variable I was thinking of is called
DBUS_TEST_HOMEDIR. Also, if I had spelled it correctly, the tests
would have failed, because libdbus (quite reasonably) won't create
a nonexistent $HOME to write out cookie_sha1 files in ~/.dbus_keyrings.

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89846
2015-04-16 13:06:17 +01:00
Simon McVittie
d752d07a54 installed-tests: declare that the output is in TAP format
For the ones written using GLib, the output is in TAP format if we
say --tap. For the one not written using GLib, the output is in TAP
and the command-line is ignored.

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89846
2015-04-16 13:06:16 +01:00
Simon McVittie
58eefa1031 test-shell, test-printf: produce TAP output like the other installable tests
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89846
2015-04-16 13:06:13 +01:00
Simon McVittie
a6b68598c4 tests: provide g_test_skip() emulation for older GLib
We don't hard-depend on a new enough GLib to have g_test_skip();
if our GLib is older, fake it using g_test_message() and degrade to
reporting it as a pass rather than a skip.

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89846
2015-04-16 13:06:07 +01:00
Simon McVittie
b7e56c18a9 tests: avoid noise on stdout when not --verbose
This makes life easier for frameworks like LAVA that screen-scrape
test results.

g_test_message() is not displayed by default, but each test can be run
with either --tap or --verbose to get these messages displayed.

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89846
2015-04-16 13:05:37 +01:00
Ralf Habacker
54f92110f6 CID 54766: Resource leak (RESOURCE_LEAK).
Variable original_argv going out of scope leaks the storage it points to.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-04-14 19:51:33 +02:00
Ralf Habacker
718843d351 Merge branch 'dbus-1.8'
Conflicts:
	dbus/dbus-sysdeps-win.c
2015-04-13 15:41:08 +02:00
Ralf Habacker
c225ff8330 Fix 'dbus connection referencing issue in test-relay'.
The watches added on connection setup should be removed on shutdown.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90005
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-04-13 15:31:28 +02:00
Simon McVittie
7647179096 Fix assorted compiler warnings on Windows.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
[rh: rebased because a few hunks have already been applied with commit
 92c39d1d8a]
2015-03-24 08:27:09 +01:00
Ralf Habacker
92c39d1d8a Fix of 'warning: variable ‘..‘ set but not used [-Wunused-but-set-variable]'.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89284
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-03-17 16:52:51 +01: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
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
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
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
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
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
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
dbd731491b tests: always use libdbus-internal for main loop, never dbus-glib
This gets rid of a potential circular dependency, which is annoying
when bootstrapping. It is nice to have the regression tests use
the shared libdbus, but we're about to make it possible to
do that anyway, even though some of them use internal symbols.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83115
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-20 20:49:32 +00:00
Simon McVittie
2e6879bc1b Add regression test for LinuxSecurityLabel credential
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89041
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-18 10:35:05 +00:00
Simon McVittie
890b1dd5c5 Add manual-paths test to the Autotools (mingw) build too
As in CMake, it is restricted to Windows builds, since the
functionality that it tests is not present in Unix builds.
2015-02-16 11:43:57 +00:00
Ralf Habacker
53d3914946 Add manual-paths test executable with cmake build support.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83539
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-12 23:22:18 +01:00
Simon McVittie
e387331220 Reduce the number of fds the fdpass test uses
It was relying on a higher-than-default fd limit; cut it down to
more than 256 but rather less than 1024, since the default Linux
limit is 1024 fds per user.

Also automatically skip this test if our rlimit is too small.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88998
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-11 14:32:58 +00:00
Ralf Habacker
87d40ec950 Add test for windows sid.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54445
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-11 11:57:46 +00:00
Simon McVittie
3d1426ac72 Add a regression test for making systemd activation appear to fail 2015-02-09 11:06:38 +00:00
Simon McVittie
239fa20812 Add test-fdpass to the build, and make it compile again
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88998
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-05 15:23:22 +00:00
Simon McVittie
4f99a694b5 tests: make installable metadata Windows-friendly by using EXEEXT
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88980
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-05 14:14:34 +00:00
Simon McVittie
3f762bef24 tests: make sure to specify CPPFLAGS where needed
test-marshal and test-syntax need the
$(testutils_shared_if_possible_cppflags), so that they will get the
$(static_cflags) when we are not linking to dbus-glib.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88980
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-05 14:14:17 +00:00
Simon McVittie
94610d7de6 Add a common test_init() for GLib tests which prevents hanging forever
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-04 17:15:36 +00:00
Simon McVittie
a650bd055f Add a regression test for being a new-style monitor
This includes most of the situations I could think of:

* method call on dbus-daemon and response
* NameOwnerChanged
* NameAcquired, NameLost (although I'm not 100% sure these should
  get captured, since they're redundant with NameOwnerChanged)
* unicast message is allowed through
* unicast message is rejected by no-sending or no-receiving policy
* broadcast is allowed through
* broadcast is rejected by no-sending policy (the error reply
  is also captured)
* broadcast is rejected by no-receiving policy (there is no error
  reply)
* message causing service activation, and the message telling systemd
  to do the actual activation
* systemd reporting that activation failed

It does not cover:

* sending a message to dbus-daemon, then provoking a reply, then
  dbus-daemon does not allow itself to send the reply due to its
  own security policy

This is such an obscure corner case that I'm not even convinced it's
testable without dropping down into lower-level socket manipulation:
dbus-daemon's replies are always assumed to be requested replies,
and replies contain so little other metadata that I think we can
only forbid them by forbidding all method replies. If we do that,
the reply to Hello() won't arrive and the client-side connection will
not become active.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-04 17:15:24 +00:00
Simon McVittie
3cf71c2707 Treat root as a valid candidate for TEST_USER_ME
If spawn_dbus_daemon() can fail for TEST_USER_ME, then we'd have to
go through all the tests adding the ability to skip tests after
it fails, which is a fairly extensive change.

The tests have historically all run as whatever uid is supplied, and
if the tests are being run as root for some reason - perhaps in a CI
framework for an embedded platform that doesn't have non-root users,
or in an environment where you can be root or non-root but not both -
there is no particular reason to skip them.
2015-02-03 19:35:39 +00:00
Simon McVittie
cf35dad25a Add a regression test for systemd activation
4.5 years after it was implemented, here is the regression test.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=57952
Reviewed-by: Philip Withnall
2015-02-03 16:20:01 +00:00
Simon McVittie
1f716452e7 bus driver: factor out bus_driver_check_caller_is_privileged, and allow root
Unlike the initial mitigation for CVE-2014-8148, we now allow
uid 0 to call UpdateActivationEnvironment. There's no point in root
doing that, but there's also no reason why it's particularly bad -
if an attacker is uid 0 we've already lost - and it simplifies
use of this function for future things that do want to be callable
by root, like BecomeMonitor for #46787.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:19:11 +00:00
Simon McVittie
98ae1149ad Add a test for uid-controlled permissions
This is technical debt from mitigating CVE-2014-8148, which should
really have had a regression test at the time.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:19:08 +00:00
Simon McVittie
6a49ced2dd Add infrastructure to run bits of tests under an alternative uid
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:19:05 +00:00
Simon McVittie
1e21cc86bf test: implement GLib-style "installed tests"
We run each test twice:

* once with the system's session.conf, as an integration test
  (test-cases that need a special configuration are automatically
  skipped)
* once with our special test configuration files, which provide better
  coverage

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:19:01 +00:00
Simon McVittie
ee032f5a11 Generate test configuration files via build-time sed, not configure
This means we can generate a version that works when installed,
from the same source files.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:19:00 +00:00
Simon McVittie
8b238f3f0d Factor out some utility functions from test/dbus-daemon*
In the process, make test_kill_pid() safer: do not try to terminate
more than one pid, or the NULL handle.

Also stop leaking the address_fd in spawn_dbus_daemon, a pre-existing
bug that was spotted by Philip Withnall during review.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:18:57 +00:00
Simon McVittie
6976a7f199 Bump required GLib version to 2.36
This is for g_close(), which the next commit will use. It also lets us
rely on g_type_init() being a no-op (since 2.32 the type system is
always initialized by a global constructor).

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:18:47 +00:00
Lukasz Skalski
9668c61726 Update .gitignore files
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88943
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-03 15:40:01 +00:00
Ralf Habacker
fa1ada44ea Add manual tcp test case.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=87999
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-01-30 09:33:40 +01:00
Simon McVittie
04056bba41 Use pygi instead of pygobject 2
pygobject 2 is obsolete and unmaintained, and anyway this is for
optional functionality (full regression test coverage) rather than
anything that will be needed in production builds.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=85969
2015-01-27 14:29:59 +00:00
Simon McVittie
ae9d7149aa Merge branch 'dbus-1.8' and prepare 1.9.6
Conflicts:
	NEWS
	configure.ac
	test/dbus-daemon.c
2015-01-01 23:48:13 +00:00
Simon McVittie
4daf4bdc92 Add a regression test for path-based UpdateActivationEnvironment hardening
Reviewed-by: Thiago Macieira <thiago@kde.org>
2015-01-01 23:32:33 +00:00
Alban Crequy
84db0981e0 DBusSystemLogSeverity: add DBUS_SYSTEM_LOG_WARNING
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=85105
2014-11-18 19:13:29 +00:00