Commit graph

6699 commits

Author SHA1 Message Date
Khem Raj
c3e2c873ff Define _DBUS_ALIGNOF using _Alignof when using C11 or newer
WG14 N2350 made very clear that it is an UB having type definitions
within "offsetof" [1]. This patch changes the implementation of macro
_DBUS_ALIGNOF to builtin "_Alignof" to avoid undefined behavior.

clang 16+ has started to diagnose this [2]

Fixes build when using -std >= gnu11 and using clang16+

[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm
[2] https://reviews.llvm.org/D133574

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2023-01-14 12:43:15 -08:00
Simon McVittie
218b35a57c Merge branch 'jepio/fix-log-callback-segfault' into 'master'
bus/selinux: Move vsnprintf call to avoid va_list reuse

See merge request dbus/dbus!386
2023-01-10 11:59:06 +00:00
Jeremi Piotrowski
52b73d511b bus/selinux: Move vsnprintf call to avoid va_list reuse
In log_callback() the same va_list is reused for a call to vsnprintf and
vsyslog. A va_list can't be reused in this manner, such use is undefined
behavior that changes depending on glibc version.

In current glibc versions a segfault can be observed from the callsite at
bus/selinux.c:412. When trying to log a non-auditable event, the segfault
happens in strlen inside vsyslog.

Moving the call to vsnprintf closer to audit_log_user_avc_message (which is
followed by a 'goto out') avoids the reuse and segfault.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2023-01-09 20:03:29 +00:00
Simon McVittie
237063358e Merge branch 'meson-fvisibility-hidden' into 'master'
meson: Use -fvisibility=hidden on Unix if supported

See merge request dbus/dbus!383
2023-01-09 15:01:52 +00:00
Simon McVittie
c1661d7c5d meson: Use -fvisibility=hidden on Unix if supported
This avoids accidentally exporting all of our private symbols as part
of the LIBDBUS_PRIVATE_x.y.z verdef, including ones that don't need to
be visible outside the shared library even when testing internals
(_dbus_watch_set_handler is a good example).

Helps: https://gitlab.freedesktop.org/dbus/dbus/-/issues/437
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-01-09 14:46:02 +00:00
Ralf Habacker
81dc8af6ae Merge branch 'fix-data-race' into 'master'
Fix data race with members of struct DBusCounter

Closes #426

See merge request dbus/dbus!379
2023-01-07 09:17:43 +00:00
Ralf Habacker
1741df3b97 Fix data race in multithreaded application
This commit fixes a data race condition discovered by the
gcc thread sanitizer by also locking the associated mutex
when reading the corresponding counter.

Fixes #426
2023-01-05 16:44:25 +01:00
Ralf Habacker
20febb522b Add multithreaded unit test for DBusCounter to available build systems
The mentioned test is build on unix like platforms when embedded tests
are enabled.
2023-01-05 16:43:55 +01:00
Simon McVittie
255f103b5c Merge branch 'meson-declare-dependency' into 'master'
meson: Declare dependency for use as a subproject

See merge request dbus/dbus!368
2023-01-04 14:26:56 +00:00
Daniel Wagner
afb5bbaba4 meson: Introduce message_bus and tools command line option
To make the consume libdbus via Meson's subproject use case more useful,
introduce message_bus and tools command line options which control if
the D-Bus daemon and/or the tools are build. The idea here is that
depending projects are interested only in the library.

The strong recommendation is only to build libdbus as static library:

  libdbus_dep = dependency(
    'dbus-1',
    required: get_option('libdbus'),
    fallback: ['dbus', 'libdbus_dep'],
    default_options: [
      'default_library=static',
      'embedded_tests=false',
      'message_bus=false',
      'modular_tests=disabled',
      'tools=false',
    ],
  )

This ensures that any installed D-Bus infrastructure on the target
system is not overwritten.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2023-01-04 09:35:06 +01:00
Daniel Wagner
6a774fbb79 meson: Declare dependency
Allow other Meson project to consume libdbus as subproject. For this
we need to instantiate a dependency object.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2023-01-04 09:04:57 +01:00
Ralf Habacker
a33ce73f1f Merge branch 'spdx-afl-2.1-or-gpl-2.0' into 'master'
Add SPDX license marker for the AFL-2.1 OR GPL-2.0-or-later license

See merge request dbus/dbus!375
2023-01-04 07:54:16 +00:00
Ralf Habacker
dcf62703d9 dbus/dbus-macros-internal.h: Add blank line after the copyright state
Thus it is identical with the other places.
2023-01-04 07:53:44 +00:00
Ralf Habacker
2dee523608 Add SPDX license marker for the AFL-2.1 OR GPL-2.0-or-later license
The full license texts are not added because they were already
added in a previous commit.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>

see #394
2023-01-04 07:53:44 +00:00
Ralf Habacker
53733fcc58 Merge branch 'master' into 'master'
_dbus_loop_iterate: `timeout` can be defined as int

See merge request dbus/dbus!381
2023-01-04 07:40:59 +00:00
Xin Shi
5073b0f8a6 _dbus_loop_iterate: timeout can be defined as int
all places where `timeout` is used can be represented as int.
This MR is a response to issue #430.

Signed-off-by: Xin Shi <shixin21@huawei.com>
2023-01-04 10:24:46 +08:00
Simon McVittie
fee1595c68 Merge branch 'spdx-FSFULLR' into 'master'
Add SPDX license marker for the FSFULLR license

See merge request dbus/dbus!376
2023-01-03 19:24:08 +00:00
Ralf Habacker
410704bdda Add SPDX license marker for the FSFULLR license
The associated full license text was retrieved from https://spdx.org.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2023-01-03 19:24:02 +00:00
Simon McVittie
719b9cdbab Merge branch 'fix-425' into 'master'
Permit access to /tmp dbus socket

See merge request dbus/dbus!380
2023-01-03 19:02:12 +00:00
Dave Jones
9950464761 Permit access to /tmp dbus socket
After 6e48c317 the test-apparmor-activation test fails as it can no
longer access the dbus socket in /tmp. This commit updates the apparmor
profile used within the test
2023-01-03 18:42:51 +00:00
Ralf Habacker
45b7e104ca Merge branch 'master' into 'master'
socket_handle_watch: break when `found` is TRUE in server

See merge request dbus/dbus!374
2023-01-03 10:47:04 +00:00
Aiknow
4f6e029598 socket_handle_watch: break when found is TRUE in server
skip useless loop when `found` is TRUE.
This MR is a response to issue #431.

Signed-off-by: Aiknow <shixin21@huawei.com>
2023-01-03 10:51:35 +08:00
Simon McVittie
ce5c01ae41 Merge branch 'use-gitlab-uri' into 'master'
cleanup: Use gitlab URI for bug reporting

See merge request dbus/dbus!372
2022-11-30 19:17:33 +00:00
Marco Trevisan (Treviño)
dc59aa5df2 cleanup: Use gitlab URI for bug reporting
Bugzilla is dead for long time now.
2022-11-30 16:51:27 +01:00
Simon McVittie
a3636a1d9e Merge branch 'pointer-assumptions' into 'master'
Statically assert some things we assume about pointers

See merge request dbus/dbus!345
2022-11-29 22:26:39 +00:00
Simon McVittie
0b221c4694 internals: Statically assert some things we assume about pointers
Like many relatively-low-level codebases, dbus has historically assumed
that data pointers are interchangeable with function pointers (which is
implied by POSIX and also true on Windows, but not guaranteed by ISO C).

Before dbus!335 was merged, we also assumed that size_t is the same
size as a pointer (which is frequently assumed, but not guaranteed by
ISO C, and notably not true on CHERI). dbus!335 is believed to have
removed all uses of that assumption.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-29 22:11:07 +00:00
Simon McVittie
c0805bc3f1 dbus-marshal-basic: Use _DBUS_ALIGNOF to compare alignments
This means we get the alignment comparisons even on non-gcc compilers.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-29 22:11:07 +00:00
Simon McVittie
721307c401 Merge branch 'cmake-licenseref' into 'master'
Fix SPDX license reference in FindGLIB2

See merge request dbus/dbus!371
2022-11-29 22:10:46 +00:00
Simon McVittie
0827d76553 Fix SPDX license reference in FindGLIB2
The `.txt` here was unnecessary.

Fixes: d6abc1da "cmake: Add BSD-style licenses"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-29 20:44:50 +00:00
Simon McVittie
9be499d802 Merge branch 'lgpl' into 'master'
Add missing license text for LGPL-2.1-or-later

See merge request dbus/dbus!369
2022-11-29 20:44:35 +00:00
Simon McVittie
1843215257 Add missing license text for LGPL-2.1-or-later
Fixes: 8c1d0f13 "dbus/dbus-backtrace-win.c: New file with backtrace generator for Windows"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-29 20:43:49 +00:00
Simon McVittie
639931bfa0 Merge branch 'gpl' into 'master'
Fix some stray filename references for GPL-2.0-or-later

See merge request dbus/dbus!370
2022-11-29 20:43:44 +00:00
Simon McVittie
a7e4bac015 Fix some stray filename references for GPL-2.0-or-later
The SPDX name for this license includes the `.0`.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-29 20:43:01 +00:00
Ralf Habacker
ad6f030ef2 Merge branch 'goto-considered-unnecessary' into 'master'
Use 'continue' keyword in preference to 'goto' where possible

See merge request dbus/dbus!356
2022-11-29 19:02:38 +00:00
Simon McVittie
54b56ab875 Use 'continue' keyword in preference to 'goto' where possible
In some more complicated loops, we do need to use 'goto' to exit from
an inner loop, or to jump to cleanup or an increment of an iterator
immediately before the next loop iteration. However, in these simple
cases, jumping to a label immediately before the 'while' keyword is
unnecessary: we can use an equivalent 'continue' statement for flow
control.

This makes it easier for maintainers to notice the loops where we are
doing something more complicated, which still use 'goto', and know
that they need to pay more attention in those cases.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-29 18:50:06 +00:00
Ralf Habacker
2f9d987c0a Merge branch 'spdx' into 'master'
Add SPDX licensing information for the uncommon licenses (not AFL-2.1|GPL-2.0+ and not MIT)

See merge request dbus/dbus!311
2022-11-29 17:53:36 +00:00
Ralf Habacker
e3a365e7ac tools/cmake-format: Relicense to BSD-3-Clause
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-11-29 13:33:53 +00:00
Simon McVittie
d6abc1da02 cmake: Add BSD-style licenses
I've erred on the side of caution and treated the COPYING-CMAKE-SCRIPTS
license (a BSD-3-Clause variation) as its own distinct license.

Co-authored-by: Ralf Habacker <ralf.habacker@freenet.de>
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-29 13:33:53 +00:00
Ralf Habacker
8c1d0f1391 dbus/dbus-backtrace-win.c: New file with backtrace generator for Windows
This file was added to simplify the license documentation, because the
code moved from dbus-sysdeps-win.c is subject to a different license.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
[smcv: keep license grant; add to Meson build system]
Co-authored-by: Simon McVittie <smcv@collabora.com>
2022-11-29 13:33:53 +00:00
Simon McVittie
33bc01e1b5 tools: Mark GPL-only files with SPDX license identifier
These files are licensed under the GPL only, without the AFL dual-license
of most of the dbus codebase.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Co-authored-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-11-29 13:33:53 +00:00
Simon McVittie
205063a0a9 dbus-arch-deps: Mark as AFL-2.0 OR GPL-2.0-or-later
This was probably meant to be relicensed from AFL-2.0 to AFL-2.1 at the
same time as the rest of the codebase, but it wasn't. For now, just
convert its documented license status into machine-readable form.

The history of this file seems to be completely Red Hat and Collabora,
so we should be able to relicense it to (AFL-2.1 OR GPL-2.0-or-later)
or even to MIT, but let's start by making the stated license more
obvious.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-29 13:33:53 +00:00
Simon McVittie
eae69d2c1a dbus-hash: Add (AFL-2.1 OR GPL-2.0-or-later) AND TCL SPDX license identifier
The TCL-derived code is under its own license, so the overall license
of the file is (AFL-2.1 OR GPL-2.0-or-later) AND TCL.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-29 13:33:53 +00:00
Ralf Habacker
d0d4d4d3d3 dbus/dbus-sha.c: add LicenseRef-pycrypto-orig SPDX license marker
This permissive license does not appear to be a match for anything
on the SPDX license list, so we need to use the LicenseRef- prefix
for a custom license.

Co-authored-by: Simon McVittie <smcv@collabora.com>
2022-11-29 13:33:53 +00:00
Ralf Habacker
87ebf5ecc2 dbus/versioninfo.rc.in: add LicenseRef-GAP SPDX license marker
This permissive license does not appear to be a match for anything
on the SPDX license list, so we need to use the LicenseRef- prefix
for a custom license.

It's referred to as GAP (presumably short for "GNU all-permissive") in
https://sources.debian.org/src/libassuan/2.5.5-1/debian/copyright/
so use the same abbreviation here.

Co-authored-by: Simon McVittie <smcv@collabora.com>
2022-11-29 13:33:53 +00:00
Simon McVittie
b30c2c293d Merge branch 'clang-ci' into 'master'
ci: build dbus with clang as well

See merge request dbus/dbus!358
2022-10-14 14:40:46 +00:00
Evgeny Vereshchagin
738d8dbe6f ci: get UBSan to fail and print full backtraces
Unlike ASan, by default UBSan prints one-line warnings and keeps going
and it makes it impossible for the CI to catch issues automatically when
it runs the unit tests. With this patch applied the CI should be able to
prevent issues like
https://gitlab.freedesktop.org/smcv/dbus-issue413/-/merge_requests/1#note_1549306
from making it into the repository going forward.

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2022-10-13 03:20:31 +00:00
Evgeny Vereshchagin
9803fb09fc ci: build dbus with clang as well
It should make it possible to catch issues like
like https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/357

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2022-10-13 03:20:07 +00:00
Simon McVittie
0c3702bfd8 Merge branch 'mit-license-some-tests' into 'master'
Add copyright holders and MIT license to some tests that did not specify

See merge request dbus/dbus!359
2022-10-12 12:08:46 +00:00
Simon McVittie
4aa7052c6f test-exit: Add a permissive license
Red Hat have previously given permission for relicensing, and all
subsequent contributions to this file were trivial.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-12 12:08:38 +00:00
Simon McVittie
fb1460ee32 test-threads-init: Add a permissive license
With permission from Philip Withnall on behalf of Endless, me on behalf
of Collabora, and relying on previous permission from Red Hat
representatives.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-12 12:08:38 +00:00