summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-format7
-rw-r--r--.editorconfig57
-rw-r--r--.gitignore29
-rw-r--r--.gitlab-ci.yml481
-rw-r--r--.gitlab/issue_templates/Bug.md17
-rw-r--r--.gitlab/issue_templates/Feature.md15
-rw-r--r--.reuse/dep59
-rw-r--r--AUTHORS145
-rw-r--r--CMakeLists.txt304
-rw-r--r--CONTRIBUTING.md100
-rw-r--r--COPYING561
-rw-r--r--Doxyfile.in4
-rw-r--r--INSTALL329
-rw-r--r--LICENSES/AFL-2.0.txt45
-rw-r--r--LICENSES/AFL-2.1.txt45
-rw-r--r--LICENSES/Apache-2.0.txt73
-rw-r--r--LICENSES/BSD-3-Clause.txt11
-rw-r--r--LICENSES/FSFULLR.txt5
-rw-r--r--LICENSES/GPL-2.0-or-later.txt117
-rw-r--r--LICENSES/LGPL-2.1-or-later.txt175
-rw-r--r--LICENSES/LicenseRef-CMakeScripts.txt (renamed from cmake/modules/COPYING-CMAKE-SCRIPTS)3
-rw-r--r--LICENSES/LicenseRef-GAP.txt7
-rw-r--r--LICENSES/LicenseRef-pycrypto-orig.txt3
-rw-r--r--LICENSES/MIT.txt9
-rw-r--r--LICENSES/TCL.txt9
-rw-r--r--Makefile.am45
-rw-r--r--NEWS790
-rw-r--r--README31
-rw-r--r--README.cmake14
-rw-r--r--README.win7
-rwxr-xr-xautogen.sh108
-rw-r--r--bus/CMakeLists.txt5
-rw-r--r--bus/Makefile.am250
-rw-r--r--bus/activation-exit-codes.h2
-rw-r--r--bus/activation-helper-bin.c2
-rw-r--r--bus/activation-helper.c10
-rw-r--r--bus/activation-helper.h2
-rw-r--r--bus/activation.c22
-rw-r--r--bus/activation.h2
-rw-r--r--bus/apparmor.c2
-rw-r--r--bus/apparmor.h2
-rw-r--r--bus/audit.c2
-rw-r--r--bus/audit.h2
-rw-r--r--bus/bus.c120
-rw-r--r--bus/bus.h4
-rw-r--r--bus/config-loader-expat.c2
-rw-r--r--bus/config-parser-common.c2
-rw-r--r--bus/config-parser-common.h2
-rw-r--r--bus/config-parser-trivial.c5
-rw-r--r--bus/config-parser-trivial.h2
-rw-r--r--bus/config-parser.c12
-rw-r--r--bus/config-parser.h2
-rw-r--r--bus/connection.c40
-rw-r--r--bus/connection.h2
-rw-r--r--bus/containers.c10
-rw-r--r--bus/containers.h2
-rw-r--r--bus/dbus.service.in3
-rw-r--r--bus/desktop-file.c2
-rw-r--r--bus/desktop-file.h2
-rw-r--r--bus/dir-watch-default.c2
-rw-r--r--bus/dir-watch-inotify.c48
-rw-r--r--bus/dir-watch-kqueue.c16
-rw-r--r--bus/dir-watch.h2
-rw-r--r--bus/dispatch.c72
-rw-r--r--bus/dispatch.h2
-rw-r--r--bus/driver.c59
-rw-r--r--bus/driver.h5
-rw-r--r--bus/expirelist.c21
-rw-r--r--bus/expirelist.h4
-rw-r--r--bus/legacy-config/meson.build36
-rw-r--r--bus/main.c63
-rw-r--r--bus/meson.build223
-rw-r--r--bus/policy.c4
-rw-r--r--bus/policy.h2
-rw-r--r--bus/selinux.c7
-rw-r--r--bus/selinux.h2
-rw-r--r--bus/services.c8
-rw-r--r--bus/services.h2
-rw-r--r--bus/session.conf.in6
-rw-r--r--bus/signals.c66
-rw-r--r--bus/signals.h12
-rw-r--r--bus/stats.c2
-rw-r--r--bus/stats.h4
-rw-r--r--bus/system.conf.in4
-rw-r--r--bus/systemd-user/dbus.service.in1
-rw-r--r--bus/systemd-user/meson.build34
-rw-r--r--bus/sysusers.d/meson.build27
-rw-r--r--bus/test.c4
-rw-r--r--bus/test.h6
-rw-r--r--bus/tmpfiles.d/meson.build27
-rw-r--r--bus/utils.c2
-rw-r--r--bus/utils.h2
-rw-r--r--cmake/ConfigureChecks.cmake179
-rw-r--r--cmake/DBus1Config.cmake.in7
-rw-r--r--cmake/DBus1Config.pkgconfig.in5
-rw-r--r--cmake/config.h.cmake120
-rw-r--r--cmake/meson.build44
-rw-r--r--cmake/modules/CPackInstallConfig.cmake6
-rw-r--r--cmake/modules/FindDocBookXSL.cmake1
-rw-r--r--cmake/modules/FindGLIB2.cmake (renamed from cmake/modules/FindGLib2.cmake)3
-rw-r--r--cmake/modules/Macros.cmake118
-rw-r--r--cmake/modules/MacrosAutotools.cmake168
-rw-r--r--cmake/modules/MacrosMeson.cmake52
-rw-r--r--cmake/modules/Win32Macros.cmake7
-rw-r--r--configure.ac1840
-rw-r--r--dbus-1-uninstalled.pc.in20
-rw-r--r--dbus/CMakeLists.txt13
-rw-r--r--dbus/Makefile.am335
-rw-r--r--dbus/dbus-address.c2
-rw-r--r--dbus/dbus-address.h2
-rw-r--r--dbus/dbus-arch-deps.h.in4
-rw-r--r--dbus/dbus-asv-util.c41
-rw-r--r--dbus/dbus-asv-util.h5
-rw-r--r--dbus/dbus-auth.c26
-rw-r--r--dbus/dbus-auth.h2
-rw-r--r--dbus/dbus-backtrace-win.c213
-rw-r--r--dbus/dbus-bus.c2
-rw-r--r--dbus/dbus-bus.h2
-rw-r--r--dbus/dbus-connection-internal.h4
-rw-r--r--dbus/dbus-connection.c68
-rw-r--r--dbus/dbus-connection.h5
-rw-r--r--dbus/dbus-credentials.c120
-rw-r--r--dbus/dbus-credentials.h10
-rw-r--r--dbus/dbus-dataslot.c2
-rw-r--r--dbus/dbus-dataslot.h2
-rw-r--r--dbus/dbus-errors.c2
-rw-r--r--dbus/dbus-errors.h2
-rw-r--r--dbus/dbus-file-unix.c52
-rw-r--r--dbus/dbus-file-win.c2
-rw-r--r--dbus/dbus-file.c2
-rw-r--r--dbus/dbus-file.h2
-rw-r--r--dbus/dbus-hash.c1
-rw-r--r--dbus/dbus-hash.h4
-rw-r--r--dbus/dbus-init-win.cpp4
-rw-r--r--dbus/dbus-init-win.h17
-rw-r--r--dbus/dbus-internals.c62
-rw-r--r--dbus/dbus-internals.h76
-rw-r--r--dbus/dbus-keyring.c28
-rw-r--r--dbus/dbus-keyring.h2
-rw-r--r--dbus/dbus-list.c2
-rw-r--r--dbus/dbus-list.h2
-rw-r--r--dbus/dbus-macros-internal.h54
-rw-r--r--dbus/dbus-macros.h18
-rw-r--r--dbus/dbus-mainloop.c18
-rw-r--r--dbus/dbus-mainloop.h2
-rw-r--r--dbus/dbus-marshal-basic.c87
-rw-r--r--dbus/dbus-marshal-basic.h2
-rw-r--r--dbus/dbus-marshal-byteswap.c20
-rw-r--r--dbus/dbus-marshal-byteswap.h2
-rw-r--r--dbus/dbus-marshal-header.c2
-rw-r--r--dbus/dbus-marshal-header.h2
-rw-r--r--dbus/dbus-marshal-recursive.c7
-rw-r--r--dbus/dbus-marshal-recursive.h13
-rw-r--r--dbus/dbus-marshal-validate.c63
-rw-r--r--dbus/dbus-marshal-validate.h2
-rw-r--r--dbus/dbus-memory.c36
-rw-r--r--dbus/dbus-memory.h2
-rw-r--r--dbus/dbus-mempool.c69
-rw-r--r--dbus/dbus-mempool.h2
-rw-r--r--dbus/dbus-message-internal.h2
-rw-r--r--dbus/dbus-message-private.h2
-rw-r--r--dbus/dbus-message-util.c2
-rw-r--r--dbus/dbus-message.c45
-rw-r--r--dbus/dbus-message.h20
-rw-r--r--dbus/dbus-misc.c2
-rw-r--r--dbus/dbus-misc.h2
-rw-r--r--dbus/dbus-nonce.c5
-rw-r--r--dbus/dbus-nonce.h2
-rw-r--r--dbus/dbus-object-tree.c2
-rw-r--r--dbus/dbus-object-tree.h2
-rw-r--r--dbus/dbus-pending-call-internal.h2
-rw-r--r--dbus/dbus-pending-call.c2
-rw-r--r--dbus/dbus-pending-call.h2
-rw-r--r--dbus/dbus-pipe-unix.c2
-rw-r--r--dbus/dbus-pipe-win.c2
-rw-r--r--dbus/dbus-pipe.c2
-rw-r--r--dbus/dbus-pipe.h4
-rw-r--r--dbus/dbus-pollable-set-epoll.c2
-rw-r--r--dbus/dbus-pollable-set-poll.c2
-rw-r--r--dbus/dbus-pollable-set.c2
-rw-r--r--dbus/dbus-pollable-set.h2
-rw-r--r--dbus/dbus-protocol.h2
-rw-r--r--dbus/dbus-resources.c14
-rw-r--r--dbus/dbus-resources.h10
-rw-r--r--dbus/dbus-server-debug-pipe.c8
-rw-r--r--dbus/dbus-server-debug-pipe.h2
-rw-r--r--dbus/dbus-server-launchd.c2
-rw-r--r--dbus/dbus-server-launchd.h1
-rw-r--r--dbus/dbus-server-protected.h6
-rw-r--r--dbus/dbus-server-socket.c298
-rw-r--r--dbus/dbus-server-socket.h5
-rw-r--r--dbus/dbus-server-unix.c247
-rw-r--r--dbus/dbus-server-win.c2
-rw-r--r--dbus/dbus-server-win.h2
-rw-r--r--dbus/dbus-server.c4
-rw-r--r--dbus/dbus-server.h2
-rw-r--r--dbus/dbus-sha.c1
-rw-r--r--dbus/dbus-sha.h2
-rw-r--r--dbus/dbus-shared.h4
-rw-r--r--dbus/dbus-shell.c2
-rw-r--r--dbus/dbus-shell.h2
-rw-r--r--dbus/dbus-signature.c2
-rw-r--r--dbus/dbus-signature.h2
-rw-r--r--dbus/dbus-sockets-win.h2
-rw-r--r--dbus/dbus-spawn-unix.c30
-rw-r--r--dbus/dbus-spawn-win.c230
-rw-r--r--dbus/dbus-spawn.h2
-rw-r--r--dbus/dbus-string-private.h2
-rw-r--r--dbus/dbus-string-util.c2
-rw-r--r--dbus/dbus-string.c123
-rw-r--r--dbus/dbus-string.h19
-rw-r--r--dbus/dbus-syntax.c2
-rw-r--r--dbus/dbus-syntax.h2
-rw-r--r--dbus/dbus-sysdeps-pthread.c2
-rw-r--r--dbus/dbus-sysdeps-thread-win.c38
-rw-r--r--dbus/dbus-sysdeps-unix.c441
-rw-r--r--dbus/dbus-sysdeps-unix.h20
-rw-r--r--dbus/dbus-sysdeps-util-unix.c196
-rw-r--r--dbus/dbus-sysdeps-util-win.c34
-rw-r--r--dbus/dbus-sysdeps-util.c2
-rw-r--r--dbus/dbus-sysdeps-win.c1371
-rw-r--r--dbus/dbus-sysdeps-win.h39
-rw-r--r--dbus/dbus-sysdeps-wince-glue.c2
-rw-r--r--dbus/dbus-sysdeps-wince-glue.h2
-rw-r--r--dbus/dbus-sysdeps.c41
-rw-r--r--dbus/dbus-sysdeps.h83
-rw-r--r--dbus/dbus-test-tap.c11
-rw-r--r--dbus/dbus-test-tap.h1
-rw-r--r--dbus/dbus-test.h2
-rw-r--r--dbus/dbus-threads-internal.h71
-rw-r--r--dbus/dbus-threads.c2
-rw-r--r--dbus/dbus-threads.h2
-rw-r--r--dbus/dbus-timeout.c2
-rw-r--r--dbus/dbus-timeout.h2
-rw-r--r--dbus/dbus-transport-protected.h2
-rw-r--r--dbus/dbus-transport-socket.c148
-rw-r--r--dbus/dbus-transport-socket.h8
-rw-r--r--dbus/dbus-transport-unix.c170
-rw-r--r--dbus/dbus-transport-unix.h12
-rw-r--r--dbus/dbus-transport-win.c2
-rw-r--r--dbus/dbus-transport-win.h2
-rw-r--r--dbus/dbus-transport.c6
-rw-r--r--dbus/dbus-transport.h2
-rw-r--r--dbus/dbus-types.h23
-rw-r--r--dbus/dbus-userdb-util.c70
-rw-r--r--dbus/dbus-userdb.c2
-rw-r--r--dbus/dbus-userdb.h5
-rw-r--r--dbus/dbus-uuidgen.c2
-rw-r--r--dbus/dbus-uuidgen.h3
-rw-r--r--dbus/dbus-valgrind-internal.h2
-rw-r--r--dbus/dbus-watch.c2
-rw-r--r--dbus/dbus-watch.h2
-rw-r--r--dbus/dbus.h2
-rw-r--r--dbus/meson.build251
-rw-r--r--dbus/test-version-script10
-rw-r--r--dbus/versioninfo.rc.in1
-rw-r--r--doc/CMakeLists.txt167
-rw-r--r--doc/Makefile.am214
-rw-r--r--doc/catalog.xml.in10
-rw-r--r--doc/dbus-api-design.duck18
-rw-r--r--doc/dbus-cleanup-sockets.1.xml.in4
-rw-r--r--doc/dbus-daemon.1.xml.in38
-rw-r--r--doc/dbus-launch.1.xml.in6
-rw-r--r--doc/dbus-monitor.1.xml.in4
-rw-r--r--doc/dbus-run-session.1.xml.in7
-rw-r--r--doc/dbus-send.1.xml.in4
-rw-r--r--doc/dbus-specification.xml259
-rw-r--r--doc/dbus-test-tool.1.xml.in11
-rw-r--r--doc/dbus-update-activation-environment.1.xml.in7
-rw-r--r--doc/dbus-uuidgen.1.xml.in6
-rw-r--r--doc/file-boilerplate.c2
-rw-r--r--doc/introspect.xsl2
-rw-r--r--doc/list-doc-source.py9
-rwxr-xr-xdoc/maintainer-upload-docs.sh53
-rw-r--r--doc/meson.build252
-rw-r--r--doc/meson_post_install.py45
-rw-r--r--m4/as-ac-expand.m449
-rw-r--r--m4/ax_ac_append_to_file.m432
-rw-r--r--m4/ax_ac_print_to_file.m432
-rw-r--r--m4/ax_add_am_macro_static.m428
-rw-r--r--m4/ax_am_macros_static.m438
-rw-r--r--m4/ax_code_coverage.m4272
-rw-r--r--m4/ax_file_escapes.m430
-rw-r--r--m4/ld-version-script.m443
-rw-r--r--m4/pkg.m4155
-rw-r--r--m4/visibility.m477
-rw-r--r--maint/i686-w64-mingw32.txt33
-rw-r--r--maint/release-checklist.md89
-rwxr-xr-xmaint/update-authors.sh12
-rw-r--r--maint/x86_64-w64-mingw32.txt33
-rw-r--r--meson.build1381
-rw-r--r--meson_options.txt314
-rwxr-xr-xmeson_post_install.py106
-rw-r--r--subprojects/expat.wrap11
-rw-r--r--subprojects/glib.wrap10
-rw-r--r--test/CMakeLists.txt63
-rw-r--r--test/Makefile.am847
-rw-r--r--test/bus/common.c (renamed from test/bus/dispatch.c)19
-rw-r--r--test/bus/common.h21
-rw-r--r--test/bus/dispatch-sha1.c35
-rw-r--r--test/bus/failed-helper-activation.c (renamed from dbus/dbus-server-unix.h)30
-rw-r--r--test/bus/helper-activation.c35
-rw-r--r--test/bus/launch-helper-for-tests.c6
-rw-r--r--test/bus/launch-helper-oom.c2
-rw-r--r--test/bus/main.c35
-rw-r--r--test/bus/normal-activation.c35
-rw-r--r--test/bus/system.c2
-rw-r--r--test/containers.c3
-rw-r--r--test/corrupt.c25
-rwxr-xr-xtest/data/copy_data_for_tests.py35
-rw-r--r--test/data/dbus-installed-tests.aaprofile.in5
-rw-r--r--test/data/installable/meson.build45
-rw-r--r--test/data/invalid-messages/boolean-has-no-value.message-raw.license2
-rw-r--r--test/data/invalid-messages/fixed-array-not-divisible.message-rawbin0 -> 296 bytes
-rw-r--r--test/data/invalid-messages/fixed-array-not-divisible.message-raw.hex55
-rw-r--r--test/data/invalid-messages/fixed-array-not-divisible.message-raw.license3
-rw-r--r--test/data/invalid-messages/issue418.message-rawbin0 -> 68 bytes
-rw-r--r--test/data/invalid-messages/issue418.message-raw.hex47
-rw-r--r--test/data/invalid-messages/issue418.message-raw.license3
-rw-r--r--test/data/invalid-messages/mis-nested-sig.message-rawbin0 -> 40 bytes
-rw-r--r--test/data/invalid-messages/mis-nested-sig.message-raw.hex26
-rw-r--r--test/data/invalid-messages/mis-nested-sig.message-raw.license3
-rw-r--r--test/data/invalid-messages/truncated-variant-sig.message-rawbin0 -> 24 bytes
-rw-r--r--test/data/invalid-messages/truncated-variant-sig.message-raw.hex23
-rw-r--r--test/data/invalid-messages/truncated-variant-sig.message-raw.license2
-rw-r--r--test/data/invalid-messages/zero-length-variant-sig.message-rawbin0 -> 24 bytes
-rw-r--r--test/data/invalid-messages/zero-length-variant-sig.message-raw.hex23
-rw-r--r--test/data/invalid-messages/zero-length-variant-sig.message-raw.license2
-rw-r--r--test/data/meson.build239
-rw-r--r--test/data/valid-config-files/forbidding.conf.in3
-rw-r--r--test/data/valid-config-files/limit-containers.conf.in5
-rw-r--r--test/data/valid-config-files/listen-autolaunch-win.conf.in11
-rw-r--r--test/data/valid-config-files/tmp-session.conf.in7
-rw-r--r--test/data/valid-messages/byteswap-fd-index.message-rawbin0 -> 36 bytes
-rw-r--r--test/data/valid-messages/byteswap-fd-index.message-raw.hex43
-rw-r--r--test/data/valid-messages/byteswap-fd-index.message-raw.license3
-rw-r--r--test/data/valid-messages/minimal.message-rawbin0 -> 24 bytes
-rw-r--r--test/data/valid-messages/minimal.message-raw.hex25
-rw-r--r--test/data/valid-messages/minimal.message-raw.license2
-rw-r--r--test/dbus-daemon-eavesdrop.c1
-rw-r--r--test/dbus-daemon.c170
-rw-r--r--test/disable-crash-handling.c2
-rw-r--r--test/disable-crash-handling.h2
-rw-r--r--test/fdpass.c10
-rw-r--r--test/header-fields.c1
-rw-r--r--test/integration/transient-services.sh16
-rw-r--r--test/internals/address.c2
-rw-r--r--test/internals/assertions.c3
-rw-r--r--test/internals/atomic.c1
-rw-r--r--test/internals/counter.c120
-rw-r--r--test/internals/dbus-auth-script.c13
-rw-r--r--test/internals/dbus-auth-script.h2
-rw-r--r--test/internals/dbus-auth-util.c5
-rw-r--r--test/internals/dbus-credentials-util.c35
-rw-r--r--test/internals/dbus-marshal-byteswap-util.c2
-rw-r--r--test/internals/dbus-marshal-recursive-util.c33
-rw-r--r--test/internals/dbus-marshal-recursive-util.h2
-rw-r--r--test/internals/dbus-marshal-validate-util.c2
-rw-r--r--test/internals/dbus-message-factory.c2
-rw-r--r--test/internals/dbus-message-factory.h2
-rw-r--r--test/internals/dbus-message-util.c9
-rw-r--r--test/internals/dbus-message-util.h2
-rw-r--r--test/internals/dbus-string-util.c4
-rw-r--r--test/internals/dbus-sysdeps-util.c2
-rw-r--r--test/internals/desktop-file.c1
-rw-r--r--test/internals/hash.c1
-rw-r--r--test/internals/marshal-recursive.c2
-rw-r--r--test/internals/mempool.c2
-rw-r--r--test/internals/message-internals.c2
-rw-r--r--test/internals/misc-internals.c128
-rw-r--r--test/internals/misc-internals.h2
-rw-r--r--test/internals/printf.c32
-rw-r--r--test/internals/refs.c1
-rw-r--r--test/internals/server-oom.c17
-rw-r--r--test/internals/sha.c28
-rw-r--r--test/internals/spawn-oom.c2
-rw-r--r--test/internals/strings.c45
-rw-r--r--test/internals/sysdeps.c143
-rw-r--r--test/internals/syslog.c1
-rw-r--r--test/internals/userdb.c143
-rw-r--r--test/internals/variant.c1
-rw-r--r--test/loopback.c160
-rw-r--r--test/manual-authz.c1
-rw-r--r--test/manual-backtrace.c2
-rw-r--r--test/manual-dir-iter.c4
-rw-r--r--test/manual-paths.c4
-rw-r--r--test/manual-tcp.c3
-rw-r--r--test/marshal.c1
-rw-r--r--test/meson.build763
-rw-r--r--test/message.c251
-rw-r--r--test/meta_template.test.in4
-rwxr-xr-xtest/mkdir-m700.py15
-rw-r--r--test/monitor.c87
-rw-r--r--test/name-test/CMakeLists.txt8
-rw-r--r--test/name-test/Makefile.am111
-rw-r--r--test/name-test/meson.build103
-rwxr-xr-xtest/name-test/run-test-systemserver.sh11
-rwxr-xr-xtest/name-test/run-test.sh10
-rw-r--r--test/name-test/test-autolaunch-win.c343
-rw-r--r--test/name-test/test-autolaunch.c6
-rw-r--r--test/name-test/test-ids.c5
-rw-r--r--test/name-test/test-pending-call-disconnected.c1
-rw-r--r--test/name-test/test-pending-call-dispatch.c11
-rw-r--r--test/name-test/test-pending-call-timeout.c10
-rw-r--r--test/name-test/test-shutdown.c6
-rw-r--r--test/name-test/test-threads-init.c6
-rw-r--r--test/relay.c24
-rw-r--r--test/sd-activation.c1
-rw-r--r--test/syntax.c11
-rw-r--r--test/test-apparmor-activation.sh1
-rwxr-xr-xtest/test-dbus-daemon-fork.sh1
-rwxr-xr-xtest/test-dbus-launch-eval.sh1
-rwxr-xr-xtest/test-dbus-launch-x11.sh1
-rw-r--r--test/test-exit.c5
-rw-r--r--test/test-platform-mutex.c281
-rw-r--r--test/test-privserver.c35
-rw-r--r--test/test-segfault.c11
-rw-r--r--test/test-utils-glib.c94
-rw-r--r--test/test-utils-glib.h16
-rw-r--r--test/test-utils.c79
-rw-r--r--test/thread-blocking.c4
-rw-r--r--test/uid-permissions.c1
-rw-r--r--test/use-as-subproject/.gitignore5
-rw-r--r--test/use-as-subproject/config.h6
-rw-r--r--test/use-as-subproject/dummy-config.h.in6
-rw-r--r--test/use-as-subproject/meson.build38
-rw-r--r--test/use-as-subproject/use-libdbus.c17
-rw-r--r--tools/CMakeLists.txt2
-rw-r--r--tools/Makefile.am153
-rwxr-xr-xtools/build-timestamp.py32
-rwxr-xr-xtools/check-runstatedir.sh77
-rwxr-xr-xtools/ci-build.sh471
-rwxr-xr-xtools/ci-install.sh288
-rwxr-xr-xtools/cmake-format46
-rw-r--r--tools/dbus-cleanup-sockets.c1
-rw-r--r--tools/dbus-echo.c1
-rw-r--r--tools/dbus-launch-win.c2
-rw-r--r--tools/dbus-launch-x11.c25
-rw-r--r--tools/dbus-launch.c111
-rw-r--r--tools/dbus-launch.h2
-rw-r--r--tools/dbus-monitor.c18
-rw-r--r--tools/dbus-print-message.c18
-rw-r--r--tools/dbus-print-message.h3
-rw-r--r--tools/dbus-run-session.c92
-rw-r--r--tools/dbus-send.c102
-rw-r--r--tools/dbus-spam.c1
-rw-r--r--tools/dbus-update-activation-environment.c1
-rw-r--r--tools/dbus-uuidgen.c1
-rw-r--r--tools/disable-uac.rc1
-rw-r--r--tools/docker/windows/Dockerfile65
-rw-r--r--tools/docker/windows/Install.cmd19
-rw-r--r--tools/docker/windows/container.ps160
-rwxr-xr-xtools/meson-compat-install-emptydirs.py19
-rwxr-xr-xtools/meson-compat-install-symlink.py22
-rw-r--r--tools/meson.build116
-rw-r--r--tools/strtoll.c166
-rw-r--r--tools/strtoull.c145
-rw-r--r--tools/test-tool.c1
-rw-r--r--tools/test-tool.h1
-rw-r--r--tools/tool-common.c8
-rw-r--r--tools/tool-common.h2
461 files changed, 15439 insertions, 8993 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00000000..62f39b58
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,7 @@
+BasedOnStyle: GNU
+AlwaysBreakAfterDefinitionReturnType: All
+BreakBeforeBinaryOperators: None
+BinPackParameters: false
+SpaceAfterCStyleCast: true
+SpaceBeforeParens: Always
+AlignEscapedNewlines: DontAlign
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..83da4400
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,57 @@
+# For format see editorconfig.org
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+
+root = true
+
+[*]
+# In general all dbus code is in Unix text format, encoded as UTF-8
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+# Hard tabs (if used, but please don't) are worth 8 spaces, even if we
+# are indenting by 2 or 4 spaces per indent level
+tab_width = 8
+
+[{*.py,*.sh,meson.build,CMakeLists.txt,*.cmake}]
+# Most scripts are 4-space indented
+indent_size = 4
+indent_style = space
+
+[{*.c,*.cpp,*.h,*.h.in,Version.in,*.h.cmake}]
+# C/C++ code is GNU-style, see CONTRIBUTING.md
+# Note that order is important: *.h.cmake appears after *.cmake so that
+# the more specific rule takes precedence
+indent_size = 2
+indent_style = space
+
+[{*.xml,*.xml.in}]
+# As a special case, XML is 2-space indented
+indent_size = 2
+indent_style = space
+
+[configure.ac]
+# Inconsistently 2, 4 or arbitrary, so choose the lowest common denominator
+indent_size = 2
+indent_style = space
+
+[Makefile.am]
+# Hard tabs are syntactically significant in Make
+indent_size = 8
+indent_style = tab
+
+[*.md]
+indent_size = 4
+indent_style = space
+# The Markdown spec assumes tabs are only worth 4 spaces, so if hard tabs
+# exist, treat them as a 4-space indent
+tab_width = 4
+
+[test/name-test/*.sh]
+# As a special case, these older scripts are 2-space indented
+indent_size = 2
+indent_style = space
+
+[*.reg.in]
+# As a special case, this has Windows line-endings
+end_of_line = crlf
diff --git a/.gitignore b/.gitignore
index 7de60e0b..84c0b6ba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,48 +1,33 @@
/*.pc
/.ccache/
/Doxyfile
-/aclocal.m4
-/aminclude_static.am
-/autom4te.cache
-/build-aux/
+/build/
/bus/tmpfiles.d/dbus.conf
+/ci-build*/
+/*-prefix/
+*.zst*
+file*.lst
/cmake/DBus1Config*.cmake
-/config.cache
-/config.h
-/config.h.in
-/config.log
-/config.status
-/configure
/dbus-1.*-coverage.info
/dbus-1.*-coverage.info.tmp
/dbus-1.*-coverage/
/dbus-1.*.tar.*
/dbus-1.*/
-/libtool
-/m4/libtool.m4
-/m4/lt*.m4
-/stamp-h
-/stamp-h.in
-/stamp-h1
-/test-driver
-
+/src-from-dist/
*.bb
*.bbg
*.da
*.gcda
*.gcno
*.gcov
-*.la
-*.lo
*.o
*.orig
*.rej
*~
.*.sw?
.deps/
-.dirstamp
.libs/
Makefile
-Makefile.in
+__pycache__/
cscope.out
tags
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d0b1a01f..c496b3d4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,5 @@
# Copyright © 2015-2018 Collabora Ltd.
+# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
@@ -20,120 +21,464 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-image: debian:buster-slim
+workflow:
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+ - if: $CI_PIPELINE_SOURCE == 'push' && $CI_PROJECT_NAMESPACE == 'dbus'
-stages:
- - build
+include:
+ - project: 'freedesktop/ci-templates'
+ ref: fb33e1b244ec2a0b8edf8ee5590a96369c3b4666
+ file:
+ - '/templates/debian.yml'
+ - '/templates/freebsd.yml'
+ - '/templates/opensuse.yml'
-before_script:
- - ./tools/ci-install.sh
- - mkdir -p .ccache
- - export CCACHE_BASEDIR="$(pwd)"
- - export CCACHE_DIR="$CCACHE_BASEDIR/.ccache"
- # Debian's ccache package creates symlinks here for all supported
- # compilers
- - export PATH="/usr/lib/ccache:$PATH"
+image: debian:bullseye-slim
-cache:
- key: ${CI_JOB_NAME}
- paths:
- - .ccache/
+stages:
+ - 'build docker'
+ - build
variables:
+ ci_builddir: "build"
ci_in_docker: "yes"
ci_local_packages: "yes"
ci_parallel: "2"
ci_sudo: "yes"
- ci_distro: "debian"
- ci_suite: "buster"
+ # Temporarily needed to clean up after dbus/dbus#447
+ GIT_STRATEGY: clone
-build:production:
- stage: build
- image: "debian:buster-slim"
+ ###
+ # IMPORTANT
+ # These are the version tags for the docker images the CI runs against.
+ # If you are hacking on them or need a them to rebuild, its enough
+ # to change any part of the string of the image you want.
+ ###
+ WINDOWS_TAG: "2023-05-12.0"
+
+ UPSTREAM_BRANCH: 'master'
+ UPSTREAM_REPO: 'dbus/dbus'
+ WINDOWS_AMD64_SUFFIX: 'amd64/windows'
+ WINDOWS_IMAGE: "$CI_REGISTRY_IMAGE/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$UPSTREAM_BRANCH"
+ WINDOWS_UPSTREAM_IMAGE: "$CI_REGISTRY/$UPSTREAM_REPO/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$UPSTREAM_BRANCH"
+ # variables used by the ci-templates scripts:
+ FDO_UPSTREAM_REPO: dbus/dbus
+ FDO_DISTRIBUTION_EXEC: './tools/ci-install.sh'
+
+.debian-vars:
+ variables:
+ FDO_DISTRIBUTION_VERSION: 'bullseye-slim'
+ FDO_DISTRIBUTION_TAG: '2022-04-17' # Bump this version on every ci-install.sh or dist version change
+
+.opensuse-vars:
+ variables:
+ FDO_DISTRIBUTION_VERSION: 'leap'
+ FDO_DISTRIBUTION_TAG: '2023-12-01' # Bump this version on every ci-install.sh or dist version change
+
+.freebsd-vars:
+ variables:
+ BUILD_OS: freebsd
+ BUILD_ARCH: "x86_64"
+ FDO_DISTRIBUTION_VERSION: '13.1'
+ FDO_DISTRIBUTION_TAG: '2022-09-21.0' # Bump this version on every ci-install.sh or dist version change
+ FDO_REPO_SUFFIX: "$BUILD_OS/$BUILD_ARCH"
+
+.cmake-common:
+ variables:
+ # Default to generating JUnit XML output for all CMake jobs.
+ # This works fine even for older versions of CMake since the extra arguments
+ # to CTest are ignored and a missing JUnit XML file does not fail the build.
+ ci_cmake_junit_output: "$CI_PROJECT_DIR/test-results.xml"
+ ci_buildsys: "cmake"
+ artifacts:
+ name: dbus-$CI_JOB_NAME
+ when: always
+ paths:
+ - $CI_PROJECT_DIR/test-results.xml
+ - "build/config.h"
+ reports:
+ junit: $CI_PROJECT_DIR/test-results.xml
+
+.meson-common:
+ variables:
+ ci_buildsys: "meson"
+ artifacts:
+ reports:
+ junit: "build/meson-logs/testlog.junit.xml"
+ name: "dbus-$CI_JOB_NAME"
+ when: always
+ paths:
+ - "build/config.h"
+ - "build/meson-logs/*.txt"
+
+windows amd64 image:
+ stage: "build docker"
variables:
- ci_variant: "production"
- script: &script
- - chown -R user .
- - runuser -u user ./tools/ci-build.sh
+ # this file needs to be relative to docker/windows/ subdir
+ # as it makes life easier in the powershell script
+ DOCKERFILE: "tools/docker/windows/Dockerfile"
+ timeout: 2h 30m
+ tags:
+ - windows
+ - shell
+ - "2022"
+ script:
+ # We need to pass an array and to resolve the env vars, so we can't use a variable:
+ - $DOCKER_BUILD_ARGS = @("--build-arg", "DEFAULT_BRANCH=$UPSTREAM_BRANCH")
-build:debug:
+ - "& tools/docker/windows/container.ps1 $CI_REGISTRY $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD $WINDOWS_IMAGE $WINDOWS_UPSTREAM_IMAGE $DOCKERFILE"
+ - |
+ if (!($?)) {
+ echo "Failed to build the image"
+ Exit 1
+ }
+
+.unix-host-build:
stage: build
- image: "debian:buster-slim"
+ # No need to wait for the Windows Docker image to be built
+ needs: []
+ cache:
+ key: ${CI_JOB_NAME}
+ paths:
+ - .ccache/
+ before_script:
+ - ./tools/ci-install.sh
+ - mkdir -p .ccache
+ - export CCACHE_BASEDIR="$(pwd)"
+ - export CCACHE_DIR="$CCACHE_BASEDIR/.ccache"
+ # Debian's ccache package creates symlinks here for all supported
+ # compilers
+ - export PATH="/usr/lib/ccache:$PATH"
+ script:
+ - ./tools/ci-build.sh
+
+debian image:
+ extends:
+ - .fdo.container-build@debian
+ - .debian-vars
+ stage: 'build docker'
+
+.debian-build:
+ needs: ["debian image"]
+ extends:
+ - .fdo.distribution-image@debian
+ - .debian-vars
+ - .unix-host-build
+ stage: build
+
+debian cmake:
+ extends:
+ - .cmake-common
+ - .debian-build
+ when: manual
+ variables:
+ ci_buildsys: "cmake"
+
+debian meson:
+ extends:
+ - .meson-common
+ - .debian-build
variables:
+ ci_buildsys: "meson"
+
+debian meson clang debug:
+ extends:
+ - .meson-common
+ - .debian-build
+ variables:
+ ci_buildsys: "meson"
+ ci_compiler: "clang"
ci_variant: "debug"
- script: *script
+ script:
+ - ./tools/ci-build.sh
+ # Also test that we can be used as a subproject:
+ # https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/388
+ - meson dist -C $ci_builddir --formats xztar --no-tests
+ - mkdir -p test/use-as-subproject/subprojects/dbus
+ - tar --strip-components=1 -C test/use-as-subproject/subprojects/dbus -xf $ci_builddir/meson-dist/*.tar.xz
+ - meson setup --wrap-mode=forcefallback test/use-as-subproject/_build test/use-as-subproject
+ - meson compile -C test/use-as-subproject/_build
+ - meson test -C test/use-as-subproject/_build
-build:reduced:
- stage: build
+debian meson reduced:
+ extends:
+ - .meson-common
+ - .debian-build
when: manual
- image: "debian:buster-slim"
variables:
+ ci_buildsys: "meson"
ci_variant: "reduced"
- script: *script
-build:legacy:
- stage: build
+debian meson legacy:
+ extends:
+ - .meson-common
+ - .debian-build
when: manual
- image: "debian:buster-slim"
variables:
+ ci_buildsys: "meson"
ci_variant: "legacy"
- script: *script
-build:cmake:
- stage: build
- image: "debian:buster-slim"
+debian mingw32 cmake:
+ extends:
+ - .cmake-common
+ - .debian-build
+ when: manual
variables:
- ci_buildsys: "cmake-dist"
- script: *script
+ ci_host: "i686-w64-mingw32"
-build:i686-w64-mingw32-debug:
- stage: build
- image: "debian:buster-slim"
+debian mingw32 meson:
+ extends:
+ - .meson-common
+ - .debian-build
+ variables:
+ ci_host: "i686-w64-mingw32"
+
+debian mingw32 meson debug:
+ extends:
+ - .meson-common
+ - .debian-build
+ when: manual
variables:
+ ci_buildsys: "meson"
ci_host: "i686-w64-mingw32"
ci_variant: "debug"
- script: *script
-build:i686-w64-mingw32-cmake:
- stage: build
+debian mingw64 cmake debug:
+ extends:
+ - .cmake-common
+ - .debian-build
when: manual
- image: "debian:buster-slim"
variables:
ci_buildsys: "cmake"
- ci_host: "i686-w64-mingw32"
- script: *script
+ ci_host: "x86_64-w64-mingw32"
+ ci_variant: "debug"
-build:x86_64-w64-mingw32:
- stage: build
- image: "debian:buster-slim"
+debian mingw64 meson debug:
+ extends:
+ - .meson-common
+ - .debian-build
variables:
ci_host: "x86_64-w64-mingw32"
- script: *script
+ ci_variant: "debug"
+
+opensuse image:
+ extends:
+ - .fdo.container-build@opensuse
+ - .opensuse-vars
+ stage: 'build docker'
-build:x86_64-w64-mingw32-cmake-debug:
+.suse-build:
+ needs: ["opensuse image"]
+ extends:
+ - .fdo.distribution-image@opensuse
+ - .opensuse-vars
+ - .unix-host-build
stage: build
- image: "debian:buster-slim"
+
+opensuse cmake:
+ extends:
+ - .cmake-common
+ - .suse-build
+ variables:
+ ci_local_packages: "no"
+
+opensuse mingw32 cmake:
+ extends:
+ - .cmake-common
+ - .suse-build
+ when: manual
+ variables:
+ ci_host: "i686-w64-mingw32"
+ ci_local_packages: "no"
+
+opensuse mingw64 cmake debug:
+ extends:
+ - .cmake-common
+ - .suse-build
variables:
- ci_buildsys: "cmake"
ci_host: "x86_64-w64-mingw32"
+ ci_local_packages: "no"
ci_variant: "debug"
- script: *script
-build:stretch:
- when: manual
- stage: build
- image: "debian:stretch-slim"
+opensuse mingw64 meson debug:
+ extends:
+ - .meson-common
+ - .suse-build
+ variables:
+ ci_host: "x86_64-w64-mingw32"
+ ci_local_packages: "no"
+ # TODO: Tests in this configuration fail to find the mingw builds
+ # of expat and GLib in /usr/x86_64-w64-mingw32/sys-root/mingw/bin
+ ci_test: "no"
+ ci_variant: "debug"
+
+.ubuntu-build:
+ extends: .unix-host-build
+ image: "ubuntu:latest"
variables:
- ci_suite: "stretch"
- script: *script
+ ci_distro: "ubuntu"
+
+.win-build:
+ image: $WINDOWS_IMAGE
+ stage: build
+ tags:
+ - 'docker'
+ - 'windows'
+ - '2022'
+ needs:
+ - "windows amd64 image"
+ timeout: '2h'
+ before_script:
+ - $ErrorActionPreference = "Stop"
+ - $WarningPreference = "Stop"
+ - $env:DBUS_TEST_MALLOC_FAILURES = 0
+ - $env:PATH += ";C:\bin"
-build:xenial:
+windows msys64 ucrt64 cmake:
+ extends: .win-build
+ artifacts:
+ name: dbus-$CI_JOB_NAME
+ when: always
+ paths:
+ - "build/config.h"
+ script:
+ - $env:MSYSTEM = "UCRT64"
+ - $env:CHERE_INVOKING = "1"
+ - $env:MSYS2_PATH_TYPE = "inherit"
+ - $env:PATH += ";C:\msys64\usr\bin"
+ # FIXME: glib from msys2 has issues, disable it for now
+ - C:\msys64\usr\bin\bash -lc 'cmake -G \"MinGW Makefiles\" -S . -B build -DDBUS_WITH_GLIB=OFF && cmake --build build --config Release'
+
+windows vs15-64 cmake:
+ extends:
+ - .cmake-common
+ - .win-build
+ script:
+ - cmake -DCMAKE_PREFIX_PATH=C:/ -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Debug -DDBUS_ENABLE_VERBOSE_MODE=OFF -S . -B build
+ - cmake --build build --config Debug
+ - cmake --install build --config Debug
+ # FIXME: a few tests timeout on gitlab runner for unknown reason
+ - cd build ; ctest -C Debug -VV --timeout 1200 -E '(dbus-daemon|monitor|header-fields)' --output-junit $ci_cmake_junit_output
+
+windows-meson-mingw-ucrt64:
+ extends: .win-build
+ script:
+ - $env:MSYSTEM = "UCRT64"
+ - $env:CHERE_INVOKING = "1"
+ - $env:MSYS2_PATH_TYPE = "inherit"
+ - $env:PATH += ";C:\msys64\usr\bin"
+ # FIXME: -j1: for some reason on CI ninja: fatal: pipe: Too many open files
+ - C:\msys64\usr\bin\bash -lc "
+ meson build &&
+ ninja -j1 -C build &&
+ meson test --no-suite=runs-dbus-daemon -C build"
+ artifacts:
+ reports:
+ junit: "build/meson-logs/testlog.junit.xml"
+ name: "dbus-$CI_JOB_NAME"
+ when: always
+ paths:
+ - "build/config.h"
+ - "build/meson-logs/*.txt"
+ # Currently broken, https://gitlab.freedesktop.org/dbus/dbus/-/issues/462
when: manual
+
+windows-meson-vs15-x86:
+ extends: .win-build
+ script:
+ # FIXME: tests that run dbus-daemon time out on the Gitlab runner
+ - cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=x86 &&
+ meson --force-fallback-for=expat,glib,zlib build &&
+ meson compile -C build &&
+ meson test --no-suite=runs-dbus-daemon -C build"
+ artifacts:
+ reports:
+ junit: "build/meson-logs/testlog.junit.xml"
+ name: "dbus-$CI_JOB_NAME"
+ when: always
+ paths:
+ - "build/config.h"
+ - "build/meson-logs/*.txt"
+
+freebsd image:
+ extends:
+ - .fdo.qemu-build@freebsd@x86_64
+ - .freebsd-vars
+ stage: 'build docker'
+
+# Full build and test.
+.do-build-qemu:
stage: build
- image: "ubuntu:xenial"
variables:
- ci_distro: "ubuntu"
- ci_suite: "xenial"
- script: *script
+ ci_parallel: "${FDO_CI_CONCURRENT:-2}"
+ ci_distro: "$BUILD_OS"
+ ci_suite: "$FDO_DISTRIBUTION_VERSION"
+ script:
+ # Start the VM and copy our workspace to the VM
+ - /app/vmctl start
+ # Copy files over to the VM using rsync (not scp) to preserve permissions.
+ - rsync -av $PWD "vm:"
+ - /app/vmctl exec "cd $CI_PROJECT_NAME && ./tools/ci-install.sh"
+ # Variables are not forwarded to the vm automatically so we forward the
+ # ones starting with ci_ to ci-build.sh manually. This works because
+ # $(env | grep "ci_.*=") is evaluated on the current host not in the VM.
+ - /app/vmctl exec "cd $CI_PROJECT_NAME && env make=gmake $(echo $(env | grep "ci_.*=")) bash -x ./tools/ci-build.sh $CI_BUILD_ARGS"
+ # Copy build artifacts from the VM for archiving/JUnit XML display
+ - mkdir -p "$ci_builddir"
+ - rsync -av "vm:$CI_PROJECT_NAME/$ci_builddir/meson-logs" "$ci_builddir/" || true
+ - scp -v "vm:$CI_PROJECT_NAME/$ci_builddir/config.h" . || true
+ - scp -v "vm:$ci_cmake_junit_output" "$ci_cmake_junit_output" || true
+ # Finally, shut down the VM.
+ - /app/vmctl stop
+ artifacts:
+ name: dbus-$CI_JOB_NAME
+ when: always
+ paths:
+ - test-results.xml
+ reports:
+ junit: test-results.xml
+
+.build-env-freebsd:
+ extends:
+ - .fdo.suffixed-image@freebsd
+ - .freebsd-vars
+ - .do-build-qemu
+ needs:
+ - job: "freebsd image"
+ artifacts: false
+ variables:
+ # Don't install with sudo (since we are already building as root and sudo
+ # is not currently installed on the CI image).
+ ci_sudo: "no"
+
+freebsd cmake debug:
+ extends:
+ - .cmake-common
+ - .build-env-freebsd
+ variables:
+ # Don't build doxygen documentation since installing the required tools
+ # massively increases the VM image (and therefore container) size.
+ CI_BUILD_ARGS: "-DDBUS_ENABLE_DOXYGEN_DOCS=OFF -DDBUS_ENABLE_XML_DOCS=ON -DCMAKE_BUILD_TYPE=Debug"
+
+freebsd cmake release:
+ extends:
+ - .cmake-common
+ - .build-env-freebsd
+ variables:
+ # Don't build doxygen documentation since installing the required tools
+ # massively increases the VM image (and therefore container) size.
+ CI_BUILD_ARGS: "-DDBUS_ENABLE_DOXYGEN_DOCS=OFF -DDBUS_ENABLE_XML_DOCS=ON -DCMAKE_BUILD_TYPE=Release"
+
+freebsd meson:
+ extends:
+ - .build-env-freebsd
+ - .meson-common
+ variables:
+ # On FreeBSD the `environ` symbol is provided by the c startup code and is
+ # only defined in the main executable and not available in libc.so, so
+ # building with -Wl,-no-undefined results in errors.
+ # See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263265.
+ CI_BUILD_ARGS: "-Db_lundef=false"
# vim:set sw=2 sts=2 et:
diff --git a/.gitlab/issue_templates/Bug.md b/.gitlab/issue_templates/Bug.md
new file mode 100644
index 00000000..6efc8232
--- /dev/null
+++ b/.gitlab/issue_templates/Bug.md
@@ -0,0 +1,17 @@
+## To reproduce
+
+Steps to reproduce the behavior:
+1. ...
+2. ...
+
+## Expected result
+
+A clear and concise description of what you expected to happen.
+
+## Actual result
+
+A clear and concise description of what the bug is.
+
+## Additional context
+
+Add any other context about the problem here.
diff --git a/.gitlab/issue_templates/Feature.md b/.gitlab/issue_templates/Feature.md
new file mode 100644
index 00000000..d9eeec2d
--- /dev/null
+++ b/.gitlab/issue_templates/Feature.md
@@ -0,0 +1,15 @@
+## Is your feature request related to a problem? Please describe.
+
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+## Describe the solution you'd like
+
+A clear and concise description of what you want to happen.
+
+## Describe alternatives you've considered
+
+A clear and concise description of any alternative solutions or features you've considered.
+
+## Additional context
+
+Add any other context or screenshots about the feature request here.
diff --git a/.reuse/dep5 b/.reuse/dep5
new file mode 100644
index 00000000..07c8b23e
--- /dev/null
+++ b/.reuse/dep5
@@ -0,0 +1,9 @@
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: dbus
+Source: https://gitlab.freedesktop.org/dbus/dbus
+
+Files:
+ subprojects/*.wrap
+Copyright:
+ © 2022-2023 Meson contributors
+License: MIT
diff --git a/AUTHORS b/AUTHORS
index ed8afdf1..8447bfed 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,31 +1,81 @@
+Adrian Szyndela <adrian.s@samsung.com>
+Ahmed Abdelfattah <a.abfattah@gmail.com>
+Aiknow <shixin21@huawei.com>
+Alan Coopersmith <alan.coopersmith@oracle.com>
Alban Crequy <alban.crequy@collabora.co.uk>
Alexander Larsson <alexl@redhat.com>
+Alex Richardson <arichardson@FreeBSD.org>
+Alex Richardson <arichardson.kde@gmail.com>
Anders Carlsson <andersca@codefactory.se>
+Andoni Morales Alastruey <ylatuya@gmail.com>
Andre Heinecke <aheinecke@intevation.de>
+Andrey Mazo <ahippo@yandex.ru>
+Andy Fiddaman <omnios@citrus-it.co.uk>
+Antoine Jacoutot <ajacoutot@gnome.org>
+Antoine Jacoutot <ajacoutot openbsd org>
+Arnout Engelen <arnout@bzzt.net>
Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
+Arun Raghavan <arun.raghavan@collabora.co.uk>
Aurelien Jarno <aurel32@debian.org>
+Barnabás Pőcze <pobrn@protonmail.com>
+Benedikt Heine <bebe@bebehei.de>
Benjamin Reed <rangerrick@befunk.com>
+Bertrand SIMONNET <bsimonnet@chromium.org>
+Brad Smith <brad comstyle com>
Brian Cameron <brian.cameron@oracle.com>
Brian Cameron <brian.cameron@sun.com>
+Cameron Norman <camerontnorman@gmail.com>
+Chengwei Yang <chengwei.yang@intel.com>
+Chigozirim Chukwu <nobleman.code@gmx.com>
+Chris Lesiak <chris.lesiak@licor.com>
Chris Mayo <aklhfex gmail com>
+Chris Morin <cmtm@google.com>
+Chris PeBenito <chpebeni@linux.microsoft.com>
Christian Dywan <christian.dywan@lanedo.com>
Christian Ehrlicher <Ch.Ehrlicher@gmx.de>
Christian Persch (GNOME) <chpe@gnome.org>
+Christopher Morin <chris.morin2@gmail.com>
+Clemens Lang <clemens.lang@bmw-carit.de>
Colin Walters <walters@verbum.org>
Colin Watson <cjwatson@ubuntu.com>
+Cosimo Alfarano <cosimo.alfarano@collabora.com>
Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
+cptpcrd <cptpcrd.git@gmail.com>
+Cristian Onet <onet.cristian@gmail.com>
Cristian Rodríguez <cristian.rodriguez@opensuse.org>
+Cristian Rodríguez <crrodriguez@opensuse.org>
Cyril Brulebois <kibi@debian.org>
+Dagobert Michelsen <dam@opencsw.org>
Daniel P. Berrange <dan@berrange.com>
Daniel Reed <djr@redhat.com>
+Daniel Wagner <dwagner@suse.de>
+Daniel Wendt <daniel.wendt@linux.com>
+Dan Williams <dcbw@redhat.com>
+Dave Jones <dave.jones@canonical.com>
+Dave Reisner <dreisner@archlinux.org>
+David King <dking@redhat.com>
+David Redondo <kde@david-redondo.de>
David Zeuthen <davidz@redhat.com>
+David Zeuthen <zeuthen@gmail.com>
+Deepika Aggarwal <deepika.a@samsung.com>
Dennis Kaarsemaker <dennis@kaarsemaker.net>
Diego E. 'Flameeyes' Pettenò <flameeyes@gmail.com>
+Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
+Dmitri Iouchtchenko <johnnyspoon@gmail.com>
+DreamNik <dreamnik@mail.ru>
Eamon Walsh <ewalsh@tycho.nsa.gov>
+Evgeny Vereshchagin <evvers@ya.ru>
+eXeC001er <execooler@gmail.com>
Federico Mena Quintero <federico@novell.com>
+Felipe Franciosi <felipe@nutanix.com>
+Felipe Gasper <felipe@felipegasper.com>
+Félix Piédallu <felix@piedallu.me>
+Francesco Turco <fturco fastmail fm>
Frank Osterfeld <frank@kdab.net>
Frederic Crozat <fcrozat@mandriva.com>
+Frederik Van Bogaert <frederik.vanbogaert@mind.be>
Fridrich Štrba <fridrich.strba@bluewin.ch>
+Geoffrey Thomas <gthomas@mokafive.com>
Grzegorz Dąbrowski <gdx@poczta.fm>
Harald Fernengel <harry@kdevelop.org>
Harri Porten <porten@kde.org>
@@ -33,90 +83,185 @@ Hasso Tepper <hasso@estpak.ee>
Havoc Pennington <hp@pobox.com>
Havoc Pennington <hp@redhat.com>
Hendrik Buschmeier <hbuschme@TechFak.Uni-Bielefeld.DE>
+hongjinghao <q1204531485@163.com>
+hyeric <eric.hyer@diehl.com>
+ilovezfs <ilovezfs@icloud.com>
+Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
+Issam E. Maghni <issam.e.maghni@mailbox.org>
+Ivan Romanov <drizt land ru>
+Jaap Boender <jaapb@kerguelen.org>
+Jacek Bukarewicz <j.bukarewicz@samsung.com>
+Jack Nagel <jacknagel@gmail.com>
James Carter <jwcart2@tycho.nsa.gov>
James Westby <jw+debian@jameswestby.net>
James Willcox <jwillcox@gnome.org>
+Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
+Jan Tojnar <jtojnar@gmail.com>
+Jean-Louis Fuchs <jean-louis.fuchs@adfinis-sygroup.ch>
Jens Granseuer <jensgr@gmx.net>
Jérémie Dimino <jeremie@dimino.org>
+Jeremi Piotrowski <jpiotrowski@microsoft.com>
+Jesper Dam <jalf@medical-insight.com>
Jiří Klimeš <jklimes@redhat.com>
Joe Marcus Clarke <marcus@freedesktop.org>
Joe Shaw <joeshaw@novell.com>
Johan Gyllenspetz <johangy@axis.com>
Johannes Carlsson <johannes.carlsson.x@sonyericsson.com>
+Johannes Kauffmann <johanneskauffmann@hotmail.com>
+John Bradshaw <john johnbradshaw org>
John (J5) Palmieri <johnp@redhat.com>
+John Johansen <john.johansen@canonical.com>
+Jonathan Perkin <jonathan perkin org uk>
Jon Gosting <yukarionsen@gmail.com>
Jon Trowbridge <trow@ximian.com>
+Jordan Williams <jordan@jwillikers.com>
+Julien Schueller <schueller@phimeca.com>
+Justin Lee <justinlee5455@gmail.com>
+Kai A. Hiller <V02460@gmail.com>
Kay Sievers <kay.sievers@vrfy.org>
+Khem Raj <raj.khem@gmail.com>
Kimmo Hämäläinen <kimmo.hamalainen@nokia.com>
+Kir Kolyshkin <kolyshkin@gmail.com>
Kjartan Maraas <kmaraas@gnome.org>
Kristian Høgsberg <krh@redhat.com>
Kristian Rietveld <kris@gtk.org>
+Krzysztof Konopko <krzysztof.konopko@youview.com>
Kurt Miller <kurt@intricatesoftware.com>
+Lars Uebernickel <lars@uebernic.de>
+Lars Wendler <polynomial-c@gentoo.org>
+Laurent Bigonville <bigon@bigon.be>
Lawrence R. Steeger <lsteeger@gmail.com>
Lennart Poettering <lennart@poettering.net>
Lennart Poettering <mzqohf@0pointer.de>
Lionel Landwerlin <lionel.landwerlin@openwide.fr>
+Luca Boccassi <bluca@debian.org>
Luiz Augusto Von Dentz <luiz.dentz-von@nokia.com>
+Lukasz Skalski <l.skalski@samsung.com>
+Manish Narang <Manish.Narang@kpit.com>
+Marc-André Lureau <marcandre.lureau@redhat.com>
Marc Brockschmidt <he@debian.org>
Marc Mutz <marc@kdab.net>
+Marc Mutz <marc.mutz@kdab.com>
+Marco Trevisan (Treviño) <mail@3v1n0.net>
Marcus Brinkmann <marcus.brinkmann@ruhr-uni-bochum.de>
Mark Brand <mabrand@mabrand.nl>
Mark McLoughlin <mark@skynet.ie>
+Martin Pitt <martinpitt@gnome.org>
+Martin Pitt <martin.pitt@ubuntu.com>
+Matt Fischer <matt.fischer@garmin.com>
Matthias Clasen <mclasen@redhat.com>
+Matthijs van Duin <matthijsvanduin@gmail.com>
+Matt Hoosier <matt.hoosier@garmin.com>
Matt McCutchen <matt@mattmccutchen.net>
Michael Meeks <michael.meeks@novell.com>
Michael Meeks <michael@ximian.com>
+Michael Nosthoff <freedesktop@heine.tech>
+Michal Koutný <mkoutny@suse.com>
+Michel HERMIER <hermier@frugalware.org>
Mikael Hallendal <micke@codefactory.se>
Mikael Hallendal <micke@imendio.com>
+Mike Gilbert <floppym@gentoo.org>
Mike McQuaid <mike@mikemcquaid.com>
+Milan Crha <mcrha redhat com>
Miloslav Trmac <mitr@volny.cz>
Murray Cumming <murrayc@murrayc.com>
+Natanael Copa <ncopa@alpinelinux.org>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
+Nick Lewycky <nlewycky@google.com>
Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>
Olivier Andrieu <oliv__a@users.sourceforge.net>
+osmond sun <osmond.sun@gmail.com>
Oswald Buddenhagen <ossi@kde.org>
Owen Fraser-Green <owen@discobabe.net>
Patrick von Reth <patrick.vonreth@gmail.com>
+Patrick Welche <prlw1@cam.ac.uk>
Pau Garcia i Quiles <pgquiles@elpauer.org>
Paul Bolle <pebolle@tiscali.nl>
+Pavel Strashkin <pavel.strashkin@gmail.com>
+Pavel Strashkin <pavel.strashkin@nexenta.com>
+Peter Benie <pjb1008>
Peter Breitenlohner <peb@mppmu.mpg.de>
Peter Kümmel <syntheticpp@gmx.net>
+Peter McCurdy <peter.mccurdy@gmail.com>
Peter McCurdy <pmccurdy@skeptopotamus>
Philip Blundell <philb@gnu.org>
+Philip Withnall <philip.withnall@collabora.co.uk>
+Philip Withnall <withnall@endlessm.com>
+Pino Toscano <toscano.pino@tiscali.it>
Plácido Revilla <unknown@unknown.domain>
+Radoslaw Pajak <r.pajak@samsung.com>
Ralf Habacker <ralf.habacker@freenet.de>
+Ralf Habacker <ralf.habacker@sag.eu>
Ray Strode <rstrode@redhat.com>
Richard A. Hankins <richard.a.hankins@gmail.com>
Richard Hughes <richard@hughsie.com>
Richard Hult <rhult@codefactory.se>
Richard Hult <richard@imendio.com>
+rim <rozhuk.im@gmail.com>
+Robert Ancell <robert.ancell@canonical.com>
Robert McQueen <robot101@debian.org>
Roberto Guido <bob4job@gmail.com>
+Rolland Dudemaine <rolland ghs com>
Romain Pokrzywka <romain@kdab.com>
Ross Burton <ross@openedhand.com>
Ryan Lortie <desrt@desrt.ca>
+Samy Mahmoudi <samy.mahmoudi@gmail.com>
Sascha Silbe <sascha-pgp@silbe.org>
Sascha Silbe <sascha-web-bugs.freedesktop.org@silbe.org>
+SCOTT-HAMILTON <sgn.hamilton+github@protonmail.com>
Scott James Remnant <scott@netsplit.com>
Scott James Remnant <scott@ubuntu.com>
+Sebastian Rasmussen <sebras@hotmail.com>
Sebastian Sauer <sebsauer@kdab.net>
Seth Nickell <seth@gnome.org>
+Shin-ichi MORITA <shin1morita@gmail.com>
Simon McVittie <simon.mcvittie@collabora.co.uk>
+Simon McVittie <smcv@collabora.com>
+Simon McVittie <smcv@debian.org>
+Simon Peeters <peeters.simon@gmail.com>
+Siraj Razick <siraj.razick@collabora.co.uk>
Sjoerd Simons <sjoerd@luon.net>
Sledz <sledz@MOBIL-400-586.intern.dresearch.de>
Steve Grubb <sgrubb@redhat.com>
Sven Herzberg <sven@imendio.com>
+Sviatoslav Chagaev <sviatoslav.chagaev@gmail.com>
+Taras Zaporozhets <taras.zaporozhets@ev-box.com>
Thiago Macieira <thiago@kde.org>
+Thiago Macieira <thiago.macieira@intel.com>
+Thomas Fitzsimmons <fitzsim@cisco.com>
+Thomas Haller <thaller@redhat.com>
+Thomas Kluyver <thomas@kluyver.me.uk>
+Thomas Zajic <zlatko gmx at>
+Thomas Zimmermann <tdz@users.sourceforge.net>
Tim Dijkstra <tim@famdijkstra.org>
Tobias Mueller <fdo-bugs@cryptobitch.de>
Tomas Hoger <thoger@redhat.com>
Tomas Pelka <tpelka@redhat.com>
+Tom Gundersen <teg@jklm.no>
Tom Hughes <tom.hughes@palm.com>
+Tony Theodore <tonyt logyst com>
+Topi Miettinen <toiwoton@gmail.com>
Tor Lillqvist <tml@iki.fi>
+Tuomo Rinne <tuomo.rinne@pm.me>
+Tyler Hicks <tyhicks@canonical.com>
+Umut Tezduyar Lindskog <umut@tezduyar.com>
+Vasiliy Balyasnyy <v.balyasnyy@samsung.com>
Waldo Bastian <bastian@kde.org>
+WaLyong Cho <walyong.cho@samsung.com>
+William Earley <nitrous@sourt.in>
William Lachance <wrlach@gmail.com>
Will Thompson <will.thompson@collabora.co.uk>
+Wolfgang Baron <netz.frei freenet de>
Wulf C. Krueger <philantrop@exherbo.org>
Xan Lopez <xan@gnome.org>
+Xin Shi <shixin21@huawei.com>
Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
+Yen-Chin, Lee <coldnew.tw@gmail.com>
+Yiyang Fei <YiYang.Fei@barco.com>
Zack Rusin <zack@kde.org>
+Zeeshan Ali <zeenix@gmail.com>
+Zeeshan Ali <zeeshanak@gnome.org>
+Zygmunt Krynicki <me@zygoon.pl>
+Илья А. Ткаченко <ilya.tkachenko@syncopate.ru>
+Роман Донченко <dpb corrigendum ru>
+Руслан Ижбулатов <lrn1986@gmail.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d86b8ac4..d3ec71be 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,49 +1,34 @@
-# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
+cmake_minimum_required(VERSION 3.9)
# we do not need to have WIN32 defined
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
-project(dbus)
-
-# we need to be up to date
-cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
-if(COMMAND cmake_policy)
- cmake_policy(SET CMP0003 NEW)
-endif()
-
-if(CMAKE_MAJOR_VERSION GREATER 2)
- cmake_policy(SET CMP0026 NEW)
- if(CMAKE_MAJOR_VERSION GREATER 4 OR CMAKE_MINOR_VERSION GREATER 1)
- cmake_policy(SET CMP0053 NEW)
- cmake_policy(SET CMP0054 NEW)
- endif()
-endif()
-
-option(DBUS_BUILD_TESTS "enable unit test code" ON)
+# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
# detect version
-include(MacrosAutotools)
-autoinit(configure.ac)
-autoversion(dbus)
+include(MacrosMeson)
+meson_init(meson.build)
+meson_version(dbus)
+set(DBUS_PATCH_VERSION 0)
+set(VERSION "${DBUS_VERSION}")
-if(EXISTS ${CMAKE_SOURCE_DIR}/config.h.in)
- autoheaderchecks(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_SOURCE_DIR}/cmake/ConfigureChecks.cmake ${CMAKE_SOURCE_DIR}/cmake/config.h.cmake)
+if(WIN32)
+ set(LANGUAGES C CXX)
else()
- message(STATUS "Generate config.h.in with autogen.sh to enable cmake header difference check.")
+ set(LANGUAGES C)
endif()
+project(dbus
+ VERSION ${DBUS_VERSION}
+ LANGUAGES C CXX
+)
-# used by file version info
-set(DBUS_PATCH_VERSION "0")
+option(DBUS_BUILD_TESTS "enable unit test code" ON)
-# set PACKAGE_... variables
-autopackage(
- dbus
- ${DBUS_VERSION_STRING}
- "http://dbus.freedesktop.org"
- "https://gitlab.freedesktop.org/dbus/dbus/issues"
-)
+# replacement for AC_C_BIGENDIAN
+include (TestBigEndian)
+test_big_endian(WORDS_BIGENDIAN)
include(Macros)
string(TIMESTAMP DBUS_BUILD_TIMESTAMP "%Y%m%d%H%M" UTC)
@@ -79,7 +64,7 @@ set(DBUS_MACHINE_UUID_FILE ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/dbus/machin
set(DBUS_BINDIR ${CMAKE_INSTALL_FULL_BINDIR})
set(DBUS_DAEMONDIR ${CMAKE_INSTALL_FULL_BINDIR})
set(DBUS_LOCALSTATEDIR ${CMAKE_INSTALL_FULL_LOCALSTATEDIR})
-set(DBUS_RUNSTATEDIR ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run)
+set(DBUS_RUNSTATEDIR ${CMAKE_INSTALL_FULL_RUNSTATEDIR})
# On Windows this is relative to where we put the bus setup, in
# ${datadir}/dbus-1. For simplicity, we only do this if
@@ -96,6 +81,7 @@ endif()
option(DBUS_RELOCATABLE "Attempt to make metadata relocatable" ON)
option(DBUS_ENABLE_PKGCONFIG "Enable pkgconfig support" ON)
+option(ENABLE_VERBOSE_CONFIG "Be verbose on generating config files" OFF)
# For simplicity, we're not relocatable if CMAKE_INSTALL_LIBDIR
# is something more complicated (e.g. Debian multiarch);
@@ -118,13 +104,14 @@ set(BUILD_SHARED_LIBS ON)
set(INSTALL_TARGETS_DEFAULT_ARGS EXPORT DBus1Targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(CYGWIN)
+ # TODO cygwin is not using WIN32 api
set(WIN32)
endif()
# search for required packages
if(WIN32)
# include local header first to avoid using old installed header
- set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/..)
+ set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${PROJECT_SOURCE_DIR})
include(Win32Macros)
addExplorerWrapper(${CMAKE_PROJECT_NAME})
endif()
@@ -137,12 +124,15 @@ endif()
option(DBUS_DISABLE_ASSERT "Disable assertion checking" OFF)
option(DBUS_ENABLE_STATS "enable bus daemon usage statistics" OFF)
-option(DBUS_ENABLE_CONTAINERS "enable restricted servers for app-containers" OFF)
option(ENABLE_TRADITIONAL_ACTIVATION "Enable traditional activation (without using systemd)" ON)
+find_package(PkgConfig)
+
if(DBUS_LINUX)
add_auto_option(ENABLE_SYSTEMD "build with systemd at_console support" AUTO)
- include(FindPkgConfig)
+ if (NOT PKG_CONFIG_FOUND)
+ message(SEND_ERROR "pkg-config not found, this is required on Linux systems")
+ endif()
pkg_check_modules(SYSTEMD libsystemd>=209)
if(NOT SYSTEMD_FOUND)
pkg_check_modules(SYSTEMD libsystemd-login>=32 libsystemd-daemon>=32 libsystemd-journal>=32)
@@ -191,27 +181,20 @@ endif()
find_package(EXPAT)
find_package(X11)
-find_package(GLib2)
+find_package(GLIB2)
if(GLIB2_FOUND)
option(DBUS_WITH_GLIB "build with glib" ON)
endif()
# analogous to AC_USE_SYSTEM_EXTENSIONS in configure.ac
-add_definitions(-D_GNU_SOURCE)
+set(_GNU_SOURCE 1)
# do config checks
include(ConfigureChecks)
-# @TODO: how to remove last dir from ${CMAKE_SOURCE_DIR} ?
-set(DBUS_SOURCE_DIR ${CMAKE_SOURCE_DIR}/..)
-
# make some more macros available
include(MacroLibrary)
-if(VCS)
- set(DBUS_VERBOSE_C_S 1 CACHE STRING "verbose mode" FORCE)
-endif()
-
if(MSVC)
# controll folders in msvc projects
include(ProjectSourceGroup)
@@ -220,14 +203,23 @@ if(MSVC)
set(GROUP_CODE flat)
endif()
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /FIconfig.h")
- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /FIconfig.h")
+ string(APPEND CMAKE_C_FLAGS_DEBUG " /FIconfig.h")
+ string(APPEND CMAKE_C_FLAGS_RELEASE " /FIconfig.h")
option(DBUS_MSVC_ANALYZE "Enable code analyzing for MSVC compiler: /analyze" OFF)
endif()
#
# setup warnings
#
+if(NOT MSVC)
+ # We're treating -fno-common like a warning: it makes the linker more
+ # strict, because on some systems the linker is *always* this strict
+ string(APPEND CMAKE_C_FLAGS " -fno-common")
+ string(APPEND CMAKE_CXX_FLAGS " -fno-common")
+endif()
+
+option(ENABLE_WERROR "Unconditionally make all compiler warnings fatal" OFF)
+
if(MSVC)
# Use the highest warning level
if(WALL)
@@ -236,13 +228,13 @@ if(MSVC)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
+ string(APPEND CMAKE_CXX_FLAGS " /W4")
endif()
if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else()
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
+ string(APPEND CMAKE_C_FLAGS " /W4")
endif()
else()
set(CMAKE_CXX_WARNING_LEVEL 3 CACHE STRING "warning level" FORCE)
@@ -250,12 +242,12 @@ if(MSVC)
# see https://msdn.microsoft.com/en-us/library/z78503e6.aspx
# 4018 'expression' : signed/unsigned mismatch
- set(WARNINGS "4018")
+ set(WARNINGS 4018)
# 4090 'operation' : different 'modifier' qualifiers
# 4101 'identifier' : unreferenced local variable
# 4127 conditional expression is constant
# 4244 'argument' : conversion from 'type1' to 'type2', possible loss of data
- set(WARNINGS_DISABLED "4090 4101 4127 4244")
+ set(WARNINGS_DISABLED 4090 4101 4127 4244)
# 4002 too many actual parameters for macro 'identifier'
# 4003 not enough actual parameters for macro 'identifier'
# 4013 'function' undefined; assuming extern returning int
@@ -264,38 +256,131 @@ if(MSVC)
# 4047 operator' : 'identifier1' differs in levels of indirection from 'identifier2'
# 4114 same type qualifier used more than once
# 4133 'type' : incompatible types - from 'type1' to 'type2'
- set(WARNINGS_ERRORS "4002 4003 4013 4028 4031 4047 4114 4133")
+ set(WARNINGS_ERRORS 4002 4003 4013 4028 4031 4047 4114 4133)
if(DBUS_MSVC_ANALYZE AND MSVC_VERSION GREATER 1600)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /analyze")
+ string(APPEND CMAKE_C_FLAGS " /analyze")
endif()
else()
- set(WARNINGS "sign-compare")
- set(WARNINGS_DISABLED "")
- set(WARNINGS_ERRORS "")
+ set(WARNINGS
+ all
+ array-bounds
+ cast-align
+ char-subscripts
+ declaration-after-statement
+ double-promotion
+ duplicated-branches
+ duplicated-cond
+ extra
+ float-equal
+ format-nonliteral
+ format-security
+ format=2
+ implicit-function-declaration
+ init-self
+ inline
+ jump-misses-init
+ logical-op
+ missing-declarations
+ missing-format-attribute
+ missing-include-dirs
+ missing-noreturn
+ missing-prototypes
+ nested-externs
+ no-error=missing-field-initializers
+ no-error=unused-label
+ no-error=unused-parameter
+ no-missing-field-initializers
+ no-unused-label
+ no-unused-parameter
+ null-dereference
+ old-style-definition
+ packed
+ pointer-arith
+ pointer-sign
+ redundant-decls
+ restrict
+ return-type
+ shadow
+ sign-compare
+ strict-aliasing
+ strict-prototypes
+ switch-default
+ switch-enum
+ undef
+ unused-but-set-variable
+ write-strings
+ )
+ set(WARNINGS_C
+ pointer-sign
+ )
+ set(WARNINGS_DISABLED
+ error=inline
+ error=overloaded-virtual
+ error=missing-field-initializers
+ error=null-dereference
+ error=strict-aliasing
+ error=unused-parameter
+ inline
+ unused-parameter
+ )
+ set(WARNINGS_ERRORS
+ )
+ if(ENABLE_WERROR)
+ list(APPEND WARNINGS error)
+ endif()
endif()
-generate_warning_cflags(WARNINGS_CFLAGS "${WARNINGS}" "${WARNINGS_DISABLED}" "${WARNINGS_ERRORS}")
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNINGS_CFLAGS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNINGS_CFLAGS}")
+
+generate_compiler_warning_flags(
+ RESULTVAR
+ WARNINGS_CFLAGS
+ WARNINGS
+ ${WARNINGS}
+ ${WARNINGS_C}
+ DISABLED
+ ${WARNINGS_DISABLED}
+ ERRORS
+ ${WARNINGS_ERRORS}
+)
+generate_compiler_warning_flags(
+ CXX
+ RESULTVAR
+ WARNINGS_CXXFLAGS
+ WARNINGS
+ ${WARNINGS}
+ DISABLED
+ ${WARNINGS_DISABLED}
+ ERRORS
+ ${WARNINGS_ERRORS}
+)
+
+string(APPEND CMAKE_C_FLAGS " ${WARNINGS_CFLAGS}")
+string(APPEND CMAKE_CXX_FLAGS " ${WARNINGS_CXXFLAGS}")
# let wine be able to show file and lines in backtrace
if(DBUS_USE_WINE)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -gstabs")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gstabs")
+ string(APPEND CMAKE_C_FLAGS " -gdwarf-2")
+ string(APPEND CMAKE_CXX_FLAGS " -gdwarf-2")
endif()
if(UNIX AND NOT DBUS_DISABLE_ASSERT)
# required for backtrace
- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wl,--export-dynamic")
- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wl,--export-dynamic")
- add_definitions(-DDBUS_BUILT_R_DYNAMIC)
+ if (APPLE)
+ string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,-export_dynamic")
+ string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,-export_dynamic")
+ else()
+ string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,--export-dynamic")
+ string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--export-dynamic")
+ endif()
+ set(DBUS_BUILT_R_DYNAMIC 1)
endif()
if(DBUS_WITH_GLIB)
- autodefine(GLIB_VERSION_MIN_REQUIRED)
- autodefine(GLIB_VERSION_MAX_ALLOWED)
+ # keep in sync with meson.build
+ set(GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_38)
+ set(GLIB_VERSION_MAX_ALLOWED "G_ENCODE_VERSION(2,44)")
endif()
-set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
+string(APPEND CMAKE_C_FLAGS_DEBUG " -D_DEBUG")
#########################################################################
# Windows CE (>= 5.0.0)
@@ -330,23 +415,23 @@ enable_testing()
#macro_ensure_out_of_source_build("dbus requires an out of source build. Please create a separate build directory and run 'cmake path_to_dbus [options]' there.")
# ... and warn in case of an earlier in-source build
-#set(generatedFileInSourceDir EXISTS ${dbus_SOURCE_DIR}/config.h)
+#set(generatedFileInSourceDir EXISTS ${PROJECT_SOURCE_DIR}/config.h)
#if(${generatedFileInSourceDir})
# message(STATUS "config.h exists in your source directory.")
#endif(${generatedFileInSourceDir})
#########################################################################
########### build output path definitions ###############
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
if(WIN32 OR CYGWIN)
- set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
else()
- set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
endif()
-set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
# for including config.h and for includes like <dir/foo.h>
-include_directories(. ${CMAKE_BINARY_DIR} ${CMAKE_INCLUDE_PATH})
+include_directories(. ${PROJECT_BINARY_DIR} ${CMAKE_INCLUDE_PATH})
# linker search directories
link_directories(${DBUS_LIB_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} )
@@ -474,12 +559,18 @@ if(MSVC_IDE)
message(STATUS)
endif()
set(TEST_PATH_FORCE FORCE)
- file(REMOVE ${CMAKE_BINARY_DIR}/data/dbus-1/services)
+ file(REMOVE ${PROJECT_BINARY_DIR}/data/dbus-1/services)
endif()
#### Find socket directories
+set(DBUS_SESSION_SOCKET_DIR "" CACHE STRING "Default directory for session socket")
if(UNIX)
- if(NOT $ENV{TMPDIR} STREQUAL "")
+ if (CMAKE_CROSSCOMPILING)
+ if (NOT DBUS_SESSION_SOCKET_DIR)
+ message(FATAL_ERROR "cannot autodetect session socket directory "
+ "when crosscompiling, pass -DDBUS_SESSION_SOCKET_DIR=...")
+ endif()
+ elseif(NOT $ENV{TMPDIR} STREQUAL "")
set(DBUS_SESSION_SOCKET_DIR $ENV{TMPDIR})
elseif(NOT $ENV{TEMP} STREQUAL "")
set(DBUS_SESSION_SOCKET_DIR $ENV{TEMP})
@@ -493,8 +584,6 @@ endif()
# Not used on Windows, where there is no system bus
set(DBUS_SYSTEM_PID_FILE ${DBUS_RUNSTATEDIR}/dbus/pid)
-set(DBUS_CONSOLE_AUTH_DIR "" CACHE STRING "Directory to check for pam_console/pam_foreground flag files, or empty to ignore")
-
# This won't work on Windows. It's not meant to - the system bus is
# meaningless on Windows anyway.
#
@@ -505,6 +594,18 @@ set(DBUS_CONSOLE_AUTH_DIR "" CACHE STRING "Directory to check for pam_console/pa
# address.
set(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "unix:path=${DBUS_RUNSTATEDIR}/dbus/system_bus_socket" CACHE STRING "system bus default address")
+# This check assumes that the disposition of /run and /var/run on the
+# system where we're building is the same as on the system we're building
+# for, so we can't usefully do this check if we're building for Windows,
+# or if we're cross-building for Unix on a Windows machine.
+#
+# The check is shared between Autotools and CMake.
+# Because we only run it on Unix, it's fine to make it a shell script.
+if(UNIX AND (NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows"))
+ execute_process(
+ COMMAND "${CMAKE_SOURCE_DIR}/tools/check-runstatedir.sh" "${DBUS_RUNSTATEDIR}/dbus/system_bus_socket")
+endif()
+
if(WIN32)
set(DBUS_SESSION_BUS_LISTEN_ADDRESS "autolaunch:" CACHE STRING "session bus default listening address")
set(DBUS_SESSION_BUS_CONNECT_ADDRESS "autolaunch:" CACHE STRING "session bus fallback address for clients")
@@ -518,10 +619,8 @@ if(WIN32)
else(WIN32)
set(DBUS_SESSION_BUS_LISTEN_ADDRESS "unix:tmpdir=${DBUS_SESSION_SOCKET_DIR}" CACHE STRING "session bus default listening address")
set(DBUS_SESSION_BUS_CONNECT_ADDRESS "autolaunch:" CACHE STRING "session bus fallback address for clients")
- set(sysconfdir "")
- set(configdir ${sysconfdir}/dbus-1 )
- set(DBUS_SYSTEM_CONFIG_FILE ${configdir}/system.conf)
- set(DBUS_SESSION_CONFIG_FILE ${configdir}/session.conf)
+ set(DBUS_SYSTEM_CONFIG_FILE ${DBUS_DATADIR}/dbus-1/system.conf)
+ set(DBUS_SESSION_CONFIG_FILE ${DBUS_DATADIR}/dbus-1/session.conf)
set(DBUS_USER "messagebus")
set(DBUS_TEST_USER "nobody")
# For best security, assume that all non-Windows platforms can do
@@ -549,14 +648,14 @@ if(DBUS_BUILD_TESTS)
# different, and it has no direct Autotools equivalent (Autotools
# tests automatically get their own ${builddir} as working directory).
set(DBUS_TEST_WORKING_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}${IDE_BIN})
- set(DBUS_TEST_DATA ${Z_DRIVE_IF_WINE}${CMAKE_BINARY_DIR}/test/data)
+ set(DBUS_TEST_DATA ${Z_DRIVE_IF_WINE}${PROJECT_BINARY_DIR}/test/data)
set(DBUS_TEST_DAEMON ${Z_DRIVE_IF_WINE}${CMAKE_RUNTIME_OUTPUT_DIRECTORY}${IDE_BIN}/dbus-daemon${EXEEXT})
set(DBUS_TEST_DBUS_LAUNCH ${Z_DRIVE_IF_WINE}${CMAKE_RUNTIME_OUTPUT_DIRECTORY}${IDE_BIN}/dbus-launch${EXEEXT})
- set(DBUS_TEST_HOMEDIR ${Z_DRIVE_IF_WINE}${CMAKE_BINARY_DIR}/dbus)
+ set(DBUS_TEST_HOMEDIR ${Z_DRIVE_IF_WINE}${PROJECT_BINARY_DIR}/dbus)
set(DBUS_TEST_RUN_SESSION ${Z_DRIVE_IF_WINE}${CMAKE_RUNTIME_OUTPUT_DIRECTORY}${IDE_BIN}/dbus-run-session${EXEEXT})
set(TEST_LAUNCH_HELPER_BINARY ${Z_DRIVE_IF_WINE}${DBUS_TEST_EXEC}/dbus-daemon-launch-helper-for-tests${EXEEXT})
if(UNIX)
- set(TEST_SOCKET_DIR ${DBUS_SESSION_SOCKET_DIR})
+ set(TEST_SOCKET_DIR ${DBUS_SESSION_SOCKET_DIR} CACHE STRING "Where to put test sockets")
set(TEST_LISTEN "unix:tmpdir=${TEST_SOCKET_DIR}")
endif()
if(WIN32)
@@ -570,11 +669,11 @@ set(DBUS_INTERNAL_LIBRARIES dbus-internal)
set(DBUS_INTERNAL_ADD_LIBRARY_OPTIONS STATIC)
set(DBUS_INTERNAL_CLIENT_DEFINITIONS "-DDBUS_COMPILATION")
-configure_file(cmake/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
+configure_file(cmake/config.h.cmake ${PROJECT_BINARY_DIR}/config.h)
if(WIN32)
-configure_file(cmake/dbus-env.bat.cmake ${CMAKE_BINARY_DIR}/bin/dbus-env.bat )
- install(FILES ${CMAKE_BINARY_DIR}/bin/dbus-env.bat DESTINATION ${CMAKE_INSTALL_BINDIR})
+configure_file(cmake/dbus-env.bat.cmake ${PROJECT_BINARY_DIR}/bin/dbus-env.bat)
+ install(FILES ${PROJECT_BINARY_DIR}/bin/dbus-env.bat DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
#
@@ -582,14 +681,14 @@ endif()
#
set(INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/DBus1)
if(WIN32)
- configure_file(cmake/DBus1Config.cmake.in "${CMAKE_BINARY_DIR}/DBus1Config.cmake" @ONLY)
+ configure_file(cmake/DBus1Config.cmake.in "${PROJECT_BINARY_DIR}/DBus1Config.cmake" @ONLY)
else()
- configure_file(cmake/DBus1Config.pkgconfig.in "${CMAKE_BINARY_DIR}/DBus1Config.cmake" @ONLY)
+ configure_file(cmake/DBus1Config.pkgconfig.in "${PROJECT_BINARY_DIR}/DBus1Config.cmake" @ONLY)
endif()
-configure_file(cmake/DBus1ConfigVersion.cmake.in "${CMAKE_BINARY_DIR}/DBus1ConfigVersion.cmake" @ONLY)
+configure_file(cmake/DBus1ConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/DBus1ConfigVersion.cmake" @ONLY)
install(FILES
- "${CMAKE_BINARY_DIR}/DBus1Config.cmake"
- "${CMAKE_BINARY_DIR}/DBus1ConfigVersion.cmake"
+ "${PROJECT_BINARY_DIR}/DBus1Config.cmake"
+ "${PROJECT_BINARY_DIR}/DBus1ConfigVersion.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}"
)
@@ -630,7 +729,7 @@ message(" install libexecdir: ${CMAKE_INSTALL_FULL_LIBEXECDIR} "
message(" install bindir: ${CMAKE_INSTALL_FULL_BINDIR} ")
message(" install sysconfdir: ${CMAKE_INSTALL_FULL_SYSCONFDIR} ")
message(" install datadir: ${CMAKE_INSTALL_FULL_DATADIR} ")
-message(" source code location: ${DBUS_SOURCE_DIR} ")
+message(" source code location: ${CMAKE_SOURCE_DIR} ")
message(" build dir: ${CMAKE_BINARY_DIR} ")
message(" c compiler: ${C_COMPILER} ")
message(" cflags: ${CMAKE_C_FLAGS} ")
@@ -643,6 +742,7 @@ message(" cxxflags release: ${CMAKE_CXX_FLAGS_RELEASE} "
message(" 64-bit int: ${DBUS_INT64_TYPE} ")
message(" 32-bit int: ${DBUS_INT32_TYPE} ")
message(" 16-bit int: ${DBUS_INT16_TYPE} ")
+message(" pointer size: ${DBUS_SIZEOF_VOID_P} ")
message(" Doxygen: ${DOXYGEN} ")
message(" Docbook Generator: ${DOCBOOK_GENERATOR_NAME} ")
@@ -678,12 +778,6 @@ message(" System bus PID file: ${DBUS_SYSTEM_PID_FILE} "
message(" System bus user: ${DBUS_USER} ")
message(" Session bus socket dir: ${DBUS_SESSION_SOCKET_DIR} ")
-if(DBUS_CONSOLE_AUTH_DIR)
-message(" pam_console auth dir: ${DBUS_CONSOLE_AUTH_DIR} ")
-else()
-message(" pam_console auth dir: (none) ")
-endif()
-
message(" 'make check' socket dir: ${TEST_SOCKET_DIR} ")
endif()
message(" Test listen address: ${TEST_LISTEN} ")
@@ -726,7 +820,7 @@ include(CPackInstallConfig)
add_custom_target(help-options
cmake -LH
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
#
@@ -753,7 +847,7 @@ if(DBUS_ENABLE_PKGCONFIG)
set(datadir "\${prefix}/${CMAKE_INSTALL_DATADIR}")
set(datarootdir "\${prefix}/${CMAKE_INSTALL_DATADIR}")
set(dbus_daemondir "\${prefix}/${CMAKE_INSTALL_BINDIR}")
- configure_file(dbus-1.pc.in ${CMAKE_BINARY_DIR}/dbus-1.pc @ONLY)
- install(FILES ${CMAKE_BINARY_DIR}/dbus-1.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+ configure_file(dbus-1.pc.in ${PROJECT_BINARY_DIR}/dbus-1.pc @ONLY)
+ install(FILES ${PROJECT_BINARY_DIR}/dbus-1.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
endif()
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index ba428928..fb163452 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -17,6 +17,8 @@ please report it privately to dbus-security@lists.freedesktop.org
or by reporting a Gitlab issue at
https://gitlab.freedesktop.org/dbus/dbus/issues/new and marking it
as "confidential".
+For appropriate patches, please create a "confidential" merge request,
+see [Sending a merge request](#sending-a-merge-request] for details.
## Mailing list
@@ -122,6 +124,9 @@ When you consider your changes to be ready for merging to mainline:
* push your changes to your personal fork as a branch
* create a merge request at
<https://gitlab.freedesktop.org/dbus/dbus/merge_requests>
+* Merge requests for "confidential" issues must also be created as
+ "confidential", see <https://docs.gitlab.com/ee/user/project/merge_requests/confidential.html>
+ for details.
### Security guidelines
@@ -175,11 +180,15 @@ http://vsftpd.beasts.org/ has other good security suggestions.
### Licensing
-Please match the existing licensing (a dual-license: AFL-2.1 or GPL-2+,
-recipient's choice). Entirely new modules can be placed under a more
-permissive license: to avoid license proliferation, our preferred
-permissive license is the variant of the MIT/X11 license used by the
-Expat XML library (for example see the top of tools/ci-build.sh).
+Please match the existing licensing, which is generally a dual-license:
+AFL-2.1 or GPL-2+, recipient's choice (`AFL-2.1 OR GPL-2.0-or-later`
+in SPDX notation).
+
+Entirely new modules can be placed under a more permissive license:
+to avoid license proliferation, our preferred permissive license is
+the variant of the MIT/X11 license used by the Expat XML library (`MIT`
+in SPDX notation), which can be found in LICENSES/MIT.txt. For example,
+tools/ci-build.sh is under this license.
### Build systems
@@ -265,86 +274,7 @@ This section is not directly relevant to infrequent contributors.
### Releasing
-To make a release of D-Bus, do the following:
-
- - check out a fresh copy from Git
-
- - verify that the libtool versioning/library soname is
- changed if it needs to be, or not changed if not
-
- - update the file NEWS based on the git history
-
- - verify that the version number of dbus-specification.xml is
- changed if it needs to be; if changes have been made, update the
- release date in that file
-
- - update the AUTHORS file with "make update-authors" if necessary
-
- - the version number should have major.minor.micro, even
- if micro is 0, i.e. "1.0.0" and "1.2.0" not "1.0"/"1.2"; the micro
- version should be even for releases, and odd for intermediate snapshots
-
- - "make distcheck" (DO NOT just "make dist" - pass the check!)
-
- - if make distcheck fails, fix it.
-
- - once distcheck succeeds, "git commit -a". This is the version
- of the tree that corresponds exactly to the released tarball.
-
- - tag the tree with "git tag -s -m 'Released X.Y.Z' dbus-X.Y.Z"
- where X.Y.Z is the version of the release. If you can't sign
- then simply created an unsigned annotated tag:
- "git tag -a -m 'Released X.Y.Z' dbus-X.Y.Z".
-
- - bump the version number up in configure.ac (so the micro version is odd),
- and commit it. Make sure you do this *after* tagging the previous
- release! The idea is that git has a newer version number
- than anything released. Similarly, bump the version number of
- dbus-specification.xml and set the release date to "(not finalized)".
-
- - merge the branch you've released to the chronologically-later
- branch (usually "master"). You'll probably have to fix a merge
- conflict in configure.ac (the version number).
-
- - push your changes and the tag to the central repository with
- git push origin master dbus-X.Y dbus-X.Y.Z
-
- - scp your tarball to freedesktop.org server and copy it to
- dbus.freedesktop.org:/srv/dbus.freedesktop.org/www/releases/dbus/dbus-X.Y.Z.tar.xz.
- This should be possible if you're in group "dbus"
-
- - Update the online documentation with `make -C doc maintainer-upload-docs`.
-
- - update the wiki page http://www.freedesktop.org/Software/dbus by
- adding the new release under the Download heading. Then, cut the
- link and changelog for the previous that was there.
-
- - post to dbus@lists.freedesktop.org announcing the release.
-
-### Making a ".0" stable release
-
-We create a branch for each stable release. The branch name should be
-dbus-X.Y which is a branch that has releases versioned X.Y.Z;
-changes on a stable branch should be limited to significant bug fixes.
-
-Because we won't make minor changes like keeping up with the latest
-deprecations on a stable branch, stable branches should turn off the
-gcc warning for deprecated declarations (e.g. see commit 4ebb275ab7).
-
-Be extra-careful not to merge master (or any branch based on master) into a
-stable branch.
-
-To branch:
-
- git branch dbus-X.Y
-
-and upload the branch tag to the server:
-
- git push origin dbus-X.Y
-
-To develop in this branch:
-
- git checkout dbus-X.Y
+See maint/release-checklist.md.
### Code reviews
diff --git a/COPYING b/COPYING
index 8260b100..d0afa71b 100644
--- a/COPYING
+++ b/COPYING
@@ -1,552 +1,23 @@
-D-Bus is licensed to you under your choice of the Academic Free
+dbus is licensed to you under your choice of the Academic Free
License version 2.1, or the GNU General Public License version 2
(or, at your option any later version).
+The full text of these licenses can be found in LICENSES/AFL-2.1.txt
+and LICENSES/GPL-2.0-or-later.txt.
-Both licenses are included here. Some of the standalone binaries are
-under the GPL only; in particular, but not limited to,
-tools/dbus-cleanup-sockets.c and test/decode-gcov.c. Each source code
-file is marked with the proper copyright information - if you find a
-file that isn't marked please bring it to our attention.
+Some source files are under more permissive BSD-/MIT-style licenses
+that are compatible with the AFL and GPL.
-The Academic Free License
-v. 2.1
+When contributing new code, our preferred license for new code is the
+version of the MIT/X11 license used by the Expat library, referred to
+as "MIT" by SPDX, which can be found in LICENSES/MIT.txt.
-This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following notice immediately following the copyright notice for the Original Work:
+Some of the standalone binaries are under the GPL only; in particular,
+but not limited to, tools/dbus-cleanup-sockets.c and test/decode-gcov.c.
-Licensed under the Academic Free License version 2.1
+Each source code file is marked with the proper copyright information -
+if you find a file that isn't marked please bring it to our attention.
-1) Grant of Copyright License. Licensor hereby grants You a
-world-wide, royalty-free, non-exclusive, perpetual, sublicenseable
-license to do the following:
-
-a) to reproduce the Original Work in copies;
-
-b) to prepare derivative works ("Derivative Works") based upon the Original Work;
-
-c) to distribute copies of the Original Work and Derivative Works to the public;
-
-d) to perform the Original Work publicly; and
-
-e) to display the Original Work publicly.
-
-2) Grant of Patent License. Licensor hereby grants You a world-wide,
-royalty-free, non-exclusive, perpetual, sublicenseable license, under
-patent claims owned or controlled by the Licensor that are embodied in
-the Original Work as furnished by the Licensor, to make, use, sell and
-offer for sale the Original Work and Derivative Works.
-
-3) Grant of Source Code License. The term "Source Code" means the
-preferred form of the Original Work for making modifications to it and
-all available documentation describing how to modify the Original
-Work. Licensor hereby agrees to provide a machine-readable copy of the
-Source Code of the Original Work along with each copy of the Original
-Work that Licensor distributes. Licensor reserves the right to satisfy
-this obligation by placing a machine-readable copy of the Source Code
-in an information repository reasonably calculated to permit
-inexpensive and convenient access by You for as long as Licensor
-continues to distribute the Original Work, and by publishing the
-address of that information repository in a notice immediately
-following the copyright notice that applies to the Original Work.
-
-4) Exclusions From License Grant. Neither the names of Licensor, nor
-the names of any contributors to the Original Work, nor any of their
-trademarks or service marks, may be used to endorse or promote
-products derived from this Original Work without express prior written
-permission of the Licensor. Nothing in this License shall be deemed to
-grant any rights to trademarks, copyrights, patents, trade secrets or
-any other intellectual property of Licensor except as expressly stated
-herein. No patent license is granted to make, use, sell or offer to
-sell embodiments of any patent claims other than the licensed claims
-defined in Section 2. No right is granted to the trademarks of
-Licensor even if such marks are included in the Original Work. Nothing
-in this License shall be interpreted to prohibit Licensor from
-licensing under different terms from this License any Original Work
-that Licensor otherwise would have a right to license.
-
-5) This section intentionally omitted.
-
-6) Attribution Rights. You must retain, in the Source Code of any
-Derivative Works that You create, all copyright, patent or trademark
-notices from the Source Code of the Original Work, as well as any
-notices of licensing and any descriptive text identified therein as an
-"Attribution Notice." You must cause the Source Code for any
-Derivative Works that You create to carry a prominent Attribution
-Notice reasonably calculated to inform recipients that You have
-modified the Original Work.
-
-7) Warranty of Provenance and Disclaimer of Warranty. Licensor
-warrants that the copyright in and to the Original Work and the patent
-rights granted herein by Licensor are owned by the Licensor or are
-sublicensed to You under the terms of this License with the permission
-of the contributor(s) of those copyrights and patent rights. Except as
-expressly stated in the immediately proceeding sentence, the Original
-Work is provided under this License on an "AS IS" BASIS and WITHOUT
-WARRANTY, either express or implied, including, without limitation,
-the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A
-PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL
-WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential
-part of this License. No license to Original Work is granted hereunder
-except under this disclaimer.
-
-8) Limitation of Liability. Under no circumstances and under no legal
-theory, whether in tort (including negligence), contract, or
-otherwise, shall the Licensor be liable to any person for any direct,
-indirect, special, incidental, or consequential damages of any
-character arising as a result of this License or the use of the
-Original Work including, without limitation, damages for loss of
-goodwill, work stoppage, computer failure or malfunction, or any and
-all other commercial damages or losses. This limitation of liability
-shall not apply to liability for death or personal injury resulting
-from Licensor's negligence to the extent applicable law prohibits such
-limitation. Some jurisdictions do not allow the exclusion or
-limitation of incidental or consequential damages, so this exclusion
-and limitation may not apply to You.
-
-9) Acceptance and Termination. If You distribute copies of the
-Original Work or a Derivative Work, You must make a reasonable effort
-under the circumstances to obtain the express assent of recipients to
-the terms of this License. Nothing else but this License (or another
-written agreement between Licensor and You) grants You permission to
-create Derivative Works based upon the Original Work or to exercise
-any of the rights granted in Section 1 herein, and any attempt to do
-so except under the terms of this License (or another written
-agreement between Licensor and You) is expressly prohibited by
-U.S. copyright law, the equivalent laws of other countries, and by
-international treaty. Therefore, by exercising any of the rights
-granted to You in Section 1 herein, You indicate Your acceptance of
-this License and all of its terms and conditions.
-
-10) Termination for Patent Action. This License shall terminate
-automatically and You may no longer exercise any of the rights granted
-to You by this License as of the date You commence an action,
-including a cross-claim or counterclaim, against Licensor or any
-licensee alleging that the Original Work infringes a patent. This
-termination provision shall not apply for an action alleging patent
-infringement by combinations of the Original Work with other software
-or hardware.
-
-11) Jurisdiction, Venue and Governing Law. Any action or suit relating
-to this License may be brought only in the courts of a jurisdiction
-wherein the Licensor resides or in which Licensor conducts its primary
-business, and under the laws of that jurisdiction excluding its
-conflict-of-law provisions. The application of the United Nations
-Convention on Contracts for the International Sale of Goods is
-expressly excluded. Any use of the Original Work outside the scope of
-this License or after its termination shall be subject to the
-requirements and penalties of the U.S. Copyright Act, 17 U.S.C. § 101
-et seq., the equivalent laws of other countries, and international
-treaty. This section shall survive the termination of this License.
-
-12) Attorneys Fees. In any action to enforce the terms of this License
-or seeking damages relating thereto, the prevailing party shall be
-entitled to recover its costs and expenses, including, without
-limitation, reasonable attorneys' fees and costs incurred in
-connection with such action, including any appeal of such action. This
-section shall survive the termination of this License.
-
-13) Miscellaneous. This License represents the complete agreement
-concerning the subject matter hereof. If any provision of this License
-is held to be unenforceable, such provision shall be reformed only to
-the extent necessary to make it enforceable.
-
-14) Definition of "You" in This License. "You" throughout this
-License, whether in upper or lower case, means an individual or a
-legal entity exercising rights under, and complying with all of the
-terms of, this License. For legal entities, "You" includes any entity
-that controls, is controlled by, or is under common control with
-you. For purposes of this definition, "control" means (i) the power,
-direct or indirect, to cause the direction or management of such
-entity, whether by contract or otherwise, or (ii) ownership of fifty
-percent (50%) or more of the outstanding shares, or (iii) beneficial
-ownership of such entity.
-
-15) Right to Use. You may use the Original Work in all ways not
-otherwise restricted or conditioned by this License or by law, and
-Licensor promises not to interfere with or be responsible for such
-uses by You.
-
-This license is Copyright (C) 2003-2004 Lawrence E. Rosen. All rights
-reserved. Permission is hereby granted to copy and distribute this
-license without modification. This license may not be modified without
-the express written permission of its copyright owner.
-
-
---
-END OF ACADEMIC FREE LICENSE. The following is intended to describe the essential
-differences between the Academic Free License (AFL) version 1.0 and other
-open source licenses:
-
-The Academic Free License is similar to the BSD, MIT, UoI/NCSA and Apache
-licenses in many respects but it is intended to solve a few problems with
-those licenses.
-
-* The AFL is written so as to make it clear what software is being
-licensed (by the inclusion of a statement following the copyright notice
-in the software). This way, the license functions better than a template
-license. The BSD, MIT and UoI/NCSA licenses apply to unidentified software.
-
-* The AFL contains a complete copyright grant to the software. The BSD
-and Apache licenses are vague and incomplete in that respect.
-
-* The AFL contains a complete patent grant to the software. The BSD, MIT,
-UoI/NCSA and Apache licenses rely on an implied patent license and contain
-no explicit patent grant.
-
-* The AFL makes it clear that no trademark rights are granted to the
-licensor's trademarks. The Apache license contains such a provision, but the
-BSD, MIT and UoI/NCSA licenses do not.
-
-* The AFL includes the warranty by the licensor that it either owns the
-copyright or that it is distributing the software under a license. None of
-the other licenses contain that warranty. All other warranties are disclaimed,
-as is the case for the other licenses.
-
-* The AFL is itself copyrighted (with the right granted to copy and distribute
-without modification). This ensures that the owner of the copyright to the
-license will control changes. The Apache license contains a copyright notice,
-but the BSD, MIT and UoI/NCSA licenses do not.
---
-START OF GNU GENERAL PUBLIC LICENSE
---
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
+Some files contain a SPDX-License-Identifier marker. These markers
+indicate the license of that file, consistent with the SPDX and REUSE
+specifications: see <https://reuse.software/>. dbus is not yet fully
+REUSE-compliant, and not all files carry these markers.
diff --git a/Doxyfile.in b/Doxyfile.in
index 38baf5d8..750d966c 100644
--- a/Doxyfile.in
+++ b/Doxyfile.in
@@ -30,7 +30,7 @@ INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 8
-GENERATE_TODOLIST = YES
+GENERATE_TODOLIST = NO
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
ALIASES =
@@ -49,7 +49,7 @@ WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
-INPUT = @top_srcdir@/dbus
+INPUT = @top_srcdir@/dbus @top_builddir@/dbus
FILE_PATTERNS = *.c *.h
RECURSIVE = YES
#EXCLUDE = test
diff --git a/INSTALL b/INSTALL
index f2f0122c..99ee1b5c 100644
--- a/INSTALL
+++ b/INSTALL
@@ -4,245 +4,118 @@
Quick start
===========
-DBus could be build with GNU AutoTools or with cmake for its build system,
-thus the basic install procedure can be summarized as:
+This branch of dbus can be built by using Meson or CMake.
+The Meson build system is the recommended build system for the master
+branch (versions >= 1.15.0), except when building on Windows, for which
+CMake is recommended (this recommendation might change to Meson in future).
-with autotools:
+Meson only supports out-of-tree builds, and must be passed a directory to put
+built and generated sources into. We'll call that directory "build" here. It's
+recommended to create a separate build directory for each configuration you
+might want to use.
- ./configure --prefix=/usr
- make
- su make install
+Basic configuration is done with:
-The configure script will automatically determine whether to try and
-build bindings for GLib, Qt, Qt3, Python and Mono based on what tools
-are installed on the host system. The default build behaviour can be
-overridden using the --enable-XXX/--disable-XXX arguments to configure.
-A typical scenario in which it is desirable to override automatic
-detection, is during packaging of binary builds, where a predictable
-dependancy chain is required. For more details on GNU AutoTools
-installation, consult the generic instructions later in this document
-
-with cmake:
- mkdir dbus-build-dir
- cd dbus-build-dir
- cmake -G <makefile-generator-name> [-D<option>] <dbus-src-root>/cmake
- make
- make install
-
-cmake will automatically determine whether to build some features
-based on what tools and/or libraries are installed on the host system.
-The default build behaviour can be overridden using the
+``` sh
+meson build/
+```
+
+This will create the build directory. If any dependencies are missing, you can
+install them, or try to remove the dependency with a Meson configuration option
+(see below).
+
+Older versions of dbus required Autotools or CMake, with Autotools
+recommended for Unix systems and CMake recommended for Windows systems.
+
+Configuration flags
+===================
+
+When using Meson, to review the options which Meson chose, run:
+
+``` sh
+meson configure build/
+```
+
+With additional arguments meson configure can be used to change options for a
+previously configured build directory. All options passed to this command are in
+the form `-D "option"="value"`. For example:
+
+``` sh
+meson configure build/ -Dprefix=/tmp/install
+```
+
+See `meson_options.txt` for details of dbus-specific options, and
+<https://mesonbuild.com/Builtin-options.html> for details of generic
+Meson options.
+
+When using CMake, inspect README.cmake to see the possible
+configuration options and environment variables.
+
+Building
+========
+
+To build with meson, here is a quick guide:
+
+``` sh
+cd dbus
+meson setup build/ && cd build/
+meson compile
+meson test
+```
+
+Full build instructions can be found on mesonbuild website:
+https://mesonbuild.com/Running-Meson.html
+
+Building with CMake
+-------------------
+
+The CMake equivalent is:
+
+``` sh
+cd <dbus-src-root>
+cmake -G <makefile-generator-name> [-D<option>] -B dbus-build-dir
+cmake --build <dbus-build-dir>
+cmake --build <dbus-build-dir> -t check
+```
+
+The installation of the build with CMake is performed with:
+
+``` sh
+cmake --build <dbus-build-dir> -t install [DESTDIR=<install-dir>]
+```
+
+When using makefile generator `-t install/fast` can also be used,
+which prevents rebuilding.
+
+CMake will automatically determine whether to build some features
+based on what tools and/or libraries are installed on the host system.
+The default build behaviour can be overridden using the
-DENABLE_<XXX> arguments to cmake.
A typical scenario in which it is desirable to override automatic
detection, is during packaging of binary builds, where a predictable
-dependancy chain is required. For more details on cmake installation,
-consult http://www.cmake.org/cmake/help/help.html.
+dependancy chain is required. For more details on cmake installation,
+consult http://www.cmake.org/cmake/help/help.html.
-External software dependancies
+External software dependencies
==============================
-The only fundamental requirement to build DBus is an XML parser,
-however, there are a number of other software packages which (if
-present) will enhance functionality.
-
-Core library
-------------
-
- Requisite:
+Required:
- - Gettext
- expat
- Optional:
+Optional:
- - libselinux (for SELinux integration)
+ - libapparmor (for AppArmor LSM integration on Linux)
+ - libaudit (for AppArmor/SELinux audit logging on Linux)
+ - libcap-ng (for capabilities management on Linux)
+ - libselinux (for SELinux LSM integration on Linux)
+ - libsystemd (for logging, socket activation and session tracking on Linux)
+ - libX11 (for X11 autolaunching on Unix platforms)
- doxygen (for API documentation)
- - xmlto or meinproc4 (for Spec & other XML documentation)
-
-====================================================================
-
-The rest of this document contains the generic GNU AutoTools install
-insructions....
-
-Basic Installation
-==================
-
- These are generic installation instructions.
-
- The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation. It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions. Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, a file
-`config.cache' that saves the results of its tests to speed up
-reconfiguring, and a file `config.log' containing compiler output
-(useful mainly for debugging `configure').
-
- If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release. If at some point `config.cache'
-contains results you don't want to keep, you may remove or edit it.
-
- The file `configure.in' is used to create `configure' by a program
-called `autoconf'. You only need `configure.in' if you want to change
-it or regenerate `configure' using a newer version of `autoconf'.
-
-The simplest way to compile this package is:
-
- 1. `cd' to the directory containing the package's source code and type
- `./configure' to configure the package for your system. If you're
- using `csh' on an old version of System V, you might need to type
- `sh ./configure' instead to prevent `csh' from trying to execute
- `configure' itself.
-
- Running `configure' takes awhile. While running, it prints some
- messages telling which features it is checking for.
-
- 2. Type `make' to compile the package.
-
- 3. Optionally, type `make check' to run any self-tests that come with
- the package.
-
- 4. Type `make install' to install the programs and any data files and
- documentation.
-
- 5. You can remove the program binaries and object files from the
- source code directory by typing `make clean'. To also remove the
- files that `configure' created (so you can compile the package for
- a different kind of computer), type `make distclean'. There is
- also a `make maintainer-clean' target, but that is intended mainly
- for the package's developers. If you use it, you may have to get
- all sorts of other programs in order to regenerate files that came
- with the distribution.
-
-Compilers and Options
-=====================
-
- Some systems require unusual options for compilation or linking that
-the `configure' script does not know about. You can give `configure'
-initial values for variables by setting them in the environment. Using
-a Bourne-compatible shell, you can do that on the command line like
-this:
- CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
-
-Or on systems that have the `env' program, you can do it like this:
- env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
-
-Compiling For Multiple Architectures
-====================================
-
- You can compile the package for more than one kind of computer at the
-same time, by placing the object files for each architecture in their
-own directory. To do this, you must use a version of `make' that
-supports the `VPATH' variable, such as GNU `make'. `cd' to the
-directory where you want the object files and executables to go and run
-the `configure' script. `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.
-
- If you have to use a `make' that does not supports the `VPATH'
-variable, you have to compile the package for one architecture at a time
-in the source code directory. After you have installed the package for
-one architecture, use `make distclean' before reconfiguring for another
-architecture.
-
-Installation Names
-==================
-
- By default, `make install' will install the package's files in
-`/usr/local/bin', `/usr/local/man', etc. You can specify an
-installation prefix other than `/usr/local' by giving `configure' the
-option `--prefix=PATH'.
-
- You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files. If you
-give `configure' the option `--exec-prefix=PATH', the package will use
-PATH as the prefix for installing programs and libraries.
-Documentation and other data files will still use the regular prefix.
-
- In addition, if you use an unusual directory layout you can give
-options like `--bindir=PATH' to specify different values for particular
-kinds of files. Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.
-
- If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-Optional Features
-=================
-
- Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System). The
-`README' should mention any `--enable-' and `--with-' options that the
-package recognizes.
-
- For packages that use the X Window System, `configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
-
-Specifying the System Type
-==========================
-
- There may be some features `configure' can not figure out
-automatically, but needs to determine by the type of host the package
-will run on. Usually `configure' can figure that out, but if it prints
-a message saying it can not guess the host type, give it the
-`--host=TYPE' option. TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name with three fields:
- CPU-COMPANY-SYSTEM
-
-See the file `config.sub' for the possible values of each field. If
-`config.sub' isn't included in this package, then this package doesn't
-need to know the host type.
-
- If you are building compiler tools for cross-compiling, you can also
-use the `--target=TYPE' option to select the type of system they will
-produce code for and the `--build=TYPE' option to select the type of
-system on which you are compiling the package.
-
-Sharing Defaults
-================
-
- If you want to set default values for `configure' scripts to share,
-you can create a site shell script called `config.site' that gives
-default values for variables like `CC', `cache_file', and `prefix'.
-`configure' looks for `PREFIX/share/config.site' if it exists, then
-`PREFIX/etc/config.site' if it exists. Or, you can set the
-`CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
-
-Operation Controls
-==================
-
- `configure' recognizes the following options to control how it
-operates.
-
-`--cache-file=FILE'
- Use and save the results of the tests in FILE instead of
- `./config.cache'. Set FILE to `/dev/null' to disable caching, for
- debugging `configure'.
-
-`--help'
- Print a summary of the options to `configure', and exit.
-
-`--quiet'
-`--silent'
-`-q'
- Do not print messages saying which checks are being made. To
- suppress all normal output, redirect it to `/dev/null' (any error
- messages will still be shown).
-
-`--srcdir=DIR'
- Look for the package's source code in directory DIR. Usually
- `configure' can determine that directory automatically.
-
-`--version'
- Print the version of Autoconf used to generate the `configure'
- script, and exit.
-
-`configure' also accepts some other, not widely useful, options.
+ - xsltproc (for Spec & other XML documentation)
+ - Docbook XSL stylesheets (for Spec & other XML documentation)
+ - ducktype (for additional documentation)
+ - qhelpgenerator (for additional documentation)
+ - yelp-build (for additional documentation)
+ - GLib (for improved test coverage)
+ - Python 3 (for improved test coverage)
diff --git a/LICENSES/AFL-2.0.txt b/LICENSES/AFL-2.0.txt
new file mode 100644
index 00000000..f3bd601b
--- /dev/null
+++ b/LICENSES/AFL-2.0.txt
@@ -0,0 +1,45 @@
+The Academic Free License
+v. 2.0
+
+This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following notice immediately following the copyright notice for the Original Work:
+
+ Licensed under the Academic Free License version 2.0
+
+1) Grant of Copyright License. Licensor hereby grants You a world-wide, royalty-free, non-exclusive, perpetual, sublicenseable license to do the following:
+
+ a) to reproduce the Original Work in copies;
+ b) to prepare derivative works ("Derivative Works") based upon the Original Work;
+ c) to distribute copies of the Original Work and Derivative Works to the public;
+ d) to perform the Original Work publicly; and
+ e) to display the Original Work publicly.
+
+2) Grant of Patent License. Licensor hereby grants You a world-wide, royalty-free, non-exclusive, perpetual, sublicenseable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, to make, use, sell and offer for sale the Original Work and Derivative Works.
+
+3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor hereby agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work, and by publishing the address of that information repository in a notice immediately following the copyright notice that applies to the Original Work.
+
+4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior written permission of the Licensor. Nothing in this License shall be deemed to grant any rights to trademarks, copyrights, patents, trade secrets or any other intellectual property of Licensor except as expressly stated herein. No patent license is granted to make, use, sell or offer to sell embodiments of any patent claims other than the licensed claims defined in Section 2. No right is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under different terms from this License any Original Work that Licensor otherwise would have a right to license.
+
+5) This section intentionally omitted.
+
+6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
+
+7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately proceeding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to Original Work is granted hereunder except under this disclaimer.
+
+8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to any person for any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to liability for death or personal injury resulting from Licensor's negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You.
+
+9) Acceptance and Termination. If You distribute copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. Nothing else but this License (or another written agreement between Licensor and You) grants You permission to create Derivative Works based upon the Original Work or to exercise any of the rights granted in Section 1 herein, and any attempt to do so except under the terms of this License (or another written agreement between Licensor and You) is expressly prohibited by U.S. copyright law, the equivalent laws of other countries, and by international treaty. Therefore, by exercising any of the rights granted to You in Section 1 herein, You indicate Your acceptance of this License and all of its terms and conditions.
+
+10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, for patent infringement (i) against Licensor with respect to a patent applicable to software or (ii) against any entity with respect to a patent applicable to the Original Work (but excluding combinations of the Original Work with other software or hardware).
+
+11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of the U.S. Copyright Act, 17 U.S.C. ¤ 101 et seq., the equivalent laws of other countries, and international treaty. This section shall survive the termination of this License.
+
+12) Attorneys Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
+
+13) Miscellaneous. This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
+
+14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
+
+This license is Copyright (C) 2003 Lawrence E. Rosen. All rights reserved.
+Permission is hereby granted to copy and distribute this license without modification. This license may not be modified without the express written permission of its copyright owner.
diff --git a/LICENSES/AFL-2.1.txt b/LICENSES/AFL-2.1.txt
new file mode 100644
index 00000000..011d6d48
--- /dev/null
+++ b/LICENSES/AFL-2.1.txt
@@ -0,0 +1,45 @@
+The Academic Free License
+v.2.1
+
+This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following notice immediately following the copyright notice for the Original Work:
+
+ Licensed under the Academic Free License version 2.1
+
+1) Grant of Copyright License. Licensor hereby grants You a world-wide, royalty-free, non-exclusive, perpetual, sublicenseable license to do the following:
+
+ a) to reproduce the Original Work in copies;
+ b) to prepare derivative works ("Derivative Works") based upon the Original Work;
+ c) to distribute copies of the Original Work and Derivative Works to the public;
+ d) to perform the Original Work publicly; and
+ e) to display the Original Work publicly.
+
+2) Grant of Patent License. Licensor hereby grants You a world-wide, royalty-free, non-exclusive, perpetual, sublicenseable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, to make, use, sell and offer for sale the Original Work and Derivative Works.
+
+3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor hereby agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work, and by publishing the address of that information repository in a notice immediately following the copyright notice that applies to the Original Work.
+
+4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior written permission of the Licensor. Nothing in this License shall be deemed to grant any rights to trademarks, copyrights, patents, trade secrets or any other intellectual property of Licensor except as expressly stated herein. No patent license is granted to make, use, sell or offer to sell embodiments of any patent claims other than the licensed claims defined in Section 2. No right is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under different terms from this License any Original Work that Licensor otherwise would have a right to license.
+
+5) This section intentionally omitted.
+
+6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
+
+7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately proceeding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to Original Work is granted hereunder except under this disclaimer.
+
+8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to any person for any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to liability for death or personal injury resulting from Licensor's negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You.
+
+ 9) Acceptance and Termination. If You distribute copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. Nothing else but this License (or another written agreement between Licensor and You) grants You permission to create Derivative Works based upon the Original Work or to exercise any of the rights granted in Section 1 herein, and any attempt to do so except under the terms of this License (or another written agreement between Licensor and You) is expressly prohibited by U.S. copyright law, the equivalent laws of other countries, and by international treaty. Therefore, by exercising any of the rights granted to You in Section 1 herein, You indicate Your acceptance of this License and all of its terms and conditions.
+
+10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
+
+11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of the U.S. Copyright Act, 17 U.S.C. § 101 et seq., the equivalent laws of other countries, and international treaty. This section shall survive the termination of this License.
+
+12) Attorneys Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
+
+13) Miscellaneous. This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
+
+14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
+
+This license is Copyright (C) 2003-2004 Lawrence E. Rosen. All rights reserved.
+Permission is hereby granted to copy and distribute this license without modification. This license may not be modified without the express written permission of its copyright owner.
diff --git a/LICENSES/Apache-2.0.txt b/LICENSES/Apache-2.0.txt
new file mode 100644
index 00000000..137069b8
--- /dev/null
+++ b/LICENSES/Apache-2.0.txt
@@ -0,0 +1,73 @@
+Apache License
+Version 2.0, January 2004
+http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/LICENSES/BSD-3-Clause.txt b/LICENSES/BSD-3-Clause.txt
new file mode 100644
index 00000000..ea890afb
--- /dev/null
+++ b/LICENSES/BSD-3-Clause.txt
@@ -0,0 +1,11 @@
+Copyright (c) <year> <owner>.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/LICENSES/FSFULLR.txt b/LICENSES/FSFULLR.txt
new file mode 100644
index 00000000..beb44ec1
--- /dev/null
+++ b/LICENSES/FSFULLR.txt
@@ -0,0 +1,5 @@
+Copyright 1996-2006 Free Software Foundation, Inc.
+
+This file is free software; the Free Software Foundation
+gives unlimited permission to copy and/or distribute it,
+with or without modifications, as long as this notice is preserved.
diff --git a/LICENSES/GPL-2.0-or-later.txt b/LICENSES/GPL-2.0-or-later.txt
new file mode 100644
index 00000000..17cb2864
--- /dev/null
+++ b/LICENSES/GPL-2.0-or-later.txt
@@ -0,0 +1,117 @@
+GNU GENERAL PUBLIC LICENSE
+Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+
+Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification follow.
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
+
+1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+END OF TERMS AND CONDITIONS
+
+How to Apply These Terms to Your New Programs
+
+If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
+
+To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
+
+ one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author
+
+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice
diff --git a/LICENSES/LGPL-2.1-or-later.txt b/LICENSES/LGPL-2.1-or-later.txt
new file mode 100644
index 00000000..c9aa5301
--- /dev/null
+++ b/LICENSES/LGPL-2.1-or-later.txt
@@ -0,0 +1,175 @@
+GNU LESSER GENERAL PUBLIC LICENSE
+
+Version 2.1, February 1999
+
+Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.]
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
+
+This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below.
+
+When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things.
+
+To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.
+
+For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights.
+
+We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.
+
+To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others.
+
+Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license.
+
+Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs.
+
+When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library.
+
+We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances.
+
+For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License.
+
+In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system.
+
+Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library.
+
+The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run.
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you".
+
+A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
+
+The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)
+
+"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library.
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.
+
+1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
+
+(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.
+
+Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.
+
+This option is useful when you wish to copy part of the code of the Library into a program that is not a library.
+
+4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange.
+
+If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.
+
+5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
+
+However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.
+
+When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.
+
+If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)
+
+Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself.
+
+6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.
+
+You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
+
+ a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy.
+
+For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.
+
+7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
+
+ b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
+
+8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
+
+10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License.
+
+11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.
+
+14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+END OF TERMS AND CONDITIONS
+
+How to Apply These Terms to Your New Libraries
+
+If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License).
+
+To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
+
+ one line to give the library's name and an idea of what it does.
+ Copyright (C) year name of author
+
+ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names:
+
+Yoyodyne, Inc., hereby disclaims all copyright interest in
+the library `Frob' (a library for tweaking knobs) written
+by James Random Hacker.
+
+signature of Ty Coon, 1 April 1990
+Ty Coon, President of Vice
+That's all there is to it!
diff --git a/cmake/modules/COPYING-CMAKE-SCRIPTS b/LICENSES/LicenseRef-CMakeScripts.txt
index 53b6b71e..d039066d 100644
--- a/cmake/modules/COPYING-CMAKE-SCRIPTS
+++ b/LICENSES/LicenseRef-CMakeScripts.txt
@@ -20,3 +20,6 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+(This is a variation of the BSD-3-Clause license, with slightly different
+wording.)
diff --git a/LICENSES/LicenseRef-GAP.txt b/LICENSES/LicenseRef-GAP.txt
new file mode 100644
index 00000000..8007ecd5
--- /dev/null
+++ b/LICENSES/LicenseRef-GAP.txt
@@ -0,0 +1,7 @@
+This file is free software; as a special exception the author gives
+unlimited permission to copy and/or distribute it, with or without
+modifications, as long as this notice is preserved.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/LICENSES/LicenseRef-pycrypto-orig.txt b/LICENSES/LicenseRef-pycrypto-orig.txt
new file mode 100644
index 00000000..cb143211
--- /dev/null
+++ b/LICENSES/LicenseRef-pycrypto-orig.txt
@@ -0,0 +1,3 @@
+Distribute and use freely; there are no restrictions on further
+dissemination and usage except those imposed by the laws of your
+country of residence.
diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt
new file mode 100644
index 00000000..2071b23b
--- /dev/null
+++ b/LICENSES/MIT.txt
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) <year> <copyright holders>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/LICENSES/TCL.txt b/LICENSES/TCL.txt
new file mode 100644
index 00000000..4b9cdb48
--- /dev/null
+++ b/LICENSES/TCL.txt
@@ -0,0 +1,9 @@
+This software is copyrighted by the Regents of the University of California, Sun Microsystems, Inc., Scriptics Corporation, ActiveState Corporation and other parties. The following terms apply to all files associated with the software unless explicitly disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions. No written agreement, license, or royalty fee is required for any of the authorized uses. Modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated on the first page of each file where they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the U.S. government, the Government shall have only "Restricted Rights" in the software and related documentation as defined in the Federal Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you are acquiring the software on behalf of the Department of Defense, the software shall be classified as "Commercial Computer Software" and the Government shall have only "Restricted Rights" as defined in Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the authors grant the U.S. Government and others acting in its behalf permission to use and distribute the software in accordance with the terms specified in this license.
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index 54baa326..00000000
--- a/Makefile.am
+++ /dev/null
@@ -1,45 +0,0 @@
-SUBDIRS=dbus bus tools test doc
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = dbus-1.pc
-
-cmakeconfigdir = $(libdir)/cmake/DBus1
-cmakeconfig_DATA = cmake/DBus1Config.cmake \
- cmake/DBus1ConfigVersion.cmake
-
-EXTRA_DIST = \
- autogen.sh \
- CONTRIBUTING.md \
- dbus-1.pc.in \
- cleanup-man-pages.sh \
- NEWS.pre-1-0 \
- NEWS.pre-1-2 \
- README.cmake \
- README.valgrind \
- README.win \
- README.wince \
- README.cygwin \
- README.launchd \
- CMakeLists.txt \
- bus/CMakeLists.txt \
- dbus/CMakeLists.txt \
- doc/CMakeLists.txt \
- test/CMakeLists.txt \
- test/name-test/CMakeLists.txt \
- tools/CMakeLists.txt \
- cmake \
- $(NULL)
-
-all-local: Doxyfile
-
-update-authors:
- git shortlog -s -e | cut -c 8- | sort > AUTHORS
-
-DISTCHECK_CONFIGURE_FLAGS = \
- --enable-xml-docs \
- --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
-
-ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
-
-# Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE
-include $(top_srcdir)/aminclude_static.am
diff --git a/NEWS b/NEWS
index 6baa3a46..5f062c9b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,793 @@
+dbus 1.15.10 (UNRELEASED)
+=========================
+
+Build-time configuration changes:
+
+• The Autotools build system has been removed. Its replacement is Meson.
+ (dbus#443, Ralf Habacker)
+
+Enhancements:
+
+• Use 64-bit timestamps internally.
+ This will allow 32-bit builds of libdbus to continue working after 2038
+ if there is OS-level support for 64-bit time_t, either opt-in
+ (as on 32-bit glibc systems) or by default. (dbus!444, Alexander Kanavin)
+
+dbus 1.15.8 (2023-08-21)
+========================
+
+Build-time configuration changes:
+
+• For this version of dbus, Meson is the recommended build system for all
+ Unix platforms. CMake continues to be recommended for Windows, but this
+ recommendation might change to Meson in a future release, so please
+ test the Meson build. See INSTALL for details.
+
+• Autotools-generated files are no longer included in the tarball release.
+ The Autotools build system is likely to be removed in a future dbus
+ release, so Autotools users should migrate to Meson as soon as possible.
+ It is still possible to build using Autotools, by following the same
+ procedure as for a git clone (starting with the `./autogen.sh` script).
+
+Enhancements:
+
+• On Linux with sufficiently new glibc and kernel headers, report a pinned
+ process file descriptor (pidfd) as the ProcessFD member of the
+ GetConnectionCredentials() result
+ (dbus!420, dbus!398; Luca Boccassi)
+
+• On Linux with systemd, start as the target user/group (retaining
+ CAP_AUDIT_WRITE to preserve the ability to write to the audit log),
+ instead of starting as root and dropping privileges
+ (dbus!399, Luca Boccassi)
+
+• On 32-bit glibc systems, opt-in to 64-bit timestamps if possible.
+ This will allow 32-bit builds of libdbus to continue working after 2038.
+ (dbus#465, Simon McVittie)
+
+• On 32-bit glibc systems when built with CMake, also opt-in to large
+ file sizes, offsets and inode numbers, as was done for Autotools
+ since 1.12.x and Meson since the Meson build was introduced
+ (dbus#465, fd.o #93545; Simon McVittie)
+
+• Avoid known dbus-daemon options being interpreted as optional arguments
+ (dbus#467, Xin Shi)
+
+• If libdbus is a Meson subproject in a larger project, announce it as an
+ implementation of the dbus-1 dependency (dbus!415, Barnabás Pőcze)
+
+• When built with CMake, get the version number from Meson instead of
+ Autotools, in preparation for the Autotools build system being removed
+ (dbus!382, Ralf Habacker)
+
+• When built with Meson, disable some unwanted warnings when either
+ assertions or checks is disabled (dbus!412, Simon McVittie)
+
+• Use C11 <stdatomic.h> if possible (dbus!431, Simon McVittie)
+
+• Expand coverage of SPDX/REUSE copyright/license information
+ (dbus!427, Simon McVittie)
+
+• On Linux, let dbus-daemon start up successfully (with a warning) if
+ inotify initialization fails, even if DBUS_FATAL_WARNINGS=1 is present
+ in the environment (dbus#473, Simon McVittie)
+
+• On Unix, provide a better error message when looking up a user by name
+ or user ID fails (dbus!442, Simon McVittie)
+
+Bug fixes:
+
+• Avoid a dbus-daemon crash if re-creating a connection's policy fails.
+ If it isn't possible to re-create its policy (for example if it belongs
+ to a user account that has been deleted or if the Name Service Switch is
+ broken, on a system not supporting SO_PEERGROUPS), we now log a warning,
+ continue to use its current policy, and continue to reload other
+ connections' policies. (dbus#343; Peter Benie, Simon McVittie)
+
+• If getting the groups from a user ID fails, report the error correctly,
+ instead of logging "(null)" (dbus#343, Simon McVittie)
+
+• Return the primary group ID in GetConnectionCredentials()' UnixGroupIDs
+ field for processes with a valid-but-empty supplementary group list
+ (dbus!422, cptpcrd)
+
+• `sudo meson install` without a DESTDIR is now possible, although
+ strongly discouraged on production systems (dbus#436, Simon McVittie)
+
+• Fix a Meson deprecation warning (dbus#439, Simon McVittie)
+
+Tests and CI enhancements:
+
+• Internal CI changes
+ (dbus#455, dbus!414, dbus#468, dbus#469, dbus!424, dbus!430, dbus#436,
+ dbus#470; Ralf Habacker, Simon McVittie)
+
+dbus 1.15.6 (2023-06-06)
+========================
+
+Denial-of-service fixes:
+
+• Fix an assertion failure in dbus-daemon when a privileged Monitoring
+ connection (dbus-monitor, busctl monitor, gdbus monitor or similar)
+ is active, and a message from the bus driver cannot be delivered to a
+ client connection due to <deny> rules or outgoing message quota. This
+ is a denial of service if triggered maliciously by a local attacker.
+ (dbus#457; hongjinghao, Simon McVittie)
+
+Enhancements:
+
+• Special-case reading pseudo-files from Linux /proc to take into
+ account the filesystem's unusual semantics (dbus!401, Luca Boccassi)
+
+Other fixes:
+
+• Fix compilation on compilers not supporting __FUNCTION__
+ (dbus!404, Barnabás Pőcze)
+
+• Fix some memory leaks on out-of-memory conditions
+ (dbus!403, Barnabás Pőcze)
+
+• Documentation:
+ · Update the README to recommend building with Meson
+ (dbus!402, Ahmed Abdelfattah)
+ · Fix syntax of a code sample in dbus-api-design
+ (dbus!396; Yen-Chin, Lee)
+
+• CMake build fixes:
+ · Detect presence of <sys/syscall.h> (dbus!400, Luca Boccassi)
+
+Tests and CI enhancements:
+
+• Fix CI pipelines after freedesktop/freedesktop#540
+ (dbus!405, dbus#456; Simon McVittie)
+
+• Ensure the messagebus user is created if necessary
+ (dbus#445, Ralf Habacker)
+
+dbus 1.15.4 (2023-02-08)
+========================
+
+Dependencies:
+
+• Building with CMake now requires CMake ≥ 3.9.
+
+Build-time configuration changes:
+
+• On Unix platforms, a path in the runtime state directory (often /run)
+ is now used for the well-known system bus socket by default. OS
+ distributors should check that the path used is equivalent to the
+ interoperable path /var/run/dbus/system_bus_socket, especially if
+ running on an OS where /var/run is not guaranteed to be a symbolic
+ link to /run.
+ (dbus#180; Issam E. Maghni, Simon McVittie)
+ · With Autotools, this is controlled by --runstatedir, which defaults
+ to ${localstatedir}/run but is often set to /run by OS distributors.
+ The path to the system bus socket can be overridden with the
+ --with-system-socket option if required.
+ · With CMake, this is controlled by the RUNSTATEDIR option, which has
+ behaviour similar to Autotools. There is no separate option for the
+ path to the system bus socket.
+ · With Meson, this is controlled by the runtime_dir option, which
+ defaults to /run if the installation prefix is set to /usr, or has
+ behaviour similar to Autotools otherwise. The path to the system bus
+ socket can be overridden with the system_socket option if required.
+
+Denial of service fixes:
+
+• Fix an incorrect assertion that could be used to crash dbus-daemon or
+ other users of DBusServer prior to authentication, if libdbus was compiled
+ with assertions enabled.
+ We recommend that production builds of dbus, for example in OS distributions,
+ should be compiled with checks but without assertions.
+ (dbus#421, Ralf Habacker; thanks to Evgeny Vereshchagin)
+
+Enhancements:
+
+• D-Bus Specification 0.41:
+ · Clarify handling of /run vs. /var/run on Unix systems
+ (dbus#180, Simon McVittie)
+
+• Add dbus_connection_set_builtin_filters_enabled(), intended to be called
+ by tools that use BecomeMonitor() such as dbus-monitor
+ (dbus#301, Kai A. Hiller)
+
+• When using the Meson build system, dbus can now be used as a subproject.
+ To avoid colliding with a separate system copy of dbus, building it as a
+ static library with tests, tools and the message bus disabled is
+ strongly recommended. See test/use-as-subproject for sample code.
+ (dbus!368, dbus!388; Daniel Wagner)
+
+Other fixes:
+
+• When connected to a dbus-broker, stop dbus-monitor from incorrectly
+ replying to Peer method calls that were sent to the dbus-broker with
+ a NULL destination (dbus#301, Kai A. Hiller)
+
+• Fix out-of-bounds varargs read in the dbus-daemon's config-parser.
+ This is not attacker-triggerable and appears to be harmless in practice,
+ but is technically undefined behaviour and is detected as such by
+ AddressSanitizer. (dbus!357, Evgeny Vereshchagin)
+
+• Avoid a data race in multi-threaded use of DBusCounter
+ (dbus#426, Ralf Habacker)
+
+• Fix a crash with some glibc versions when non-auditable SELinux events
+ are logged (dbus!386, Jeremi Piotrowski)
+
+• If dbus_message_demarshal() runs out of memory while validating a message,
+ report it as NoMemory rather than InvalidArgs (dbus#420, Simon McVittie)
+
+• Use C11 _Alignof if available, for better standards-compliance
+ (dbus!389, Khem Raj)
+
+• Stop including an outdated copy of pkg.m4 in the git tree
+ (dbus!365, Simon McVittie)
+
+• Meson build fixes:
+ · Use -fvisibility=hidden on Unix if supported, in particular on Linux
+ (dbus!383, dbus#437; Simon McVittie)
+ · Fix build on macOS, and any other platform that has
+ CLOCK_MONOTONIC but not pthread_condattr_setclock()
+ (dbus#419, Jordan Williams)
+
+• Documentation:
+ · Consistently use Gitlab bug reporting URL (dbus!372, Marco Trevisan)
+
+• Licensing:
+ · Use MIT license for some test files that did not previous specify a
+ license, with permission from their authors (dbus!359, Simon McVittie)
+ · Add more SPDX/REUSE license markers
+ (dbus!311, dbus!369, dbus!370, dbus!371, dbus!375, dbus!376;
+ Ralf Habacker, Simon McVittie)
+ · Correct syntax of some SPDX license markers (dbus!360, Ralf Habacker)
+
+• Tests fixes:
+ · Fix an assertion failure in test-autolaunch-win
+ (dbus#422, Ralf Habacker)
+ · Expand test coverage under CMake (dbus!322, Ralf Habacker)
+ · Fix the test-apparmor-activation test after dbus#416
+ (dbus!380, Dave Jones)
+
+Internal changes:
+
+• Add static assertions for some things we assume about pointers
+ (dbus!345, Simon McVittie)
+
+• Refactoring (dbus!356, dbus#430, dbus#431; Simon McVittie, Xin Shi)
+
+• Fix CI builds with recent git versions (dbus#447, Simon McVittie)
+
+• Build dbus with clang during CI (dbus!358, Evgeny Vereshchagin)
+
+dbus 1.15.2 (2022-10-05)
+========================
+
+This development release incorporates the same denial-of-service fixes and
+security hardening as dbus 1.14.4.
+
+Behaviour changes:
+
+• On Linux, dbus-daemon and other uses of DBusServer now create a
+ path-based Unix socket, unix:path=..., when asked to listen on a
+ unix:tmpdir=... address. This makes unix:tmpdir=... equivalent to
+ unix:dir=... on all platforms.
+ Previous versions would have created an abstract socket, unix:abstract=...,
+ in this situation.
+ This change primarily affects the well-known session bus when run via
+ dbus-launch(1) or dbus-run-session(1). The user bus, enabled by configuring
+ dbus with --enable-user-session and running it on a systemd system,
+ already used path-based Unix sockets and is unaffected by this change.
+ This behaviour change prevents a sandbox escape via the session bus socket
+ in sandboxing frameworks that can share the network namespace with the host
+ system, such as Flatpak.
+ This change might cause a regression in situations where the abstract socket
+ is intentionally shared between the host system and a chroot or container,
+ such as some use-cases of schroot(1). That regression can be resolved by
+ using a bind-mount to share either the D-Bus socket, or the whole /tmp
+ directory, with the chroot or container.
+ (dbus#416, Simon McVittie)
+
+Denial of service fixes:
+
+Evgeny Vereshchagin discovered several ways in which an authenticated
+local attacker could cause a crash (denial of service) in
+dbus-daemon --system or a custom DBusServer. In uncommon configurations
+these could potentially be carried out by an authenticated remote attacker.
+
+• An invalid array of fixed-length elements where the length of the array
+ is not a multiple of the length of the element would cause an assertion
+ failure in debug builds or an out-of-bounds read in production builds.
+ This was a regression in version 1.3.0.
+ (dbus#413, CVE-2022-42011; Simon McVittie)
+
+• A syntactically invalid type signature with incorrectly nested parentheses
+ and curly brackets would cause an assertion failure in debug builds.
+ Similar messages could potentially result in a crash or incorrect message
+ processing in a production build, although we are not aware of a practical
+ example. (dbus#418, CVE-2022-42010; Simon McVittie)
+
+• A message in non-native endianness with out-of-band Unix file descriptors
+ would cause a use-after-free and possible memory corruption in production
+ builds, or an assertion failure in debug builds. This was a regression in
+ version 1.3.0. (dbus#417, CVE-2022-42012; Simon McVittie)
+
+Enhancements:
+
+• D-Bus Specification 0.40 (dbus#416, Simon McVittie)
+ · Clarify that unix:tmpdir is not required to use abstract sockets,
+ even where supported
+ · Mention implications of abstract sockets for Linux namespacing
+
+dbus 1.15.0 (2022-09-22)
+========================
+
+Dependencies:
+
+• On platforms where a pointer is larger than 64 bits, dbus requires at
+ least a C11 compiler.
+ On other platforms, dbus now requires either a C99 compiler such as
+ gcc or clang, or Microsoft Visual Studio 2015 or later. Some workarounds
+ for pre-C99 environments are currently still present, but we plan to
+ remove them during this development cycle.
+
+• Building with CMake now requires CMake ≥ 3.4.
+
+• Building with Meson requires Meson ≥ 0.56 and Python ≥ 3.5.
+
+Feature removal:
+
+• Remove support for the obsolete pam_console and pam_foreground modules
+ (the Autotools --with-console-auth-dir= and CMake -DDBUS_CONSOLE_AUTH_DIR=
+ options, which have been deprecated since dbus 1.11.18).
+ (dbus#181, fd.o#101629)
+
+Build-time configuration changes:
+
+• Add a Meson build system. This is currently considered experimental,
+ but the intention is for it to replace Autotools and/or CMake in future
+ releases, preferably both. Please test!
+ (dbus!303, dbus!325; Félix Piédallu, Marc-André Lureau, Simon McVittie)
+ · This requires Meson 0.56 or newer, and Python 3.5 or newer.
+ · Expat can be built as a subproject using Meson's "wrap" mechanism,
+ if desired. This should make it considerably easier to build dbus
+ for Windows or other platforms without a library packaging system.
+ · GLib can also be built as a subproject using Meson's "wrap" mechanism,
+ if desired. This should make it considerably easier to build full
+ test coverage on Windows or other platforms without a library
+ packaging system.
+
+• Please note that not all Meson build options correspond 1:1 to how
+ the closest equivalents in Autotools or CMake behave, and the Meson
+ build options are subject to change.
+ Distributors and developers evaluating the Meson build should check
+ that they are configuring dbus the way they intend to.
+
+Enhancements:
+
+• D-Bus Specification 0.39:
+ · Document how to represent internationalized domain names in D-Bus
+ names (dbus!324, Simon McVittie)
+ · Improve documentation of AF_UNIX sockets (Marc-André Lureau)
+
+• On Unix, speed up closing file descriptors for subprocesses by using
+ closefrom() or close_range() where available
+ (dbus#278; rim, Simon McVittie)
+
+• On Windows, dbus can now use AF_UNIX sockets, not just TCP.
+ This requires Windows 10 build 17063 or later at runtime,
+ and either Windows 10 SDK 17063 or mingw-w64 version 9.0.0 or later
+ at compile-time. (dbus!249, Marc-André Lureau)
+
+• Teach dbus-send to handle variants in containers: arrays of variants,
+ variant values in dictionaries, and nested variants
+ (dbus!206, Frederik Van Bogaert)
+
+• Detect programming errors with Windows mutexes if assertions are
+ enabled, similar to what we already did for pthreads mutexes
+ (dbus#369, Ralf Habacker)
+
+• Move license text into LICENSES, and start to use SPDX markers
+ (Simon McVittie, Ralf Habacker)
+
+Fixes:
+
+• Portability to CPU architectures with larger-than-64-bit pointers
+ (dbus!335, dbus!318; Alex Richardson)
+
+• Fix build failure on FreeBSD (dbus!277, Alex Richardson)
+
+• Fix build failure on macOS with launchd enabled
+ (dbus!287, Dawid Wróbel)
+
+• Preserve errno on failure to open /proc/self/oom_score_adj
+ (dbus!285, Gentoo#834725; Mike Gilbert)
+
+• Improve dbus-launch --autolaunch so it can pick up an existing bus from
+ Linux XDG_RUNTIME_DIR or macOS launchd, even if X11 autolaunching was
+ disabled (dbus#385, dbus#392; Simon McVittie, Alex Richardson)
+
+• Correctly escape AF_UNIX socket paths when converting them to D-Bus
+ address strings (dbus#405, Marc-André Lureau)
+
+• On Linux, don't log warnings if oom_score_adj is read-only but does not
+ need to be changed (dbus!291, Simon McVittie)
+
+• Slightly improve error-handling for inotify
+ (dbus!235, Simon McVittie)
+
+• Don't crash if dbus-daemon is asked to watch more than 128 directories
+ for changes (dbus!302, Jan Tojnar)
+
+• Silence various compiler warnings
+ (dbus!275, dbus!289, dbus!305, dbus!307, dbus!312, dbus!315;
+ Ralf Habacker, Simon McVittie, Alex Richardson, Marc-André Lureau)
+
+• On Windows, use safer locking patterns for the system-global mutex used
+ to implement autolaunching (dbus#368, dbus#370; Ralf Habacker)
+
+• Index dbus-arch-deps.h for API documentation when building out-of-tree
+ (dbus!312, Marc-André Lureau)
+
+• Silence xmlto warnings when building man pages
+ (dbus!312, Marc-André Lureau)
+
+• Fix build failure when checks are disabled but assertions are enabled
+ (dbus#412, Johannes Kauffmann)
+
+• Use C99 flexible arrays in the memory pool implementation for better
+ support for modern compilers
+ (dbus!343, dbus!344; Alex Richardson, Simon McVittie)
+
+• Autotools build system fixes:
+ · Don't treat --with-x or --with-x=yes as a request to disable X11,
+ fixing a regression in 1.13.20. Instead, require X11 libraries and
+ fail if they cannot be detected. (dbus!263, Lars Wendler)
+ · When a CMake project uses an Autotools-built libdbus in a
+ non-standard prefix, find dbus-arch-deps.h successfully
+ (dbus#314, Simon McVittie)
+ · Don't include generated XML catalog in source releases
+ (dbus!317, Jan Tojnar)
+ · Improve robustness of detecting gcc __sync atomic builtins
+ (dbus!320, Alex Richardson)
+
+• CMake build system fixes:
+ · Detect endianness correctly, fixing interoperability with other D-Bus
+ implementations on big-endian systems (dbus#375, Ralf Habacker)
+ · Fix a race condition generating man pages and HTML documentation
+ (dbus#381, Ralf Habacker)
+ · When building for Unix, install session and system bus setup
+ in the intended locations
+ (dbus!267, dbus!297; Ralf Habacker, Alex Richardson)
+ · Detect setresuid() and getresuid() (dbus!319, Alex Richardson)
+ · Detect backtrace() on FreeBSD (dbus!281, Alex Richardson)
+ · Don't include headers from parent directory (dbus!282, Alex Richardson)
+ · Fix -Wunused-command-line-argument on FreeBSD
+ (dbus!278, Alex Richardson)
+ · Only add warning flags if the compiler supports them
+ (dbus!276, Alex Richardson)
+ · Distinguish between host and target TMPDIR when cross-compiling
+ (dbus!279, Alex Richardson)
+ · Improve compiler warning detection (dbus#387, Ralf Habacker)
+ · Allow TEST_SOCKET_DIR to be overridden (dbus!295, Ralf Habacker)
+ · Fix detection of atomic operations (dbus!306, Alex Richardson)
+ · Use DWARF 2 instead of STABS for debug symbols on Windows, for
+ compatibility with newer gcc versions (dbus!323, Marc-André Lureau)
+ · Fix use of paths relative to the dbus project directory when dbus is
+ vendored into a larger CMake project (dbus!332, Jordan Williams)
+
+Tests and CI enhancements:
+
+• Add an automated test for Windows autolaunching
+ (dbus#235, Ralf Habacker)
+
+• Avoid compiler warnings in test code
+ (dbus#383, dbus!274, dbus!275; Simon McVittie, Ralf Habacker)
+
+• Avoid LeakSanitizer warnings in test code
+ (dbus!326, Simon McVittie)
+
+• Speed up a particularly slow unit test by a factor of 30
+ (dbus!328, Simon McVittie)
+
+• On Unix, skip tests that switch uid if run in a container that is
+ unable to do so, instead of failing (dbus#407, Simon McVittie)
+
+• On Unix, consistently create test sockets in DBUS_TEST_SOCKET_DIR and
+ not the build directory, allowing the build directory to be mounted with
+ a non-POSIX filesystem (dbus!334, Alex Richardson)
+
+• Gitlab-CI improvements
+ (dbus#383, dbus#388, dbus!262, dbus!288, dbus!292, dbus!296, dbus!299,
+ dbus!301;
+ Ralf Habacker, Simon McVittie, Alex Richardson)
+
+• Added FreeBSD Gitlab-CI build jobs
+ (dbus!280, dbus!347; Alex Richardson)
+
+• Use the latest MSYS2 packages for CI
+ (Ralf Habacker, Simon McVittie)
+
+dbus 1.14.0 (2022-02-28)
+========================
+
+1.14.x is a new stable branch, superseding 1.12.x.
+
+Summary of major changes between 1.12.x and 1.14.0
+--------------------------------------------------
+
+Dependencies:
+
+• dbus now requires at least a basic level of support for C99 variadic
+ macros, as implemented in gcc >= 3, all versions of Clang, and
+ MSVC >= 2005. In practice this requirement has existed since version
+ 1.9.2, but it is now official.
+
+• dbus now requires a C99-compatible va_copy() macro (or a __va_copy()
+ macro with the same behaviour), except when building for Windows using
+ MSVC and CMake.
+
+• On Unix platforms, if getpwnam_r() and getgrnam_r() are implemented,
+ they must be POSIX-conformant. The non-POSIX signature seen in ancient
+ Solaris versions will no longer work.
+
+• All Windows builds now require Windows Vista or later.
+ (Note that we do not recommend or support use of dbus on operating
+ systems outside their vendor's security support lifetime, such as Vista.)
+
+• GLib >= 2.38 is required if full test coverage is enabled
+ (reduced from 2.40 in dbus 1.12.x.)
+
+• Building using CMake now requires CMake 3.4.
+
+• Building documentation using CMake now requires xsltproc, Docbook DTDs
+ (for example docbook-xml on Debian derivatives), and Docbook XSLT
+ stylesheets (for example docbook-xsl on Debian derivatives). Using
+ KDE's meinproc4 documentation processor is no longer supported.
+
+Build-time configuration changes:
+
+• Move CMake build system to top level, matching normal practice for
+ CMake projects
+
+Deprecations:
+
+• Third-party software should install default dbus policies for the system
+ bus into ${datadir}/dbus-1/system.d (this has been supported since dbus
+ 1.10, released in August 2015). Installing default dbus policies in
+ ${sysconfdir}/dbus-1/system.d is now considered to be deprecated. Policy
+ files in ${sysconfdir}/dbus-1/system.d continue to be read, but this
+ directory should only be used by system administrators wishing to
+ override the default policies.
+
+ The ${datadir} applicable to dbus is usually /usr/share and the
+ ${sysconfdir} is usually /etc.
+
+• A similar pattern applies to the session bus policies in session.d.
+
+• The dbus-send(1) man page now documents --bus and --peer instead of
+ the old --address synonym for --peer, which has been deprecated since
+ the introduction of --bus and --peer in 1.7.6
+
+• The dbus-daemon man page now has scarier warnings about
+ <allow_anonymous/> and non-local TCP, which are insecure and should
+ not be used, particularly for the standard system and session buses
+
+• DBusServer (and hence the dbus-daemon) no longer accepts usernames
+ (login names) for the recommended EXTERNAL authentication mechanism,
+ only numeric user IDs or the empty string. See 1.13.0 release notes
+ for full details.
+
+New features:
+
+• On Linux 4.13 or later when built against a suitable glibc version,
+ GetConnectionCredentials() now includes UnixGroupIDs, the effective
+ group IDs of the initiator of the connection, taken from
+ SO_PEERGROUPS.
+
+• On Linux 4.13 or later, <policy group="…"> now uses the SO_PEERGROUPS
+ credentials-passing socket option to get the effective group IDs
+ of the initiator of the connection. See 1.13.4 release notes for details.
+
+• Add a --sender option to dbus-send, which requests a name and holds it
+ until the signal has been sent
+
+• dbus-daemon <allow> and <deny> rules can now specify a
+ send_destination_prefix attribute, which is like a combination of
+ send_destination and the arg0namespace keyword in match rules.
+ See 1.13.12 release notes for more details
+
+• The dbus-daemon now filters the messages that it relays, removing
+ header fields that it does not understand. Clients must not rely on
+ this behaviour unless they have confirmed that they are connected to
+ a suitable message bus implementation, for example by querying its
+ Features property.
+
+• The dbus-daemon now emits a signal, ActivatableServicesChanged, when
+ the list of activatable services may have changed. Support for this
+ signal can be discovered by querying the Features property.
+
+• It is now possible to disable traditional (non-systemd) service
+ activation at build-time (Autotools: --disable-traditional-activation,
+ CMake: -DENABLE_TRADITIONAL_ACTIVATION=OFF). See 1.13.10 release notes
+ for details.
+
+• The API reference manual can be built as a Qt compiled help file if
+ qhelpgenerator(-qt5) is available. See 1.13.16 release notes for details.
+
+Miscellaneous behaviour changes:
+
+• When using the "user bus" (--enable-user-session), put the dbus-daemon
+ in the session slice
+
+• Several environment variables set by systemd are no longer passed
+ on to activated services
+
+• If the dbus-daemon is compiled for Linux with systemd support, it
+ now informs systemd that it is ready for use via the sd_notify()
+ mechanism
+
+• Tarball releases no longer contain pre-2007 changelogs and are now
+ compressed with xz, making them around 35% smaller.
+
+Changes since 1.13.22
+---------------------
+
+• On Windows, consistently use msvcrt.dll-style printf formats, fixing
+ builds with mingw-w64 8.0.0 (dbus#380, Simon McVittie)
+
+• Fix some broken links in the API design document
+ (dbus!257, Michael Nosthoff)
+
+• CI updates
+ · Enable -Werror for the CMake builds
+ · Use https to download MSYS packages
+ · Use Debian 11 for most builds
+ · Stop testing on Debian 9, which is EOL
+ · Stop testing on Ubuntu 16.04, which is EOL
+ · Remove workarounds for missing/outdated packages in Debian 8, Debian 9
+ and Ubuntu 16.04
+ (dbus#380, dbus!260; Simon McVittie)
+
+dbus 1.13.22 (2022-02-23)
+=========================
+
+This is a release candidate for a new dbus 1.14.x stable branch.
+
+Enhancements:
+
+• D-Bus Specification 0.38:
+ · Add ActivatableServicesChanged signal and feature flag
+ (dbus#376, Ralf Habacker)
+ · Document * as optionally-escaped in D-Bus addresses, matching
+ the implementation (dbus!248, Kir Kolyshkin)
+
+• Emit the new ActivatableServicesChanged signal when configuration
+ and/or activatable services are reloaded (dbus#376, Ralf Habacker)
+
+• Add an XML catalog file for the DTDs we install
+ (dbus!202, Jan Tojnar)
+
+Bug fixes:
+
+• On Linux, when using traditional (non-systemd) service activation,
+ don't log warnings about failing to reset OOM score adjustment if the
+ process is already more susceptible to the OOM killer, as user processes
+ usually are with systemd ≥ 250. (dbus#374, Simon McVittie)
+
+• On Linux, when using traditional (non-systemd) system bus activation,
+ reset the OOM score adjustment to 0 as intended.
+ If the system dbus-daemon is protected from the OOM killer, this
+ avoids that protection unintentionally being inherited by every
+ system service. (dbus#378, Simon McVittie)
+
+• Fix a code path that could result in a crash on out-of-memory
+ (dbus#246, Marc-André Lureau)
+
+• Fix compilation if embedded tests are enabled but verbose mode and
+ stats are both disabled (Marc-André Lureau)
+
+• CMake: Improve support for Windows with MSVC and add CI coverage
+ (dbus!218, Marc-André Lureau)
+
+• CMake: Improve Docbook documentation-generation
+ (dbus#377, Ralf Habacker)
+
+• On Linux, fix a race condition in the integration test for transient
+ services (Debian#1005889, dbus!256; Simon McVittie)
+
+dbus 1.13.20 (2021-12-17)
+=========================
+
+The “not how anyone wanted to learn the Greek alphabet” release.
+
+Dependencies:
+
+• Building using CMake now requires CMake 3.4.
+
+Enhancements:
+
+• D-Bus Specification 0.37:
+ · Update recommendations for DBUS_COOKIE_SHA1 timeouts
+ (dbus!171, Simon McVittie)
+ · Clarify padding requirements for arrays and variants
+ (dbus!203, Zeeshan Ali)
+ · Describe where the interoperable machine ID comes from
+ (dbus!198, Thomas Kluyver)
+ · Clarify use of dictionary (array of dict-entry) types
+ (dbus#347, Ralf Habacker)
+
+• When using the "user bus" (--enable-user-session), put the dbus-daemon
+ in the session slice (dbus!219, David Redondo)
+
+Feature removal:
+
+• Disable the experimental Containers1 interface that was added in 1.13.0.
+ It is incomplete and not ready for production use, so we're disabling it
+ in preparation for a new 1.14.x stable branch; the code remains present
+ and will be re-enabled later, but there is no longer a build-time
+ configuration option to enable it. (dbus!236, Simon McVittie)
+
+Bug fixes:
+
+• Avoid malloc() after fork on non-GNU libc (dbus!181, Jean-Louis Fuchs)
+
+• Don't return successfully from RemoveMatch if the match rule didn't
+ exist (dbus#351, Simon McVittie)
+
+• On Windows, fix a race condition where dbus-run-session could start the
+ wrapped application before the dbus-daemon was ready
+ (dbus#297, Ralf Habacker)
+
+• Fix build with clang 13 by using Standard C offsetof where available
+ (dbus!237, Simon McVittie)
+
+• Fix build of tests on FreeBSD (dbus!167, Simon McVittie)
+
+• Various CMake build improvements
+ (dbus#310, dbus!213, dbus#319, dbus!217, dbus#346, dbus#356;
+ Ralf Habacker)
+
+• Set IMPORTED_IMPLIB property in CMake metadata installed via Autotools
+ with mingw toolchain
+ (dbus!172, Julien Schueller)
+
+• Make documentation build more reproducible
+ (dbus!189, dbus!238; Arnout Engelen, Simon McVittie)
+
+• On Unix, make X11 autolaunch cope with slashes in DISPLAY
+ (dbus#8, dbus#311; William Earley)
+
+• Don't try to raise RLIMIT_NOFILE beyond OPEN_MAX on macOS
+ (dbus#309, William Earley)
+
+• Improve SELinux audit messages (dbus!173, Chris PeBenito)
+
+• Validate various strings in dbus-send to avoid client-side assertion
+ failures on invalid input (dbus#338, Simon McVittie)
+
+• Fix a memory leak in a unit test (dbus!208, David King)
+
+• In Autotools builds, use pkg-config in preference to AC_PATH_XTRA
+ (dbus!212, Scott Hamilton)
+
+• On Windows, prevent (theoretical?) stack buffer overflow with very
+ long paths (dbus!221, Ralf Habacker)
+
+• Fix build with newer mingw compilers (dbus#355, Ralf Habacker)
+
+• Various Windows error-handling fixes
+ (dbus!229, dbus#357, dbus#279, dbus#360, dbus#365;
+ Ralf Habacker, Simon McVittie)
+
+• Clearer diagnostics when tests are skipped (dbus#363, Simon McVittie)
+
+• CI improvements
+ (dbus#318, dbus!197, dbus!187, dbus!196, dbus!201, dbus#359;
+ Simon McVittie, Ralf Habacker, Arnout Engelen, Marc-André Lureau)
+
+• Typo fixes, etc.
+ (dbus!183, dbus!182; Chigozirim Chukwu, Samy Mahmoudi)
+
dbus 1.13.18 (2020-07-02)
=========================
diff --git a/README b/README
index 71ebc05d..e0047140 100644
--- a/README
+++ b/README
@@ -15,7 +15,7 @@ The "and coordination" part is important; D-Bus provides a bus daemon that does
- start services on demand
- support single-instance applications
-See http://www.freedesktop.org/software/dbus/ for lots of documentation,
+See https://www.freedesktop.org/wiki/Software/dbus/ for lots of documentation,
mailing lists, etc.
See also the file CONTRIBUTING.md for notes of interest to developers
@@ -31,13 +31,16 @@ only by accident; so you should evaluate carefully whether D-Bus makes
sense for your project.
Security
-==
+===
If you find a security vulnerability that is not known to the public,
please report it privately to dbus-security@lists.freedesktop.org
or by reporting a Gitlab issue at
https://gitlab.freedesktop.org/dbus/dbus/issues/new and marking it
as "confidential".
+Please do not open merge requests for security issues: if you have a
+proposed patch, it can be discussed on the confidential issue or by
+private email.
On Unix systems, the system bus (dbus-daemon --system) is designed
to be a security boundary between users with different privileges.
@@ -80,28 +83,16 @@ Development snapshots make no ABI stability guarantees for new ABI
introduced since the last stable release. Development snapshots are
likely to have more bugs than stable releases, obviously.
-Configuration
+Configuration and installation
===
-dbus could be build by using autotools or cmake.
-
-When using autotools the configure step is initiated by running ./configure
-with or without additional configuration flags. dbus requires GNU Make
-(on BSD systems, this is typically called gmake) or a "make" implementation
-with compatible extensions.
-
-When using cmake the configure step is initiated by running the cmake
-program with or without additional configuration flags.
-
-Configuration flags
-===
+This branch of dbus can be built by using Meson or CMake.
+The Meson build system is the recommended build system for the master
+branch (versions >= 1.15.0), except when building on Windows, for which
+CMake is recommended (this recommendation might change to Meson in future).
-When using autotools, run "./configure --help" to see the possible
-configuration options and environment variables.
+Please see `INSTALL` for full details.
-When using cmake, inspect README.cmake to see the possible
-configuration options and environment variables.
-
API/ABI Policy
===
diff --git a/README.cmake b/README.cmake
index 7c984430..03e5f27b 100644
--- a/README.cmake
+++ b/README.cmake
@@ -2,7 +2,7 @@ This file describes how to compile dbus using the cmake build system
Requirements
------------
-- cmake version >= 2.6.0 see http://www.cmake.org
+- cmake version >= 3.4 see http://www.cmake.org
- installed libexpat see http://sourceforge.net/projects/expat/
unsupported RelWithDebInfo builds could be fetched
from http://sourceforge.net/projects/kde-windows/files/expat/
@@ -139,6 +139,9 @@ DBUS_ENABLE_ANSI:BOOL=OFF
// build DOXYGEN documentation (requires Doxygen)
DBUS_ENABLE_DOXYGEN_DOCS:BOOL=OFF
+// Unconditionally make all compiler warnings fatal
+ENABLE_WERROR:BOOL=OFF
+
// build qt help documentation (requires qhelpgenerator(-qt5));
// set INSTALL_QCH_DIR for custom qch installation path
ENABLE_QT_HELP:STRING=AUTO
@@ -146,15 +149,15 @@ ENABLE_QT_HELP:STRING=AUTO
// enable bus daemon usage statistics
DBUS_ENABLE_STATS:BOOL=OFF
-// enable restricted servers for app containers
-DBUS_ENABLE_CONTAINERS:BOOL=OFF
-
// build with systemd at_console support
ENABLE_SYSTEMD:STRING=AUTO
// Directory for systemd service files
WITH_SYSTEMD_SYSTEMUNITDIR:STRING=
+// Be verbose on generating config files
+ENABLE_VERBOSE_CONFIG:BOOL=OFF
+
// enable user-session semantics for session bus under systemd
ENABLE_USER_SESSION:BOOL=ON
@@ -176,6 +179,9 @@ DBUS_SESSION_BUS_LISTEN_ADDRESS:STRING=autolaunch:
// session bus fallback address for clients
DBUS_SESSION_BUS_CONNECT_ADDRESS:STRING=autolaunch:
+//Default directory for session socket
+DBUS_SESSION_SOCKET_DIR:STRING=/tmp
+
// system bus default address (only useful on Unix)
DBUS_SYSTEM_BUS_DEFAULT_ADDRESS:STRING=unix:path=/var/run/dbus/system_bus_socket
diff --git a/README.win b/README.win
index 8a5b3c0a..0ed83e03 100644
--- a/README.win
+++ b/README.win
@@ -13,8 +13,11 @@ test not running yet and there is help needed to get them running.
Supported compilers
-------------------
-On windows Microsoft Visual Studio 2010 (Express and professional variants)
-and mingw-w64|32 are known to work.
+Building dbus for Windows requires either Microsoft Visual Studio 2015
+or later, or a recent mingw-w64 compiler.
+
+Compilers older than the ones we test in continuous integration are
+not supported.
Building
--------
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755
index 6de735f0..00000000
--- a/autogen.sh
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/bin/sh
-# Run this to generate all the initial makefiles, etc.
-
-srcdir=`dirname $0`
-test -z "$srcdir" && srcdir=.
-
-ORIGDIR=`pwd`
-cd $srcdir
-
-PROJECT=dbus
-TEST_TYPE=-f
-FILE=dbus-1.pc.in
-
-DIE=0
-
-if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then
- echo "Activating pre-commit hook."
- cp .git/hooks/pre-commit.sample .git/hooks/pre-commit
- chmod +x .git/hooks/pre-commit
-fi
-
-(autoconf --version) < /dev/null > /dev/null 2>&1 || {
- echo
- echo "You must have autoconf installed to compile $PROJECT."
- echo "Download the appropriate package for your distribution,"
- echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
- DIE=1
-}
-
-# If the user hasn't explicitly chosen an Automake version, use 1.11. This is
-# the earliest version that gives us silent rules.
-if test -z "$AUTOMAKE"; then
- AUTOMAKE=automake-1.11
- ACLOCAL=aclocal-1.11
-fi
-
-($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
- AUTOMAKE=automake
- ACLOCAL=aclocal
-}
-
-($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
- echo
- echo "You must have automake installed to compile $PROJECT."
- echo "Get ftp://ftp.cygnus.com/pub/home/tromey/automake-1.2d.tar.gz"
- echo "(or a newer version if it is available)"
- DIE=1
-}
-
-LIBTOOLIZE=`which libtoolize`
-if ! test -f "$LIBTOOLIZE"; then
- LIBTOOLIZE=`which glibtoolize`
-fi
-
-($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
- echo
- echo "You must have libtoolize installed to compile $PROJECT."
- echo "Install the libtool package from ftp.gnu.org or a mirror."
- DIE=1
-}
-
-if test "$DIE" -eq 1; then
- exit 1
-fi
-
-test $TEST_TYPE $FILE || {
- echo "You must run this script in the top-level $PROJECT directory"
- exit 1
-}
-
-if test -z "$*"; then
- echo "I am going to run ./configure with no arguments - if you wish "
- echo "to pass any to it, please specify them on the $0 command line."
-fi
-
-$LIBTOOLIZE --copy --force
-
-$ACLOCAL -I m4 $ACLOCAL_FLAGS
-
-## optionally feature autoheader
-(autoheader --version) < /dev/null > /dev/null 2>&1 && autoheader
-
-$AUTOMAKE -a $am_opt
-if ! autoconf; then
- echo "autoconf failed - version 2.5x is probably required" >&2
- exit 1
-fi
-
-cd $ORIGDIR
-
-if test x"$NOCONFIGURE" = x; then
- run_configure=true
- for arg in $*; do
- case $arg in
- --no-configure)
- run_configure=false
- ;;
- *)
- ;;
- esac
- done
-else
- run_configure=false
-fi
-
-if $run_configure; then
- $srcdir/configure --enable-developer --config-cache "$@"
-fi
diff --git a/bus/CMakeLists.txt b/bus/CMakeLists.txt
index 26f07dd2..febfaeb0 100644
--- a/bus/CMakeLists.txt
+++ b/bus/CMakeLists.txt
@@ -18,7 +18,7 @@ set(SERVICE_FILES test/data/valid-service-files)
file(GLOB FILES "${SERVICE_FILES}/*.service.in" )
foreach(FILE ${FILES})
get_filename_component(FILENAME ${FILE} NAME_WE)
- set(TARGET ${CMAKE_BINARY_DIR}/data/dbus-1/services/${FILENAME}.service)
+ set(TARGET ${PROJECT_BINARY_DIR}/data/dbus-1/services/${FILENAME}.service)
if(CONFIG_VERBOSE)
message("FROM: ${FILE}\nTO: ${TARGET}\n")
endif()
@@ -84,8 +84,7 @@ if(DBUS_ENABLE_STATS)
endif()
include_directories(
- ${CMAKE_BINARY_DIR}
- ${CMAKE_SOURCE_DIR}/..
+ ${PROJECT_BINARY_DIR}
${EXPAT_INCLUDE_DIR}
)
diff --git a/bus/Makefile.am b/bus/Makefile.am
deleted file mode 100644
index 1595432c..00000000
--- a/bus/Makefile.am
+++ /dev/null
@@ -1,250 +0,0 @@
-dbusdatadir=$(datadir)/dbus-1
-legacydbusdatadir=$(sysconfdir)/dbus-1
-dbus_daemon_execdir = $(DBUS_DAEMONDIR)
-# Always lib, even if ${libdir} is lib64 or lib/x86_64-linux-gnu
-systemdtmpfilesdir = $(prefix)/lib/tmpfiles.d
-systemdsysusersdir = $(prefix)/lib/sysusers.d
-
-DBUS_BUS_LIBS = \
- $(CODE_COVERAGE_LIBS) \
- $(EXPAT_LIBS) \
- $(SELINUX_LIBS) \
- $(APPARMOR_LIBS) \
- $(THREAD_LIBS) \
- $(ADT_LIBS) \
- $(NETWORK_libs) \
- $(NULL)
-
-DBUS_LAUNCHER_LIBS = \
- $(CODE_COVERAGE_LIBS) \
- $(EXPAT_LIBS) \
- $(THREAD_LIBS) \
- $(NETWORK_libs) \
- $(NULL)
-
-AM_CPPFLAGS = \
- $(CODE_COVERAGE_CPPFLAGS) \
- -I$(top_srcdir) \
- $(DBUS_STATIC_BUILD_CPPFLAGS) \
- $(EXPAT_CFLAGS) \
- $(APPARMOR_CFLAGS) \
- -DDBUS_SYSTEM_CONFIG_FILE=\""$(dbusdatadir)/system.conf"\" \
- -DDBUS_RUNSTATEDIR=\""$(runstatedir)"\" \
- -DDBUS_COMPILATION \
- $(NULL)
-
-# if assertions are enabled, improve backtraces
-AM_LDFLAGS = @R_DYNAMIC_LDFLAG@
-
-AM_CFLAGS = \
- $(CODE_COVERAGE_CFLAGS) \
- $(SANITIZE_CFLAGS) \
- $(NULL)
-
-EFENCE=
-
-EXTRA_DIST = \
- session.conf.in \
- system.conf.in \
- legacy-config/session.conf.in \
- legacy-config/system.conf.in \
- org.freedesktop.dbus-session.plist.in \
- example-system-enable-stats.conf.in \
- example-session-disable-stats.conf.in \
- $(NULL)
-
-dbusdata_DATA = session.conf
-legacydbusdata_DATA = legacy-config/session.conf
-
-if DBUS_UNIX
-dbusdata_DATA += system.conf
-legacydbusdata_DATA += legacy-config/system.conf
-endif
-
-examplesdir = ${docdir}/examples
-examples_DATA = \
- example-system-enable-stats.conf \
- example-session-disable-stats.conf \
- $(NULL)
-
-dist_examples_DATA = \
- example-system-hardening-without-traditional-activation.conf \
- $(NULL)
-
-if DBUS_ENABLE_LAUNCHD
-agentdir=$(LAUNCHD_AGENT_DIR)
-agent_DATA=org.freedesktop.dbus-session.plist
-endif
-
-if DBUS_BUS_ENABLE_KQUEUE
-DIR_WATCH_SOURCE=dir-watch-kqueue.c
-else
-if DBUS_BUS_ENABLE_INOTIFY
-DIR_WATCH_SOURCE=dir-watch-inotify.c
-else
-DIR_WATCH_SOURCE=dir-watch-default.c
-endif
-endif
-
-noinst_LTLIBRARIES = libdbus-daemon-internal.la
-
-libdbus_daemon_internal_la_SOURCES = \
- activation.c \
- activation.h \
- activation-exit-codes.h \
- apparmor.c \
- apparmor.h \
- audit.c \
- audit.h \
- bus.c \
- bus.h \
- config-loader-expat.c \
- config-parser.c \
- config-parser.h \
- config-parser-common.c \
- config-parser-common.h \
- connection.c \
- connection.h \
- containers.c \
- containers.h \
- desktop-file.c \
- desktop-file.h \
- $(DIR_WATCH_SOURCE) \
- dir-watch.h \
- dispatch.c \
- dispatch.h \
- driver.c \
- driver.h \
- expirelist.c \
- expirelist.h \
- policy.c \
- policy.h \
- selinux.h \
- selinux.c \
- services.c \
- services.h \
- signals.c \
- signals.h \
- stats.c \
- stats.h \
- test.c \
- test.h \
- utils.c \
- utils.h \
- $(NULL)
-
-libdbus_daemon_internal_la_LIBADD = \
- $(top_builddir)/dbus/libdbus-1.la \
- $(top_builddir)/dbus/libdbus-internal.la \
- $(EFENCE) \
- $(DBUS_BUS_LIBS) \
- $(NULL)
-
-dbus_daemon_SOURCES = main.c
-dbus_daemon_LDADD = libdbus-daemon-internal.la
-
-liblaunch_helper_internal_la_SOURCES = \
- config-loader-expat.c \
- config-parser-common.c \
- config-parser-common.h \
- config-parser-trivial.c \
- config-parser-trivial.h \
- desktop-file.c \
- desktop-file.h \
- utils.c \
- utils.h \
- activation-exit-codes.h \
- activation-helper.h \
- $(NULL)
-
-## This is the installed launch helper with the setuid checks
-## All files that have special cases #ifdef ACTIVATION_LAUNCHER_TEST must
-## be listed here and included in test/bus/launch-helper-for-tests.c,
-## not in liblaunch-helper-internal.la.
-dbus_daemon_launch_helper_SOURCES = \
- activation-helper.c \
- activation-helper-bin.c \
- $(NULL)
-dbus_daemon_launch_helper_LDADD = liblaunch-helper-internal.la
-
-liblaunch_helper_internal_la_LIBADD = \
- $(top_builddir)/dbus/libdbus-1.la \
- $(top_builddir)/dbus/libdbus-internal.la \
- $(DBUS_LAUNCHER_LIBS)
-
-noinst_PROGRAMS =
-dbus_daemon_exec_PROGRAMS = dbus-daemon
-if DBUS_UNIX
-if ENABLE_TRADITIONAL_ACTIVATION
-noinst_LTLIBRARIES += liblaunch-helper-internal.la
-libexec_PROGRAMS = dbus-daemon-launch-helper
-endif ENABLE_TRADITIONAL_ACTIVATION
-endif DBUS_UNIX
-
-install-data-hook:
- $(mkinstalldirs) $(DESTDIR)$(dbusdatadir)/session.d
- $(mkinstalldirs) $(DESTDIR)$(dbusdatadir)/services
-if DBUS_UNIX
- $(mkinstalldirs) $(DESTDIR)$(localstatedir)/run/dbus
- $(mkinstalldirs) $(DESTDIR)$(dbusdatadir)/system.d
- $(mkinstalldirs) $(DESTDIR)$(dbusdatadir)/system-services
-endif
-if HAVE_SYSTEMD
-# Install dbus.socket as default implementation of a D-Bus stack.
-# Deliberately not using $(LN_S) here: ln -fs is not universally portable,
-# but neither is systemd, so it's OK to assume here that ln complies with SUS.
-# Unconditionally enable D-Bus on systemd installations
- $(mkinstalldirs) $(DESTDIR)$(systemdsystemunitdir)/sockets.target.wants
- ln -fs ../dbus.socket $(DESTDIR)$(systemdsystemunitdir)/sockets.target.wants/dbus.socket
- $(mkinstalldirs) $(DESTDIR)$(systemdsystemunitdir)/multi-user.target.wants
- ln -fs ../dbus.service $(DESTDIR)$(systemdsystemunitdir)/multi-user.target.wants/dbus.service
-endif
-if DBUS_ENABLE_USER_SESSION
- $(mkinstalldirs) $(DESTDIR)$(systemduserunitdir)/sockets.target.wants
- ln -fs ../dbus.socket $(DESTDIR)$(systemduserunitdir)/sockets.target.wants/dbus.socket
-endif
-
-if DBUS_UNIX
-if ENABLE_TRADITIONAL_ACTIVATION
-install-exec-hook:
- if test `id -u` -eq 0; then \
- chown root:$(DBUS_USER) $(DESTDIR)$(libexecdir)/dbus-daemon-launch-helper$(EXEEXT); \
- chmod 4750 $(DESTDIR)$(libexecdir)/dbus-daemon-launch-helper$(EXEEXT); \
- else \
- echo "Not installing $(DESTDIR)$(libexecdir)/dbus-daemon-launch-helper binary setuid!"; \
- echo "You'll need to manually set permissions to root:$(DBUS_USER) and permissions 4750"; \
- fi
-endif ENABLE_TRADITIONAL_ACTIVATION
-endif DBUS_UNIX
-
-EXTRA_DIST += \
- dbus.service.in \
- dbus.socket.in \
- systemd-user/dbus.service.in \
- systemd-user/dbus.socket.in \
- sysusers.d/dbus.conf.in \
- tmpfiles.d/dbus.conf.in \
- $(NULL)
-
-if HAVE_SYSTEMD
-systemdsystemunit_DATA = \
- dbus.service \
- dbus.socket
-
-nodist_systemdsysusers_DATA = \
- sysusers.d/dbus.conf
-
-nodist_systemdtmpfiles_DATA = \
- tmpfiles.d/dbus.conf \
- $(NULL)
-endif
-
-if DBUS_ENABLE_USER_SESSION
-systemduserunit_DATA = \
- systemd-user/dbus.service \
- systemd-user/dbus.socket \
- $(NULL)
-endif
-
-# Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE
-include $(top_srcdir)/aminclude_static.am
diff --git a/bus/activation-exit-codes.h b/bus/activation-exit-codes.h
index ffedb86b..0a093372 100644
--- a/bus/activation-exit-codes.h
+++ b/bus/activation-exit-codes.h
@@ -4,6 +4,8 @@
*
* Copyright (C) 2007 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/activation-helper-bin.c b/bus/activation-helper-bin.c
index 0446ee23..cefc8d33 100644
--- a/bus/activation-helper-bin.c
+++ b/bus/activation-helper-bin.c
@@ -4,6 +4,8 @@
*
* Copyright (C) 2007 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/activation-helper.c b/bus/activation-helper.c
index 8172b6cf..1b640cfb 100644
--- a/bus/activation-helper.c
+++ b/bus/activation-helper.c
@@ -4,6 +4,8 @@
*
* Copyright (C) 2007 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -32,6 +34,7 @@
#include "activation-helper.h"
#include "activation-exit-codes.h"
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -43,6 +46,7 @@
#include <dbus/dbus-misc.h>
#include <dbus/dbus-shell.h>
#include <dbus/dbus-marshal-validate.h>
+#include <dbus/dbus-sysdeps-unix.h>
static BusDesktopFile *
desktop_file_for_name (BusConfigParser *parser,
@@ -337,11 +341,17 @@ exec_for_correct_user (char *exec, char *user, DBusError *error)
char **argv;
int argc;
dbus_bool_t retval;
+ const char *error_str = NULL;
argc = 0;
retval = TRUE;
argv = NULL;
+ /* Resetting the OOM score adjustment is best-effort, so we don't
+ * treat a failure to do so as fatal. */
+ if (!_dbus_reset_oom_score_adj (&error_str))
+ _dbus_log (DBUS_SYSTEM_LOG_WARNING, "%s: %s", error_str, strerror (errno));
+
if (!switch_user (user, error))
return FALSE;
diff --git a/bus/activation-helper.h b/bus/activation-helper.h
index 4b85ccb0..d5bc7ef8 100644
--- a/bus/activation-helper.h
+++ b/bus/activation-helper.h
@@ -4,6 +4,8 @@
*
* Copyright (C) 2007 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/activation.c b/bus/activation.c
index 19ac869a..68cbaae1 100644
--- a/bus/activation.c
+++ b/bus/activation.c
@@ -5,6 +5,8 @@
* Copyright (C) 2003 Red Hat, Inc.
* Copyright (C) 2004 Imendio HB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -898,6 +900,7 @@ bus_activation_reload (BusActivation *activation,
{
DBusList *link;
char *dir;
+ DBusError local_error = DBUS_ERROR_INIT;
if (activation->server_address != NULL)
dbus_free (activation->server_address);
@@ -965,13 +968,18 @@ bus_activation_reload (BusActivation *activation,
}
/* only fail on OOM, it is ok if we can't read the directory */
- if (!update_directory (activation, s_dir, error))
- {
- if (dbus_error_has_name (error, DBUS_ERROR_NO_MEMORY))
- goto failed;
- else
- dbus_error_free (error);
- }
+ if (!update_directory (activation, s_dir, &local_error))
+ {
+ if (dbus_error_has_name (&local_error, DBUS_ERROR_NO_MEMORY))
+ {
+ dbus_move_error (&local_error, error);
+ goto failed;
+ }
+ else
+ {
+ dbus_error_free (&local_error);
+ }
+ }
link = _dbus_list_get_next_link (directories, link);
}
diff --git a/bus/activation.h b/bus/activation.h
index 7ae8ade9..e9f102af 100644
--- a/bus/activation.h
+++ b/bus/activation.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/apparmor.c b/bus/apparmor.c
index 985f5e9f..fe6cb305 100644
--- a/bus/apparmor.c
+++ b/bus/apparmor.c
@@ -5,6 +5,8 @@
*
* Copyright © 2014-2015 Canonical, Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/apparmor.h b/bus/apparmor.h
index ed465f71..9c3356f3 100644
--- a/bus/apparmor.h
+++ b/bus/apparmor.h
@@ -5,6 +5,8 @@
* Tyler Hicks <tyhicks@canonical.com>
* Based on: selinux.h by Matthew Rickard
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/audit.c b/bus/audit.c
index 9bfe456a..7287c61b 100644
--- a/bus/audit.c
+++ b/bus/audit.c
@@ -6,6 +6,8 @@
* Copyright © 2014-2015 Canonical, Ltd.
* Copyright © 2015 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/audit.h b/bus/audit.h
index e17016f3..dd41577c 100644
--- a/bus/audit.h
+++ b/bus/audit.h
@@ -1,6 +1,8 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
* audit.h - libaudit integration for SELinux and AppArmor
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/bus.c b/bus/bus.c
index db20bbbc..62d58f8e 100644
--- a/bus/bus.c
+++ b/bus/bus.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003, 2004 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -30,6 +32,7 @@
#include "activation.h"
#include "connection.h"
#include "containers.h"
+#include "dispatch.h"
#include "services.h"
#include "utils.h"
#include "policy.h"
@@ -764,11 +767,13 @@ process_config_postinit (BusContext *context,
return TRUE;
}
+/* Takes ownership of print_addr_pipe fds, print_pid_pipe fds and ready_event_handle */
BusContext*
bus_context_new (const DBusString *config_file,
BusContextFlags flags,
DBusPipe *print_addr_pipe,
DBusPipe *print_pid_pipe,
+ void *ready_event_handle,
const DBusString *address,
DBusError *error)
{
@@ -891,6 +896,17 @@ bus_context_new (const DBusString *config_file,
_dbus_string_free (&addr);
}
+#ifdef DBUS_WIN
+ if (ready_event_handle != NULL)
+ {
+ _dbus_verbose ("Notifying that we are ready to receive connections (event handle=%p)\n", ready_event_handle);
+ if (!_dbus_win_event_set (ready_event_handle, error))
+ goto failed;
+ if (!_dbus_win_event_free (ready_event_handle, error))
+ goto failed;
+ }
+#endif
+
context->connections = bus_connections_new (context);
if (context->connections == NULL)
{
@@ -1062,6 +1078,66 @@ bus_context_get_id (BusContext *context,
return _dbus_uuid_encode (&context->uuid, uuid);
}
+/**
+ * Send signal to the buses that the activatable services may be changed
+ *
+ * @param context bus context to use
+ * @param error the error to set, if NULL no error will be set
+ * @return #FALSE if an error occurred, the reason is returned in \p error
+ */
+static dbus_bool_t
+bus_context_send_activatable_services_changed (BusContext *context,
+ DBusError *error)
+{
+ DBusMessage *message;
+ BusTransaction *transaction;
+ dbus_bool_t retval = FALSE;
+
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ transaction = bus_transaction_new (context);
+ if (transaction == NULL)
+ {
+ BUS_SET_OOM (error);
+ return FALSE;
+ }
+
+ message = dbus_message_new_signal (DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ "ActivatableServicesChanged");
+
+ if (message == NULL)
+ {
+ BUS_SET_OOM (error);
+ goto out;
+ }
+
+ if (!dbus_message_set_sender (message, DBUS_SERVICE_DBUS))
+ {
+ BUS_SET_OOM (error);
+ goto out;
+ }
+
+ if (!bus_transaction_capture (transaction, NULL, NULL, message))
+ {
+ BUS_SET_OOM (error);
+ goto out;
+ }
+
+ retval = bus_dispatch_matches (transaction, NULL, NULL, message, error);
+
+out:
+ if (transaction != NULL)
+ {
+ if (retval)
+ bus_transaction_execute_and_free (transaction);
+ else
+ bus_transaction_cancel_and_free (transaction);
+ }
+ dbus_clear_message (&message);
+ return retval;
+}
+
dbus_bool_t
bus_context_reload_config (BusContext *context,
DBusError *error)
@@ -1103,6 +1179,15 @@ bus_context_reload_config (BusContext *context,
if (parser != NULL)
bus_config_parser_unref (parser);
+ {
+ DBusError local_error = DBUS_ERROR_INIT;
+
+ if (!bus_context_send_activatable_services_changed (context, &local_error))
+ bus_context_log (context, DBUS_SYSTEM_LOG_INFO, "Unable to send signal that configuration has been reloaded: %s", local_error.message);
+
+ dbus_error_free (&local_error);
+ }
+
_dbus_daemon_report_reloaded ();
return ret;
}
@@ -1329,11 +1414,42 @@ bus_context_get_containers (BusContext *context)
BusClientPolicy*
bus_context_create_client_policy (BusContext *context,
DBusConnection *connection,
+ BusClientPolicy *previous,
DBusError *error)
{
+ BusClientPolicy *client;
+ DBusError local_error = DBUS_ERROR_INIT;
+ const char *conn;
+ const char *loginfo;
+
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
- return bus_policy_create_client_policy (context->policy, connection,
- error);
+
+ client = bus_policy_create_client_policy (context->policy, connection,
+ &local_error);
+
+ /* On success, use new policy */
+ if (client != NULL)
+ return client;
+
+ /* On failure while setting up a new connection, fail */
+ if (previous == NULL)
+ {
+ dbus_move_error (&local_error, error);
+ return NULL;
+ }
+
+ /* On failure while reloading, keep the previous policy */
+ conn = bus_connection_get_name (connection);
+ loginfo = bus_connection_get_loginfo (connection);
+
+ if (conn == NULL)
+ conn = "(inactive)";
+
+ bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
+ "Unable to reload policy for connection \"%s\" (%s), "
+ "keeping current policy: %s",
+ conn, loginfo, local_error.message);
+ return bus_client_policy_ref (previous);
}
int
diff --git a/bus/bus.h b/bus/bus.h
index 99625ca3..88451ebb 100644
--- a/bus/bus.h
+++ b/bus/bus.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -88,6 +90,7 @@ BusContext* bus_context_new (const DBusStri
BusContextFlags flags,
DBusPipe *print_addr_pipe,
DBusPipe *print_pid_pipe,
+ void *ready_event_handle,
const DBusString *address,
DBusError *error);
dbus_bool_t bus_context_reload_config (BusContext *context,
@@ -114,6 +117,7 @@ BusContainers *bus_context_get_containers (BusContext
BusClientPolicy* bus_context_create_client_policy (BusContext *context,
DBusConnection *connection,
+ BusClientPolicy *previous,
DBusError *error);
int bus_context_get_activation_timeout (BusContext *context);
int bus_context_get_auth_timeout (BusContext *context);
diff --git a/bus/config-loader-expat.c b/bus/config-loader-expat.c
index 6cbd37eb..36cdef96 100644
--- a/bus/config-loader-expat.c
+++ b/bus/config-loader-expat.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/config-parser-common.c b/bus/config-parser-common.c
index 627c9013..12a01b47 100644
--- a/bus/config-parser-common.c
+++ b/bus/config-parser-common.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2007 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/config-parser-common.h b/bus/config-parser-common.h
index 1c601e97..be55bcd9 100644
--- a/bus/config-parser-common.h
+++ b/bus/config-parser-common.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2007 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/config-parser-trivial.c b/bus/config-parser-trivial.c
index 9a2087cf..2325ac62 100644
--- a/bus/config-parser-trivial.c
+++ b/bus/config-parser-trivial.c
@@ -4,6 +4,8 @@
*
* Copyright (C) 2003, 2004, 2007 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -552,7 +554,6 @@ process_test_valid_subdir (const DBusString *test_base_dir,
else
_dbus_test_diag ("Testing unknown files:");
- next:
while (_dbus_directory_get_next_file (dir, &filename, &error))
{
DBusString full_path;
@@ -572,7 +573,7 @@ process_test_valid_subdir (const DBusString *test_base_dir,
_dbus_verbose ("Skipping non-.conf file %s\n",
_dbus_string_get_const_data (&filename));
_dbus_string_free (&full_path);
- goto next;
+ continue;
}
_dbus_test_diag (" %s", _dbus_string_get_const_data (&filename));
diff --git a/bus/config-parser-trivial.h b/bus/config-parser-trivial.h
index ffd7d12e..32bf21bc 100644
--- a/bus/config-parser-trivial.h
+++ b/bus/config-parser-trivial.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/config-parser.c b/bus/config-parser.c
index f9b70477..de9a1398 100644
--- a/bus/config-parser.c
+++ b/bus/config-parser.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003, 2004 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -642,10 +644,11 @@ locate_attributes (BusConfigParser *parser,
va_start (args, first_attribute_retloc);
name = va_arg (args, const char*);
- retloc = va_arg (args, const char**);
+ retloc = NULL;
while (name != NULL)
{
+ retloc = va_arg (args, const char**);
_dbus_assert (retloc != NULL);
_dbus_assert (n_attrs < MAX_ATTRS);
@@ -655,7 +658,6 @@ locate_attributes (BusConfigParser *parser,
*retloc = NULL;
name = va_arg (args, const char*);
- retloc = va_arg (args, const char**);
}
va_end (args);
@@ -3239,7 +3241,6 @@ process_test_valid_subdir (const DBusString *test_base_dir,
else
_dbus_test_diag ("Testing unknown files:");
- next:
while (_dbus_directory_get_next_file (dir, &filename, &error))
{
DBusString full_path;
@@ -3259,7 +3260,7 @@ process_test_valid_subdir (const DBusString *test_base_dir,
_dbus_verbose ("Skipping non-.conf file %s\n",
_dbus_string_get_const_data (&filename));
_dbus_string_free (&full_path);
- goto next;
+ continue;
}
_dbus_test_diag (" %s", _dbus_string_get_const_data (&filename));
@@ -3556,7 +3557,6 @@ all_are_equiv (const DBusString *target_directory)
_dbus_test_diag ("Comparing equivalent files:");
- next:
while (_dbus_directory_get_next_file (dir, &filename, &error))
{
DBusString full_path;
@@ -3575,7 +3575,7 @@ all_are_equiv (const DBusString *target_directory)
_dbus_verbose ("Skipping non-.conf file %s\n",
_dbus_string_get_const_data (&filename));
_dbus_string_free (&full_path);
- goto next;
+ continue;
}
_dbus_test_diag (" %s", _dbus_string_get_const_data (&filename));
diff --git a/bus/config-parser.h b/bus/config-parser.h
index 7f4d2f47..6c05a073 100644
--- a/bus/config-parser.h
+++ b/bus/config-parser.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/connection.c b/bus/connection.c
index add1c8b8..f0177c6f 100644
--- a/bus/connection.c
+++ b/bus/connection.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -105,7 +107,7 @@ typedef struct
BusSELinuxID *selinux_id;
BusAppArmorConfinement *apparmor_confinement;
- long connection_tv_sec; /**< Time when we connected (seconds component) */
+ dbus_int64_t connection_tv_sec; /**< Time when we connected (seconds component) */
long connection_tv_usec; /**< Time when we connected (microsec component) */
int stamp; /**< connections->stamp last time we were traversed */
BusExtraHeaders want_headers;
@@ -965,7 +967,8 @@ bus_connections_expire_incomplete (BusConnections *connections)
if (connections->incomplete != NULL)
{
- long tv_sec, tv_usec;
+ dbus_int64_t tv_sec;
+ long tv_usec;
DBusList *link;
int auth_timeout;
@@ -1079,7 +1082,7 @@ bus_connection_get_unix_groups (DBusConnection *connection,
if (dbus_connection_get_unix_user (connection, &uid))
{
- if (!_dbus_unix_groups_from_uid (uid, groups, n_groups))
+ if (!_dbus_unix_groups_from_uid (uid, groups, n_groups, error))
{
_dbus_verbose ("Did not get any groups for UID %lu\n",
uid);
@@ -1584,6 +1587,7 @@ bus_connection_complete (DBusConnection *connection,
d->policy = bus_context_create_client_policy (d->connections->context,
connection,
+ NULL,
error);
/* we may have a NULL policy on OOM or error getting list of
@@ -1660,22 +1664,27 @@ bus_connections_reload_policy (BusConnections *connections,
link;
link = _dbus_list_get_next_link (&(connections->completed), link))
{
+ BusClientPolicy *policy;
+
connection = link->data;
d = BUS_CONNECTION_DATA (connection);
_dbus_assert (d != NULL);
_dbus_assert (d->policy != NULL);
- bus_client_policy_unref (d->policy);
- d->policy = bus_context_create_client_policy (connections->context,
- connection,
- error);
- if (d->policy == NULL)
+ policy = bus_context_create_client_policy (connections->context,
+ connection,
+ d->policy,
+ error);
+ if (policy == NULL)
{
_dbus_verbose ("Failed to create security policy for connection %p\n",
connection);
_DBUS_ASSERT_ERROR_IS_SET (error);
return FALSE;
}
+
+ bus_client_policy_unref (d->policy);
+ d->policy = policy;
}
return TRUE;
@@ -2374,6 +2383,21 @@ bus_transaction_send_from_driver (BusTransaction *transaction,
if (!dbus_message_set_sender (message, DBUS_SERVICE_DBUS))
return FALSE;
+ /* Make sure the message has a non-zero serial number, otherwise
+ * bus_transaction_capture_error_reply() will not be able to mock up
+ * a corresponding reply for it. Normally this would be delayed until
+ * the first time we actually send the message out from a
+ * connection, when the transaction is committed, but that's too late
+ * in this case.
+ */
+ if (dbus_message_get_serial (message) == 0)
+ {
+ dbus_uint32_t next_serial;
+
+ next_serial = _dbus_connection_get_next_client_serial (connection);
+ dbus_message_set_serial (message, next_serial);
+ }
+
if (bus_connection_is_active (connection))
{
if (!dbus_message_set_destination (message,
diff --git a/bus/connection.h b/bus/connection.h
index a48ab46b..0ce60d11 100644
--- a/bus/connection.h
+++ b/bus/connection.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003, 2004 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/containers.c b/bus/containers.c
index 213ce3c9..816f3e1b 100644
--- a/bus/containers.c
+++ b/bus/containers.c
@@ -2,6 +2,8 @@
*
* Copyright © 2017 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -27,6 +29,8 @@
#ifdef DBUS_ENABLE_CONTAINERS
+#error This feature is not ready for production use
+
#ifndef DBUS_UNIX
# error DBUS_ENABLE_CONTAINERS requires DBUS_UNIX
#endif
@@ -412,10 +416,8 @@ bus_container_instance_new (BusContext *context,
goto fail;
}
- /* We assume PRIu64 exists on all Unix platforms: it's ISO C99, and the
- * only non-C99 platform we support is MSVC on Windows. */
if (!_dbus_string_append_printf (&path,
- "/org/freedesktop/DBus/Containers1/c%" PRIu64,
+ "/org/freedesktop/DBus/Containers1/c%" DBUS_INT64_MODIFIER "u",
containers->next_container_id++))
{
BUS_SET_OOM (error);
@@ -1204,6 +1206,7 @@ bus_containers_handle_get_connection_instance (DBusConnection *caller,
goto oom;
if (!bus_driver_fill_connection_credentials (NULL, instance->creator,
+ caller,
&arr_writer))
{
dbus_message_iter_abandon_container (&writer, &arr_writer);
@@ -1287,6 +1290,7 @@ bus_containers_handle_get_instance_info (DBusConnection *connection,
goto oom;
if (!bus_driver_fill_connection_credentials (NULL, instance->creator,
+ connection,
&arr_writer))
{
dbus_message_iter_abandon_container (&writer, &arr_writer);
diff --git a/bus/containers.h b/bus/containers.h
index 7046bcbc..842a43f4 100644
--- a/bus/containers.h
+++ b/bus/containers.h
@@ -2,6 +2,8 @@
*
* Copyright © 2017 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/dbus.service.in b/bus/dbus.service.in
index 3713810b..1921db8f 100644
--- a/bus/dbus.service.in
+++ b/bus/dbus.service.in
@@ -9,3 +9,6 @@ NotifyAccess=main
ExecStart=@EXPANDED_BINDIR@/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
ExecReload=@EXPANDED_BINDIR@/dbus-send --print-reply --system --type=method_call --dest=org.freedesktop.DBus / org.freedesktop.DBus.ReloadConfig
OOMScoreAdjust=-900
+User=@DBUS_USER@
+Group=@DBUS_USER@
+@AMBIENT_CAPS@
diff --git a/bus/desktop-file.c b/bus/desktop-file.c
index b8491146..010e20b3 100644
--- a/bus/desktop-file.c
+++ b/bus/desktop-file.c
@@ -4,6 +4,8 @@
* Copyright (C) 2003 CodeFactory AB
* Copyright (C) 2003 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/desktop-file.h b/bus/desktop-file.h
index 82c7e269..7caa3fd3 100644
--- a/bus/desktop-file.h
+++ b/bus/desktop-file.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/dir-watch-default.c b/bus/dir-watch-default.c
index c123817b..c476e496 100644
--- a/bus/dir-watch-default.c
+++ b/bus/dir-watch-default.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c
index 940f09a0..4f269777 100644
--- a/bus/dir-watch-inotify.c
+++ b/bus/dir-watch-inotify.c
@@ -4,6 +4,8 @@
* Copyright (C) 2003 Red Hat, Inc.
* (c) 2006 Mandriva
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -93,13 +95,18 @@ _handle_inotify_watch (DBusWatch *passed_watch, unsigned int flags, void *data)
#include <stdio.h>
static void
-_set_watched_dirs_internal (DBusList **directories)
+_set_watched_dirs_internal (BusContext *context,
+ DBusList **directories)
{
int new_wds[MAX_DIRS_TO_WATCH];
char *new_dirs[MAX_DIRS_TO_WATCH];
DBusList *link;
int i, j, wd;
+ /* Callers must provide a context, except during shutdown, at which
+ * point the list of directories must be empty. */
+ _dbus_assert (context != NULL || *directories == NULL);
+
for (i = 0; i < MAX_DIRS_TO_WATCH; i++)
{
new_wds[i] = -1;
@@ -108,16 +115,23 @@ _set_watched_dirs_internal (DBusList **directories)
i = 0;
link = _dbus_list_get_first_link (directories);
- while (link != NULL)
+ while (link != NULL && i < MAX_DIRS_TO_WATCH)
{
new_dirs[i++] = (char *)link->data;
link = _dbus_list_get_next_link (directories, link);
}
+ if (link != NULL && context != NULL)
+ {
+ bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
+ "Too many directories to watch them all, only watching first %d.",
+ MAX_DIRS_TO_WATCH);
+ }
+
/* Look for directories in both the old and new sets, if
* we find one, move its data into the new set.
*/
- for (i = 0; new_dirs[i]; i++)
+ for (i = 0; i < MAX_DIRS_TO_WATCH && new_dirs[i]; i++)
{
for (j = 0; j < num_wds; j++)
{
@@ -146,7 +160,7 @@ _set_watched_dirs_internal (DBusList **directories)
}
}
- for (i = 0; new_dirs[i]; i++)
+ for (i = 0; i < MAX_DIRS_TO_WATCH && new_dirs[i]; i++)
{
if (new_wds[i] == -1)
{
@@ -157,7 +171,12 @@ _set_watched_dirs_internal (DBusList **directories)
/* Not all service directories need to exist. */
if (errno != ENOENT)
{
- _dbus_warn ("Cannot setup inotify for '%s'; error '%s'", new_dirs[i], _dbus_strerror (errno));
+ /* We only have context == NULL during shutdown, at which
+ * point we are not adding directories */
+ _dbus_assert (context != NULL);
+ bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
+ "Cannot set up inotify for '%s': %s",
+ new_dirs[i], _dbus_strerror (errno));
goto out;
}
else
@@ -201,7 +220,7 @@ _shutdown_inotify (void *data)
if (inotify_fd == -1)
return;
- _set_watched_dirs_internal (&empty);
+ _set_watched_dirs_internal (NULL, &empty);
if (watch != NULL)
{
@@ -234,9 +253,11 @@ _init_inotify (BusContext *context)
#else
inotify_fd = inotify_init ();
#endif
- if (inotify_fd <= 0)
+ if (inotify_fd < 0)
{
- _dbus_warn ("Cannot initialize inotify");
+ bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
+ "Cannot initialize inotify: %s",
+ _dbus_strerror (errno));
goto out;
}
@@ -252,13 +273,15 @@ _init_inotify (BusContext *context)
if (watch == NULL)
{
- _dbus_warn ("Unable to create inotify watch");
+ bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
+ "Unable to create inotify watch");
goto out;
}
if (!_dbus_loop_add_watch (loop, watch))
{
- _dbus_warn ("Unable to add reload watch to main loop");
+ bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
+ "Unable to add reload watch to main loop");
_dbus_watch_unref (watch);
watch = NULL;
goto out;
@@ -266,7 +289,8 @@ _init_inotify (BusContext *context)
if (!_dbus_register_shutdown_func (_shutdown_inotify, NULL))
{
- _dbus_warn ("Unable to register shutdown func");
+ bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
+ "Unable to register shutdown func");
_dbus_watch_unref (watch);
watch = NULL;
goto out;
@@ -285,5 +309,5 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories)
if (!_init_inotify (context))
return;
- _set_watched_dirs_internal (directories);
+ _set_watched_dirs_internal (context, directories);
}
diff --git a/bus/dir-watch-kqueue.c b/bus/dir-watch-kqueue.c
index 183db241..07b505c9 100644
--- a/bus/dir-watch-kqueue.c
+++ b/bus/dir-watch-kqueue.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -51,7 +53,7 @@ static DBusWatch *watch = NULL;
static DBusLoop *loop = NULL;
static dbus_bool_t
-_handle_kqueue_watch (DBusWatch *watch, unsigned int flags, void *data)
+_handle_kqueue_watch (DBusWatch *_watch, unsigned int flags, void *data)
{
struct kevent ev;
struct timespec nullts = { 0, 0 };
@@ -73,6 +75,7 @@ _handle_kqueue_watch (DBusWatch *watch, unsigned int flags, void *data)
else if (res < 0 && errno == EBADF)
{
kq = -1;
+ _dbus_assert (watch == _watch);
if (watch != NULL)
{
_dbus_loop_remove_watch (loop, watch);
@@ -218,16 +221,21 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories)
i = 0;
link = _dbus_list_get_first_link (directories);
- while (link != NULL)
+ while (link != NULL && i < MAX_DIRS_TO_WATCH)
{
new_dirs[i++] = (char *)link->data;
link = _dbus_list_get_next_link (directories, link);
}
+ if (link != NULL)
+ {
+ _dbus_warn ("Too many directories to watch them all, only watching first %d.", MAX_DIRS_TO_WATCH);
+ }
+
/* Look for directories in both the old and new sets, if
* we find one, move its data into the new set.
*/
- for (i = 0; new_dirs[i]; i++)
+ for (i = 0; i < MAX_DIRS_TO_WATCH && new_dirs[i]; i++)
{
for (j = 0; j < num_fds; j++)
{
@@ -256,7 +264,7 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories)
}
}
- for (i = 0; new_dirs[i]; i++)
+ for (i = 0; i < MAX_DIRS_TO_WATCH && new_dirs[i]; i++)
{
if (new_fds[i] == -1)
{
diff --git a/bus/dir-watch.h b/bus/dir-watch.h
index 537d2d1d..c0acefaa 100644
--- a/bus/dir-watch.h
+++ b/bus/dir-watch.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/dispatch.c b/bus/dispatch.c
index c3019b1e..9bfdf795 100644
--- a/bus/dispatch.c
+++ b/bus/dispatch.c
@@ -5,6 +5,8 @@
* Copyright (C) 2003, 2004, 2005 Red Hat, Inc.
* Copyright (C) 2004 Imendio HB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -4797,25 +4799,27 @@ setenv_TEST_LAUNCH_HELPER_CONFIG(const DBusString *test_data_dir,
}
static dbus_bool_t
-bus_dispatch_test_conf (const DBusString *test_data_dir,
- const char *filename,
- dbus_bool_t use_launcher)
+bus_dispatch_test_conf (const char *test_data_dir_cstr,
+ const char *filename,
+ dbus_bool_t use_launcher)
{
BusContext *context;
DBusConnection *foo;
DBusConnection *bar;
DBusConnection *baz;
DBusError error;
+ DBusString test_data_dir;
+ _dbus_string_init_const (&test_data_dir, test_data_dir_cstr);
_dbus_test_diag ("%s:%s...", _DBUS_FUNCTION_NAME, filename);
/* save the config name for the activation helper */
- if (!setenv_TEST_LAUNCH_HELPER_CONFIG (test_data_dir, filename))
+ if (!setenv_TEST_LAUNCH_HELPER_CONFIG (&test_data_dir, filename))
_dbus_test_fatal ("no memory setting TEST_LAUNCH_HELPER_CONFIG");
dbus_error_init (&error);
- context = bus_context_new_test (test_data_dir, filename);
+ context = bus_context_new_test (&test_data_dir, filename);
if (context == NULL)
{
_dbus_test_not_ok ("%s:%s - bus_context_new_test() failed",
@@ -4972,22 +4976,24 @@ bus_dispatch_test_conf (const DBusString *test_data_dir,
#if defined(ENABLE_TRADITIONAL_ACTIVATION) && !defined(DBUS_WIN)
static dbus_bool_t
-bus_dispatch_test_conf_fail (const DBusString *test_data_dir,
- const char *filename)
+bus_dispatch_test_conf_fail (const char *test_data_dir_cstr,
+ const char *filename)
{
BusContext *context;
DBusConnection *foo;
DBusError error;
+ DBusString test_data_dir;
+ _dbus_string_init_const (&test_data_dir, test_data_dir_cstr);
_dbus_test_diag ("%s:%s...", _DBUS_FUNCTION_NAME, filename);
/* save the config name for the activation helper */
- if (!setenv_TEST_LAUNCH_HELPER_CONFIG (test_data_dir, filename))
+ if (!setenv_TEST_LAUNCH_HELPER_CONFIG (&test_data_dir, filename))
_dbus_test_fatal ("no memory setting TEST_LAUNCH_HELPER_CONFIG");
dbus_error_init (&error);
- context = bus_context_new_test (test_data_dir, filename);
+ context = bus_context_new_test (&test_data_dir, filename);
if (context == NULL)
{
_dbus_test_not_ok ("%s:%s - bus_context_new_test() failed",
@@ -5036,36 +5042,40 @@ bus_dispatch_test_conf_fail (const DBusString *test_data_dir,
}
#endif
+#ifdef ENABLE_TRADITIONAL_ACTIVATION
dbus_bool_t
-bus_dispatch_test (const char *test_data_dir_cstr)
+bus_test_normal_activation (const char *test_data_dir_cstr)
{
- DBusString test_data_dir;
-
- _dbus_string_init_const (&test_data_dir, test_data_dir_cstr);
-
-#ifdef ENABLE_TRADITIONAL_ACTIVATION
- /* run normal activation tests */
- _dbus_verbose ("Normal activation tests\n");
- if (!bus_dispatch_test_conf (&test_data_dir,
- "valid-config-files/debug-allow-all.conf", FALSE))
+ if (!bus_dispatch_test_conf (test_data_dir_cstr,
+ "valid-config-files/debug-allow-all.conf", FALSE))
return FALSE;
+ return TRUE;
+}
+
#ifndef DBUS_WIN
- /* run launch-helper activation tests */
- _dbus_verbose ("Launch helper activation tests\n");
- if (!bus_dispatch_test_conf (&test_data_dir,
- "valid-config-files-system/debug-allow-all-pass.conf", TRUE))
+dbus_bool_t
+bus_test_helper_activation (const char *test_data_dir_cstr)
+{
+ if (!bus_dispatch_test_conf (test_data_dir_cstr,
+ "valid-config-files-system/debug-allow-all-pass.conf", TRUE))
return FALSE;
+ return TRUE;
+}
+
+dbus_bool_t
+bus_test_failed_helper_activation (const char *test_data_dir_cstr)
+{
/* run select launch-helper activation tests on broken service files */
- if (!bus_dispatch_test_conf_fail (&test_data_dir,
- "valid-config-files-system/debug-allow-all-fail.conf"))
+ if (!bus_dispatch_test_conf_fail (test_data_dir_cstr,
+ "valid-config-files-system/debug-allow-all-fail.conf"))
return FALSE;
-#endif
-#endif
return TRUE;
}
+#endif /* !DBUS_WIN */
+#endif /* ENABLE_TRADITIONAL_ACTIVATION */
dbus_bool_t
bus_dispatch_sha1_test (const char *test_data_dir_cstr)
@@ -5181,9 +5191,9 @@ bus_unix_fds_passing_test (const char *test_data_dir_cstr)
DBUS_TYPE_INVALID))
_dbus_test_fatal ("Failed to attach fds.");
- if (!_dbus_close_socket (one[0], &error))
+ if (!_dbus_close_socket (&one[0], &error))
_dbus_test_fatal ("Failed to close pipe #1 ");
- if (!_dbus_close_socket (two[0], &error))
+ if (!_dbus_close_socket (&two[0], &error))
_dbus_test_fatal ("Failed to close pipe #2 ");
if (!(dbus_connection_can_send_type(foo, DBUS_TYPE_UNIX_FD)))
@@ -5250,9 +5260,9 @@ bus_unix_fds_passing_test (const char *test_data_dir_cstr)
if (read(two[1].fd, &r, 1) != 1 || r != 'Z')
_dbus_test_fatal ("Failed to read value from pipe.");
- if (!_dbus_close_socket (one[1], &error))
+ if (!_dbus_close_socket (&one[1], &error))
_dbus_test_fatal ("Failed to close pipe #1 ");
- if (!_dbus_close_socket (two[1], &error))
+ if (!_dbus_close_socket (&two[1], &error))
_dbus_test_fatal ("Failed to close pipe #2 ");
_dbus_verbose ("Disconnecting foo\n");
diff --git a/bus/dispatch.h b/bus/dispatch.h
index 32093dcb..befe4c1b 100644
--- a/bus/dispatch.h
+++ b/bus/dispatch.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/driver.c b/bus/driver.c
index 3898cfd6..7bc12f42 100644
--- a/bus/driver.c
+++ b/bus/driver.c
@@ -4,6 +4,8 @@
* Copyright (C) 2003 CodeFactory AB
* Copyright (C) 2003, 2004, 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -1409,6 +1411,7 @@ bus_driver_handle_remove_match (DBusConnection *connection,
const char *text;
DBusString str;
BusMatchmaker *matchmaker;
+ DBusList *link;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
@@ -1429,17 +1432,21 @@ bus_driver_handle_remove_match (DBusConnection *connection,
if (rule == NULL)
goto failed;
- /* Send the ack before we remove the rule, since the ack is undone
- * on transaction cancel, but rule removal isn't.
- */
- if (!bus_driver_send_ack_reply (connection, transaction, message, error))
- goto failed;
-
matchmaker = bus_connection_get_matchmaker (connection);
- if (!bus_matchmaker_remove_rule_by_value (matchmaker, rule, error))
+ /* Check whether the rule exists and prepare to remove it, but don't
+ * actually do it yet. */
+ link = bus_matchmaker_prepare_remove_rule_by_value (matchmaker, rule, error);
+ if (link == NULL)
goto failed;
+ /* We do this before actually removing the rule, because removing the
+ * rule cannot be undone if we run out of memory here. */
+ if (!bus_driver_send_ack_reply (connection, transaction, message, error))
+ goto failed;
+
+ /* The rule exists, so now we can do things we can't undo. */
+ bus_matchmaker_commit_remove_rule_by_value (matchmaker, rule, link);
bus_match_rule_unref (rule);
return TRUE;
@@ -1963,21 +1970,30 @@ bus_driver_credentials_fill_unix_gids (DBusCredentials *credentials,
*/
dbus_bool_t
bus_driver_fill_connection_credentials (DBusCredentials *credentials,
- DBusConnection *conn,
+ DBusConnection *peer_conn,
+ DBusConnection *caller_conn,
DBusMessageIter *asv_iter)
{
dbus_uid_t uid = DBUS_UID_UNSET;
dbus_pid_t pid = DBUS_PID_UNSET;
const char *windows_sid = NULL;
const char *linux_security_label = NULL;
+#ifdef DBUS_ENABLE_CONTAINERS
const char *path;
+#endif
+#ifdef HAVE_UNIX_FD_PASSING
+ int pid_fd = -1; /* owned by credentials */
+#endif
- if (credentials == NULL && conn != NULL)
- credentials = _dbus_connection_get_credentials (conn);
+ if (credentials == NULL && peer_conn != NULL)
+ credentials = _dbus_connection_get_credentials (peer_conn);
if (credentials != NULL)
{
pid = _dbus_credentials_get_pid (credentials);
+#ifdef HAVE_UNIX_FD_PASSING
+ pid_fd = _dbus_credentials_get_pid_fd (credentials);
+#endif
uid = _dbus_credentials_get_unix_uid (credentials);
windows_sid = _dbus_credentials_get_windows_sid (credentials);
linux_security_label =
@@ -2025,15 +2041,24 @@ bus_driver_fill_connection_credentials (DBusCredentials *credentials,
return FALSE;
}
+#ifdef DBUS_ENABLE_CONTAINERS
/* This has to come from the connection, not the credentials */
- if (conn != NULL &&
- bus_containers_connection_is_contained (conn, &path, NULL, NULL))
+ if (peer_conn != NULL &&
+ bus_containers_connection_is_contained (peer_conn, &path, NULL, NULL))
{
if (!_dbus_asv_add_object_path (asv_iter,
DBUS_INTERFACE_CONTAINERS1 ".Instance",
path))
return FALSE;
}
+#endif
+
+#ifdef HAVE_UNIX_FD_PASSING
+ if (caller_conn != NULL && pid_fd >= 0 &&
+ dbus_connection_can_send_type (caller_conn, DBUS_TYPE_UNIX_FD) &&
+ !_dbus_asv_add_unix_fd (asv_iter, "ProcessFD", pid_fd))
+ return FALSE;
+#endif
return TRUE;
}
@@ -2083,7 +2108,7 @@ bus_driver_handle_get_connection_credentials (DBusConnection *connection,
reply = _dbus_asv_new_method_return (message, &reply_iter, &array_iter);
if (reply == NULL ||
- !bus_driver_fill_connection_credentials (credentials, conn, &array_iter) ||
+ !bus_driver_fill_connection_credentials (credentials, conn, connection, &array_iter) ||
!_dbus_asv_close (&reply_iter, &array_iter))
goto oom;
@@ -2728,6 +2753,8 @@ static InterfaceHandler interface_handlers[] = {
" </signal>\n"
" <signal name=\"NameAcquired\">\n"
" <arg type=\"s\"/>\n"
+ " </signal>\n"
+ " <signal name=\"ActivatableServicesChanged\">\n"
" </signal>\n",
/* Not in the Interfaces property because if you can get the properties
* of the o.fd.DBus interface, then you certainly have the o.fd.DBus
@@ -3149,6 +3176,12 @@ features_getter (BusContext *context,
&arr_iter))
return FALSE;
+ s = "ActivatableServicesChanged";
+
+ if (!dbus_message_iter_append_basic (&arr_iter, DBUS_TYPE_STRING, &s))
+ goto abandon;
+
+
if (bus_apparmor_enabled ())
{
s = "AppArmor";
diff --git a/bus/driver.h b/bus/driver.h
index d9d6d20d..4365e016 100644
--- a/bus/driver.h
+++ b/bus/driver.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -56,7 +58,8 @@ dbus_bool_t bus_driver_generate_introspect_string (DBusString *xml,
dbus_bool_t canonical_path,
DBusMessage *message);
dbus_bool_t bus_driver_fill_connection_credentials (DBusCredentials *credentials,
- DBusConnection *conn,
+ DBusConnection *peer_conn,
+ DBusConnection *caller_conn,
DBusMessageIter *asv_iter);
BusDriverFound bus_driver_get_conn_helper (DBusConnection *connection,
diff --git a/bus/expirelist.c b/bus/expirelist.c
index 77dbf718..cfb85c00 100644
--- a/bus/expirelist.c
+++ b/bus/expirelist.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -123,7 +125,7 @@ bus_expire_list_recheck_immediately (BusExpireList *list)
static int
do_expiration_with_monotonic_time (BusExpireList *list,
- long tv_sec,
+ dbus_int64_t tv_sec,
long tv_usec)
{
DBusList *link;
@@ -191,7 +193,8 @@ bus_expirelist_expire (BusExpireList *list)
if (list->items != NULL)
{
- long tv_sec, tv_usec;
+ dbus_int64_t tv_sec;
+ long tv_usec;
_dbus_get_monotonic_time (&tv_sec, &tv_usec);
@@ -303,7 +306,7 @@ test_expire_func (BusExpireList *list,
}
static void
-time_add_milliseconds (long *tv_sec,
+time_add_milliseconds (dbus_int64_t *tv_sec,
long *tv_usec,
int milliseconds)
{
@@ -321,10 +324,14 @@ bus_expire_list_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
{
DBusLoop *loop;
BusExpireList *list;
- long tv_sec, tv_usec;
- long tv_sec_not_expired, tv_usec_not_expired;
- long tv_sec_expired, tv_usec_expired;
- long tv_sec_past, tv_usec_past;
+ dbus_int64_t tv_sec;
+ long tv_usec;
+ dbus_int64_t tv_sec_not_expired;
+ long tv_usec_not_expired;
+ dbus_int64_t tv_sec_expired;
+ long tv_usec_expired;
+ dbus_int64_t tv_sec_past;
+ long tv_usec_past;
TestExpireItem *item;
int next_interval;
dbus_bool_t result = FALSE;
diff --git a/bus/expirelist.h b/bus/expirelist.h
index 887cb97b..b16f138e 100644
--- a/bus/expirelist.h
+++ b/bus/expirelist.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -39,7 +41,7 @@ typedef dbus_bool_t (* BusExpireFunc) (BusExpireList *list,
/* embed this in a child expire item struct */
struct BusExpireItem
{
- long added_tv_sec; /**< Time we were added (seconds component) */
+ dbus_int64_t added_tv_sec; /**< Time we were added (seconds component) */
long added_tv_usec; /**< Time we were added (microsec component) */
};
diff --git a/bus/legacy-config/meson.build b/bus/legacy-config/meson.build
new file mode 100644
index 00000000..1e635713
--- /dev/null
+++ b/bus/legacy-config/meson.build
@@ -0,0 +1,36 @@
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+if platform_unix
+ configure_file(
+ input: 'system.conf.in',
+ output: 'system.conf',
+ configuration: data_config,
+ install_dir: get_option('sysconfdir') / 'dbus-1',
+ )
+endif
+
+configure_file(
+ input: 'session.conf.in',
+ output: 'session.conf',
+ configuration: data_config,
+ install_dir: get_option('sysconfdir') / 'dbus-1',
+)
diff --git a/bus/main.c b/bus/main.c
index 84f601b3..cf1abc64 100644
--- a/bus/main.c
+++ b/bus/main.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -48,6 +50,10 @@
static BusContext *context;
+#ifdef DBUS_WIN
+#include <dbus/dbus-sysdeps-win.h>
+#endif
+
#ifdef DBUS_UNIX
/* Despite its name and its unidirectional nature, this is actually
@@ -163,6 +169,9 @@ usage (void)
" [--syslog]"
" [--syslog-only]"
" [--nofork]"
+#ifdef DBUS_WIN
+ " [--ready-event-handle=value]"
+#endif
#ifdef DBUS_UNIX
" [--fork]"
" [--systemd-activation]"
@@ -380,11 +389,8 @@ close_reload_pipe (DBusWatch **watch)
_dbus_watch_unref (*watch);
*watch = NULL;
- _dbus_close_socket (reload_pipe[RELOAD_READ_END], NULL);
- _dbus_socket_invalidate (&reload_pipe[RELOAD_READ_END]);
-
- _dbus_close_socket (reload_pipe[RELOAD_WRITE_END], NULL);
- _dbus_socket_invalidate (&reload_pipe[RELOAD_WRITE_END]);
+ _dbus_close_socket (&reload_pipe[RELOAD_READ_END], NULL);
+ _dbus_close_socket (&reload_pipe[RELOAD_WRITE_END], NULL);
}
#endif /* DBUS_UNIX */
@@ -403,6 +409,8 @@ main (int argc, char **argv)
dbus_bool_t print_address;
dbus_bool_t print_pid;
BusContextFlags flags;
+ void *ready_event_handle;
+
#ifdef DBUS_UNIX
const char *error_str;
@@ -428,6 +436,7 @@ main (int argc, char **argv)
* to inherit fds we might have inherited from our caller. */
_dbus_fd_set_all_close_on_exec ();
#endif
+ ready_event_handle = NULL;
if (!_dbus_string_init (&config_file))
return 1;
@@ -577,16 +586,6 @@ main (int argc, char **argv)
print_address = TRUE;
}
- else if (prev_arg &&
- strcmp (prev_arg, "--print-address") == 0)
- {
- check_two_addr_descriptors (&addr_fd, "print-address");
-
- if (!_dbus_string_append (&addr_fd, arg))
- exit (1);
-
- print_address = TRUE;
- }
else if (strcmp (arg, "--print-address") == 0)
{
print_address = TRUE; /* and we'll get the next arg if appropriate */
@@ -605,6 +604,34 @@ main (int argc, char **argv)
print_pid = TRUE;
}
+ else if (strcmp (arg, "--print-pid") == 0)
+ {
+ print_pid = TRUE; /* and we'll get the next arg if appropriate */
+ }
+#ifdef DBUS_WIN
+ else if (strstr (arg, "--ready-event-handle=") == arg)
+ {
+ const char *desc;
+ desc = strchr (arg, '=');
+ _dbus_assert (desc != NULL);
+ ++desc;
+ if (sscanf (desc, "%p", &ready_event_handle) != 1)
+ {
+ fprintf (stderr, "%s specified, but invalid handle provided\n", arg);
+ exit (1);
+ }
+ }
+#endif
+ else if (prev_arg &&
+ strcmp (prev_arg, "--print-address") == 0)
+ {
+ check_two_addr_descriptors (&addr_fd, "print-address");
+
+ if (!_dbus_string_append (&addr_fd, arg))
+ exit (1);
+
+ print_address = TRUE;
+ }
else if (prev_arg &&
strcmp (prev_arg, "--print-pid") == 0)
{
@@ -615,10 +642,6 @@ main (int argc, char **argv)
print_pid = TRUE;
}
- else if (strcmp (arg, "--print-pid") == 0)
- {
- print_pid = TRUE; /* and we'll get the next arg if appropriate */
- }
else
{
usage ();
@@ -693,7 +716,7 @@ main (int argc, char **argv)
dbus_error_init (&error);
context = bus_context_new (&config_file, flags,
- &print_addr_pipe, &print_pid_pipe,
+ &print_addr_pipe, &print_pid_pipe, ready_event_handle,
_dbus_string_get_length(&address) > 0 ? &address : NULL,
&error);
_dbus_string_free (&config_file);
diff --git a/bus/meson.build b/bus/meson.build
new file mode 100644
index 00000000..058e3b25
--- /dev/null
+++ b/bus/meson.build
@@ -0,0 +1,223 @@
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+session_conf = configure_file(
+ input: 'session.conf.in',
+ output: 'session.conf',
+ configuration: data_config,
+ install_dir: get_option('datadir') / 'dbus-1',
+)
+
+if platform_unix
+ configure_file(
+ input: 'system.conf.in',
+ output: 'system.conf',
+ configuration: data_config,
+ install_dir: get_option('datadir') / 'dbus-1',
+ )
+endif
+
+configure_file(
+ input: 'example-system-enable-stats.conf.in',
+ output: 'example-system-enable-stats.conf',
+ configuration: data_config,
+ install_dir: get_option('datadir') / 'doc' / 'dbus' / 'examples',
+)
+
+configure_file(
+ input: 'example-session-disable-stats.conf.in',
+ output: 'example-session-disable-stats.conf',
+ configuration: data_config,
+ install_dir: get_option('datadir') / 'doc' / 'dbus' / 'examples',
+)
+
+install_data(
+ 'example-system-hardening-without-traditional-activation.conf',
+ install_dir: get_option('datadir') / 'doc' / 'dbus' / 'examples',
+)
+
+if use_launchd
+ configure_file(
+ input: 'org.freedesktop.dbus-session.plist.in',
+ output: 'org.freedesktop.dbus-session.plist',
+ configuration: data_config,
+ install_dir: launchd_agent_dir,
+ )
+endif
+
+if use_systemd
+ configure_file(
+ input: 'dbus.service.in',
+ output: 'dbus.service',
+ configuration: data_config,
+ install_dir: systemd_system_unitdir,
+ )
+ configure_file(
+ input: 'dbus.socket.in',
+ output: 'dbus.socket',
+ configuration: data_config,
+ install_dir: systemd_system_unitdir,
+ )
+ subdir('sysusers.d')
+ subdir('tmpfiles.d')
+
+ if enable_user_session
+ subdir('systemd-user')
+ endif
+endif
+
+subdir('legacy-config')
+
+
+libdbus_daemon_internal_sources = [
+ 'activation.c',
+ 'apparmor.c',
+ 'audit.c',
+ 'bus.c',
+ 'config-loader-expat.c',
+ 'config-parser-common.c',
+ 'config-parser.c',
+ 'connection.c',
+ 'containers.c',
+ 'desktop-file.c',
+ 'dispatch.c',
+ 'driver.c',
+ 'expirelist.c',
+ 'policy.c',
+ 'selinux.c',
+ 'services.c',
+ 'signals.c',
+ 'stats.c',
+ 'test.c',
+ 'utils.c',
+]
+
+if use_kqueue
+ libdbus_daemon_internal_sources += 'dir-watch-kqueue.c'
+elif use_inotify
+ libdbus_daemon_internal_sources += 'dir-watch-inotify.c'
+else
+ libdbus_daemon_internal_sources += 'dir-watch-default.c'
+endif
+
+libdbus_daemon_internal = static_library('dbus-daemon-internal',
+ libdbus_daemon_internal_sources,
+ include_directories: root_include,
+ dependencies: [
+ adt_libs,
+ apparmor,
+ expat,
+ network_libs,
+ selinux,
+ threads,
+ ],
+ link_with: [
+ libdbus,
+ libdbus_internal,
+ ],
+)
+
+dbus_daemon = executable('dbus-daemon',
+ 'main.c',
+ include_directories: root_include,
+ link_with: libdbus_daemon_internal,
+ install: true,
+)
+
+
+if platform_unix and use_traditional_activation
+ liblaunch_helper_internal_sources = [
+ 'config-loader-expat.c',
+ 'config-parser-common.c',
+ 'config-parser-trivial.c',
+ 'desktop-file.c',
+ 'utils.c',
+ ]
+ liblaunch_helper_internal = static_library('launch-helper-internal',
+ liblaunch_helper_internal_sources,
+ include_directories: root_include,
+ link_with: [
+ libdbus,
+ libdbus_internal,
+ ],
+ dependencies: [
+ expat,
+ network_libs,
+ threads,
+ ],
+ install: false,
+ )
+
+ dbus_daemon_launch_helper_sources = [
+ 'activation-helper.c',
+ 'activation-helper-bin.c',
+ ]
+
+ # This is the installed launch helper with the setuid checks
+ # All files that have special cases #ifdef ACTIVATION_LAUNCHER_TEST must
+ # be listed here and included in test/bus/launch-helper-for-tests.c,
+ # not in liblaunch_helper_internal.
+ dbus_daemon_launch_helper = executable('dbus-daemon-launch-helper',
+ dbus_daemon_launch_helper_sources,
+ include_directories: root_include,
+ link_with: liblaunch_helper_internal,
+ install: true,
+ install_dir: get_option('libexecdir'),
+ )
+endif
+
+install_emptydirs += [
+ get_option('datadir') / 'dbus-1' / 'session.d',
+ get_option('datadir') / 'dbus-1' / 'services',
+]
+
+if platform_unix
+ install_emptydirs += [
+ runstatedir / 'dbus',
+ get_option('datadir') / 'dbus-1' / 'system.d',
+ get_option('datadir') / 'dbus-1' / 'system-services',
+ ]
+endif
+
+if use_systemd
+ install_symlinks += [
+ {
+ 'link_name': 'dbus.service',
+ 'install_dir': systemd_system_unitdir / 'multi-user.target.wants',
+ 'pointing_to': '../dbus.service',
+ },
+ {
+ 'link_name': 'dbus.socket',
+ 'install_dir': systemd_system_unitdir / 'sockets.target.wants',
+ 'pointing_to': '../dbus.socket',
+ },
+ ]
+endif
+
+if use_systemd and get_option('user_session')
+ install_symlinks += [
+ {
+ 'link_name': 'dbus.socket',
+ 'install_dir': systemd_user_unitdir / 'sockets.target.wants',
+ 'pointing_to': '../dbus.socket',
+ },
+ ]
+endif
diff --git a/bus/policy.c b/bus/policy.c
index 74cb41bd..6ef26a29 100644
--- a/bus/policy.c
+++ b/bus/policy.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003, 2004 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -450,7 +452,7 @@ bus_policy_allow_unix_user (BusPolicy *policy,
int n_group_ids;
/* On OOM or error we always reject the user */
- if (!_dbus_unix_groups_from_uid (uid, &group_ids, &n_group_ids))
+ if (!_dbus_unix_groups_from_uid (uid, &group_ids, &n_group_ids, NULL))
{
_dbus_verbose ("Did not get any groups for UID %lu\n",
uid);
diff --git a/bus/policy.h b/bus/policy.h
index df59d090..482f5fe4 100644
--- a/bus/policy.h
+++ b/bus/policy.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/selinux.c b/bus/selinux.c
index 42017e7a..16665f45 100644
--- a/bus/selinux.c
+++ b/bus/selinux.c
@@ -3,6 +3,8 @@
*
* Author: Matthew Rickard <mjricka@epoch.ncsc.mil>
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -112,9 +114,6 @@ log_callback (int type, const char *fmt, ...)
* syslog if OOM, like the equivalent AppArmor code does. */
char buf[PATH_MAX*2];
- /* FIXME: need to change this to show real user */
- vsnprintf(buf, sizeof(buf), fmt, ap);
-
switch (type)
{
case SELINUX_AVC:
@@ -137,6 +136,8 @@ log_callback (int type, const char *fmt, ...)
}
if (audit_type > 0) {
+ /* FIXME: need to change this to show real user */
+ vsnprintf(buf, sizeof(buf), fmt, ap);
audit_log_user_avc_message(audit_fd, audit_type, buf, NULL, NULL,
NULL, getuid());
goto out;
diff --git a/bus/selinux.h b/bus/selinux.h
index 471f2629..22d63caf 100644
--- a/bus/selinux.h
+++ b/bus/selinux.h
@@ -2,6 +2,8 @@
*
* Author: Matthew Rickard <mjricka@epoch.ncsc.mil>
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/services.c b/bus/services.c
index 6f642a43..8a2bb61a 100644
--- a/bus/services.c
+++ b/bus/services.c
@@ -4,6 +4,8 @@
* Copyright (C) 2003 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -1082,6 +1084,7 @@ bus_service_swap_owner (BusService *service,
_dbus_assert (link != NULL);
link = _dbus_list_get_next_link (&service->owners, link);
_dbus_assert (link != NULL);
+ _dbus_assert (link->data != NULL);
new_owner = (BusOwner *)link->data;
new_owner_conn = new_owner->conn;
@@ -1147,6 +1150,10 @@ bus_service_remove_owner (BusService *service,
BusOwner *temp_owner;
link = _bus_service_find_owner_link (service, connection);
+ /* This function is only valid to call if connection owns service.
+ * If that's the case, we should always find connection in the
+ * list of owners. */
+ _dbus_assert (link != NULL);
_dbus_list_unlink (&service->owners, link);
temp_owner = (BusOwner *)link->data;
bus_owner_unref (temp_owner);
@@ -1176,6 +1183,7 @@ bus_service_remove_owner (BusService *service,
_dbus_assert (link != NULL);
link = _dbus_list_get_next_link (&service->owners, link);
_dbus_assert (link != NULL);
+ _dbus_assert (link->data != NULL);
new_owner = (BusOwner *)link->data;
new_owner_conn = new_owner->conn;
diff --git a/bus/services.h b/bus/services.h
index 962db904..0a56b851 100644
--- a/bus/services.h
+++ b/bus/services.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/session.conf.in b/bus/session.conf.in
index ace073c9..affa7f1d 100644
--- a/bus/session.conf.in
+++ b/bus/session.conf.in
@@ -76,11 +76,5 @@
<limit name="max_names_per_connection">50000</limit>
<limit name="max_match_rules_per_connection">50000</limit>
<limit name="max_replies_per_connection">50000</limit>
- <limit name="max_containers">10000</limit>
- <limit name="max_containers_per_user">10000</limit>
- <limit name="max_container_metadata_bytes">1000000000</limit>
- <!-- This is relatively low so that app-containers (which we do not fully
- trust) do not cause DoS. -->
- <limit name="max_connections_per_container">16</limit>
</busconfig>
diff --git a/bus/signals.c b/bus/signals.c
index 08304c5b..10230b3a 100644
--- a/bus/signals.c
+++ b/bus/signals.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003, 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -122,7 +124,7 @@ bus_match_rule_unref (BusMatchRule *rule)
}
}
-#if defined(DBUS_ENABLE_VERBOSE_MODE) || defined(DBUS_ENABLE_STATS)
+#if defined(DBUS_ENABLE_VERBOSE_MODE) || defined(DBUS_ENABLE_STATS) || defined(DBUS_ENABLE_EMBEDDED_TESTS)
static dbus_bool_t
append_key_and_escaped_value (DBusString *str, const char *token, const char *value)
{
@@ -312,7 +314,7 @@ match_rule_to_string (BusMatchRule *rule)
_dbus_string_free (&str);
return NULL;
}
-#endif /* defined(DBUS_ENABLE_VERBOSE_MODE) || defined(DBUS_ENABLE_STATS) */
+#endif /* defined(DBUS_ENABLE_VERBOSE_MODE) || defined(DBUS_ENABLE_STATS) || defined(DBUS_ENABLE_EMBEDDED_TESTS) */
dbus_bool_t
bus_match_rule_set_message_type (BusMatchRule *rule,
@@ -1608,21 +1610,32 @@ bus_matchmaker_remove_rule (BusMatchmaker *matchmaker,
bus_match_rule_unref (rule);
}
-/* Remove a single rule which is equal to the given rule by value */
-dbus_bool_t
-bus_matchmaker_remove_rule_by_value (BusMatchmaker *matchmaker,
- BusMatchRule *value,
- DBusError *error)
+/*
+ * Prepare to remove the the most-recently-added rule which is equal to
+ * the given rule by value, but do not actually do it yet.
+ *
+ * Return a linked-list link which must be treated as opaque by the caller:
+ * the only valid thing to do with it is to pass it to
+ * bus_matchmaker_commit_remove_rule_by_value().
+ *
+ * The returned linked-list link becomes invalid when control returns to
+ * the main loop. If the caller decides not to remove the rule after all,
+ * there is currently no need to cancel explicitly.
+ */
+DBusList *
+bus_matchmaker_prepare_remove_rule_by_value (BusMatchmaker *matchmaker,
+ BusMatchRule *value,
+ DBusError *error)
{
DBusList **rules;
DBusList *link = NULL;
- _dbus_verbose ("Removing rule by value with message_type %d, interface %s\n",
+ _dbus_verbose ("Finding rule by value with message_type %d, interface %s\n",
value->message_type,
value->interface != NULL ? value->interface : "<null>");
rules = bus_matchmaker_get_rules (matchmaker, value->message_type,
- value->interface, FALSE);
+ value->interface, FALSE);
if (rules != NULL)
{
@@ -1639,26 +1652,37 @@ bus_matchmaker_remove_rule_by_value (BusMatchmaker *matchmaker,
prev = _dbus_list_get_prev_link (rules, link);
if (match_rule_equal (rule, value))
- {
- bus_matchmaker_remove_rule_link (rules, link);
- break;
- }
+ return link;
link = prev;
}
}
- if (link == NULL)
- {
- dbus_set_error (error, DBUS_ERROR_MATCH_RULE_NOT_FOUND,
- "The given match rule wasn't found and can't be removed");
- return FALSE;
- }
+ dbus_set_error (error, DBUS_ERROR_MATCH_RULE_NOT_FOUND,
+ "The given match rule wasn't found and can't be removed");
+ return NULL;
+}
+
+/*
+ * Commit a previous call to bus_matchmaker_prepare_remove_rule_by_value(),
+ * which must have been done during the same main-loop iteration.
+ */
+void
+bus_matchmaker_commit_remove_rule_by_value (BusMatchmaker *matchmaker,
+ BusMatchRule *value,
+ DBusList *link)
+{
+ DBusList **rules;
+ _dbus_assert (match_rule_equal (link->data, value));
+ rules = bus_matchmaker_get_rules (matchmaker, value->message_type,
+ value->interface, FALSE);
+ /* Should only be called if a rule matching value was successfully
+ * added, which means rules must contain at least link */
+ _dbus_assert (rules != NULL);
+ bus_matchmaker_remove_rule_link (rules, link);
bus_matchmaker_gc_rules (matchmaker, value->message_type, value->interface,
rules);
-
- return TRUE;
}
static void
diff --git a/bus/signals.h b/bus/signals.h
index 0edfb07e..fd90d81c 100644
--- a/bus/signals.h
+++ b/bus/signals.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -91,9 +93,6 @@ void bus_matchmaker_unref (BusMatchmaker *matchmaker);
dbus_bool_t bus_matchmaker_add_rule (BusMatchmaker *matchmaker,
BusMatchRule *rule);
-dbus_bool_t bus_matchmaker_remove_rule_by_value (BusMatchmaker *matchmaker,
- BusMatchRule *value,
- DBusError *error);
void bus_matchmaker_remove_rule (BusMatchmaker *matchmaker,
BusMatchRule *rule);
void bus_matchmaker_disconnected (BusMatchmaker *matchmaker,
@@ -105,4 +104,11 @@ dbus_bool_t bus_matchmaker_get_recipients (BusMatchmaker *matchmaker,
DBusMessage *message,
DBusList **recipients_p);
+DBusList *bus_matchmaker_prepare_remove_rule_by_value (BusMatchmaker *matchmaker,
+ BusMatchRule *value,
+ DBusError *error);
+void bus_matchmaker_commit_remove_rule_by_value (BusMatchmaker *matchmaker,
+ BusMatchRule *value,
+ DBusList *link);
+
#endif /* BUS_SIGNALS_H */
diff --git a/bus/stats.c b/bus/stats.c
index 15822556..dacbd186 100644
--- a/bus/stats.c
+++ b/bus/stats.c
@@ -3,6 +3,8 @@
* Copyright © 2011-2012 Nokia Corporation
* Copyright © 2012-2013 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/stats.h b/bus/stats.h
index dcb022c4..23b05430 100644
--- a/bus/stats.h
+++ b/bus/stats.h
@@ -1,5 +1,9 @@
/* stats.h - statistics from the bus driver
*
+ * Copyright 2011 Nokia Corporation
+ * Copyright 2014 Collabora Ltd.
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/system.conf.in b/bus/system.conf.in
index 7c79a1ae..d2f3244b 100644
--- a/bus/system.conf.in
+++ b/bus/system.conf.in
@@ -126,10 +126,6 @@
<!-- <limit name="max_names_per_connection">512</limit> -->
<!-- <limit name="max_match_rules_per_connection">512</limit> -->
<!-- <limit name="max_replies_per_connection">128</limit> -->
- <!-- <limit name="max_containers">512</limit> -->
- <!-- <limit name="max_containers_per_user">16</limit> -->
- <!-- <limit name="max_container_metadata_bytes">4096</limit> -->
- <!-- <limit name="max_connections_per_container">8</limit> -->
<!-- Config files are placed here that among other things, punch
holes in the above policy for specific services. -->
diff --git a/bus/systemd-user/dbus.service.in b/bus/systemd-user/dbus.service.in
index b291b923..cafcc5c1 100644
--- a/bus/systemd-user/dbus.service.in
+++ b/bus/systemd-user/dbus.service.in
@@ -8,3 +8,4 @@ Type=notify
NotifyAccess=main
ExecStart=@EXPANDED_BINDIR@/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
ExecReload=@EXPANDED_BINDIR@/dbus-send --print-reply --session --type=method_call --dest=org.freedesktop.DBus / org.freedesktop.DBus.ReloadConfig
+Slice=session.slice
diff --git a/bus/systemd-user/meson.build b/bus/systemd-user/meson.build
new file mode 100644
index 00000000..1f95c4ee
--- /dev/null
+++ b/bus/systemd-user/meson.build
@@ -0,0 +1,34 @@
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+configure_file(
+ input: 'dbus.service.in',
+ output: 'dbus.service',
+ configuration: data_config,
+ install_dir: systemd_user_unitdir,
+)
+
+configure_file(
+ input: 'dbus.socket.in',
+ output: 'dbus.socket',
+ configuration: data_config,
+ install_dir: systemd_user_unitdir,
+)
diff --git a/bus/sysusers.d/meson.build b/bus/sysusers.d/meson.build
new file mode 100644
index 00000000..1e03896c
--- /dev/null
+++ b/bus/sysusers.d/meson.build
@@ -0,0 +1,27 @@
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+configure_file(
+ input: 'dbus.conf.in',
+ output: 'dbus.conf',
+ configuration: data_config,
+ install_dir: get_option('prefix') / 'lib' / 'sysusers.d',
+)
diff --git a/bus/test.c b/bus/test.c
index 42651e77..6c9e62c1 100644
--- a/bus/test.c
+++ b/bus/test.c
@@ -5,6 +5,8 @@
* Copyright 2011 Collabora Ltd.
* Copyright 2018 Laurent Bigonville
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -296,7 +298,7 @@ bus_context_new_test (const DBusString *test_data_dir,
}
dbus_error_init (&error);
- context = bus_context_new (&config_file, BUS_CONTEXT_FLAG_NONE, NULL, NULL, NULL, &error);
+ context = bus_context_new (&config_file, BUS_CONTEXT_FLAG_NONE, NULL, NULL, NULL, NULL, &error);
if (context == NULL)
{
_DBUS_ASSERT_ERROR_IS_SET (&error);
diff --git a/bus/test.h b/bus/test.h
index 6f1f6b0d..3a4fab47 100644
--- a/bus/test.h
+++ b/bus/test.h
@@ -6,6 +6,8 @@
* Copyright 2009 Lennart Poettering
* Copyright 2018 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -36,7 +38,9 @@
typedef dbus_bool_t (* BusConnectionForeachFunction) (DBusConnection *connection,
void *data);
-dbus_bool_t bus_dispatch_test (const char *test_data_dir_cstr);
+dbus_bool_t bus_test_normal_activation (const char *test_data_dir_cstr);
+dbus_bool_t bus_test_helper_activation (const char *test_data_dir_cstr);
+dbus_bool_t bus_test_failed_helper_activation (const char *test_data_dir_cstr);
dbus_bool_t bus_dispatch_sha1_test (const char *test_data_dir_cstr);
dbus_bool_t bus_config_parser_test (const char *test_data_dir_cstr);
dbus_bool_t bus_config_parser_trivial_test (const char *test_data_dir_cstr);
diff --git a/bus/tmpfiles.d/meson.build b/bus/tmpfiles.d/meson.build
new file mode 100644
index 00000000..f866879c
--- /dev/null
+++ b/bus/tmpfiles.d/meson.build
@@ -0,0 +1,27 @@
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+configure_file(
+ input: 'dbus.conf.in',
+ output: 'dbus.conf',
+ configuration: data_config,
+ install_dir: get_option('prefix') / 'lib' / 'tmpfiles.d',
+)
diff --git a/bus/utils.c b/bus/utils.c
index 1972b756..922c8e0f 100644
--- a/bus/utils.c
+++ b/bus/utils.c
@@ -4,6 +4,8 @@
* Copyright (C) 2003 CodeFactory AB
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/bus/utils.h b/bus/utils.h
index 30d7e0f8..5657e4f4 100644
--- a/bus/utils.h
+++ b/bus/utils.h
@@ -4,6 +4,8 @@
* Copyright (C) 2003 CodeFactory AB
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake
index 7bc789f0..b7f37020 100644
--- a/cmake/ConfigureChecks.cmake
+++ b/cmake/ConfigureChecks.cmake
@@ -6,69 +6,88 @@ include(CheckTypeSize)
include(CheckCSourceCompiles)
include(CheckCSourceRuns)
+set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
+
+# keep in sync with check_headers in meson.build
+check_include_files("winsock2.h;afunix.h" HAVE_AFUNIX_H)
check_include_file(alloca.h HAVE_ALLOCA_H)
check_include_file(byteswap.h HAVE_BYTESWAP_H)
check_include_file(crt/externs.h HAVE_CRT_EXTERNS_H)
check_include_file(dirent.h HAVE_DIRENT_H) # dbus-sysdeps-util.c
-check_include_file(dlfcn.h HAVE_DLFCN_H)
-check_include_file(execinfo.h HAVE_EXECINFO_H)
check_include_file(errno.h HAVE_ERRNO_H) # dbus-sysdeps.c
-check_include_file(expat.h HAVE_EXPAT_H)
-check_include_file(grp.h HAVE_GRP_H) # dbus-sysdeps-util-win.c
check_include_file(inttypes.h HAVE_INTTYPES_H) # dbus-pipe.h
check_include_file(io.h HAVE_IO_H) # internal
+check_include_file(linux/close_range.h HAVE_LINUX_CLOSE_RANGE_H)
+check_include_file(linux/magic.h HAVE_LINUX_MAGIC_H)
check_include_file(locale.h HAVE_LOCALE_H)
-check_include_file(memory.h HAVE_MEMORY_H)
check_include_file(signal.h HAVE_SIGNAL_H)
-check_include_file(stdint.h HAVE_STDINT_H) # dbus-pipe.h
-check_include_file(stdlib.h HAVE_STDLIB_H)
+check_include_file(stdatomic.h HAVE_STDATOMIC_H)
check_include_file(stdio.h HAVE_STDIO_H) # dbus-sysdeps.h
-check_include_file(string.h HAVE_STRING_H)
-check_include_file(strings.h HAVE_STRINGS_H)
-check_include_file(syslog.h HAVE_SYSLOG_H)
check_include_files("stdint.h;sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
check_include_file(sys/inotify.h HAVE_SYS_INOTIFY_H)
+check_include_file(sys/inotify.h DBUS_BUS_ENABLE_INOTIFY)
+check_include_file(sys/prctl.h HAVE_SYS_PRCTL_H)
check_include_file(sys/random.h HAVE_SYS_RANDOM_H)
check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H)
-check_include_file(sys/stat.h HAVE_SYS_STAT_H)
-check_include_file(sys/types.h HAVE_SYS_TYPES_H)
-check_include_file(sys/uio.h HAVE_SYS_UIO_H)
-check_include_file(sys/prctl.h HAVE_SYS_PRCTL_H)
-check_include_file(sys/syslimits.h HAVE_SYS_SYSLIMITS_H) # dbus-sysdeps-unix.c
+check_include_file(sys/syscall.h HAVE_SYS_SYSCALL_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)# dbus-sysdeps-win.c
-check_include_file(sys/wait.h HAVE_SYS_WAIT_H)# dbus-sysdeps-win.c
-check_include_file(time.h HAVE_TIME_H) # dbus-sysdeps-win.c
-check_include_file(ws2tcpip.h HAVE_WS2TCPIP_H)# dbus-sysdeps-win.c
+check_include_file(sys/vfs.h HAVE_SYS_VFS_H)
+check_include_file(syslog.h HAVE_SYSLOG_H)
check_include_file(unistd.h HAVE_UNISTD_H) # dbus-sysdeps-util-win.c
-check_include_file(sys/inotify.h DBUS_BUS_ENABLE_INOTIFY)
+check_include_file(ws2tcpip.h HAVE_WS2TCPIP_H)# dbus-sysdeps-win.c
-check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE) # dbus-sysdeps.c, dbus-sysdeps-win.c
+find_package(Backtrace) # dbus-sysdeps.c, dbus-sysdeps-win.c
+set(HAVE_BACKTRACE ${Backtrace_FOUND})
+
+# keep in sync with check_functions in meson.build
+check_symbol_exists(LOG_PERROR "syslog.h" HAVE_DECL_LOG_PERROR)
+check_symbol_exists(MSG_NOSIGNAL "sys/socket.h" HAVE_DECL_MSG_NOSIGNAL)
+check_symbol_exists(SCM_RIGHTS "sys/types.h;sys/socket.h;sys/un.h" HAVE_UNIX_FD_PASSING)
+check_symbol_exists(SYS_pidfd_open "sys/syscall.h" HAVE_DECL_SYS_PIDFD_OPEN) # dbus-sysdeps-unix.c
+check_symbol_exists(accept4 "sys/socket.h" HAVE_ACCEPT4)
+check_symbol_exists(clearenv "stdlib.h" HAVE_CLEARENV) # dbus-sysdeps.c
+check_symbol_exists(close_range "unistd.h" HAVE_CLOSE_RANGE) # dbus-sysdeps-unix.c
+check_symbol_exists(closefrom "unistd.h" HAVE_CLOSEFROM) # dbus-sysdeps-unix.c
+check_symbol_exists(environ "unistd.h" HAVE_DECL_ENVIRON)
+check_symbol_exists(fstatfs "sys/vfs.h" HAVE_FSTATFS)
check_symbol_exists(getgrouplist "grp.h" HAVE_GETGROUPLIST) # dbus-sysdeps.c
check_symbol_exists(getpeerucred "ucred.h" HAVE_GETPEERUCRED) # dbus-sysdeps.c, dbus-sysdeps-win.c
-check_symbol_exists(nanosleep "time.h" HAVE_NANOSLEEP) # dbus-sysdeps.c
check_symbol_exists(getpwnam_r "errno.h;pwd.h" HAVE_GETPWNAM_R) # dbus-sysdeps-util-unix.c
-check_symbol_exists(setenv "stdlib.h" HAVE_SETENV) # dbus-sysdeps.c
-check_symbol_exists(unsetenv "stdlib.h" HAVE_UNSETENV) # dbus-sysdeps.c
-check_symbol_exists(clearenv "stdlib.h" HAVE_CLEARENV) # dbus-sysdeps.c
-check_symbol_exists(writev "sys/uio.h" HAVE_WRITEV) # dbus-sysdeps.c, dbus-sysdeps-win.c
-check_symbol_exists(setrlimit "sys/resource.h" HAVE_SETRLIMIT) # dbus-sysdeps.c, dbus-sysdeps-win.c, test/test-segfault.c
-check_symbol_exists(socketpair "sys/socket.h" HAVE_SOCKETPAIR) # dbus-sysdeps.c
-check_symbol_exists(setlocale "locale.h" HAVE_SETLOCALE) # dbus-test-main.c
+check_symbol_exists(getrandom "sys/random.h" HAVE_GETRANDOM)
+check_symbol_exists(getresuid "unistd.h" HAVE_GETRESUID)
+check_symbol_exists(getrlimit "sys/resource.h;sys/time.h" HAVE_GETRLIMIT)
+check_symbol_exists(inotify_init1 "sys/inotify.h" HAVE_INOTIFY_INIT1)
check_symbol_exists(localeconv "locale.h" HAVE_LOCALECONV) # dbus-sysdeps.c
-check_symbol_exists(poll "poll.h" HAVE_POLL) # dbus-sysdeps-unix.c
-check_symbol_exists(strtoll "stdlib.h" HAVE_STRTOLL) # dbus-send.c
-check_symbol_exists(strtoull "stdlib.h" HAVE_STRTOULL) # dbus-send.c
-set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
+check_symbol_exists(nanosleep "time.h" HAVE_NANOSLEEP) # dbus-sysdeps.c
check_symbol_exists(pipe2 "fcntl.h;unistd.h" HAVE_PIPE2)
-check_symbol_exists(accept4 "sys/socket.h" HAVE_ACCEPT4)
-check_symbol_exists(inotify_init1 "sys/inotify.h" HAVE_INOTIFY_INIT1)
-check_symbol_exists(SCM_RIGHTS "sys/types.h;sys/socket.h;sys/un.h" HAVE_UNIX_FD_PASSING)
+check_symbol_exists(poll "poll.h" HAVE_POLL) # dbus-sysdeps-unix.c
check_symbol_exists(prctl "sys/prctl.h" HAVE_PRCTL)
-check_symbol_exists(raise "signal.h" HAVE_RAISE)
-check_symbol_exists(getrandom "sys/random.h" HAVE_GETRANDOM)
-check_symbol_exists(getrlimit "sys/resource.h;sys/time.h" HAVE_GETRLIMIT)
check_symbol_exists(prlimit "sys/resource.h;sys/time.h" HAVE_PRLIMIT)
+check_symbol_exists(raise "signal.h" HAVE_RAISE)
+check_symbol_exists(setenv "stdlib.h" HAVE_SETENV) # dbus-sysdeps.c
+check_symbol_exists(setlocale "locale.h" HAVE_SETLOCALE) # dbus-test-main.c
+check_symbol_exists(setresuid "unistd.h" HAVE_SETRESUID)
+check_symbol_exists(setrlimit "sys/resource.h" HAVE_SETRLIMIT) # dbus-sysdeps.c, dbus-sysdeps-win.c, test/test-segfault.c
check_symbol_exists(setrlimit "sys/resource.h;sys/time.h" HAVE_SETRLIMIT)
+check_symbol_exists(socketpair "sys/socket.h" HAVE_SOCKETPAIR) # dbus-sysdeps.c
+check_symbol_exists(unsetenv "stdlib.h" HAVE_UNSETENV) # dbus-sysdeps.c
+check_symbol_exists(writev "sys/uio.h" HAVE_WRITEV) # dbus-sysdeps.c, dbus-sysdeps-win.c
+
+# It doesn't really matter which specific header we use for these, as long as
+# we include at least one glibc-provided header. time.h is suitable.
+check_symbol_exists(__GLIBC__ "time.h" HAVE___GLIBC__)
+check_symbol_exists(_FILE_OFFSET_BITS "time.h" HAVE__FILE_OFFSET_BITS)
+check_symbol_exists(_TIME_BITS "time.h" HAVE__TIME_BITS)
+
+# Opt-in to large inode number and timestamp support, which we know doesn't
+# break libdbus ABI: https://gitlab.freedesktop.org/dbus/dbus/-/issues/465
+if(HAVE___GLIBC__ AND CMAKE_SIZEOF_VOID_P EQUAL 4 AND NOT HAVE__FILE_OFFSET_BITS)
+ set(_FILE_OFFSET_BITS 64)
+endif()
+
+if(HAVE___GLIBC__ AND CMAKE_SIZEOF_VOID_P EQUAL 4 AND NOT HAVE__TIME_BITS)
+ set(_TIME_BITS 64)
+endif()
check_struct_member(cmsgcred cmcred_pid "sys/types.h;sys/socket.h" HAVE_CMSGCRED) # dbus-sysdeps.c
@@ -82,83 +101,14 @@ epoll_create1 (EPOLL_CLOEXEC);
}" DBUS_HAVE_LINUX_EPOLL)
CHECK_C_SOURCE_COMPILES("
-#include <stdarg.h>
-#include <stdlib.h>
-static void f (int i, ...) {
- va_list args1, args2;
- va_start (args1, i);
- va_copy (args2, args1);
- if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
- exit (1);
- va_end (args1); va_end (args2);
-}
-int main() {
- f (0, 42);
- return 0;
-}
-" HAVE_VA_COPY)
-
-CHECK_C_SOURCE_COMPILES("
-#include <stdarg.h>
-#include <stdlib.h>
-static void f (int i, ...) {
- va_list args1, args2;
- va_start (args1, i);
- __va_copy (args2, args1);
- if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
- exit (1);
- va_end (args1); va_end (args2);
-}
-int main() {
- f (0, 42);
- return 0;
-}
-" HAVE___VA_COPY)
-
-if(HAVE_VA_COPY)
- set(DBUS_VA_COPY va_copy CACHE STRING "va_copy function")
-elseif(HAVE___VA_COPY)
- set(DBUS_VA_COPY __va_copy CACHE STRING "va_copy function")
-elseif(MSVC)
- # this is used for msvc < 2013
- set(DBUS_VA_COPY _DBUS_VA_COPY_ASSIGN)
-else()
- message(FATAL_ERROR "dbus requires an ISO C99-compatible va_copy() macro, or a similar __va_copy(), or MSVC >= 2010")
-endif()
-
-CHECK_C_SOURCE_COMPILES("
int main() {
int a = 4;
int b = __sync_sub_and_fetch(&a, 4);
- exit(b);
+ return b;
}
" DBUS_USE_SYNC)
-CHECK_C_SOURCE_COMPILES("
-#include <sys/types.h>
-#include <dirent.h>
-int main(
- DIR *dirp;
- dirp = opendir(\".\");
- dirfd(dirp);
- closedir(dirp);
-)
-" HAVE_DIRFD)
-
-if(NOT HAVE_DIRFD)
- CHECK_C_SOURCE_COMPILES("
- #include <sys/types.h>
- #include <dirent.h>
- int main()
- {
- DIR *dirp;
- int fd;
- dirp = opendir(\".\");
- fd = dirp->dd_fd;
- closedir(dirp);
- }
- " HAVE_DDFD)
-endif()
+set(DBUS_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
check_type_size("short" SIZEOF_SHORT)
check_type_size("int" SIZEOF_INT)
@@ -166,7 +116,7 @@ check_type_size("long" SIZEOF_LONG)
check_type_size("long long" SIZEOF_LONG_LONG)
check_type_size("__int64" SIZEOF___INT64)
set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h")
-check_type_size("socklen_t" SOCKLEN_T) # define HAVE_SOCKLEN_T and SOCKLEN_T for size
+check_type_size("socklen_t" HAVE_SOCKLEN_T) # dbus-sysdeps-unix.c
set(CMAKE_EXTRA_INCLUDE_FILES)
# DBUS_INT64_TYPE
@@ -174,22 +124,31 @@ if(SIZEOF_INT EQUAL 8)
set(DBUS_INT64_TYPE "int")
set(DBUS_INT64_CONSTANT "(val)")
set(DBUS_UINT64_CONSTANT "(val##U)")
+ set(DBUS_INT64_MODIFIER "")
elseif(SIZEOF_LONG EQUAL 8)
set(DBUS_INT64_TYPE "long")
set(DBUS_INT64_CONSTANT "(val##L)")
set(DBUS_UINT64_CONSTANT "(val##UL)")
+ set(DBUS_INT64_MODIFIER "l")
elseif(SIZEOF_LONG_LONG EQUAL 8)
set(DBUS_INT64_TYPE "long long")
set(DBUS_INT64_CONSTANT "(val##LL)")
set(DBUS_UINT64_CONSTANT "(val##ULL)")
+ set(DBUS_INT64_MODIFIER "ll")
elseif(SIZEOF___INT64 EQUAL 8)
set(DBUS_INT64_TYPE "__int64")
set(DBUS_INT64_CONSTANT "(val##i64)")
set(DBUS_UINT64_CONSTANT "(val##ui64)")
+ set(DBUS_INT64_MODIFIER "I64")
else(SIZEOF_INT EQUAL 8)
message(FATAL_ERROR "Could not find a 64-bit integer type")
endif()
+# MSVCRT.dll printf() doesn't support %lld
+if(WIN32 AND NOT CYGWIN)
+ set(DBUS_INT64_MODIFIER "I64")
+endif()
+
# DBUS_INT32_TYPE
if(SIZEOF_INT EQUAL 4)
set(DBUS_INT32_TYPE "int")
diff --git a/cmake/DBus1Config.cmake.in b/cmake/DBus1Config.cmake.in
index c389d5ea..1775b939 100644
--- a/cmake/DBus1Config.cmake.in
+++ b/cmake/DBus1Config.cmake.in
@@ -26,12 +26,9 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/DBus1Targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/DBus1Targets.cmake")
endif()
- set(DBus1_INCLUDE_DIRS "${DBus1_INSTALL_DIR}/@CMAKE_INSTALL_INCLUDEDIR@/dbus-1.0" "${DBus1_INSTALL_DIR}/@CMAKE_INSTALL_LIBDIR@/dbus-1.0/include")
set(DBus1_DEFINITIONS)
- set(DBus1_LIBRARIES dbus-1)
-
- set_property(TARGET dbus-1 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${DBus1_INCLUDE_DIRS})
- set_property(TARGET dbus-1 PROPERTY INTERFACE_COMPILE_DEFINITIONS ${DBus1_DEFINITIONS})
+ get_target_property(DBus1_INCLUDE_DIRS dbus-1 INTERFACE_INCLUDE_DIRECTORIES)
+ set(DBus1_LIBRARY dbus-1)
else()
message(FATAL_ERROR "Incomplete cmake support in DBus1 find_package configuration")
endif()
diff --git a/cmake/DBus1Config.pkgconfig.in b/cmake/DBus1Config.pkgconfig.in
index 8c0a25e4..0f021850 100644
--- a/cmake/DBus1Config.pkgconfig.in
+++ b/cmake/DBus1Config.pkgconfig.in
@@ -9,6 +9,7 @@
# to a target with target_link_libraries
get_filename_component(DBus1_PKGCONFIG_DIR "${CMAKE_CURRENT_LIST_DIR}/../../pkgconfig" ABSOLUTE)
+get_filename_component(DBus1_NEARBY_ARCH_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../dbus-1.0/include" ABSOLUTE)
find_package(PkgConfig)
if(DEFINED ENV{PKG_CONFIG_DIR})
set(_dbus_pkgconfig_dir "$ENV{PKG_CONFIG_DIR}")
@@ -51,6 +52,9 @@ find_path(DBus1_INCLUDE_DIR dbus/dbus.h
HINTS ${PC_DBUS1_INCLUDEDIR} ${PC_DBUS1_INCLUDE_DIRS}
PATH_SUFFIXES dbus-1.0)
find_path(DBus1_ARCH_INCLUDE_DIR dbus/dbus-arch-deps.h
+ PATHS ${DBus1_NEARBY_ARCH_INCLUDE_DIR}
+ NO_DEFAULT_PATH)
+find_path(DBus1_ARCH_INCLUDE_DIR dbus/dbus-arch-deps.h
HINTS ${PC_DBUS1_INCLUDE_DIRS}
PATH_SUFFIXES dbus-1.0)
find_library(DBus1_LIBRARY NAMES ${PC_DBUS1_LIBRARIES}
@@ -71,5 +75,6 @@ set(DBus1_INCLUDE_DIRS "${DBus1_INCLUDE_DIR}" "${DBus1_ARCH_INCLUDE_DIR}")
# setup imported target
add_library(dbus-1 SHARED IMPORTED)
set_property(TARGET dbus-1 APPEND PROPERTY IMPORTED_LOCATION ${DBus1_LIBRARY})
+set_property(TARGET dbus-1 APPEND PROPERTY IMPORTED_IMPLIB ${DBus1_LIBRARY})
set_property(TARGET dbus-1 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${DBus1_INCLUDE_DIRS})
set_property(TARGET dbus-1 APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS ${DBus1_DEFINITIONS})
diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake
index f45a8fb3..77fc19c3 100644
--- a/cmake/config.h.cmake
+++ b/cmake/config.h.cmake
@@ -2,16 +2,20 @@
#ifndef _DBUS_CONFIG_H
#define _DBUS_CONFIG_H
-/****************************/
-/* indicate that we are building with cmake */
-#define DBUS_CMAKE 1
-@AUTOPACKAGE_CONFIG_H_TEMPLATE@
+#cmakedefine VERSION "@VERSION@"
-/*
- * Variables defined by AC_DEFINE in ../configure.ac
- * should be placed in this file
-*/
+/* On Windows, we expect to be using msvcrt.dll-compatible printf
+ * (%I64u instead of %llu) unless otherwise specified. This must be
+ * done near the beginning of config.h, before we have included any
+ * system headers that might check the value of this macro. */
+#ifndef __USE_MINGW_ANSI_STDIO
+# define __USE_MINGW_ANSI_STDIO 0
+#endif
+
+#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
+#cmakedefine _TIME_BITS @_TIME_BITS@
+#cmakedefine WORDS_BIGENDIAN
/* Opt-in to modern APIs and thread-safety for Solaris. In the Autotools
* build system we do the equivalent of this by appending to CFLAGS
@@ -23,7 +27,6 @@
# define _XOPEN_SOURCE 500
#endif
-#cmakedefine DBUS_CONSOLE_AUTH_DIR "@DBUS_CONSOLE_AUTH_DIR@"
#cmakedefine DBUS_DATADIR "@DBUS_DATADIR@"
#cmakedefine DBUS_BINDIR "@DBUS_BINDIR@"
#cmakedefine DBUS_PREFIX "@DBUS_PREFIX@"
@@ -38,7 +41,6 @@
#cmakedefine DBUS_RUNSTATEDIR "@DBUS_RUNSTATEDIR@"
#cmakedefine DBUS_ENABLE_STATS
-#cmakedefine DBUS_ENABLE_CONTAINERS
#cmakedefine ENABLE_TRADITIONAL_ACTIVATION
#define TEST_LISTEN "@TEST_LISTEN@"
@@ -77,17 +79,12 @@
# define DBUS_ENABLE_X11_AUTOLAUNCH 1
#endif
-/* A 'va_copy' style function */
-#cmakedefine DBUS_VA_COPY @DBUS_VA_COPY@
-
-/* for msvc */
-#define _DBUS_VA_COPY_ASSIGN(a1,a2) { a1 = a2; }
-
#cmakedefine DBUS_WITH_GLIB 1
#cmakedefine GLIB_VERSION_MIN_REQUIRED @GLIB_VERSION_MIN_REQUIRED@
#cmakedefine GLIB_VERSION_MAX_ALLOWED @GLIB_VERSION_MAX_ALLOWED@
// headers
+#cmakedefine HAVE_AFUNIX_H 1
#cmakedefine HAVE_ALLOCA_H 1
#cmakedefine HAVE_BYTESWAP_H 1
#cmakedefine HAVE_CRT_EXTERNS_H 1
@@ -95,17 +92,9 @@
/* Define to 1 if you have dirent.h */
#cmakedefine HAVE_DIRENT_H 1
-#cmakedefine HAVE_DLFCN_H 1
-
/* Define to 1 if you have errno.h */
#cmakedefine HAVE_ERRNO_H 1
-#cmakedefine HAVE_EXECINFO_H 1
-#cmakedefine HAVE_EXPAT_H 1
-
-/* Define to 1 if you have grp.h */
-#cmakedefine HAVE_GRP_H 1
-
/* Define to 1 if you have inttypes.h */
#cmakedefine HAVE_INTTYPES_H 1
@@ -115,48 +104,29 @@
/* Define to 1 if you have locale.h */
#cmakedefine HAVE_LOCALE_H 1
-#cmakedefine HAVE_MEMORY_H 1
-
/* Define to 1 if you have poll */
#cmakedefine HAVE_POLL 1
/* Define to 1 if you have signal.h */
#cmakedefine HAVE_SIGNAL_H 1
-/* Define to 1 if you have stdint.h */
-#cmakedefine HAVE_STDINT_H 1
-
-#cmakedefine HAVE_STDLIB_H 1
-
/* Define to 1 if you have stdio.h */
#cmakedefine HAVE_STDIO_H 1
-#cmakedefine HAVE_STRINGS_H 1
-#cmakedefine HAVE_STRING_H 1
+#cmakedefine HAVE_STDATOMIC_H 1
#cmakedefine HAVE_SYSLOG_H 1
#cmakedefine HAVE_SYS_EVENTS_H 1
#cmakedefine HAVE_SYS_INOTIFY_H 1
+#cmakedefine HAVE_LINUX_MAGIC_H 1
#cmakedefine HAVE_SYS_PRCTL_H 1
#cmakedefine HAVE_SYS_RANDOM_H 1
#cmakedefine HAVE_SYS_RESOURCE_H 1
-#cmakedefine HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have sys/syslimits.h */
-#cmakedefine HAVE_SYS_SYSLIMITS_H 1
+#cmakedefine HAVE_SYS_SYSCALL_H 1
+#cmakedefine HAVE_SYS_VFS_H 1
/* Define to 1 if you have sys/time.h */
#cmakedefine HAVE_SYS_TIME_H 1
-#cmakedefine HAVE_SYS_TYPES_H 1
-
-#cmakedefine HAVE_SYS_UIO_H 1
-
-/* Define to 1 if you have sys/wait.h */
-#cmakedefine HAVE_SYS_WAIT_H 1
-
-/* Define to 1 if you have time.h */
-#cmakedefine HAVE_TIME_H 1
-
/* Define to 1 if you have unistd.h */
#cmakedefine HAVE_UNISTD_H 1
@@ -191,6 +161,12 @@
/* Define to 1 if you have clearenv */
#cmakedefine HAVE_CLEARENV 1
+/* Define to 1 if you have closefrom */
+#cmakedefine HAVE_CLOSEFROM 1
+
+/* Define to 1 if you have close_range */
+#cmakedefine HAVE_CLOSE_RANGE 1
+
/* Define to 1 if you have writev */
#cmakedefine HAVE_WRITEV 1
@@ -203,23 +179,12 @@
/* Define to 1 if you have localeconv */
#cmakedefine HAVE_LOCALECONV 1
-/* Define to 1 if you have strtoll */
-#cmakedefine HAVE_STRTOLL 1
-
-/* Define to 1 if you have strtoull */
-#cmakedefine HAVE_STRTOULL 1
-
/* Define to 1 if you have pip2 */
#cmakedefine HAVE_PIPE2 1
#cmakedefine HAVE_ACCEPT4 1
-/* Have dirfd function */
-#cmakedefine HAVE_DIRFD 1
-
-/* Have the ddfd member of DIR */
-#cmakedefine HAVE_DDFD 1
-
+#cmakedefine HAVE_FSTATFS 1
#cmakedefine HAVE_INOTIFY_INIT1 1
#cmakedefine HAVE_GETRANDOM 1
#cmakedefine HAVE_GETRLIMIT 1
@@ -234,7 +199,17 @@
#cmakedefine DBUS_HAVE_LINUX_EPOLL 1
/* Use the gcc __sync extension */
-#cmakedefine DBUS_USE_SYNC 1
+#cmakedefine01 DBUS_USE_SYNC
+
+#cmakedefine HAVE_SETRESUID 1
+#cmakedefine HAVE_GETRESUID 1
+/* whether -export-dynamic was passed to libtool */
+#cmakedefine DBUS_BUILT_R_DYNAMIC 1
+
+/* Enable GNU extensions on systems that have them. */
+#ifndef _GNU_SOURCE
+#cmakedefine _GNU_SOURCE 1
+#endif
// structs
/* Define to 1 if you have struct cmsgred */
@@ -245,6 +220,8 @@
#cmakedefine DBUS_USER "@DBUS_USER@"
#cmakedefine DBUS_TEST_USER "@DBUS_TEST_USER@"
#cmakedefine DBUS_TEST_EXEC "@DBUS_TEST_EXEC@"
+/* Where to put test sockets */
+#define DBUS_TEST_SOCKET_DIR "@TEST_SOCKET_DIR@"
// system type defines
#if defined(_WIN32) || defined(_WIN64) || defined (_WIN32_WCE)
@@ -269,14 +246,7 @@
# define uid_t int
# define gid_t int
# else
-# define snprintf _snprintf
typedef int mode_t;
-# if !defined(_WIN32_WCE)
-# define strtoll _strtoi64
-# define strtoull _strtoui64
-# define HAVE_STRTOLL 1
-# define HAVE_STRTOULL 1
-# endif
# endif
#endif // defined(_WIN32) || defined(_WIN64)
@@ -288,19 +258,13 @@
#define SIGHUP 1
#endif
-#cmakedefine DBUS_VERBOSE_C_S 1
-#ifdef DBUS_VERBOSE_C_S
-#define _dbus_verbose_C_S printf
-#else
-#define _dbus_verbose_C_S _dbus_verbose
-#endif
-
-# if defined(_MSC_VER) && !defined(inline)
-#define inline __inline
-#endif
-
#ifdef DBUS_WIN
#define FD_SETSIZE @FD_SETSIZE@
#endif
+#cmakedefine01 HAVE_DECL_ENVIRON
+#cmakedefine01 HAVE_DECL_LOG_PERROR
+#cmakedefine01 HAVE_DECL_MSG_NOSIGNAL
+#cmakedefine01 HAVE_DECL_SYS_PIDFD_OPEN
+
#endif // _DBUS_CONFIG_H
diff --git a/cmake/meson.build b/cmake/meson.build
new file mode 100644
index 00000000..bba68c23
--- /dev/null
+++ b/cmake/meson.build
@@ -0,0 +1,44 @@
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+cmake_config = configuration_data()
+cmake_config.set('CMAKE_INSTALL_INCLUDEDIR',get_option('prefix') / get_option('includedir'))
+cmake_config.set('CMAKE_INSTALL_LIBDIR', get_option('prefix') / get_option('libdir'))
+cmake_config.set('DBUS_PREFIX', get_option('prefix'))
+cmake_config.set('DBUS_RELOCATABLE', relocation)
+cmake_config.set('DBUS_VERSION', version)
+
+cmake_files = [
+ configure_file(
+ input: 'DBus1Config.pkgconfig.in',
+ output: 'DBus1Config.cmake',
+ configuration: cmake_config,
+ ),
+ configure_file(
+ input: 'DBus1ConfigVersion.cmake.in',
+ output: 'DBus1ConfigVersion.cmake',
+ configuration: cmake_config,
+ )
+]
+
+install_data(cmake_files,
+ install_dir: get_option('libdir') / 'cmake' / 'DBus1',
+)
diff --git a/cmake/modules/CPackInstallConfig.cmake b/cmake/modules/CPackInstallConfig.cmake
index 221a7938..b68bea67 100644
--- a/cmake/modules/CPackInstallConfig.cmake
+++ b/cmake/modules/CPackInstallConfig.cmake
@@ -9,8 +9,8 @@ endif()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "D-BUS For Windows")
set(CPACK_PACKAGE_VENDOR "D-BUS Windows Team")
-set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README")
-set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
+set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README")
+set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
# duplicated from VERSION
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
@@ -22,7 +22,7 @@ if(WIN32 AND NOT UNIX)
set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
# There is a bug in NSI that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backlasshes.
-# SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
+# SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\dbus-launch.bat")
set(CPACK_NSIS_DISPLAY_NAME "D-Bus for Windows")
set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\sourceforge.net/projects/windbus")
diff --git a/cmake/modules/FindDocBookXSL.cmake b/cmake/modules/FindDocBookXSL.cmake
index 3d9e40c4..edb10c4e 100644
--- a/cmake/modules/FindDocBookXSL.cmake
+++ b/cmake/modules/FindDocBookXSL.cmake
@@ -6,6 +6,7 @@
# used to process DocBook XML
# Copyright (c) 2010, Luigi Toscano, <luigi.toscano@tiscali.it>
+# SPDX-License-Identifier: BSD-3-Clause
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
diff --git a/cmake/modules/FindGLib2.cmake b/cmake/modules/FindGLIB2.cmake
index 0cadba5e..e6f5979e 100644
--- a/cmake/modules/FindGLib2.cmake
+++ b/cmake/modules/FindGLIB2.cmake
@@ -7,9 +7,10 @@
# Copyright (c) 2008 Laurent Montel, <montel@kde.org>
# Copyright (c) 2013 Ralf Habacker, <ralf.habacker@freenet.de>
+# SPDX-License-Identifier: LicenseRef-CMakeScripts
#
# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+# For details see LICENSES/LicenseRef-CMakeScripts.txt.
if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
diff --git a/cmake/modules/Macros.cmake b/cmake/modules/Macros.cmake
index 6d8e5809..044e2a70 100644
--- a/cmake/modules/Macros.cmake
+++ b/cmake/modules/Macros.cmake
@@ -65,6 +65,8 @@ macro(add_unit_test _name _target)
list(APPEND _env "DBUS_TEST_EXEC=${DBUS_TEST_EXEC}")
list(APPEND _env "DBUS_TEST_HOMEDIR=${DBUS_TEST_HOMEDIR}")
list(APPEND _env "DBUS_TEST_UNINSTALLED=1")
+ list(APPEND _env "G_TEST_BUILDDIR=${Z_DRIVE_IF_WINE}${PROJECT_BINARY_DIR}/test")
+ list(APPEND _env "G_TEST_SRCDIR=${Z_DRIVE_IF_WINE}${PROJECT_SOURCE_DIR}/test")
list(APPEND _env ${__ENV})
set_tests_properties(${_name} PROPERTIES ENVIRONMENT "${_env}")
endmacro()
@@ -120,18 +122,45 @@ macro(add_session_test_executable _target _source)
)
endmacro()
-#
-# generate compiler flags from MSVC warning identifiers (e.g. '4114') or gcc warning keys (e.g. 'pointer-sign')
-#
-# @param target the variable name which will contain the warnings flags
-# @param warnings a string with space delimited warnings
-# @param disabled_warnings a string with space delimited disabled warnings
-# @param error_warnings a string with space delimited warnings which should result into compile errors
-#
-macro(generate_warning_cflags target warnings disabled_warnings error_warnings)
- if(DEBUG_MACROS)
- message("generate_warning_cflags got: ${warnings} - ${disabled_warnings} - ${error_warnings}")
+include(CheckCCompilerFlag)
+include(CheckCXXCompilerFlag)
+function(check_compiler_warning_flag _flag _result _cxx)
+ string(MAKE_C_IDENTIFIER "${_flag}" _varname)
+ # required to get errors
+ list(APPEND _flag -Werror)
+ if(_flag MATCHES "-Wformat-.*")
+ list(APPEND _flag -Wformat)
endif()
+ if (_cxx)
+ check_cxx_compiler_flag("${_flag}" HAVE_CXX_FLAG${_varname})
+ set(${_result} ${HAVE_CXX_FLAG${_varname}} PARENT_SCOPE)
+ else()
+ check_c_compiler_flag("${_flag}" HAVE_C_FLAG${_varname})
+ set(${_result} ${HAVE_C_FLAG${_varname}} PARENT_SCOPE)
+ endif()
+endfunction()
+
+# generate compiler flags from MSVC warning identifiers (e.g. '4114') or gcc warning keys (e.g. 'pointer-sign')
+# Options:
+# [DISABLED <list>] list of warnings to disable
+# [ERRORS <list>] list of warnings to report as error
+# RESULTVAR <var> variable name to get results
+# WARNINGS <list> list of warnings to add
+# [CXX] Check if the flag is supported using the C++ compiler instead of the C compiler
+#
+macro(generate_compiler_warning_flags)
+ # Support if() IN_LIST operator
+ cmake_policy(SET CMP0057 NEW)
+ set(options CXX)
+ set(oneValueArgs RESULTVAR)
+ set(multiValueArgs WARNINGS DISABLED ERRORS)
+ cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ unset(USED)
+ unset(USED_WARNINGS)
+ unset(USED_DISABLED)
+ unset(USED_UNSUPPORTED)
+
if(MSVC)
# level 1 is default
set(enabled_prefix "/w1")
@@ -144,33 +173,54 @@ macro(generate_warning_cflags target warnings disabled_warnings error_warnings)
endif()
set(temp)
- string(REPLACE " " ";" warnings_list "${warnings}")
- foreach(warning ${warnings_list})
- string(STRIP ${warning} _warning)
- if(_warning)
- set(temp "${temp} ${enabled_prefix}${_warning}")
+ foreach(warning ${ARGS_ERRORS})
+ check_compiler_warning_flag("${error_prefix}${warning}" _flag_supported "${ARGS_CXX}")
+ if(_flag_supported)
+ set(temp "${temp} ${error_prefix}${warning}")
+ list(APPEND USED ${warning})
+ elseif(NOT warning IN_LIST USED_UNSUPPORTED)
+ list(APPEND USED_UNSUPPORTED ${warning})
endif()
endforeach()
- string(REPLACE " " ";" disabled_warnings_list "${disabled_warnings}")
- foreach(warning ${disabled_warnings_list})
- string(STRIP ${warning} _warning)
- if(_warning)
- set(temp "${temp} ${disabled_prefix}${_warning}")
+ foreach(warning ${ARGS_WARNINGS})
+ if(warning IN_LIST ARGS_ERRORS)
+ message(WARNING "warning '${warning}' already specified as error, ignored")
+ elseif(warning IN_LIST ARGS_DISABLED)
+ message(WARNING "warning '${warning}' already specified as disabled, ignored")
+ elseif(NOT warning IN_LIST USED)
+ check_compiler_warning_flag("${enabled_prefix}${warning}" _flag_supported "${ARGS_CXX}")
+ if(_flag_supported)
+ set(temp "${temp} ${enabled_prefix}${warning}")
+ list(APPEND USED_WARNINGS ${warning})
+ list(APPEND USED ${warning})
+ elseif(NOT warning IN_LIST USED_UNSUPPORTED)
+ list(APPEND USED_UNSUPPORTED ${warning})
+ endif()
endif()
endforeach()
- string(REPLACE " " ";" error_warnings_list "${error_warnings}")
- foreach(warning ${error_warnings_list})
- string(STRIP ${warning} _warning)
- if(_warning)
- set(temp "${temp} ${error_prefix}${_warning}")
+ foreach(warning ${ARGS_DISABLED})
+ if(warning IN_LIST ARGS_ERRORS)
+ message(WARNING "disabled warning '${warning}' already specified as error, ignored")
+ elseif(warning IN_LIST ARGS_WARNINGS)
+ message(WARNING "disabled warning '${warning}' already specified as warning, ignored")
+ elseif(NOT warning IN_LIST USED)
+ check_compiler_warning_flag("${disabled_prefix}${warning}" _flag_supported "${ARGS_CXX}")
+ if(_flag_supported)
+ set(temp "${temp} ${disabled_prefix}${warning}")
+ list(APPEND USED_DISABLED ${warning})
+ list(APPEND USED ${warning})
+ elseif(NOT warning IN_LIST USED_UNSUPPORTED)
+ list(APPEND USED_UNSUPPORTED ${warning})
+ endif()
endif()
endforeach()
- set(${target} "${temp}")
- if(DEBUG_MACROS)
- message("generate_warning_cflags return: ${${target}}")
- endif()
+
+ set(${ARGS_RESULTVAR} "${temp}")
+ message(STATUS "effectively used warnings for '${ARGS_RESULTVAR}': ${USED_WARNINGS}")
+ message(STATUS "effectively used disabled warnings for '${ARGS_RESULTVAR}': ${USED_DISABLED}")
+ message(STATUS "unsupported warnings for '${ARGS_RESULTVAR}': ${USED_UNSUPPORTED}")
endmacro()
#
@@ -185,8 +235,8 @@ macro(add_uac_manifest _sources)
# 24 is the resource type, RT_MANIFEST
# constants are used because of a bug in windres
# see https://stackoverflow.com/questions/33000158/embed-manifest-file-to-require-administrator-execution-level-with-mingw32
- get_filename_component(UAC_FILE ${CMAKE_SOURCE_DIR}/tools/Win32.Manifest REALPATH)
- set(outfile ${CMAKE_BINARY_DIR}/disable-uac.rc)
+ get_filename_component(UAC_FILE ${PROJECT_SOURCE_DIR}/tools/Win32.Manifest REALPATH)
+ set(outfile ${PROJECT_BINARY_DIR}/disable-uac.rc)
if(NOT EXISTS outfile)
file(WRITE ${outfile} "1 24 \"${UAC_FILE}\"\n")
endif()
@@ -197,7 +247,7 @@ macro(add_executable_version_info _sources _name)
set(DBUS_VER_INTERNAL_NAME "${_name}")
set(DBUS_VER_ORIGINAL_NAME "${DBUS_VER_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}")
set(DBUS_VER_FILE_TYPE "VFT_APP")
- configure_file(${CMAKE_SOURCE_DIR}/dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc)
+ configure_file(${PROJECT_SOURCE_DIR}/dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc)
# version info and uac manifest can be combined in a binary because they use different resource types
list(APPEND ${_sources} ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc)
endmacro()
@@ -206,7 +256,7 @@ macro(add_library_version_info _sources _name)
set(DBUS_VER_INTERNAL_NAME "${_name}")
set(DBUS_VER_ORIGINAL_NAME "${DBUS_VER_INTERNAL_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(DBUS_VER_FILE_TYPE "VFT_DLL")
- configure_file(${CMAKE_SOURCE_DIR}/dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc)
+ configure_file(${PROJECT_SOURCE_DIR}/dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc)
# version info and uac manifest can be combined in a binary because they use different resource types
list(APPEND ${_sources} ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc)
endmacro()
diff --git a/cmake/modules/MacrosAutotools.cmake b/cmake/modules/MacrosAutotools.cmake
deleted file mode 100644
index ab4f1c1b..00000000
--- a/cmake/modules/MacrosAutotools.cmake
+++ /dev/null
@@ -1,168 +0,0 @@
-#
-# cmake package for autotools support
-#
-# @Author Ralf Habacker
-#
-
-#
-# load autotools configure file into an internal list named _configure_ac
-#
-macro(autoinit config)
- set(_configure_ac_name ${config})
- file(READ ${config} _configure_ac_raw)
- # Convert file contents into a CMake list (where each element in the list
- # is one line of the file)
- string(REGEX REPLACE ";" "\\\\;" _configure_ac "${_configure_ac_raw}")
- string(REGEX REPLACE "\n" ";" _configure_ac "${_configure_ac}")
-endmacro()
-
-# extracts version information from autoconf config file
-# and set related cmake variables
-#
-# returns
-# ${prefix}_VERSION
-# ${prefix}_VERSION_STRING
-# ${prefix}_MAJOR_VERSION
-# ${prefix}_MINOR_VERSION
-# ${prefix}_MICRO_VERSION
-# ${prefix}_LIBRARY_AGE
-# ${prefix}_LIBRARY_REVISION
-# ${prefix}_LIBRARY_CURRENT
-#
-macro(autoversion prefix)
- string(TOUPPER ${prefix} prefix_upper)
- string(REGEX REPLACE ".*${prefix}_major_version], .([0-9]+).*" "\\1" ${prefix_upper}_MAJOR_VERSION ${_configure_ac_raw})
- string(REGEX REPLACE ".*${prefix}_minor_version], .([0-9]+).*" "\\1" ${prefix_upper}_MINOR_VERSION ${_configure_ac_raw})
- string(REGEX REPLACE ".*${prefix}_micro_version], .([0-9]+).*" "\\1" ${prefix_upper}_MICRO_VERSION ${_configure_ac_raw})
- set(${prefix_upper}_VERSION ${${prefix_upper}_MAJOR_VERSION}.${${prefix_upper}_MINOR_VERSION}.${${prefix_upper}_MICRO_VERSION})
- set(${prefix_upper}_VERSION_STRING "${${prefix_upper}_VERSION}")
- string(REGEX REPLACE ".*LT_AGE=([0-9]+).*" "\\1" ${prefix_upper}_LIBRARY_AGE ${_configure_ac_raw})
- string(REGEX REPLACE ".*LT_CURRENT=([0-9]+).*" "\\1" ${prefix_upper}_LIBRARY_CURRENT ${_configure_ac_raw})
- string(REGEX REPLACE ".*LT_REVISION=([0-9]+).*" "\\1" ${prefix_upper}_LIBRARY_REVISION ${_configure_ac_raw})
-endmacro()
-
-#
-# Defines package related variables (PACKAGE_..., PACKAGE and VERSION)
-# as done by autotools.
-#
-# Additional it defines a cmake variable named PACKAGE_CONFIG_H_TEMPLATE
-# which could be placed in config.h templates to have those variables
-# defined at code level like shown below:
-#
-# config.h.template
-# ...
-# @AUTOPACKAGE_CONFIG_H_TEMPLATE@
-# ...
-#
-macro(autopackage name version url support_url)
- # Define to the full name of this package.
- set(PACKAGE_NAME ${name})
-
- # Define to the version of this package.
- set(PACKAGE_VERSION ${version})
-
- # Define to the home page for this package.
- set(PACKAGE_URL ${url})
-
- # Define to the address where bug reports for this package should be sent.
- set(PACKAGE_BUGREPORT ${support_url})
-
- # Define to the full name and version of this package.
- set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
-
- # Define to the one symbol short name of this package.
- set(PACKAGE_TARNAME ${PACKAGE_NAME})
-
- set(PACKAGE ${name})
- set(VERSION ${DBUS_VERSION_STRING})
-
- string(CONFIGURE "/* generated by cmake macro autopackage */\n
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT \"@PACKAGE_BUGREPORT@\"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME \"@PACKAGE_NAME@\"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING \"@PACKAGE_STRING@\"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME \"@PACKAGE_TARNAME@\"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL \"@PACKAGE_URL@\"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION \"@PACKAGE_VERSION@\"
-
-/* defined by autotools package */
-#define PACKAGE \"@PACKAGE@\"
-#define VERSION \"@VERSION@\"
-" AUTOPACKAGE_CONFIG_H_TEMPLATE)
-endmacro()
-
-#
-# define a cmake variable from autotools AC_DEFINE statement
-#
-macro(autodefine name)
- foreach(line ${_configure_ac})
- if(line MATCHES ".*AC_DEFINE(.*${name}.*).*")
- string(REGEX REPLACE ".*AC_DEFINE(.*).*" "\\1" value ${line})
- string(REGEX REPLACE "[^[]*\\[[^]]*\\], *\\[([^]]*)\\],.*" "\\1" value2 ${value})
- string(REPLACE "[" "" value3 ${value2})
- string(REPLACE "]" "" value4 ${value3})
- set(${name} ${value4})
- endif()
- endforeach()
-endmacro()
-
-macro(autoheaderchecks config_h_in configure_checks_file config_h_cmake)
- file(READ ${configure_checks_file} configure_checks_file_raw)
- file(READ ${config_h_in} _config_h_in_raw)
- file(READ ${config_h_cmake} _config_h_cmake_raw)
- string(REGEX REPLACE ";" "\\\\;" _config_h_in "${_config_h_in_raw}")
- string(REGEX REPLACE "\n" ";" _config_h_in "${_config_h_in}")
- foreach(line ${_config_h_in})
- #message(STATUS ${line})
- if(line MATCHES ".*HAVE_.*_H.*")
- string(REGEX REPLACE ".*HAVE_(.*)_H.*" "\\1" key ${line})
- set(full_key "HAVE_${key}_H")
- if(key MATCHES ".*_.*")
- string(REGEX MATCH "^[A-Z0-9]+" dir ${key})
- string(REGEX MATCH "[A-Z0-9]+$" file ${key})
- string(TOLOWER ${dir} dirname)
- string(TOLOWER ${file} filename)
- set(check "check_include_file(${dirname}/${filename}.h ${full_key})")
- set(config_define "#cmakedefine ${full_key}")
- else()
- set(file ${key})
- string(TOLOWER ${file} filename)
- set(check "check_include_file(${filename}.h ${full_key})")
- set(config_define "#cmakedefine ${full_key}")
- endif()
- if(NOT configure_checks_file_raw MATCHES ".*${full_key}.*")
- message("${check}")
- endif()
- if(NOT _config_h_cmake_raw MATCHES "${full_key}")
- message("${config_define}")
- endif()
- endif()
- endforeach()
-endmacro()
-
-#
-# parses config.h template and create cmake equivalent
-# not implemented yet
-#
-macro(autoconfig template output)
- file(READ ${template} contents)
- # Convert file contents into a CMake list (where each element in the list
- # is one line of the file)
- string(REGEX REPLACE ";" "\\\\;" contents "${contents}")
- string(REGEX REPLACE "\n" ";" contents "${contents}")
- foreach(line contents)
- message(STATUS ${line})
- # find #undef lines
- # append to config.h #define <variable-name> <variable-content>
- endforeach()
-endmacro()
diff --git a/cmake/modules/MacrosMeson.cmake b/cmake/modules/MacrosMeson.cmake
new file mode 100644
index 00000000..d26617d2
--- /dev/null
+++ b/cmake/modules/MacrosMeson.cmake
@@ -0,0 +1,52 @@
+#
+# cmake package for meson support
+#
+# SPDX-FileCopyrightText: © 2023 Ralf Habacker
+# SPDX-License-Identifier: BSD-3-Clause
+
+#
+# load meson build file into an internal list named _meson_build
+#
+macro(meson_init config)
+ set(_meson_build_name ${config})
+ file(READ ${config} _meson_build_raw)
+ # Convert file contents into a CMake list (where each element in the list
+ # is one line of the file)
+ string(REGEX REPLACE ";" "\\\\;" _meson_build "${_meson_build_raw}")
+ string(REGEX REPLACE "\n" ";" _meson_build "${_meson_build}")
+endmacro()
+
+# extracts version information from autoconf config file
+# and set related cmake variables
+#
+# returns
+# ${prefix}_VERSION
+# ${prefix}_VERSION_STRING
+# ${prefix}_MAJOR_VERSION
+# ${prefix}_MINOR_VERSION
+# ${prefix}_MICRO_VERSION
+# ${prefix}_LIBRARY_AGE
+# ${prefix}_LIBRARY_REVISION
+# ${prefix}_LIBRARY_CURRENT
+#
+macro(meson_version prefix)
+ set(WS "[ \t\r\n]")
+ string(TOUPPER ${prefix} prefix_upper)
+ string(REGEX REPLACE ".*${WS}version:${WS}*'([0-9.]+)'.*" "\\1" ${prefix_upper}_VERSION ${_meson_build_raw})
+ string(REPLACE "." ";" VERSION_LIST ${${prefix_upper}_VERSION})
+ list(GET VERSION_LIST 0 ${prefix_upper}_MAJOR_VERSION)
+ list(GET VERSION_LIST 1 ${prefix_upper}_MINOR_VERSION)
+ list(GET VERSION_LIST 2 ${prefix_upper}_MICRO_VERSION)
+ set(${prefix_upper}_VERSION_STRING "${${prefix_upper}_VERSION}")
+ string(REGEX REPLACE ".*${WS}lt_age${WS}*=${WS}*([0-9]+).*" "\\1" ${prefix_upper}_LIBRARY_AGE ${_meson_build_raw})
+ string(REGEX REPLACE ".*${WS}lt_current${WS}*=*${WS}*([0-9]+).*" "\\1" ${prefix_upper}_LIBRARY_CURRENT ${_meson_build_raw})
+ string(REGEX REPLACE ".*${WS}lt_revision${WS}*=${WS}*([0-9]+).*" "\\1" ${prefix_upper}_LIBRARY_REVISION ${_meson_build_raw})
+ message(STATUS "fetched variable from meson.build - ${prefix_upper}_VERSION = ${${prefix_upper}_VERSION} ")
+ message(STATUS "fetched variable from meson.build - ${prefix_upper}_VERSION_STRING = ${${prefix_upper}_VERSION_STRING} ")
+ message(STATUS "fetched variable from meson.build - ${prefix_upper}_MAJOR_VERSION = ${${prefix_upper}_MAJOR_VERSION} ")
+ message(STATUS "fetched variable from meson.build - ${prefix_upper}_MINOR_VERSION = ${${prefix_upper}_MINOR_VERSION} ")
+ message(STATUS "fetched variable from meson.build - ${prefix_upper}_MICRO_VERSION = ${${prefix_upper}_MICRO_VERSION} ")
+ message(STATUS "fetched variable from meson.build - ${prefix_upper}_LIBRARY_AGE = ${${prefix_upper}_LIBRARY_AGE} ")
+ message(STATUS "fetched variable from meson.build - ${prefix_upper}_LIBRARY_REVISION = ${${prefix_upper}_LIBRARY_REVISION}")
+ message(STATUS "fetched variable from meson.build - ${prefix_upper}_LIBRARY_CURRENT = ${${prefix_upper}_LIBRARY_CURRENT} ")
+endmacro()
diff --git a/cmake/modules/Win32Macros.cmake b/cmake/modules/Win32Macros.cmake
index 0946b037..4df8df51 100644
--- a/cmake/modules/Win32Macros.cmake
+++ b/cmake/modules/Win32Macros.cmake
@@ -2,6 +2,7 @@
# win32 macros
#
# Copyright (c) 2006-2007, Ralf Habacker
+# SPDX-License-Identifier: BSD-3-Clause
#
# Redistribution and use is allowed according to the terms of the BSD license.
#
@@ -31,13 +32,13 @@ if(WIN32)
if(MINGW)
get_filename_component(MINGW_BIN_PATH ${CMAKE_CXX_COMPILER} PATH)
set(ADD_PATH "${ADD_PATH};${MINGW_BIN_PATH}")
- write_file(${CMAKE_BINARY_DIR}/${_projectname}-shell.bat "set PATH=${ADD_PATH};%PATH%\ncmd.exe")
+ write_file(${PROJECT_BINARY_DIR}/${_projectname}-shell.bat "set PATH=${ADD_PATH};%PATH%\ncmd.exe")
else(MINGW)
if(CMAKE_BUILD_TOOL STREQUAL "nmake")
get_filename_component(VC_BIN_PATH ${CMAKE_CXX_COMPILER} PATH)
- write_file(${CMAKE_BINARY_DIR}/${_projectname}-shell.bat "set PATH=${ADD_PATH};%PATH%\ncall \"${VC_BIN_PATH}\\vcvars32.bat\"\ncmd.exe")
+ write_file(${PROJECT_BINARY_DIR}/${_projectname}-shell.bat "set PATH=${ADD_PATH};%PATH%\ncall \"${VC_BIN_PATH}\\vcvars32.bat\"\ncmd.exe")
else(CMAKE_BUILD_TOOL STREQUAL "nmake")
- write_file(${CMAKE_BINARY_DIR}/${_projectname}-sln.bat "set PATH=${ADD_PATH};%PATH%\nstart ${_projectname}.sln")
+ write_file(${PROJECT_BINARY_DIR}/${_projectname}-sln.bat "set PATH=${ADD_PATH};%PATH%\nstart ${_projectname}.sln")
endif()
endif()
endmacro()
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index 3f200a6c..00000000
--- a/configure.ac
+++ /dev/null
@@ -1,1840 +0,0 @@
-dnl -*- mode: m4 -*-
-AC_PREREQ([2.63])
-
-m4_define([dbus_major_version], [1])
-m4_define([dbus_minor_version], [13])
-m4_define([dbus_micro_version], [18])
-m4_define([dbus_version],
- [dbus_major_version.dbus_minor_version.dbus_micro_version])
-AC_INIT([dbus], [dbus_version], [https://gitlab.freedesktop.org/dbus/dbus/issues], [dbus])
-
-AC_CONFIG_AUX_DIR([build-aux])
-
-m4_pattern_forbid([^AX_(CHECK_ENABLE_DEBUG|CODE_COVERAGE|COMPILER_FLAGS|COMPILER_FLAGS_(CFLAGS|CXXFLAGS|LDFLAGS))\b],
- [Unexpanded AX_ macro found. Please install GNU autoconf-archive])
-
-AC_CANONICAL_HOST
-
-AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_MACRO_DIR([m4])
-
-AM_INIT_AUTOMAKE([1.13 tar-ustar no-dist-gzip dist-xz -Wno-portability subdir-objects foreign])
-
-GETTEXT_PACKAGE=dbus-1
-AC_SUBST(GETTEXT_PACKAGE)
-AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The name of the gettext domain])
-
-# By default, rebuild autotools files on demand; only use ./missing if the
-# user says --disable-maintainer-mode (some distributions like to do this)
-AM_MAINTAINER_MODE([enable])
-
-m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
-
-AC_DEFINE_UNQUOTED(DBUS_DAEMON_NAME,"dbus-daemon",[Name of executable])
-
-# libtool versioning - this applies to libdbus
-#
-# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
-#
-
-## increment if the interface has additions, changes, removals.
-LT_CURRENT=32
-
-## increment any time the source changes; set to
-## 0 if you increment CURRENT
-LT_REVISION=0
-
-## increment if any interfaces have been added; set to 0
-## if any interfaces have been changed or removed. removal has
-## precedence over adding, so set to 0 if both happened.
-LT_AGE=29
-
-AC_SUBST(LT_CURRENT)
-AC_SUBST(LT_REVISION)
-AC_SUBST(LT_AGE)
-SOVERSION=`expr ${LT_CURRENT} - ${LT_AGE}`
-AC_SUBST([SOVERSION])
-
-DBUS_MAJOR_VERSION=dbus_major_version
-DBUS_MINOR_VERSION=dbus_minor_version
-DBUS_MICRO_VERSION=dbus_micro_version
-DBUS_VERSION=dbus_major_version.dbus_minor_version.dbus_micro_version
-
-AC_SUBST(DBUS_MAJOR_VERSION)
-AC_SUBST(DBUS_MINOR_VERSION)
-AC_SUBST(DBUS_MICRO_VERSION)
-AC_SUBST(DBUS_VERSION)
-
-dnl
-dnl Build configuration
-dnl
-
-dnl This must come first: other options use this to set their defaults. Don't
-dnl enable developer mode on production builds.
-AC_ARG_ENABLE([developer],
- [AS_HELP_STRING([--enable-developer],
- [set defaults to be appropriate for a D-Bus developer instead of a distribution/end-user])],
- [enable_developer=$enableval],
- [enable_developer=no])
-
-dnl 'disable_developer' is the negation of 'enable_developer'. If
-dnl 'enable-developer' is set to 'no' (the default), the value of
-dnl 'disable_developer' is set to 'yes', and vice versa. It's used
-dnl for macros that require the opposite of 'enable_developer', such
-dnl as several AX_ macros.
-dnl See https://bugs.freedesktop.org/show_bug.cgi?id=97357
-AS_IF([test "x$enable_developer" = "xyes"],[
- disable_developer=no
- ],[
- disable_developer=yes
- ])
-
-# The debugging check must run before the compiler tests. Other command-line
-# options also use it to set their defaults. We disable debugging by default,
-# except for developer builds.
-AX_CHECK_ENABLE_DEBUG([$enable_developer])
-
-AC_PROG_CC
-AM_PROG_CC_C_O
-AC_PROG_CXX
-AC_USE_SYSTEM_EXTENSIONS
-AC_SYS_LARGEFILE
-AC_ISC_POSIX
-AC_HEADER_STDC
-AC_C_INLINE
-AM_PROG_LIBTOOL
-AC_PROG_MKDIR_P
-PKG_PROG_PKG_CONFIG
-
-# TAP test driver support
-AC_PROG_AWK
-AC_REQUIRE_AUX_FILE([tap-driver.sh])
-
-# This must come before we set up compiler warnings because it assumes
-# non-use of -Werror=missing-prototypes
-gl_VISIBILITY
-AM_CONDITIONAL([HAVE_VISIBILITY], [test "x$HAVE_VISIBILITY" = x1])
-
-# Initialize libtool
-LT_INIT([win32-dll])
-LT_LANG([Windows Resource])
-
-# Set some internal variables depending on the platform for later use.
-dbus_win=no
-dbus_cygwin=no
-dbus_unix=no
-case "${host}" in
- *-mingw32ce*)
- dbus_win=yes
- dbus_wince=yes
- ;;
- *-mingw32*)
- dbus_win=yes
- ;;
- *-cygwin*)
- dbus_cygwin=yes
- dbus_unix=yes
- ;;
- *)
- dbus_unix=yes
- ;;
-esac
-
-# Special defines for certain platforms
-if test "$dbus_win" = yes; then
- AC_DEFINE(DBUS_WIN,1,[Defined if we run on a W32 API based system])
- # Yes, on Windows it really does work like this.
- # http://support.microsoft.com/kb/111855
- AC_DEFINE(FD_SETSIZE,8192,[The maximum number of connections that can be handled at once])
- BUILD_TIMESTAMP=`date --iso-8601=minutes`
- AC_SUBST(BUILD_TIMESTAMP)
- # Assume DBUS_VERSION is always three numbers
- BUILD_FILEVERSION=`echo "$DBUS_VERSION" | sed -e 's/\./,/g'`,0
- AC_SUBST(BUILD_FILEVERSION)
- # In the CMake build system we generate multiple files, versioninfo-*.rc, with a
- # different "internal name" and "original filename", for embedding in multiple
- # executables. In the Autotools build system, we currently only generate
- # versioninfo.rc and embed it in libdbus-1-${SOVERSION}.dll.
- AC_SUBST([DBUS_VER_INTERNAL_NAME], [libdbus-1-${SOVERSION}])
- AC_SUBST([DBUS_VER_ORIGINAL_NAME], [libdbus-1-${SOVERSION}.dll])
- AC_SUBST([DBUS_VER_FILE_TYPE], [VFT_DLL])
- AS_IF([test -z "$RC"],
- [AC_MSG_ERROR([An implementation of windres is required])])
- if test "$dbus_wince" = yes; then
- AC_DEFINE(DBUS_WINCE,1,[Defined if we run on a W32 CE API based system])
- AC_DEFINE(_WIN32_WCE, 0x0502, [Defined to get newer W32 CE APIs])
- else
- AC_DEFINE([_WIN32_WINNT], [0x0600],
- [Define to the minimum supported Windows version (0x0600 is Vista)])
- fi
-else
- AC_DEFINE(DBUS_UNIX,1,[Defined if we run on a Unix-based system])
-fi
-if test "$dbus_cygwin" = yes; then
- AC_DEFINE(DBUS_CYGWIN,1,[Defined if we run on a cygwin API based system])
-fi
-
-# For best security, assume that all non-Windows platforms can do
-# credentials-passing.
-AS_IF([test "$dbus_win" = yes],
- [DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL="<!--<auth>EXTERNAL</auth>-->"],
- [DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL="<auth>EXTERNAL</auth>"])
-AC_SUBST([DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL])
-
-AM_CONDITIONAL(DBUS_WIN, test "$dbus_win" = yes)
-AM_CONDITIONAL(DBUS_WINCE, test "$dbus_wince" = yes)
-AM_CONDITIONAL(DBUS_UNIX, test "$dbus_unix" = yes)
-AM_CONDITIONAL(DBUS_CYGWIN, test "$dbus_cygwin" = yes)
-
-DBUS_STATIC_BUILD_CPPFLAGS=
-if test "x$enable_shared" = xno; then
- # On Windows, linking against the static library requires special effort
- # to turn off DLL import/export processing. We normally link some things
- # against the dynamic library, but if we're not building that, we'll
- # have to link everything statically.
- DBUS_STATIC_BUILD_CPPFLAGS=-DDBUS_STATIC_BUILD
-fi
-AC_SUBST([DBUS_STATIC_BUILD_CPPFLAGS])
-
-AC_ARG_ENABLE(ansi, AS_HELP_STRING([--enable-ansi],[enable -ansi -pedantic gcc flags]),enable_ansi=$enableval,enable_ansi=no)
-AC_ARG_ENABLE(verbose-mode, AS_HELP_STRING([--enable-verbose-mode],[support verbose debug mode]),enable_verbose_mode=$enableval,enable_verbose_mode=$enable_developer)
-AC_ARG_ENABLE(asserts, AS_HELP_STRING([--enable-asserts],[include assertion checks]),enable_asserts=$enableval,enable_asserts=$enable_developer)
-AC_ARG_ENABLE(checks, AS_HELP_STRING([--enable-checks],[include sanity checks on public API]),enable_checks=$enableval,enable_checks=yes)
-AC_ARG_ENABLE(xml-docs, AS_HELP_STRING([--enable-xml-docs],[build XML documentation (requires xmlto)]),enable_xml_docs=$enableval,enable_xml_docs=auto)
-AC_ARG_ENABLE(doxygen-docs, AS_HELP_STRING([--enable-doxygen-docs],[build DOXYGEN documentation (requires Doxygen)]),enable_doxygen_docs=$enableval,enable_doxygen_docs=auto)
-AC_ARG_ENABLE([ducktype-docs],
- AS_HELP_STRING([--enable-ducktype-docs],
- [build Ducktype documentation (requires Ducktype)]),
- [enable_ducktype_docs=$enableval], [enable_ducktype_docs=auto])
-AC_ARG_ENABLE(selinux, AS_HELP_STRING([--enable-selinux],[build with SELinux support]),enable_selinux=$enableval,enable_selinux=auto)
-AC_ARG_ENABLE([apparmor],
- [AS_HELP_STRING([--enable-apparmor], [build with AppArmor support])],
- [enable_apparmor=$enableval],
- [enable_apparmor=auto])
-AC_ARG_ENABLE(libaudit,AS_HELP_STRING([--enable-libaudit],[build audit daemon support for SELinux]),enable_libaudit=$enableval,enable_libaudit=auto)
-AC_ARG_ENABLE(inotify, AS_HELP_STRING([--enable-inotify],[build with inotify support (linux only)]),enable_inotify=$enableval,enable_inotify=auto)
-AC_ARG_ENABLE(kqueue, AS_HELP_STRING([--enable-kqueue],[build with kqueue support]),enable_kqueue=$enableval,enable_kqueue=auto)
-AC_ARG_ENABLE(console-owner-file, AS_HELP_STRING([--enable-console-owner-file],[enable console owner file]),enable_console_owner_file=$enableval,enable_console_owner_file=auto)
-AC_ARG_ENABLE(launchd, AS_HELP_STRING([--enable-launchd],[build with launchd auto-launch support]),enable_launchd=$enableval,enable_launchd=auto)
-AC_ARG_ENABLE(systemd, AS_HELP_STRING([--enable-systemd],[build with systemd at_console support]),enable_systemd=$enableval,enable_systemd=auto)
-AC_ARG_ENABLE(traditional-activation, AS_HELP_STRING([--disable-traditional-activation], [Do not build support for service activation without using SystemdService]), enable_traditional_activation="$enableval", enable_traditional_activation=yes)
-
-AC_ARG_WITH(session-socket-dir, AS_HELP_STRING([--with-session-socket-dir=[dirname]],[Where to put sockets for the per-login-session message bus]))
-AC_ARG_WITH(test-socket-dir, AS_HELP_STRING([--with-test-socket-dir=[dirname]],[Where to put sockets for make check]))
-AC_ARG_WITH(system-pid-file, AS_HELP_STRING([--with-system-pid-file=[pidfile]],[PID file for systemwide daemon]))
-AC_ARG_WITH(system-socket, AS_HELP_STRING([--with-system-socket=[filename]],[UNIX domain socket for systemwide daemon]))
-AC_ARG_WITH(console-auth-dir, AS_HELP_STRING([--with-console-auth-dir=[dirname]],[directory to check for console ownerhip]))
-AC_ARG_WITH(console-owner-file, AS_HELP_STRING([--with-console-owner-file=[filename]],[file whose owner determines current console owner]))
-AC_ARG_WITH(launchd-agent-dir, AS_HELP_STRING([--with-launchd-agent-dir=[dirname]],[directory to put the launchd agent (default: /Library/LaunchAgents)]))
-AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=<user>],[User for running the DBUS daemon (messagebus)]))
-AC_ARG_WITH([test_user],
- [AS_HELP_STRING([--with-test-user=<user>],
- [Unprivileged user for regression tests, other than root and the dbus_user (default: nobody)])])
-AC_ARG_WITH(dbus_daemondir, AS_HELP_STRING([--with-dbus-daemondir=[dirname]],[Directory for installing the DBUS daemon]))
-
-AC_ARG_ENABLE([embedded-tests],
- AS_HELP_STRING([--enable-embedded-tests],
- [enable unit test code in the library and binaries]),
- [], [enable_embedded_tests=$enable_developer])
-AC_ARG_ENABLE([modular-tests],
- AS_HELP_STRING([--enable-modular-tests],
- [enable modular regression tests (requires GLib)]),
- [], [enable_modular_tests=auto])
-# --enable-tests overrides both --enable-embedded-tests and
-# --enable-modular-tests
-AC_ARG_ENABLE([tests],
- AS_HELP_STRING([--enable-tests],
- [enable/disable all tests, overriding embedded-tests/modular-tests]),
- [
- if test "x$enableval" = xyes; then
- AC_MSG_NOTICE([Full test coverage was requested with --enable-tests=yes])
- AC_MSG_NOTICE([This requires GLib])
- fi
- enable_embedded_tests=$enableval
- enable_modular_tests=$enableval
- ],
- [])
-
-# DBUS_ENABLE_EMBEDDED_TESTS controls unit tests built in to .c files
-# and also some stuff in the test/ subdir.
-AM_CONDITIONAL([DBUS_ENABLE_EMBEDDED_TESTS],
- [test "x$enable_embedded_tests" = xyes])
-if test "x$enable_embedded_tests" = xyes; then
- AC_DEFINE([DBUS_ENABLE_EMBEDDED_TESTS], [1],
- [Define to build test code into the library and binaries])
-fi
-
-# DBUS_ENABLE_MODULAR_TESTS controls tests that work based on public API.
-# These use GTest, from GLib, because life's too short. They're enabled by
-# default (unless you don't have GLib), because they don't bloat the library
-# or binaries.
-
-dnl Don't do anything too subtle here, because the CMake build system
-dnl parses these lines with regular expressions. If necessary, adjust
-dnl cmake/modules/MacrosAutotools.cmake to compensate.
-AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_38], [Ignore post-2.38 deprecations])
-AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [G_ENCODE_VERSION(2,44)], [Prevent post-2.44 APIs])
-
-with_glib=yes
-
-AS_IF([test "x$enable_modular_tests" != xno],
- [
- PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.40, gio-2.0 >= 2.40],
- [
- AS_IF([test "x$dbus_unix" = xyes],
- [PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0],
- [AC_DEFINE([HAVE_GIO_UNIX], [1], [Define if you have gio-unix-2.0])], [])])
- ],
- [if test "x$enable_modular_tests" = xyes; then
- AC_MSG_NOTICE([Full test coverage (--enable-modular-tests=yes or --enable-tests=yes) requires GLib])
- AC_MSG_ERROR([$GLIB_ERRORS])
- else # assumed to be "auto"
- with_glib=no
- fi])
- ],
- [with_glib=no])
-
-if test "x$enable_modular_tests" != xno; then
- AC_DEFINE([DBUS_ENABLE_MODULAR_TESTS], [1],
- [Define to build independent test binaries])
-fi
-AM_CONDITIONAL([DBUS_ENABLE_MODULAR_TESTS],
- [test "x$enable_modular_tests" != xno])
-
-if test "x$with_glib" != xno; then
- AC_DEFINE([DBUS_WITH_GLIB], [1],
- [Define if GLib, GObject, GIO are available])
-fi
-AM_CONDITIONAL([DBUS_WITH_GLIB], [test "x$with_glib" != xno])
-
-AC_ARG_ENABLE([installed-tests],
- AS_HELP_STRING([--enable-installed-tests],
- [enable unit test code in the library and binaries]),
- [], [enable_installed_tests=no])
-AM_CONDITIONAL([DBUS_ENABLE_INSTALLED_TESTS],
- [test "x$enable_installed_tests" = xyes])
-
-if test x$enable_verbose_mode = xyes; then
- AC_DEFINE(DBUS_ENABLE_VERBOSE_MODE,1,[Support a verbose mode])
-fi
-
-dnl Intentional:
-dnl - $DISABLE_WARNINGS disables unused-label warnings if not
-dnl checking or not asserting (tested further below)
-dnl - missing field initializers being 0 is a C feature, not a bug
-dnl - unused-parameter is to make writing callbacks less annoying
-DISABLE_WARNINGS="$DISABLE_WARNINGS
- -Wno-missing-field-initializers
- -Wno-unused-parameter"
-
-if test x$enable_asserts = xno; then
- AC_DEFINE(DBUS_DISABLE_ASSERT,1,[Disable assertion checking])
- DISABLE_WARNINGS="$DISABLE_WARNINGS -Wno-unused-label"
- R_DYNAMIC_LDFLAG=""
- if test x$enable_embedded_tests = xyes; then
- DISABLE_WARNINGS="$DISABLE_WARNINGS
- -Wno-unused-but-set-variable
- -Wno-unused-variable
- -Wno-unused-function"
- fi
-else
- # -rdynamic is needed for glibc's backtrace_symbols to work.
- # No clue how much overhead this adds, but it's useful
- # to do this on any assertion failure,
- # so for now it's enabled anytime asserts are (currently not
- # in production builds).
-
- # To get -rdynamic you pass -export-dynamic to libtool.
- AC_DEFINE(DBUS_BUILT_R_DYNAMIC,1,[whether -export-dynamic was passed to libtool])
- R_DYNAMIC_LDFLAG=-export-dynamic
-fi
-AC_SUBST(R_DYNAMIC_LDFLAG)
-
-if test x$enable_checks = xno; then
- AC_DEFINE(DBUS_DISABLE_CHECKS,1,[Disable public API sanity checking])
- AC_DEFINE(G_DISABLE_CHECKS,1,[Disable GLib public API sanity checking])
- DISABLE_WARNINGS="$DISABLE_WARNINGS -Wno-unused-label"
-fi
-
-AH_BOTTOM([
-/* explicitly define these macros to get less confusing conditions */
-#ifndef DBUS_DISABLE_ASSERT
-# define DBUS_ENABLE_ASSERT 1
-#endif
-#ifndef DBUS_DISABLE_CHECKS
-# define DBUS_ENABLE_CHECKS 1
-#endif])
-
-# Test for code-coverage tools if --enable-code-coverage
-AX_CODE_COVERAGE
-
-AS_IF([test x$enable_code_coverage = xyes],[
- AC_DEFINE_UNQUOTED(
- [DBUS_GCOV_ENABLED], [1],
- [Defined if gcov is enabled to force a rebuild due to config.h changing])
- ])
-
-#### Simple checks for things with no special dependencies
-
-# This construct is only suitable for functions that are in the system's
-# standard C library and do not have unusual dependencies. Other
-# functions need their own checks. Please keep sorted in LC_ALL=C order
-AC_CHECK_FUNCS_ONCE([
-accept4
-clearenv
-fpathconf
-getgrouplist
-getpeereid
-getpeerucred
-getrandom
-getresuid
-getrlimit
-inotify_init1
-issetugid
-localeconv
-nanosleep
-pipe2
-poll
-prctl
-prlimit
-raise
-setenv
-setlocale
-setresuid
-setrlimit
-socketpair
-strtoll
-strtoull
-unsetenv
-usleep
-])
-
-# This construct is only suitable for headers that are self-contained
-# and do not require extra headers to be included first. More complex
-# headers need their own checks. Please keep sorted in LC_ALL=C order
-AC_CHECK_HEADERS_ONCE([
-alloca.h
-byteswap.h
-crt_externs.h
-dirent.h
-errno.h
-locale.h
-signal.h
-stdint.h
-sys/prctl.h
-sys/random.h
-sys/resource.h
-sys/syslimits.h
-sys/time.h
-unistd.h
-ws2tcpip.h
-])
-
-#### Integer sizes
-
-AC_CHECK_SIZEOF(char)
-AC_CHECK_SIZEOF(short)
-AC_CHECK_SIZEOF(long)
-AC_CHECK_SIZEOF(int)
-AC_CHECK_SIZEOF(void *)
-AC_CHECK_SIZEOF(long long)
-AC_CHECK_SIZEOF(__int64)
-
-### See what our 64 bit type is called
-AC_MSG_CHECKING([64-bit integer type])
-
-case 8 in
-$ac_cv_sizeof_int)
- dbusint64=int
- dbusint64_constant='(val)'
- dbusuint64_constant='(val)'
- ;;
-$ac_cv_sizeof_long)
- dbusint64=long
- dbusint64_constant='(val##L)'
- dbusuint64_constant='(val##UL)'
- ;;
-$ac_cv_sizeof_long_long)
- dbusint64='long long'
- dbusint64_constant='(val##LL)'
- dbusuint64_constant='(val##ULL)'
- ;;
-$ac_cv_sizeof___int64)
- dbusint64=__int64
- dbusint64_constant='(val##i64)'
- dbusuint64_constant='(val##ui64)'
- ;;
-esac
-
-AS_IF(
- [test -z "$dbusint64"],
- [AC_MSG_RESULT([not found])
- AC_MSG_ERROR([Could not find a 64-bit integer type.
-
-Please report a bug here with details of your platform and compiler:
-
- http://bugs.freedesktop.org/enter_bug.cgi?product=DBus&component=core])
- ],
- dnl else
- [
- DBUS_INT64_TYPE="$dbusint64"
- DBUS_INT64_CONSTANT="$dbusint64_constant"
- DBUS_UINT64_CONSTANT="$dbusuint64_constant"
- AC_MSG_RESULT($DBUS_INT64_TYPE)
- ])
-
-AC_SUBST(DBUS_INT64_TYPE)
-AC_SUBST(DBUS_INT64_CONSTANT)
-AC_SUBST(DBUS_UINT64_CONSTANT)
-
-### see what 32-bit int is called
-AC_MSG_CHECKING([32-bit integer type])
-
-case 4 in
-$ac_cv_sizeof_short)
- dbusint32=short
- ;;
-$ac_cv_sizeof_int)
- dbusint32=int
- ;;
-$ac_cv_sizeof_long)
- dbusint32=long
- ;;
-esac
-
-if test -z "$dbusint32" ; then
- DBUS_INT32_TYPE="no_int32_type_detected"
- AC_MSG_ERROR([No 32-bit integer type found])
-else
- DBUS_INT32_TYPE="$dbusint32"
- AC_MSG_RESULT($DBUS_INT32_TYPE)
-fi
-
-AC_SUBST(DBUS_INT32_TYPE)
-
-### see what 16-bit int is called
-AC_MSG_CHECKING([16-bit integer type])
-
-case 2 in
-$ac_cv_sizeof_short)
- dbusint16=short
- ;;
-$ac_cv_sizeof_int)
- dbusint16=int
- ;;
-esac
-
-if test -z "$dbusint16" ; then
- DBUS_INT16_TYPE="no_int16_type_detected"
- AC_MSG_ERROR([No 16-bit integer type found])
-else
- DBUS_INT16_TYPE="$dbusint16"
- AC_MSG_RESULT($DBUS_INT16_TYPE)
-fi
-
-AC_SUBST(DBUS_INT16_TYPE)
-
-## byte order
-case $host_os in
- darwin*)
- # check at compile-time, so that it is possible to build universal
- # (with multiple architectures at once on the compile line)
- AH_VERBATIM([WORDS_BIGENDIAN_DARWIN], [
- /* Use the compiler-provided endianness defines to allow universal compiling. */
- #if defined(__BIG_ENDIAN__)
- #define WORDS_BIGENDIAN 1
- #endif
- ])
- ;;
- *)
- AC_C_BIGENDIAN
- ;;
-esac
-
-# As a GNU extension, glibc declares environ in unistd.h, which is one of
-# the AC_INCLUDES_DEFAULT.
-AC_CHECK_DECLS([environ])
-
-dnl **********************************
-dnl *** va_copy checks (from GLib) ***
-dnl **********************************
-dnl we currently check for all three va_copy possibilities, so we get
-dnl all results in config.log for bug reports.
-AC_CACHE_CHECK([for an implementation of va_copy()],dbus_cv_va_copy,[
- AC_LINK_IFELSE([AC_LANG_SOURCE([#include <stdarg.h>
-#include <stdlib.h>
- static void f (int i, ...) {
- va_list args1, args2;
- va_start (args1, i);
- va_copy (args2, args1);
- if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
- exit (1);
- va_end (args1); va_end (args2);
- }
- int main() {
- f (0, 42);
- return 0;
- }])],
- [dbus_cv_va_copy=yes],
- [dbus_cv_va_copy=no])
-])
-AC_CACHE_CHECK([for an implementation of __va_copy()],dbus_cv___va_copy,[
- AC_LINK_IFELSE([AC_LANG_SOURCE([#include <stdarg.h>
-#include <stdlib.h>
- static void f (int i, ...) {
- va_list args1, args2;
- va_start (args1, i);
- __va_copy (args2, args1);
- if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
- exit (1);
- va_end (args1); va_end (args2);
- }
- int main() {
- f (0, 42);
- return 0;
- }])],
- [dbus_cv___va_copy=yes],
- [dbus_cv___va_copy=no])
-])
-
-if test "x$dbus_cv_va_copy" = "xyes"; then
- dbus_va_copy_func=va_copy
-else if test "x$dbus_cv___va_copy" = "xyes"; then
- dbus_va_copy_func=__va_copy
-fi
-fi
-
-AS_IF([test -n "$dbus_va_copy_func"],
- [AC_DEFINE_UNQUOTED([DBUS_VA_COPY], [$dbus_va_copy_func], [A 'va_copy' style function])],
- [AC_MSG_ERROR([dbus requires an ISO C99-compatible va_copy() macro, or a compatible __va_copy(), or MSVC >= 2010 and CMake])])
-
-#### Atomic integers
-
-AC_CACHE_CHECK([whether $CC knows __sync_sub_and_fetch()],
- dbus_cv_sync_sub_and_fetch,
- [AC_LINK_IFELSE([
- AC_LANG_PROGRAM([[]], [[int a = 4; int b = __sync_sub_and_fetch(&a, 4); exit(b); ]])],
- [dbus_cv_sync_sub_and_fetch=yes],
- [dbus_cv_sync_sub_and_fetch=no])
- ])
-
-if test "x$dbus_cv_sync_sub_and_fetch" = "xyes" ; then
- have_sync=1
-else
- have_sync=0
-fi
-
-AC_DEFINE_UNQUOTED([DBUS_USE_SYNC], [$have_sync], [Use the gcc __sync extension])
-
-#### Various functions
-AC_SEARCH_LIBS(socket,[socket network])
-AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])
-
-AC_CHECK_HEADERS([syslog.h])
-if test "x$ac_cv_header_syslog_h" = "xyes"; then
- AC_CHECK_DECLS([LOG_PERROR], [], [], [[#include <syslog.h>]])
-fi
-
-AC_MSG_CHECKING(for dirfd)
-AC_LINK_IFELSE([AC_LANG_PROGRAM([[
-#include <sys/types.h>
-#include <dirent.h>
-]], [[
-DIR *dirp;
-dirp = opendir(".");
-dirfd(dirp);
-closedir(dirp);
-]])],
-[dbus_have_dirfd=yes],
-[dbus_have_dirfd=no])
-AC_MSG_RESULT($dbus_have_dirfd)
-if test "$dbus_have_dirfd" = yes; then
- AC_DEFINE(HAVE_DIRFD,1,[Have dirfd function])
-else
- AC_MSG_CHECKING(for DIR *dirp->dd_fd)
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[
-#include <sys/types.h>
-#include <dirent.h>
- ]], [[
-DIR *dirp;
-int fd;
-dirp = opendir(".");
-fd = dirp->dd_fd;
-closedir(dirp);
- ]])],
- [dbus_have_ddfd=yes],
- [dbus_have_ddfd=no])
- AC_MSG_RESULT($dbus_have_ddfd)
- if test "$dbus_have_ddfd" = yes; then
- AC_DEFINE(HAVE_DDFD,1,[Have the ddfd member of DIR])
- fi
-fi
-
-AC_CHECK_HEADERS([execinfo.h],
- [AC_SEARCH_LIBS([backtrace], [execinfo],
- [AC_DEFINE([HAVE_BACKTRACE], [1],
- [Define to 1 if you have backtrace().])])])
-
-# Add -D_POSIX_PTHREAD_SEMANTICS if on Solaris
-#
-case $host_os in
- solaris*)
- CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS" ;;
-esac
-
-AC_CHECK_FUNCS_ONCE([getpwnam_r])
-
-dnl check for socklen_t
-AC_MSG_CHECKING(whether socklen_t is defined)
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-]], [[
-socklen_t foo;
-foo = 1;
-]])],
-[dbus_have_socklen_t=yes],
-[dbus_have_socklen_t=no])
-AC_MSG_RESULT($dbus_have_socklen_t)
-
-if test "x$dbus_have_socklen_t" = "xyes"; then
- AC_DEFINE(HAVE_SOCKLEN_T,1,[Have socklen_t type])
-fi
-
-dnl check for writev header and writev function so we're
-dnl good to go if HAVE_WRITEV gets defined.
-AC_CHECK_HEADERS(sys/uio.h, [AC_CHECK_FUNCS(writev)])
-
-dnl Make it easy to check if we have MSG_NOSIGNAL without actually having to include sys/socket.h
-AC_CHECK_DECLS([MSG_NOSIGNAL], [], [], [[ #include <sys/types.h>
-#include <sys/socket.h> ]])
-
-dnl Check for various credentials.
-AC_MSG_CHECKING(for struct cmsgcred)
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <sys/types.h>
-#include <sys/socket.h>
-]], [[
-struct cmsgcred cred;
-
-cred.cmcred_pid = 0;
-]])],
-[dbus_have_struct_cmsgcred=yes],
-[dbus_have_struct_cmsgcred=no])
-AC_MSG_RESULT($dbus_have_struct_cmsgcred)
-
-if test x$dbus_have_struct_cmsgcred = xyes; then
- AC_DEFINE(HAVE_CMSGCRED,1,[Have cmsgcred structure])
-fi
-
-AC_CHECK_MEMBER([struct unpcbid.unp_pid],
- [AC_DEFINE([HAVE_UNPCBID], 1, [Have unpcbid structure])],
- [],
- [[#include <sys/un.h>]])
-
-PKG_CHECK_MODULES([EXPAT], [expat])
-
-save_cflags="$CFLAGS"
-save_libs="$LIBS"
-CFLAGS="$CFLAGS $EXPAT_CFLAGS"
-LIBS="$LIBS $EXPAT_LIBS"
-AC_CHECK_FUNCS([XML_SetHashSalt])
-CFLAGS="$save_cflags"
-LIBS="$save_libs"
-
-# Thread lib detection
-AC_ARG_VAR([THREAD_LIBS])
-save_libs="$LIBS"
-LIBS="$LIBS $THREAD_LIBS"
-
-is_missing_pthread_function="is required when compiling D-Bus on Unix platforms, but is not in your libc or libpthread. Please open a bug on https://bugs.freedesktop.org/enter_bug.cgi?product=dbus with details of your platform."
-
-# Don't do these automatic checks if the user set THREAD_LIBS on the
-# configure command-line. If they did, we assume they're right.
-#
-# We also don't do these checks on Windows, because you don't need magical
-# linker flags to have threading support there.
-AS_IF([test "x$dbus_unix" = xyes && test "x$THREAD_LIBS" = x],
- [
- # Mandatory pthread functions. In principle, some of these could be made
- # optional if there are platforms that don't have them.
- #
- # Currently, we only look in -lpthread.
- # In principle we might need to look in -lpthreads, -lthreads, ...
- # as well - please file a bug if your platform needs this.
- AC_SEARCH_LIBS([pthread_cond_timedwait],
- [pthread],
- [THREAD_LIBS="$LIBS"],
- [AC_MSG_ERROR([pthread_cond_timedwait $is_missing_pthread_function])],
- [])
- AC_SEARCH_LIBS([pthread_mutexattr_init],
- [pthread],
- [THREAD_LIBS="$LIBS"],
- [AC_MSG_ERROR([pthread_mutexattr_init $is_missing_pthread_function])],
- [])
- AC_SEARCH_LIBS([pthread_mutexattr_settype],
- [pthread],
- [THREAD_LIBS="$LIBS"],
- [AC_MSG_ERROR([pthread_mutexattr_settype $is_missing_pthread_function])],
- [])
-
- # Optional, for monotonic clocks. Because it's optional, this check
- # is non-fatal if we don't find it.
- AC_SEARCH_LIBS([pthread_condattr_setclock],
- [pthread],
- [THREAD_LIBS="$LIBS"])
-
- AS_IF([test "x$ac_cv_search_pthread_condattr_setclock" != xno],
- [
- AC_SEARCH_LIBS([clock_getres], [rt], [THREAD_LIBS="$LIBS"])
- AC_MSG_CHECKING([for CLOCK_MONOTONIC])
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[#include <time.h>
-#include <pthread.h>
-]], [[
-struct timespec monotonic_timer;
-pthread_condattr_t attr;
-pthread_condattr_init (&attr);
-pthread_condattr_setclock (&attr, CLOCK_MONOTONIC);
-clock_getres (CLOCK_MONOTONIC,&monotonic_timer);
-]])],
- [have_clock_monotonic=true],
- [have_clock_monotonic=false])
- AS_IF([test x$have_clock_monotonic = xtrue],
- [
- AC_MSG_RESULT([found])
- AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1, [Define if we have CLOCK_MONOTONIC])
- ],
- [AC_MSG_RESULT([not found])])
- ]) dnl have pthread_condattr_setclock
- ]) dnl on Unix
-
-LIBS="$save_libs"
-
-AC_SUBST([THREAD_LIBS])
-
-# SELinux detection
-if test x$enable_selinux = xno ; then
- have_selinux=no;
-else
- # See if we have SELinux library
- PKG_CHECK_MODULES([SELINUX], [libselinux >= 2.0.86],
- [have_selinux=yes], [have_selinux=no])
-
- if test x$enable_selinux = xauto ; then
- if test x$have_selinux = xno ; then
- AC_MSG_WARN([Sufficiently new SELinux library not found])
- fi
- else
- if test x$have_selinux = xno ; then
- AC_MSG_ERROR([SElinux explicitly required, and SELinux library not found])
- fi
- fi
-fi
-
-AM_CONDITIONAL(HAVE_SELINUX, test x$have_selinux = xyes)
-
-if test x$have_selinux = xyes ; then
- # the selinux code creates threads
- # which requires libpthread even on linux
- AC_CHECK_FUNC(pthread_create,,[AC_CHECK_LIB(pthread,pthread_create,
- [SELINUX_THREAD_LIBS="-lpthread"])])
-
- SELINUX_LIBS="$SELINUX_LIBS $SELINUX_THREAD_LIBS"
- AC_DEFINE(HAVE_SELINUX,1,[SELinux support])
-else
- SELINUX_LIBS=
-fi
-
-# AppArmor detection
-AS_IF([test x$enable_apparmor = xno],
- [have_apparmor=no],
- [
- PKG_CHECK_MODULES([APPARMOR], [libapparmor >= 2.8.95],
- [have_apparmor=yes], [have_apparmor=no])
- PKG_CHECK_MODULES([APPARMOR_2_10], [libapparmor >= 2.10],
- [have_apparmor_2_10=yes], [have_apparmor_2_10=no])
-
- AS_IF([test x$enable_apparmor = xauto && test x$have_apparmor = xno],
- [AC_MSG_WARN([Sufficiently new AppArmor library not found])])
- AS_IF([test x$enable_apparmor != xauto && test x$have_apparmor = xno],
- [AC_MSG_ERROR([AppArmor explicitly required, and AppArmor library not found])])
- ])
-
-AS_IF([test x$have_apparmor = xyes],
- [AC_DEFINE([HAVE_APPARMOR], [1], [AppArmor Support])])
-AS_IF([test x$have_apparmor_2_10 = xyes],
- [AC_DEFINE([HAVE_APPARMOR_2_10], [1],
- [Define if libapparmor is version 2.10 or later])])
-
-# inotify checks
-if test x$enable_inotify = xno ; then
- have_inotify=no;
-else
- AC_CHECK_HEADERS(sys/inotify.h, have_inotify=yes, have_inotify=no)
-fi
-
-dnl check if inotify backend is enabled
-if test x$have_inotify = xyes; then
- AC_DEFINE(DBUS_BUS_ENABLE_INOTIFY,1,[Use inotify])
-fi
-
-AM_CONDITIONAL(DBUS_BUS_ENABLE_INOTIFY, test x$have_inotify = xyes)
-
-# For simplicity, we require the userland API for epoll_create1 at
-# compile-time (glibc 2.9), but we'll run on kernels that turn out
-# not to have it at runtime.
-AC_ARG_ENABLE([epoll],
- [AS_HELP_STRING([--enable-epoll],[use epoll(4) on Linux])],
- [enable_epoll=$enableval], [enable_epoll=auto])
-if test x$enable_epoll = xno; then
- have_linux_epoll=no
-else
- AC_MSG_CHECKING([for Linux epoll(4)])
- AC_LINK_IFELSE([AC_LANG_PROGRAM(
- [
- #ifndef __linux__
- #error This is not Linux
- #endif
- #include <sys/epoll.h>
- ],
- [epoll_create1 (EPOLL_CLOEXEC);])],
- [have_linux_epoll=yes],
- [have_linux_epoll=no])
- AC_MSG_RESULT([$have_linux_epoll])
-fi
-if test x$enable_epoll,$have_linux_epoll = xyes,no; then
- AC_MSG_ERROR([epoll support explicitly enabled but not available])
-fi
-if test x$have_linux_epoll = xyes; then
- AC_DEFINE([DBUS_HAVE_LINUX_EPOLL], 1, [Define to use epoll(4) on Linux])
-fi
-AM_CONDITIONAL([DBUS_HAVE_LINUX_EPOLL], [test x$have_linux_epoll = xyes])
-
-# kqueue checks
-if test x$enable_kqueue = xno ; then
- have_kqueue=no
-else
- have_kqueue=yes
- AC_CHECK_HEADER(sys/event.h, , have_kqueue=no)
- AC_CHECK_FUNC(kqueue, , have_kqueue=no)
-
- if test x$enable_kqueue = xyes -a x$have_kqueue = xno; then
- AC_MSG_ERROR(kqueue support explicitly enabled but not available)
- fi
-fi
-
-dnl check if kqueue backend is enabled
-if test x$have_kqueue = xyes; then
- AC_DEFINE(DBUS_BUS_ENABLE_KQUEUE,1,[Use kqueue])
-fi
-
-AM_CONDITIONAL(DBUS_BUS_ENABLE_KQUEUE, test x$have_kqueue = xyes)
-
-# launchd checks
-if test x$enable_launchd = xno ; then
- have_launchd=no
-else
- have_launchd=yes
- AC_CHECK_HEADER([launch.h], , have_launchd=no)
- AC_PATH_PROG([LAUNCHCTL], [launchctl])
- if test "x$LAUNCHCTL" = "x"; then
- have_launchd=no
- fi
-
- if test x$enable_launchd = xyes && test x$have_launchd = xno ; then
- AC_MSG_ERROR([launchd support explicitly enabled but not available])
- fi
-fi
-
-dnl check if launchd is enabled
-if test x$have_launchd = xyes; then
- AC_DEFINE(DBUS_ENABLE_LAUNCHD,1,[Use launchd autolaunch])
-fi
-
-AM_CONDITIONAL(DBUS_ENABLE_LAUNCHD, test x$have_launchd = xyes)
-
-#### Directory to place launchd agent file
-if test "x$with_launchd_agent_dir" = "x"; then
- LAUNCHD_AGENT_DIR="/Library/LaunchAgents"
-else
- LAUNCHD_AGENT_DIR="$with_launchd_agent_dir"
-fi
-
-AC_SUBST(LAUNCHD_AGENT_DIR)
-
-dnl console owner file
-if test x$enable_console_owner_file = xno ; then
- have_console_owner_file=no;
-else
- case $host_os in
- solaris*)
- have_console_owner_file=yes;
- AC_DEFINE(HAVE_CONSOLE_OWNER_FILE,1,[Have console owner file])
- ;;
- *)
- have_console_owner_file=no;;
- esac
-fi
-
-AM_CONDITIONAL(HAVE_CONSOLE_OWNER_FILE, test x$have_console_owner_file = xyes)
-
-dnl systemd detection
-if test x$enable_systemd = xno ; then
- have_systemd=no;
-else
- PKG_CHECK_MODULES([SYSTEMD],
- [libsystemd >= 209],
- [have_systemd=yes],
- [PKG_CHECK_MODULES([SYSTEMD],
- [libsystemd-login >= 32, libsystemd-daemon >= 32, libsystemd-journal >= 32],
- [have_systemd=yes],
- [have_systemd=no])])
-fi
-
-if test x$have_systemd = xyes; then
- AC_DEFINE(HAVE_SYSTEMD,1,[Have systemd])
-fi
-
-if test x$enable_systemd = xyes -a x$have_systemd != xyes ; then
- AC_MSG_ERROR([Explicitly requested systemd support, but systemd not found])
-fi
-
-AS_IF([test "x$enable_traditional_activation" = xyes],
- AC_DEFINE(ENABLE_TRADITIONAL_ACTIVATION,[1], [Enable traditional activation without using systemd])
- AS_IF([test "x$enable_systemd" = xno],
- AC_MSG_WARN([Traditional activation and systemd activation are both disabled, so service activation (automatically starting services that receive messages) will not work])))
-
-AM_CONDITIONAL(ENABLE_TRADITIONAL_ACTIVATION, test x$enable_traditional_activation = xyes)
-
-# If not found in $PATH, we might still have systemd and systemctl at runtime
-# (perhaps dbus is being compiled in a minimal chroot with no systemd).
-# Assume the upstream-recommended location. Distributors with split /usr
-# can override this with ./configure SYSTEMCTL=/bin/systemctl
-AC_PATH_PROG([SYSTEMCTL], [systemctl], [/usr/bin/systemctl])
-
-# libaudit detection
-if test x$enable_libaudit = xno ; then
- have_libaudit=no;
-else
- # See if we have audit daemon & capabilities library
- AC_CHECK_LIB(audit, audit_log_user_avc_message,
- have_libaudit=yes, have_libaudit=no)
- if test x$have_libaudit = xyes ; then
- AC_CHECK_LIB(cap-ng, capng_clear,
- have_libaudit=yes, have_libaudit=no)
- fi
-fi
-
-AM_CONDITIONAL(HAVE_LIBAUDIT, test x$have_libaudit = xyes)
-
-if test x$have_libaudit = xyes ; then
- SELINUX_LIBS="$SELINUX_LIBS -laudit -lcap-ng"
- AC_DEFINE(HAVE_LIBAUDIT,1,[audit daemon SELinux support])
-fi
-
-AC_SUBST([SELINUX_LIBS])
-
-# Check for ADT API (Solaris Basic Security Mode auditing)
-AC_MSG_CHECKING(for ADT API)
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <bsm/adt.h>
-adt_user_context = ADT_USER;
-]], [[]])], [ check_adt_audit=yes ], [ check_adt_audit=no ])
-
-if test ${check_adt_audit} = yes
-then
- AC_DEFINE([HAVE_ADT], [], [Adt audit API])
- ADT_LIBS="-lbsm"
- LIBS="-lbsm $LIBS"
- AC_MSG_RESULT(yes)
-else
- AC_MSG_RESULT(no)
-fi
-AC_SUBST([ADT_LIBS])
-
-# Check for SCM_RIGHTS
-AC_MSG_CHECKING([for SCM_RIGHTS])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-static int x = SCM_RIGHTS;
-]], [[]])],
-[ AC_MSG_RESULT([supported])
- AC_DEFINE([HAVE_UNIX_FD_PASSING], [1], [Supports sending UNIX file descriptors]) ],
-[ AC_MSG_RESULT([not supported]) ])
-
-NETWORK_libs=
-if test x$dbus_win = xyes ; then
- if test x$dbus_wince = xyes ; then
- NETWORK_libs="-lws2"
- else
- NETWORK_libs="-lws2_32 -liphlpapi -ldbghelp"
- fi
-fi
-
-AC_SUBST([NETWORK_libs])
-
-AC_ARG_WITH([valgrind],
- [AS_HELP_STRING([--with-valgrind],
- [Add instrumentation to help valgrind to understand our allocator])],
- [],
- [with_valgrind=no])
-
-AS_IF([test "x$with_valgrind" = xauto],
- [PKG_CHECK_EXISTS([valgrind >= 3.6],
- [with_valgrind=yes], [with_valgrind=no])])
-
-if test x$with_valgrind != xno; then
- PKG_CHECK_MODULES([VALGRIND], [valgrind >= 3.6])
- AC_DEFINE([WITH_VALGRIND], [1], [Define to add Valgrind instrumentation])
-fi
-
-#### Set up final flags
-LIBDBUS_LIBS="$THREAD_LIBS $NETWORK_libs $SYSTEMD_LIBS"
-AC_SUBST([LIBDBUS_LIBS])
-
-### X11 detection
-DBUS_X_LIBS=
-DBUS_X_CFLAGS=
-
-AC_ARG_ENABLE([x11-autolaunch],
- AS_HELP_STRING([--enable-x11-autolaunch], [build with X11 auto-launch support]),
- [], [enable_x11_autolaunch=auto])
-
-if test "x$dbus_win" = xyes; then
- if test "x$enable_x11_autolaunch" = xyes; then
- AC_MSG_ERROR([X11 auto-launch is not supported on Windows])
- fi
-
- enable_x11_autolaunch=no
- have_x11=no
-else
- AC_PATH_XTRA
-
- if test "x$no_x" = xyes; then
- have_x11=no
- else
- have_x11=yes
- DBUS_X_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
- DBUS_X_CFLAGS="$X_CFLAGS"
- fi
-fi
-
-if test "x$enable_x11_autolaunch,$have_x11" = xyes,no; then
- AC_MSG_ERROR([X11 auto-launch requires X headers/libraries])
-else
- # move from "auto" to "yes" or "no" if necessary
- if test "x$enable_x11_autolaunch" != xno; then
- enable_x11_autolaunch="$have_x11"
- fi
-fi
-
-if test "x$have_x11" = xyes ; then
- AC_DEFINE([DBUS_BUILD_X11], [1], [Define to build X11 functionality])
-fi
-
-if test "x$enable_x11_autolaunch" = xyes ; then
- AC_DEFINE([DBUS_ENABLE_X11_AUTOLAUNCH], [1], [Define to enable X11 auto-launch])
-fi
-AM_CONDITIONAL([DBUS_ENABLE_X11_AUTOLAUNCH],
- [test "x$enable_x11_autolaunch" = xyes])
-
-AC_SUBST([DBUS_X_CFLAGS])
-AC_SUBST([DBUS_X_LIBS])
-
-# We're treating -fno-common like a warning: it makes the linker more
-# strict, because on some systems the linker is *always* this strict
-TEST_CFLAGS="$TEST_CFLAGS -fno-common"
-
-AS_IF([test "x$enable_ansi" = "xyes"],[
- TEST_CFLAGS="$TEST_CFLAGS -ansi -pedantic"
- AC_DEFINE([_POSIX_C_SOURCE],[199309L],[Define to enable POSIX features])
- AC_DEFINE([_BSD_SOURCE],[1],[Define to enable BSD features])
- ])
-
-dnl We are only calling this for its side-effect of setting up
-dnl --enable-compile-warnings; the WARN_CFLAGS, etc. are ignored,
-dnl to work around https://github.com/peti/autoconf-archive/pull/96
-AX_COMPILER_FLAGS([], [], [$disable_developer])
-
-dnl Work around https://github.com/peti/autoconf-archive/pull/96 by using
-dnl a non-default variable name here (in particular there is no way to tell
-dnl AX_COMPILER_FLAGS to not use WARN_CXXFLAGS)
-AX_COMPILER_FLAGS_CFLAGS([EXTRA_CFLAGS],
- [$disable_developer],
- [$TEST_CFLAGS],
- [-Wchar-subscripts \
- -Wfloat-equal \
- -Wpointer-sign \
- $DISABLE_WARNINGS])
-dnl cc1plus: warning: command line option ‘-Wpointer-sign’ is valid for
-dnl C/ObjC but not for C++
-AX_COMPILER_FLAGS_CXXFLAGS([EXTRA_CXXFLAGS],
- [$disable_developer],
- [],
- [-Wchar-subscripts \
- -Wfloat-equal \
- $DISABLE_WARNINGS])
-AX_COMPILER_FLAGS_LDFLAGS([EXTRA_LDFLAGS],
- [$disable_developer])
-
-dnl TODO: In principle we should put EXTRA_CFLAGS in each Makefile.am like
-dnl telepathy-glib does, since CFLAGS is meant to be reserved for the user...
-dnl but prepending to CFLAGS (so the user can override it with later CFLAGS)
-dnl is the next best thing.
-CFLAGS="$EXTRA_CFLAGS $CFLAGS"
-CXXFLAGS="$EXTRA_CXXFLAGS $CXXFLAGS"
-LDFLAGS="$EXTRA_LDFLAGS $LDFLAGS"
-
-AC_ARG_VAR([SANITIZE_CFLAGS],
- [Extra CFLAGS for modules that are instrumented for error-checking])
-
-case $host_os in
- solaris*)
- # Solaris' C library apparently needs these runes to be threadsafe...
- CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT"
- # ... this opt-in to get sockaddr_in6 and sockaddr_storage...
- CFLAGS="$CFLAGS -D__EXTENSIONS__"
- # ... and this opt-in to get file descriptor passing support
- CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500"
- ;;
-esac
-
-### Detect if ld supports --version-script
-
-gl_LD_VERSION_SCRIPT
-AM_CONDITIONAL([HAVE_LD_VERSION_SCRIPT],
- [test "x$have_ld_version_script" = xyes])
-### Doxygen Documentation
-
-AC_PATH_PROG(DOXYGEN, doxygen, no)
-
-AC_MSG_CHECKING([whether to build Doxygen documentation])
-
-if test x$DOXYGEN = xno ; then
- have_doxygen=no
-else
- have_doxygen=yes
-fi
-
-if test x$enable_doxygen_docs = xauto ; then
- if test x$have_doxygen = xno ; then
- enable_doxygen_docs=no
- else
- enable_doxygen_docs=yes
- fi
-fi
-
-if test x$enable_doxygen_docs = xyes; then
- if test x$have_doxygen = xno; then
- AC_MSG_ERROR([Building Doxygen docs explicitly required, but Doxygen not found])
- fi
-fi
-
-if test x$dbus_win = xno; then
- DBUS_GENERATE_MAN=YES
-else
- DBUS_GENERATE_MAN=NO
-fi
-AC_SUBST([DBUS_GENERATE_MAN])
-
-AM_CONDITIONAL(DBUS_DOXYGEN_DOCS_ENABLED, test x$enable_doxygen_docs = xyes)
-AC_MSG_RESULT($enable_doxygen_docs)
-
-AC_ARG_WITH([qchdir],
- AS_HELP_STRING([--with-qchdir=DIR], [Directory for installing Qt help file]),
- [qchdir=$withval],
- [qchdir="$docdir"])
-AC_SUBST([qchdir])
-
-AC_ARG_ENABLE([qt-help],
- [AS_HELP_STRING([--enable-qt-help=auto|yes|no], [Build Qt help documentation])],
- [],
- [enable_qt_help=auto])
-AS_IF([test "x$enable_qt_help" != xno],
- [AC_CHECK_PROGS([QHELPGENERATOR], [qhelpgenerator qhelpgenerator-qt5])],
- [QHELPGENERATOR=])
-AS_IF([test "x$QHELPGENERATOR" = x && test "x$enable_qt_help" != xno && test "x$enable_qt_help" != xauto],
- [AC_MSG_ERROR([Building of Qt help requested, but qhelpgenerator not found])])
-
-AC_MSG_CHECKING([whether to build Qt help documentation])
-AS_IF([test "x$enable_doxygen_docs" = xyes && test "x$QHELPGENERATOR" != x], [
- enable_qthelp_docs=yes
- DOXYGEN_GENERATE_QHP=YES
- DOXYGEN_QHG_LOCATION="$QHELPGENERATOR"
- DOXYGEN_QCH_FILE="$(pwd)/doc/api/qch/dbus-$VERSION.qch"
- ], [
- DOXYGEN_GENERATE_QHP=NO
- enable_qthelp_docs=no
- ])
-AC_SUBST([DOXYGEN_GENERATE_QHP])
-AC_SUBST([DOXYGEN_QHG_LOCATION])
-AC_SUBST([DOXYGEN_QCH_FILE])
-
-AM_CONDITIONAL([DBUS_QTHELP_DOCS_ENABLED], [test "x$enable_qthelp_docs" = xyes])
-AC_MSG_RESULT($enable_qthelp_docs)
-
-AC_CHECK_PROGS([XSLTPROC], [xsltproc])
-AM_CONDITIONAL([DBUS_HAVE_XSLTPROC], [test "x$XSLTPROC" != "x"])
-
-### Ducktype/Yelp documentation
-
-AC_PATH_PROG([DUCKTYPE],[ducktype],[no])
-AC_PATH_PROG([YELP_BUILD],[yelp-build],[no])
-
-AC_MSG_CHECKING([whether to build Ducktype documentation])
-
-AS_IF([test "$DUCKTYPE" = "no"],[have_ducktype=no],[have_ducktype=yes])
-AS_IF([test "$YELP_BUILD" = "no"],[have_yelp_build=no],[have_yelp_build=yes])
-
-AS_IF([test "$enable_ducktype_docs" = "auto"],[
- AS_IF([test "$have_ducktype" = "no" || test "$have_yelp_build" = "no"],[
- enable_ducktype_docs=no
- ],[
- enable_ducktype_docs=yes
- ])
-])
-
-AS_IF([test "$enable_ducktype_docs" = "yes"],[
- AS_IF([test "$have_ducktype" = "no"],[
- AC_MSG_ERROR([Building Ducktype docs explicitly required, but ducktype not found])
- ])
- AS_IF([test "$have_yelp_build" = "no"],[
- AC_MSG_ERROR([Building Ducktype docs explicitly required, but yelp-build not found])
- ])
-])
-
-AM_CONDITIONAL([DBUS_DUCKTYPE_DOCS_ENABLED],[test "$enable_ducktype_docs" = "yes"])
-AC_MSG_RESULT([$enable_ducktype_docs])
-
-### XML Documentation
-
-AC_PATH_PROG(XMLTO, xmlto, no)
-
-AC_MSG_CHECKING([whether to build XML documentation])
-
-if test x$XMLTO = xno ; then
- have_xmlto=no
-else
- have_xmlto=yes
-fi
-
-if test x$enable_xml_docs = xauto ; then
- if test x$have_xmlto = xno ; then
- enable_xml_docs=no
- else
- enable_xml_docs=yes
- fi
-fi
-
-if test x$enable_xml_docs = xyes; then
- if test x$have_xmlto = xno; then
- AC_MSG_ERROR([Building XML docs explicitly required, but xmlto not found])
- fi
-fi
-
-AM_CONDITIONAL(DBUS_XML_DOCS_ENABLED, test x$enable_xml_docs = xyes)
-AC_MSG_RESULT($enable_xml_docs)
-
-AM_CONDITIONAL(DBUS_CAN_UPLOAD_DOCS,
- [test x$enable_doxygen_docs = xyes && test x$enable_xml_docs = xyes &&
- test x$enable_ducktype_docs = xyes])
-
-# Autoconf 2.70 will support this, and many distros patch this option in,
-# but Autoconf 2.70 hasn't actually been released yet.
-AS_IF([test -z "${runstatedir}"], [runstatedir='${localstatedir}/run'])
-AC_SUBST([runstatedir])
-
-#### Have to go $localstatedir->$prefix/var->/usr/local/var
-
-#### find the actual value for $prefix that we'll end up with
-## (I know this is broken and should be done in the Makefile, but
-## that's a major pain and almost nobody actually seems to care)
-AS_AC_EXPAND(EXPANDED_PREFIX, "$prefix")
-AS_AC_EXPAND(EXPANDED_LOCALSTATEDIR, "$localstatedir")
-AS_AC_EXPAND(EXPANDED_SYSCONFDIR, "$sysconfdir")
-AS_AC_EXPAND(EXPANDED_BINDIR, "$bindir")
-AS_AC_EXPAND(EXPANDED_LIBDIR, "$libdir")
-AS_AC_EXPAND(EXPANDED_LIBEXECDIR, "$libexecdir")
-AS_AC_EXPAND(EXPANDED_DATADIR, "$datadir")
-AS_AC_EXPAND(EXPANDED_RUNSTATEDIR, "$runstatedir")
-
-##### systemd unit files
-AC_ARG_WITH([systemdsystemunitdir],
-AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
- [],
- [
- PKG_CHECK_EXISTS([systemd],
- [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)],
- [with_systemdsystemunitdir=no])
- ])
-if test "x$with_systemdsystemunitdir" != xno; then
- AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
-fi
-AM_CONDITIONAL(HAVE_SYSTEMD, [test "x$have_systemd" != "xno" -a -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
-
-AC_ARG_WITH([systemduserunitdir],
-AS_HELP_STRING([--with-systemduserunitdir=DIR], [Directory for systemd user service files]),
- [],
- [
- PKG_CHECK_EXISTS([systemd],
- [with_systemduserunitdir=$($PKG_CONFIG --variable=systemduserunitdir systemd)],
- [with_systemduserunitdir='${libdir}/systemd/user'])
- ])
-AC_SUBST([systemduserunitdir], [$with_systemduserunitdir])
-
-##### Set up location for system bus socket
-if ! test -z "$with_system_socket"; then
- DBUS_SYSTEM_SOCKET=$with_system_socket
-else
- # We don't use runstatedir for this (yet?), because /var/run has been the
- # interoperable system bus socket for 10+ years.
- # See https://bugs.freedesktop.org/show_bug.cgi?id=101628
- DBUS_SYSTEM_SOCKET=${EXPANDED_LOCALSTATEDIR}/run/dbus/system_bus_socket
-fi
-
-AC_SUBST(DBUS_SYSTEM_SOCKET)
-AC_DEFINE_UNQUOTED(DBUS_SYSTEM_SOCKET,"$DBUS_SYSTEM_SOCKET",[The name of the socket the system bus listens on by default])
-
-## System bus only listens on local domain sockets, and never
-## on an abstract socket (so only root can create the socket).
-##
-## This won't work on Windows. It's not meant to - the system bus is
-## meaningless on Windows anyway.
-##
-## This has to be suitable for hard-coding in client libraries as well as
-## in the dbus-daemon's configuration, so it has to be valid to listen on
-## and also to connect to. If this ever changes, it'll need to be split into
-## two variables, one for the listening address and one for the connecting
-## address.
-DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="unix:path=$DBUS_SYSTEM_SOCKET"
-AC_SUBST(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS)
-AC_DEFINE_UNQUOTED(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS, "$DBUS_SYSTEM_BUS_DEFAULT_ADDRESS",[The default D-Bus address of the system bus])
-
-#### Set up the pid file
-if ! test -z "$with_system_pid_file"; then
- DBUS_SYSTEM_PID_FILE=$with_system_pid_file
-else
- DBUS_SYSTEM_PID_FILE="${EXPANDED_RUNSTATEDIR}/dbus/pid"
-fi
-
-AC_SUBST(DBUS_SYSTEM_PID_FILE)
-
-#### Directory to check for console ownership
-AS_IF([test -n "$with_console_auth_dir" && test "x$with_console_auth_dir" != xno],
- [AC_DEFINE_UNQUOTED([DBUS_CONSOLE_AUTH_DIR], ["$with_console_auth_dir"],
- [Directory to check for pam_console/pam_foreground flag files, or undefined])],
- [with_console_auth_dir=])
-
-#### File to check for console ownership
-if test x$have_console_owner_file = xyes; then
- if ! test -z "$with_console_owner_file"; then
- DBUS_CONSOLE_OWNER_FILE=$with_console_owner_file
- else
- DBUS_CONSOLE_OWNER_FILE=/dev/console
- fi
-else
- DBUS_CONSOLE_OWNER_FILE=
-fi
-
-AC_SUBST(DBUS_CONSOLE_OWNER_FILE)
-AC_DEFINE_UNQUOTED(DBUS_CONSOLE_OWNER_FILE, "$DBUS_CONSOLE_OWNER_FILE", [File to check for console ownerhip])
-
-#### User to start the system bus as
-if test -z "$with_dbus_user" ; then
- DBUS_USER=messagebus
-else
- DBUS_USER=$with_dbus_user
-fi
-AC_SUBST(DBUS_USER)
-AC_DEFINE_UNQUOTED(DBUS_USER,"$DBUS_USER", [User for running the system BUS daemon])
-
-#### User for regression tests
-AS_IF([test -z "$with_test_user"], [with_test_user=nobody])
-DBUS_TEST_USER="$with_test_user"
-AC_SUBST([DBUS_TEST_USER])
-AC_DEFINE_UNQUOTED([DBUS_TEST_USER], ["$DBUS_TEST_USER"],
- [Unprivileged user used in some regression tests])
-
-#### Prefix to install into
-DBUS_PREFIX=$EXPANDED_PREFIX
-AC_SUBST(DBUS_PREFIX)
-AC_DEFINE_UNQUOTED(DBUS_PREFIX,"$DBUS_PREFIX", [Prefix for installing DBUS])
-
-#### Direcotry to install data files into
-DBUS_DATADIR=$EXPANDED_DATADIR
-AC_SUBST(DBUS_DATADIR)
-AC_DEFINE_UNQUOTED(DBUS_DATADIR,"$DBUS_DATADIR", [Directory for installing DBUS data files])
-
-#### Directory to install dbus-daemon
-if test -z "$with_dbus_daemondir" ; then
- DBUS_DAEMONDIR=$EXPANDED_BINDIR
- dbus_daemondir='${bindir}'
-else
- DBUS_DAEMONDIR=$with_dbus_daemondir
- dbus_daemondir=$with_dbus_daemondir
-fi
-AC_SUBST(DBUS_DAEMONDIR)
-AC_SUBST(dbus_daemondir)
-AC_DEFINE_UNQUOTED(DBUS_DAEMONDIR,"$DBUS_DAEMONDIR", [Directory for installing the DBUS daemon])
-
-#### Directory to install the other binaries
-DBUS_BINDIR="$EXPANDED_BINDIR"
-AC_SUBST(DBUS_BINDIR)
-AC_DEFINE_UNQUOTED(DBUS_BINDIR,"$DBUS_BINDIR", [Directory for installing the binaries])
-
-#### Directory to install the libexec binaries
-DBUS_LIBEXECDIR="$EXPANDED_LIBEXECDIR"
-AC_SUBST(DBUS_LIBEXECDIR)
-AC_DEFINE_UNQUOTED(DBUS_LIBEXECDIR,"$DBUS_LIBEXECDIR", [Directory for installing the libexec binaries])
-
-AC_ARG_ENABLE([relocation],
- [AS_HELP_STRING([--enable-relocation[=yes/no/auto]],
- [Make pkg-config metadata relocatable [default=auto]])],
- [], [enable_relocation=auto])
-
-can_relocate=yes
-
-AS_CASE(["${exec_prefix}"],
- ['NONE'|'${prefix}'|"${prefix}"],
- [:],
- [*],
- [
- can_relocate=no
- # If the user said --enable-relocation but we can't do it, error out
- AS_IF([test "x$enable_relocation" = xyes],
- [AC_MSG_ERROR([Relocatable pkg-config metadata requires --exec-prefix='\${prefix}', not ${exec_prefix}])])
- ])
-
-AS_CASE(["${libdir}"],
- ['${prefix}/lib'|'${prefix}/lib64'|'${exec_prefix}/lib'|'${exec_prefix}/lib64'|"${prefix}/lib"|"${exec_prefix}/lib"|"${prefix}/lib64"|"${exec_prefix}/lib64"],
- [:],
- [*],
- [
- can_relocate=no
- # If the user said --enable-relocation but we can't do it, error out
- AS_IF([test "x$enable_relocation" = xyes],
- [AC_MSG_ERROR([Relocatable pkg-config metadata requires default libdir, not ${libdir}])])
- ])
-
-# By default, on Windows we are relocatable if possible
-AS_IF([test "x$enable_relocation" = xauto && test "x$dbus_win" = xyes],
- [enable_relocation="$can_relocate"])
-
-# By default, on non-Windows we are not relocatable because it can interfere
-# with pkg-config's ability to filter out system include directories,
-# resulting in linking an outdated system-wide library in preference to a
-# newer version installed elsewhere
-AS_IF([test "x$enable_relocation" = xauto],
- [enable_relocation="no"])
-
-
-AS_IF([test "x$enable_relocation" = xyes],
- [AC_SUBST([pkgconfig_prefix], ['${pcfiledir}/../..'])],
- [AC_SUBST([pkgconfig_prefix], ['${original_prefix}'])])
-
-#### Directory to source sysconfdir configuration from
-
-# On Windows this is relative to where we put the bus setup, in
-# ${datadir}/dbus-1. For simplicity, we only do this if
-# ${sysconfdir} = ${prefix}/etc and ${datadir} = ${prefix}/share.
-#
-# On Unix, or on Windows with weird install layouts, it's the absolute path.
-AS_IF([test "${dbus_win}" = yes && \
- test "$EXPANDED_SYSCONFDIR" = "$EXPANDED_PREFIX/etc" && \
- test "$EXPANDED_DATADIR" = "$EXPANDED_PREFIX/share"],
- [SYSCONFDIR_FROM_PKGDATADIR="../../etc"
- DATADIR_FROM_PKGSYSCONFDIR="../../share"],
- [SYSCONFDIR_FROM_PKGDATADIR="$EXPANDED_SYSCONFDIR"
- DATADIR_FROM_PKGSYSCONFDIR="$EXPANDED_DATADIR"])
-AC_SUBST([SYSCONFDIR_FROM_PKGDATADIR])
-AC_SUBST([DATADIR_FROM_PKGSYSCONFDIR])
-
-#### Tell tests where to find certain stuff in builddir
-
-DBUS_PWD=`pwd`
-# Useful in a cross-compilation environment, where the tests are run on the host system.
-AC_ARG_WITH(dbus-test-dir, AS_HELP_STRING([--with-dbus-test-dir=[dirname]],[path where the tests tools are available]),
- DBUS_PWD=$withval)
-
-DBUS_TEST_EXEC="$DBUS_PWD/test"
-DBUS_TEST_DATA="$DBUS_PWD/test/data"
-
-AC_SUBST([DBUS_TEST_DATA])
-AC_SUBST([DBUS_TEST_EXEC])
-
-AC_DEFINE_UNQUOTED([DBUS_EXEEXT], ["$EXEEXT"],
- [Extension for executables, typically empty or .exe])
-
-## Export the non-setuid external helper
-TEST_LAUNCH_HELPER_BINARY="$DBUS_TEST_EXEC/dbus-daemon-launch-helper-for-tests$EXEEXT"
-AC_SUBST(TEST_LAUNCH_HELPER_BINARY)
-AC_DEFINE_UNQUOTED(DBUS_TEST_LAUNCH_HELPER_BINARY, "$TEST_LAUNCH_HELPER_BINARY",
- [Full path to the launch helper test program in the builddir])
-
-#### Find socket directories
-if ! test -z "$TMPDIR" ; then
- DEFAULT_SOCKET_DIR=$TMPDIR
-elif ! test -z "$TEMP" ; then
- DEFAULT_SOCKET_DIR=$TEMP
-elif ! test -z "$TMP" ; then
- DEFAULT_SOCKET_DIR=$TMP
-else
- DEFAULT_SOCKET_DIR=/tmp
-fi
-
-DEFAULT_SOCKET_DIR=`echo $DEFAULT_SOCKET_DIR | sed 's/+/%2B/g'`
-
-if ! test -z "$with_test_socket_dir" ; then
- TEST_SOCKET_DIR="$with_test_socket_dir"
-else
- TEST_SOCKET_DIR=$DEFAULT_SOCKET_DIR
-fi
-AC_SUBST(TEST_SOCKET_DIR)
-AC_DEFINE_UNQUOTED(DBUS_TEST_SOCKET_DIR, "$TEST_SOCKET_DIR", [Where to put test sockets])
-
-if test "x$dbus_unix" = xyes; then
- TEST_LISTEN="unix:tmpdir=$TEST_SOCKET_DIR"
-else
- TEST_LISTEN="tcp:host=localhost"
-fi
-AC_SUBST([TEST_LISTEN])
-AC_DEFINE_UNQUOTED([TEST_LISTEN], ["$TEST_LISTEN"],
- [Listening address for regression tests])
-
-if ! test -z "$with_session_socket_dir" ; then
- DBUS_SESSION_SOCKET_DIR="$with_session_socket_dir"
-else
- DBUS_SESSION_SOCKET_DIR=$DEFAULT_SOCKET_DIR
-fi
-AC_DEFINE_UNQUOTED(DBUS_SESSION_SOCKET_DIR, "$DBUS_SESSION_SOCKET_DIR", [Where per-session bus puts its sockets])
-AC_SUBST(DBUS_SESSION_SOCKET_DIR)
-
-# This must be a listening address. It doesn't necessarily need to be an
-# address you can connect to - it can be something vague like
-# "nonce-tcp:".
-#
-# The default varies by platform.
-AC_ARG_WITH([dbus_session_bus_listen_address],
- AS_HELP_STRING([--with-dbus-session-bus-listen-address=[ADDRESS]],
- [default address for a session bus to listen on (see configure.ac)]),
- [with_dbus_session_bus_listen_address=$withval],
- [with_dbus_session_bus_listen_address=])
-
-if test "x$with_dbus_session_bus_listen_address" != "x"; then
- # the user specified something, trust them
- DBUS_SESSION_BUS_LISTEN_ADDRESS="$with_dbus_session_bus_listen_address"
-elif test x$dbus_win = xyes; then
- # On Windows, you can (and should) listen on autolaunch addresses,
- # because autolaunching is different.
- # See https://bugs.freedesktop.org/show_bug.cgi?id=38201
- DBUS_SESSION_BUS_LISTEN_ADDRESS="autolaunch:"
-elif test x$have_launchd = xyes; then
- # Mac OS X default is to use launchd
- DBUS_SESSION_BUS_LISTEN_ADDRESS="launchd:env=DBUS_LAUNCHD_SESSION_BUS_SOCKET"
-else
- # The default on all other Unix platforms (notably Linux)
- # is to create a randomly named socket in /tmp or similar
- DBUS_SESSION_BUS_LISTEN_ADDRESS="unix:tmpdir=$DBUS_SESSION_SOCKET_DIR"
-fi
-AC_SUBST([DBUS_SESSION_BUS_LISTEN_ADDRESS])
-
-# This must be an address you can connect to. It doesn't necessarily
-# need to be an address you can listen on - it can be "autolaunch:",
-# even on Unix.
-#
-# The default varies by platform.
-AC_ARG_WITH([dbus_session_bus_connect_address],
- AS_HELP_STRING([--with-dbus-session-bus-connect-address=[ADDRESS]],
- [fallback address for a session bus client to connect to (see configure.ac)]),
- [with_dbus_session_bus_connect_address=$withval],
- [with_dbus_session_bus_connect_address=])
-
-if test "x$with_dbus_session_bus_connect_address" != "x"; then
- # the user specified something, trust them
- DBUS_SESSION_BUS_CONNECT_ADDRESS="$with_dbus_session_bus_connect_address"
-elif test x$dbus_win = xyes; then
- # Windows autolaunching is a bit different; leaving it in its own
- # branch of the conditional because the default might conceivably
- # change (see #38201)
- DBUS_SESSION_BUS_CONNECT_ADDRESS="autolaunch:"
-else
- # The default on all other Unix platforms (notably Linux)
- # is to use auto-launching - this works a bit differently on Mac OS X
- # but comes out basically the same in the end
- DBUS_SESSION_BUS_CONNECT_ADDRESS="autolaunch:"
-fi
-AC_SUBST([DBUS_SESSION_BUS_CONNECT_ADDRESS])
-AC_DEFINE_UNQUOTED([DBUS_SESSION_BUS_CONNECT_ADDRESS],
- ["$DBUS_SESSION_BUS_CONNECT_ADDRESS"],
- [Fallback address for session bus clients])
-
-# darwin needs this to initialize the environment
-AC_CHECK_FUNC(_NSGetEnviron, [AC_DEFINE(HAVE_NSGETENVIRON, 1, [Define if your system needs _NSGetEnviron to set up the environment])])
-AH_VERBATIM(_DARWIN_ENVIRON,
-[
-#if defined(HAVE_NSGETENVIRON) && defined(HAVE_CRT_EXTERNS_H)
-# include <sys/time.h>
-# include <crt_externs.h>
-# define environ (*_NSGetEnviron())
-#endif
-])
-
-AC_ARG_ENABLE([stats],
- [AS_HELP_STRING([--disable-stats],
- [disable bus daemon usage statistics])],
- [], [enable_stats=yes])
-if test "x$enable_stats" = xyes; then
- AC_DEFINE([DBUS_ENABLE_STATS], [1],
- [Define to enable bus daemon usage statistics])
-fi
-
-AC_ARG_ENABLE([user-session],
- [AS_HELP_STRING([--enable-user-session],
- [enable user-session semantics for session bus under systemd])],
- [], [enable_user_session=no])
-AM_CONDITIONAL([DBUS_ENABLE_USER_SESSION],
- [test "x$enable_user_session" = xyes])
-
-AC_ARG_ENABLE([containers],
- [AS_HELP_STRING([--enable-containers],
- [enable restricted servers for app containers])],
- [], [enable_containers=no])
-AS_IF([test "x$enable_containers" = xyes && test "x$dbus_unix" != xyes],
- [AC_MSG_ERROR([Restricted servers for app containers require Unix])])
-AS_IF([test "x$enable_containers" = xyes],
- [AC_DEFINE([DBUS_ENABLE_CONTAINERS], [1],
- [Define to enable restricted servers for app containers])])
-
-AC_CONFIG_FILES([
-Doxyfile
-dbus/Version
-dbus/versioninfo.rc
-dbus/dbus-arch-deps.h
-bus/system.conf
-bus/session.conf
-bus/legacy-config/system.conf
-bus/legacy-config/session.conf
-bus/example-system-enable-stats.conf
-bus/example-session-disable-stats.conf
-bus/org.freedesktop.dbus-session.plist
-bus/dbus.service
-bus/dbus.socket
-bus/systemd-user/dbus.service
-bus/systemd-user/dbus.socket
-bus/sysusers.d/dbus.conf
-bus/tmpfiles.d/dbus.conf
-Makefile
-dbus/Makefile
-bus/Makefile
-tools/Makefile
-test/Makefile
-test/name-test/Makefile
-doc/Makefile
-doc/dbus-cleanup-sockets.1.xml
-doc/dbus-daemon.1.xml
-doc/dbus-launch.1.xml
-doc/dbus-monitor.1.xml
-doc/dbus-run-session.1.xml
-doc/dbus-send.1.xml
-doc/dbus-test-tool.1.xml
-doc/dbus-update-activation-environment.1.xml
-doc/dbus-uuidgen.1.xml
-doc/index.html
-dbus-1.pc
-dbus-1-uninstalled.pc
-cmake/DBus1Config.cmake:cmake/DBus1Config.pkgconfig.in
-cmake/DBus1ConfigVersion.cmake
-])
-AC_OUTPUT
-
-dnl ==========================================================================
-echo "
- D-Bus $VERSION
- ==============
-
- prefix: ${EXPANDED_PREFIX}
- exec_prefix: ${exec_prefix}
- libdir: ${EXPANDED_LIBDIR}
- libexecdir: ${EXPANDED_LIBEXECDIR}
- bindir: ${EXPANDED_BINDIR}
- sysconfdir: ${EXPANDED_SYSCONFDIR}
- localstatedir: ${EXPANDED_LOCALSTATEDIR}
- runstatedir: ${EXPANDED_RUNSTATEDIR}
- datadir: ${EXPANDED_DATADIR}
- source code location: ${srcdir}
- compiler: ${CC}
- cflags: ${CFLAGS}
- cppflags: ${CPPFLAGS}
- cxxflags: ${CXXFLAGS}
- ldflags: ${LDFLAGS}
- 64-bit int: ${DBUS_INT64_TYPE}
- 32-bit int: ${DBUS_INT32_TYPE}
- 16-bit int: ${DBUS_INT16_TYPE}
- Doxygen: ${DOXYGEN:-not found}
- xmlto: ${XMLTO:-not found}
- ducktype: ${DUCKTYPE:-not found}
- yelp-build: ${YELP_BUILD:-not found}"
-
-echo "
- Rebuilding generated files: ${USE_MAINTAINER_MODE}
- gcc coverage profiling: ${enable_code_coverage}
- Building embedded tests: ${enable_embedded_tests}
- Building modular tests: ${enable_modular_tests}
- - with GLib: ${with_glib}
- Installing tests: ${enable_installed_tests}
- Building verbose mode: ${enable_verbose_mode}
- Building assertions: ${enable_asserts}
- Building checks: ${enable_checks}
- Building bus stats API: ${enable_stats}
- Building container API: ${enable_containers}
- Building SELinux support: ${have_selinux}
- Building AppArmor support: ${have_apparmor}
- Building inotify support: ${have_inotify}
- Building kqueue support: ${have_kqueue}
- Building systemd support: ${have_systemd}
- Traditional activation: ${enable_traditional_activation}
- Building X11 code: ${have_x11}
- Building Doxygen docs: ${enable_doxygen_docs}
- Building Qt help file: ${enable_qthelp_docs}
- Building Ducktype docs: ${enable_ducktype_docs}
- Building XML docs: ${enable_xml_docs}
- Building launchd support: ${have_launchd}
- System bus socket: ${DBUS_SYSTEM_SOCKET}
- System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS}
- System bus PID file: ${DBUS_SYSTEM_PID_FILE}
- Session bus listens on: ${DBUS_SESSION_BUS_LISTEN_ADDRESS}
- Session clients connect to: ${DBUS_SESSION_BUS_CONNECT_ADDRESS}
- pam_console auth dir: ${with_console_auth_dir:-(none)}
- Console owner file: ${have_console_owner_file}
- Console owner file path: ${DBUS_CONSOLE_OWNER_FILE}
- System bus user: ${DBUS_USER}
- Session bus services dir: ${EXPANDED_DATADIR}/dbus-1/services
- 'make check' socket dir: ${TEST_SOCKET_DIR}
-"
-if test x$have_launchd = xyes; then
- echo " launchd agent dir: ${LAUNCHD_AGENT_DIR}"
-fi
-echo
-
-if test x$enable_embedded_tests = xyes; then
- echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure."
-fi
-if test x$enable_embedded_tests = xyes -a x$enable_asserts = xno; then
- echo "NOTE: building with embedded tests but without assertions means tests may not properly report failures (this configuration is only useful when doing something like profiling the tests)"
-fi
-AS_IF([test x$enable_code_coverage = xyes],[
- AC_MSG_WARN([Building with coverage profiling is definitely for developers only.])
- ])
-if test x$enable_verbose_mode = xyes; then
- echo "NOTE: building with verbose mode increases library size, may slightly increase security risk, and decreases performance."
-fi
-if test x$enable_asserts = xyes; then
- echo "NOTE: building with assertions increases library size and decreases performance."
-fi
-if test x$enable_checks = xno; then
- echo "NOTE: building without checks for arguments passed to public API makes it harder to debug apps using D-Bus, but will slightly decrease D-Bus library size and _very_ slightly improve performance."
-fi
diff --git a/dbus-1-uninstalled.pc.in b/dbus-1-uninstalled.pc.in
deleted file mode 100644
index b66ad2f6..00000000
--- a/dbus-1-uninstalled.pc.in
+++ /dev/null
@@ -1,20 +0,0 @@
-abs_top_builddir=@abs_top_builddir@
-abs_top_srcdir=@abs_top_srcdir@
-prefix=
-exec_prefix=
-bindir=@bindir@
-system_bus_default_address=@DBUS_SYSTEM_BUS_DEFAULT_ADDRESS@
-datarootdir=@datarootdir@
-datadir=@datadir@
-sysconfdir=@sysconfdir@
-session_bus_services_dir=${datadir}/dbus-1/services
-system_bus_services_dir=${datadir}/dbus-1/system-services
-interfaces_dir=${datadir}/dbus-1/interfaces
-daemondir=@dbus_daemondir@
-
-Name: dbus
-Description: Free desktop message bus (uninstalled copy)
-Version: @VERSION@
-Libs: ${abs_top_builddir}/dbus/libdbus-1.la
-Libs.private: @LIBDBUS_LIBS@
-Cflags: -I${abs_top_srcdir} @DBUS_STATIC_BUILD_CPPFLAGS@
diff --git a/dbus/CMakeLists.txt b/dbus/CMakeLists.txt
index a603a1aa..1f545ba6 100644
--- a/dbus/CMakeLists.txt
+++ b/dbus/CMakeLists.txt
@@ -89,7 +89,6 @@ set(DBUS_LIB_HEADERS
dbus-resources.h
dbus-server-debug-pipe.h
dbus-server-protected.h
- dbus-server-unix.h
dbus-sha.h
dbus-timeout.h
dbus-threads.h
@@ -98,7 +97,7 @@ set(DBUS_LIB_HEADERS
dbus-transport-protected.h
dbus-uuidgen.h
dbus-watch.h
- ${CMAKE_BINARY_DIR}/config.h
+ ${PROJECT_BINARY_DIR}/config.h
)
if(UNIX)
set(DBUS_LIB_HEADERS ${DBUS_LIB_HEADERS}
@@ -135,6 +134,7 @@ set(DBUS_SHARED_HEADERS
dbus-hash.h
dbus-internals.h
dbus-list.h
+ dbus-macros-internal.h
dbus-marshal-basic.h
dbus-mempool.h
dbus-string.h
@@ -177,6 +177,7 @@ set(DBUS_UTIL_HEADERS
### platform specific settings
if(WIN32)
set(DBUS_SHARED_SOURCES ${DBUS_SHARED_SOURCES}
+ dbus-backtrace-win.c
dbus-file-win.c
dbus-init-win.cpp
dbus-sysdeps-win.c
@@ -184,6 +185,7 @@ if(WIN32)
dbus-sysdeps-thread-win.c
)
set(DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS}
+ dbus-init-win.h
dbus-sockets-win.h
dbus-sysdeps-win.h
)
@@ -208,7 +210,6 @@ else(WIN32)
dbus-userdb.c
)
set(DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS}
- dbus-server-unix.h
dbus-transport-unix.h
dbus-sysdeps-unix.h
dbus-userdb.h
@@ -292,8 +293,14 @@ else(WIN32)
if(LIBSOCKET)
target_link_libraries(dbus-1 ${LIBSOCKET})
endif()
+ if (HAVE_BACKTRACE)
+ target_link_libraries(dbus-1 ${Backtrace_LIBRARY})
+ target_include_directories(dbus-1 PRIVATE ${Backtrace_INCLUDE_DIR})
+ endif()
endif()
+target_include_directories(dbus-1 INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/dbus-1.0>;$<INSTALL_INTERFACE:${CMAKE_INSTALL_LIBDIR}/dbus-1.0/include>)
+
# Assume that Linux has -Wl,--version-script and other platforms do not
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(SOVERSION ${DBUS_LIBRARY_MAJOR})
diff --git a/dbus/Makefile.am b/dbus/Makefile.am
deleted file mode 100644
index 7a71f468..00000000
--- a/dbus/Makefile.am
+++ /dev/null
@@ -1,335 +0,0 @@
-
-dbusdatadir=$(datadir)/dbus-1
-
-AM_CPPFLAGS = \
- $(CODE_COVERAGE_CPPFLAGS) \
- -I$(top_builddir) \
- -I$(top_srcdir) \
- $(DBUS_STATIC_BUILD_CPPFLAGS) \
- $(SYSTEMD_CFLAGS) \
- $(VALGRIND_CFLAGS) \
- -DDBUS_COMPILATION \
- -DDBUS_MACHINE_UUID_FILE=\""$(localstatedir)/lib/dbus/machine-id"\" \
- -DDBUS_SYSTEM_CONFIG_FILE=\""$(dbusdatadir)/system.conf"\" \
- -DDBUS_SESSION_CONFIG_FILE=\""$(dbusdatadir)/session.conf"\" \
- -DDBUS_RUNSTATEDIR=\""$(runstatedir)"\" \
- $(NULL)
-
-AM_CFLAGS = \
- $(CODE_COVERAGE_CFLAGS) \
- $(SANITIZE_CFLAGS) \
- $(NULL)
-
-if HAVE_VISIBILITY
-if !DBUS_WIN
-AM_CFLAGS += $(CFLAG_VISIBILITY)
-AM_CPPFLAGS += \
- -DDBUS_EXPORT='__attribute__((__visibility__("default")))' \
- -DDBUS_PRIVATE_EXPORT='__attribute__((__visibility__("default")))' \
- $(NULL)
-endif
-endif
-
-# if assertions are enabled, improve backtraces
-AM_LDFLAGS = @R_DYNAMIC_LDFLAG@
-
-dbusincludedir=$(includedir)/dbus-1.0/dbus
-dbusarchincludedir=$(libdir)/dbus-1.0/include/dbus
-
-lib_LTLIBRARIES=libdbus-1.la
-
-# Initialize to empty so that we can append later
-nodist_libdbus_1_la_SOURCES =
-
-#
-# Deal with W32 .def and version-info.rc stuff
-#
-if DBUS_WIN
-
-SUFFIXES = .rc
-
-.rc.lo:
- $(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $< -o $@
-
-endif
-
-
-#
-# Platform-dependent sources:
-#
-if DBUS_WIN
-DBUS_LIB_arch_sources = \
- dbus-server-win.c \
- dbus-server-win.h \
- $(NULL)
-
-nodist_libdbus_1_la_SOURCES += \
- versioninfo.rc \
- $(NULL)
-
-if DBUS_WINCE
-wince_source = dbus-sysdeps-wince-glue.h dbus-sysdeps-wince-glue.c
-else
-wince_source =
-endif
-
-DBUS_SHARED_arch_sources = \
- $(wince_source) \
- dbus-file-win.c \
- dbus-pipe-win.c \
- dbus-sockets-win.h \
- dbus-sysdeps-win.c \
- dbus-sysdeps-win.h \
- dbus-sysdeps-thread-win.c \
- dbus-transport-win.c \
- dbus-transport-win.h
-
-DBUS_UTIL_arch_sources = \
- dbus-sysdeps-util-win.c
-
-if ENABLE_TRADITIONAL_ACTIVATION
-DBUS_UTIL_arch_sources += dbus-spawn-win.c
-endif
-
-else
-
-if DBUS_ENABLE_LAUNCHD
-launchd_source = dbus-server-launchd.h dbus-server-launchd.c
-else
-launchd_source =
-endif
-
-DBUS_LIB_arch_sources = \
- dbus-uuidgen.c \
- dbus-uuidgen.h \
- dbus-server-unix.c \
- dbus-server-unix.h
-
-DBUS_SHARED_arch_sources = \
- $(launchd_source) \
- dbus-file-unix.c \
- dbus-pipe-unix.c \
- dbus-sysdeps-unix.c \
- dbus-sysdeps-unix.h \
- dbus-sysdeps-pthread.c \
- dbus-transport-unix.c \
- dbus-transport-unix.h \
- dbus-userdb.c \
- dbus-userdb.h \
- $(NULL)
-
-DBUS_UTIL_arch_sources = \
- dbus-sysdeps-util-unix.c \
- dbus-userdb-util.c \
- $(NULL)
-
-if ENABLE_TRADITIONAL_ACTIVATION
-DBUS_UTIL_arch_sources += dbus-spawn-unix.c
-endif
-endif
-
-if DBUS_HAVE_LINUX_EPOLL
-DBUS_UTIL_arch_sources += dbus-pollable-set-epoll.c
-endif
-
-dbusinclude_HEADERS= \
- dbus.h \
- dbus-address.h \
- dbus-bus.h \
- dbus-connection.h \
- dbus-errors.h \
- dbus-macros.h \
- dbus-memory.h \
- dbus-message.h \
- dbus-misc.h \
- dbus-pending-call.h \
- dbus-protocol.h \
- dbus-server.h \
- dbus-shared.h \
- dbus-signature.h \
- dbus-syntax.h \
- dbus-threads.h \
- dbus-types.h
-
-
-nodist_dbusarchinclude_HEADERS= \
- dbus-arch-deps.h
-
-### source code that goes in the installed client library
-### and is specific to library functionality
-DBUS_LIB_SOURCES= \
- dbus-address.c \
- dbus-auth.c \
- dbus-auth.h \
- dbus-bus.c \
- dbus-connection.c \
- dbus-connection-internal.h \
- dbus-credentials.c \
- dbus-credentials.h \
- dbus-errors.c \
- dbus-keyring.c \
- dbus-keyring.h \
- dbus-marshal-header.c \
- dbus-marshal-header.h \
- dbus-marshal-byteswap.c \
- dbus-marshal-byteswap.h \
- dbus-marshal-recursive.c \
- dbus-marshal-recursive.h \
- dbus-marshal-validate.c \
- dbus-marshal-validate.h \
- dbus-message.c \
- dbus-message-internal.h \
- dbus-message-private.h \
- dbus-misc.c \
- dbus-nonce.h \
- dbus-nonce.c \
- dbus-object-tree.c \
- dbus-object-tree.h \
- dbus-pending-call.c \
- dbus-pending-call-internal.h \
- dbus-resources.c \
- dbus-resources.h \
- dbus-server.c \
- dbus-server-debug-pipe.c \
- dbus-server-debug-pipe.h \
- dbus-server-protected.h \
- dbus-server-socket.c \
- dbus-server-socket.h \
- $(DBUS_LIB_arch_sources) \
- dbus-sha.c \
- dbus-sha.h \
- dbus-signature.c \
- dbus-syntax.c \
- dbus-timeout.c \
- dbus-timeout.h \
- dbus-threads-internal.h \
- dbus-threads.c \
- dbus-transport.c \
- dbus-transport.h \
- dbus-transport-protected.h \
- dbus-transport-socket.c \
- dbus-transport-socket.h \
- dbus-watch.c \
- dbus-watch.h
-
-### source code that goes in the installed client library
-### AND is generic utility functionality used by the
-### daemon or test programs (all symbols in here should
-### be underscore-prefixed)
-DBUS_SHARED_SOURCES= \
- dbus-dataslot.c \
- dbus-dataslot.h \
- dbus-file.c \
- dbus-file.h \
- dbus-hash.c \
- dbus-hash.h \
- dbus-internals.c \
- dbus-internals.h \
- dbus-list.c \
- dbus-list.h \
- dbus-marshal-basic.c \
- dbus-marshal-basic.h \
- dbus-memory.c \
- dbus-mempool.c \
- dbus-mempool.h \
- dbus-pipe.c \
- dbus-pipe.h \
- dbus-string.c \
- dbus-string.h \
- dbus-string-private.h \
- $(DBUS_SHARED_arch_sources) \
- dbus-sysdeps.c \
- dbus-sysdeps.h \
- dbus-valgrind-internal.h
-
-if DBUS_ENABLE_EMBEDDED_TESTS
-DBUS_SHARED_SOURCES += \
- dbus-test-tap.c \
- dbus-test-tap.h \
- $(NULL)
-# else they are included in the test library instead
-endif
-
-### source code that is generic utility functionality used
-### by the bus daemon or test apps, but is NOT included
-### in the D-Bus client library (all symbols in here
-### should be underscore-prefixed but don't really need
-### to be unless they move to DBUS_SHARED_SOURCES later)
-DBUS_UTIL_SOURCES= \
- dbus-asv-util.c \
- dbus-asv-util.h \
- dbus-mainloop.c \
- dbus-mainloop.h \
- dbus-message-util.c \
- dbus-shell.c \
- dbus-shell.h \
- $(DBUS_UTIL_arch_sources) \
- dbus-pollable-set.h \
- dbus-pollable-set.c \
- dbus-pollable-set-poll.c \
- dbus-spawn.h \
- dbus-string-util.c \
- dbus-sysdeps-util.c \
- dbus-test.h
-
-libdbus_1_la_SOURCES= \
- $(DBUS_LIB_SOURCES) \
- $(DBUS_SHARED_SOURCES)
-
-libdbus_internal_la_SOURCES= \
- $(DBUS_UTIL_SOURCES)
-
-BUILT_SOURCES=$(nodist_dbusarchinclude_HEADERS)
-EXTRA_DIST=dbus-arch-deps.h.in
-
-noinst_LTLIBRARIES=libdbus-internal.la
-
-libdbus_1_la_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -Ddbus_1_EXPORTS \
- $(NULL)
-
-if HAVE_LD_VERSION_SCRIPT
-SYMBOL_EXPORT_LDFLAGS=-Wl,--version-script=Version
-else
-SYMBOL_EXPORT_LDFLAGS=
-endif
-
-libdbus_1_la_LIBADD = \
- $(CODE_COVERAGE_LIBS) \
- $(LIBDBUS_LIBS) \
- $(NULL)
-libdbus_1_la_LDFLAGS = \
- $(AM_LDFLAGS) \
- -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
- $(SYMBOL_EXPORT_LDFLAGS) \
- -no-undefined \
- $(NULL)
-
-libdbus_internal_la_LIBADD = \
- $(CODE_COVERAGE_LIBS) \
- $(LIBDBUS_LIBS) \
- libdbus-1.la \
- $(NULL)
-
-if DBUS_WIN
-AM_CXXFLAGS = \
- $(CODE_COVERAGE_CXXFLAGS) \
- $(NULL)
-
-# This must be a separate convenience library, otherwise libtool notices
-# that libdbus-1 might contain C++, links it with g++ and links in libstdc++,
-# even on Unix where in fact it doesn't contain any C++. For Windows, where
-# this code is used, we don't actually need libstdc++.
-noinst_LTLIBRARIES += libdbus-init-win.la
-libdbus_init_win_la_SOURCES = dbus-init-win.cpp
-libdbus_1_la_LIBADD += libdbus-init-win.la
-endif
-
-noinst_PROGRAMS =
-
-# Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE
-include $(top_srcdir)/aminclude_static.am
-
-clean-local:
- $(AM_V_at)rm -fr ./.dbus-keyrings
diff --git a/dbus/dbus-address.c b/dbus/dbus-address.c
index 0eafdb2a..1093d7d1 100644
--- a/dbus/dbus-address.c
+++ b/dbus/dbus-address.c
@@ -6,6 +6,8 @@
* Copyright (C) 2007 Ralf Habacker
* Copyright (C) 2013 Chengwei Yang / Intel
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-address.h b/dbus/dbus-address.h
index 30df4463..c0303430 100644
--- a/dbus/dbus-address.h
+++ b/dbus/dbus-address.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-arch-deps.h.in b/dbus/dbus-arch-deps.h.in
index dfc3589e..9dcb83cd 100644
--- a/dbus/dbus-arch-deps.h.in
+++ b/dbus/dbus-arch-deps.h.in
@@ -2,6 +2,7 @@
/* dbus-arch-deps.h Header with architecture/compiler specific information, installed to libdir
*
* Copyright (C) 2003 Red Hat, Inc.
+ * SPDX-License-Identifier: AFL-2.0 OR GPL-2.0-or-later
*
* Licensed under the Academic Free License version 2.0
*
@@ -35,6 +36,7 @@ DBUS_BEGIN_DECLS
#define DBUS_HAVE_INT64 1
_DBUS_GNUC_EXTENSION typedef @DBUS_INT64_TYPE@ dbus_int64_t;
_DBUS_GNUC_EXTENSION typedef unsigned @DBUS_INT64_TYPE@ dbus_uint64_t;
+#define DBUS_INT64_MODIFIER "@DBUS_INT64_MODIFIER@"
#define DBUS_INT64_CONSTANT(val) (_DBUS_GNUC_EXTENSION @DBUS_INT64_CONSTANT@)
#define DBUS_UINT64_CONSTANT(val) (_DBUS_GNUC_EXTENSION @DBUS_UINT64_CONSTANT@)
@@ -45,6 +47,8 @@ typedef unsigned @DBUS_INT32_TYPE@ dbus_uint32_t;
typedef @DBUS_INT16_TYPE@ dbus_int16_t;
typedef unsigned @DBUS_INT16_TYPE@ dbus_uint16_t;
+#define DBUS_SIZEOF_VOID_P @DBUS_SIZEOF_VOID_P@
+
/* This is not really arch-dependent, but it's not worth
* creating an additional generated header just for this
*/
diff --git a/dbus/dbus-asv-util.c b/dbus/dbus-asv-util.c
index 31cc10ae..5ac0ef2b 100644
--- a/dbus/dbus-asv-util.c
+++ b/dbus/dbus-asv-util.c
@@ -3,6 +3,8 @@
* Copyright © 2011-2012 Nokia Corporation
* Copyright © 2012-2013 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -374,3 +376,42 @@ _dbus_asv_add_byte_array (DBusMessageIter *arr_iter,
return _dbus_asv_add_fixed_array (arr_iter, key, DBUS_TYPE_BYTE, value,
n_elements);
}
+
+/**
+ * Create a new entry in an a{sv} (map from string to variant)
+ * with a Unix file descriptor as value.
+ *
+ * If this function fails, the a{sv} must be abandoned, for instance
+ * with _dbus_asv_abandon().
+ *
+ * The FD remains owned by the caller regardless of the result returned
+ * by this function.
+ *
+ * @param arr_iter the iterator which is appending to the array
+ * @param key a UTF-8 key for the map
+ * @param value the value
+ * @returns #TRUE on success, or #FALSE if not enough memory
+ */
+dbus_bool_t
+_dbus_asv_add_unix_fd (DBusMessageIter *arr_iter,
+ const char *key,
+ int value)
+{
+ DBusMessageIter entry_iter, var_iter;
+
+ if (!_dbus_asv_open_entry (arr_iter, &entry_iter, key,
+ DBUS_TYPE_UNIX_FD_AS_STRING, &var_iter))
+ return FALSE;
+
+ if (!dbus_message_iter_append_basic (&var_iter, DBUS_TYPE_UNIX_FD,
+ &value))
+ {
+ _dbus_asv_abandon_entry (arr_iter, &entry_iter, &var_iter);
+ return FALSE;
+ }
+
+ if (!_dbus_asv_close_entry (arr_iter, &entry_iter, &var_iter))
+ return FALSE;
+
+ return TRUE;
+}
diff --git a/dbus/dbus-asv-util.h b/dbus/dbus-asv-util.h
index f717ae9a..466885ab 100644
--- a/dbus/dbus-asv-util.h
+++ b/dbus/dbus-asv-util.h
@@ -3,6 +3,8 @@
* Copyright © 2011-2012 Nokia Corporation
* Copyright © 2012-2013 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -65,5 +67,8 @@ dbus_bool_t _dbus_asv_close_entry (DBusMessageIter *arr_iter,
void _dbus_asv_abandon_entry (DBusMessageIter *arr_iter,
DBusMessageIter *entry_iter,
DBusMessageIter *var_iter);
+dbus_bool_t _dbus_asv_add_unix_fd (DBusMessageIter *arr_iter,
+ const char *key,
+ int value);
#endif
diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c
index 62b5b13c..09942f80 100644
--- a/dbus/dbus-auth.c
+++ b/dbus/dbus-auth.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003, 2004 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -525,8 +527,8 @@ sha1_handle_first_client_response (DBusAuth *auth,
/* We haven't sent a challenge yet, we're expecting a desired
* username from the client.
*/
- DBusString tmp;
- DBusString tmp2;
+ DBusString tmp = _DBUS_STRING_INIT_INVALID;
+ DBusString tmp2 = _DBUS_STRING_INIT_INVALID;
dbus_bool_t retval = FALSE;
DBusError error = DBUS_ERROR_INIT;
DBusCredentials *myself = NULL;
@@ -557,7 +559,7 @@ sha1_handle_first_client_response (DBusAuth *auth,
if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
{
dbus_error_free (&error);
- goto out;
+ return FALSE;
}
_dbus_verbose ("%s: Did not get a valid username from client: %s\n",
@@ -801,9 +803,13 @@ sha1_handle_second_client_response (DBusAuth *auth,
auth->desired_identity))
goto out_3;
- /* Copy process ID from the socket credentials if it's there
+ /* Copy process ID (and PID FD) from the socket credentials if it's there
*/
if (!_dbus_credentials_add_credential (auth->authorized_identity,
+ DBUS_CREDENTIAL_UNIX_PROCESS_FD,
+ auth->credentials))
+ goto out_3;
+ if (!_dbus_credentials_add_credential (auth->authorized_identity,
DBUS_CREDENTIAL_UNIX_PROCESS_ID,
auth->credentials))
goto out_3;
@@ -1186,6 +1192,11 @@ handle_server_data_external_mech (DBusAuth *auth,
/* also copy misc process info from the socket credentials
*/
if (!_dbus_credentials_add_credential (auth->authorized_identity,
+ DBUS_CREDENTIAL_UNIX_PROCESS_FD,
+ auth->credentials))
+ return FALSE;
+
+ if (!_dbus_credentials_add_credential (auth->authorized_identity,
DBUS_CREDENTIAL_UNIX_PROCESS_ID,
auth->credentials))
return FALSE;
@@ -1302,9 +1313,14 @@ handle_server_data_anonymous_mech (DBusAuth *auth,
/* We want to be anonymous (clear in case some other protocol got midway through I guess) */
_dbus_credentials_clear (auth->desired_identity);
- /* Copy process ID from the socket credentials
+ /* Copy process ID (and PID FD) from the socket credentials
*/
if (!_dbus_credentials_add_credential (auth->authorized_identity,
+ DBUS_CREDENTIAL_UNIX_PROCESS_FD,
+ auth->credentials))
+ return FALSE;
+
+ if (!_dbus_credentials_add_credential (auth->authorized_identity,
DBUS_CREDENTIAL_UNIX_PROCESS_ID,
auth->credentials))
return FALSE;
diff --git a/dbus/dbus-auth.h b/dbus/dbus-auth.h
index 96a8a17c..4612d5a8 100644
--- a/dbus/dbus-auth.h
+++ b/dbus/dbus-auth.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-backtrace-win.c b/dbus/dbus-backtrace-win.c
new file mode 100644
index 00000000..d9bc2dc4
--- /dev/null
+++ b/dbus/dbus-backtrace-win.c
@@ -0,0 +1,213 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/* dbus-backtrace-win.c Backtrace Generator
+ *
+ * Copyright 2004 Eric Poech
+ * Copyright 2004 Robert Shearman
+ * Copyright 2010 Patrick von Reth <patrick.vonreth@gmail.com>
+ * Copyright 2015 Ralf Habacker <ralf.habacker@freenet.de>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <config.h>
+
+#include "dbus-internals.h"
+#include "dbus-sysdeps.h"
+
+#if !defined (DBUS_DISABLE_ASSERT) || defined(DBUS_ENABLE_EMBEDDED_TESTS)
+
+#if defined(_MSC_VER) || defined(DBUS_WINCE)
+# ifdef BACKTRACES
+# undef BACKTRACES
+# endif
+#else
+# define BACKTRACES
+#endif
+
+#ifdef BACKTRACES
+#include "dbus-sysdeps-win.h"
+
+#include <stdio.h>
+#include <windows.h>
+#include <imagehlp.h>
+
+#define DPRINTF(fmt, ...) fprintf (stderr, fmt, ##__VA_ARGS__)
+
+#ifdef _MSC_VER
+#define BOOL int
+
+#define __i386__
+#endif
+
+static void dump_backtrace_for_thread (HANDLE hThread)
+{
+ ADDRESS old_address;
+ STACKFRAME sf;
+ CONTEXT context;
+ DWORD dwImageType;
+ int i = 0;
+
+ SymSetOptions (SYMOPT_UNDNAME | SYMOPT_LOAD_LINES);
+ SymInitialize (GetCurrentProcess (), NULL, TRUE);
+
+
+ /* can't use this function for current thread as GetThreadContext
+ * doesn't support getting context from current thread */
+ if (hThread == GetCurrentThread())
+ return;
+
+ DPRINTF ("Backtrace:\n");
+
+ _DBUS_ZERO (old_address);
+ _DBUS_ZERO (context);
+ context.ContextFlags = CONTEXT_FULL;
+
+ SuspendThread (hThread);
+
+ if (!GetThreadContext (hThread, &context))
+ {
+ DPRINTF ("Couldn't get thread context (error %ld)\n", GetLastError ());
+ ResumeThread (hThread);
+ return;
+ }
+
+ _DBUS_ZERO (sf);
+
+#ifdef __i386__
+ dwImageType = IMAGE_FILE_MACHINE_I386;
+ sf.AddrFrame.Offset = context.Ebp;
+ sf.AddrFrame.Mode = AddrModeFlat;
+ sf.AddrPC.Offset = context.Eip;
+ sf.AddrPC.Mode = AddrModeFlat;
+#elif defined(_M_X64)
+ dwImageType = IMAGE_FILE_MACHINE_AMD64;
+ sf.AddrPC.Offset = context.Rip;
+ sf.AddrPC.Mode = AddrModeFlat;
+ sf.AddrFrame.Offset = context.Rsp;
+ sf.AddrFrame.Mode = AddrModeFlat;
+ sf.AddrStack.Offset = context.Rsp;
+ sf.AddrStack.Mode = AddrModeFlat;
+#elif defined(_M_IA64)
+ dwImageType = IMAGE_FILE_MACHINE_IA64;
+ sf.AddrPC.Offset = context.StIIP;
+ sf.AddrPC.Mode = AddrModeFlat;
+ sf.AddrFrame.Offset = context.IntSp;
+ sf.AddrFrame.Mode = AddrModeFlat;
+ sf.AddrBStore.Offset= context.RsBSP;
+ sf.AddrBStore.Mode = AddrModeFlat;
+ sf.AddrStack.Offset = context.IntSp;
+ sf.AddrStack.Mode = AddrModeFlat;
+#else
+# error You need to fill in the STACKFRAME structure for your architecture
+#endif
+
+ /*
+ backtrace format
+ <level> <address> <symbol>[+offset] [ '[' <file> ':' <line> ']' ] [ 'in' <module> ]
+ example:
+ 6 0xf75ade6b wine_switch_to_stack+0x2a [/usr/src/debug/wine-snapshot/libs/wine/port.c:59] in libwine.so.1
+ */
+ while (StackWalk (dwImageType, GetCurrentProcess (),
+ hThread, &sf, &context, NULL, SymFunctionTableAccess,
+ SymGetModuleBase, NULL))
+ {
+ char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(char)];
+ PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer;
+ DWORD64 displacement;
+ IMAGEHLP_LINE line;
+ DWORD dwDisplacement;
+ IMAGEHLP_MODULE moduleInfo;
+
+ /*
+ on Wine64 version 1.7.54, we get an infinite number of stack entries
+ pointing to the same stack frame (_start+0x29 in <wine-loader>)
+ see bug https://bugs.winehq.org/show_bug.cgi?id=39606
+ */
+#ifndef __i386__
+ if (old_address.Offset == sf.AddrPC.Offset)
+ {
+ break;
+ }
+#endif
+
+ pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
+ pSymbol->MaxNameLen = MAX_SYM_NAME;
+
+ if (SymFromAddr (GetCurrentProcess (), sf.AddrPC.Offset, &displacement, pSymbol))
+ {
+ if (displacement)
+ DPRINTF ("%3d %s+0x%I64x", i++, pSymbol->Name, displacement);
+ else
+ DPRINTF ("%3d %s", i++, pSymbol->Name);
+ }
+ else
+ DPRINTF ("%3d 0x%Ix", i++, sf.AddrPC.Offset);
+
+ line.SizeOfStruct = sizeof(IMAGEHLP_LINE);
+ if (SymGetLineFromAddr (GetCurrentProcess (), sf.AddrPC.Offset, &dwDisplacement, &line))
+ {
+ DPRINTF (" [%s:%ld]", line.FileName, line.LineNumber);
+ }
+
+ moduleInfo.SizeOfStruct = sizeof(moduleInfo);
+ if (SymGetModuleInfo (GetCurrentProcess (), sf.AddrPC.Offset, &moduleInfo))
+ {
+ DPRINTF (" in %s", moduleInfo.ModuleName);
+ }
+ DPRINTF ("\n");
+ old_address = sf.AddrPC;
+ }
+ ResumeThread (hThread);
+}
+
+static DWORD WINAPI dump_thread_proc (LPVOID lpParameter)
+{
+ dump_backtrace_for_thread ((HANDLE) lpParameter);
+ return 0;
+}
+
+/* cannot get valid context from current thread, so we have to execute
+ * backtrace from another thread */
+static void
+dump_backtrace (void)
+{
+ HANDLE hCurrentThread;
+ HANDLE hThread;
+ DWORD dwThreadId;
+ DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
+ GetCurrentProcess (), &hCurrentThread,
+ 0, FALSE, DUPLICATE_SAME_ACCESS);
+ hThread = CreateThread (NULL, 0, dump_thread_proc, (LPVOID)hCurrentThread,
+ 0, &dwThreadId);
+ WaitForSingleObject (hThread, INFINITE);
+ CloseHandle (hThread);
+ CloseHandle (hCurrentThread);
+}
+#endif
+#endif /* asserts or tests enabled */
+
+#ifdef BACKTRACES
+void _dbus_print_backtrace (void)
+{
+ dump_backtrace ();
+}
+#else
+void _dbus_print_backtrace (void)
+{
+ _dbus_verbose (" D-Bus not compiled with backtrace support\n");
+}
+#endif
diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c
index 35fc135e..f0c790df 100644
--- a/dbus/dbus-bus.c
+++ b/dbus/dbus-bus.c
@@ -4,6 +4,8 @@
* Copyright (C) 2003 CodeFactory AB
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-bus.h b/dbus/dbus-bus.h
index c4c602ab..31ade9a6 100644
--- a/dbus/dbus-bus.h
+++ b/dbus/dbus-bus.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-connection-internal.h b/dbus/dbus-connection-internal.h
index de4e55b1..747e6e54 100644
--- a/dbus/dbus-connection-internal.h
+++ b/dbus/dbus-connection-internal.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -55,6 +57,8 @@ DBUS_PRIVATE_EXPORT
DBusConnection * _dbus_connection_ref_unlocked (DBusConnection *connection);
DBUS_PRIVATE_EXPORT
void _dbus_connection_unref_unlocked (DBusConnection *connection);
+DBUS_PRIVATE_EXPORT
+dbus_uint32_t _dbus_connection_get_next_client_serial (DBusConnection *connection);
void _dbus_connection_queue_received_message_link (DBusConnection *connection,
DBusList *link);
dbus_bool_t _dbus_connection_has_messages_to_send_unlocked (DBusConnection *connection);
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
index 159dbe1b..13f5085f 100644
--- a/dbus/dbus-connection.c
+++ b/dbus/dbus-connection.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002-2006 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -316,6 +318,8 @@ struct DBusConnection
unsigned int exit_on_disconnect : 1; /**< If #TRUE, exit after handling disconnect signal */
+ unsigned int builtin_filters_enabled : 1; /**< If #TRUE, handle org.freedesktop.DBus.Peer messages automatically, whether they have a bus name or not */
+
unsigned int route_peer_messages : 1; /**< If #TRUE, if org.freedesktop.DBus.Peer messages have a bus name, don't handle them automatically */
unsigned int disconnected_message_arrived : 1; /**< We popped or are dispatching the disconnected message.
@@ -1343,6 +1347,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport)
connection->objects = objects;
connection->exit_on_disconnect = FALSE;
connection->shareable = FALSE;
+ connection->builtin_filters_enabled = TRUE;
connection->route_peer_messages = FALSE;
connection->disconnected_message_arrived = FALSE;
connection->disconnected_message_processed = FALSE;
@@ -1456,7 +1461,16 @@ _dbus_connection_unref_unlocked (DBusConnection *connection)
_dbus_connection_last_unref (connection);
}
-static dbus_uint32_t
+/**
+ * Allocate and return the next non-zero serial number for outgoing messages.
+ *
+ * This method is only valid to call from single-threaded code, such as
+ * the dbus-daemon, or with the connection lock held.
+ *
+ * @param connection the connection
+ * @returns A suitable serial number for the next message to be sent on the connection.
+ */
+dbus_uint32_t
_dbus_connection_get_next_client_serial (DBusConnection *connection)
{
dbus_uint32_t serial;
@@ -2379,8 +2393,10 @@ check_for_reply_and_update_dispatch_unlocked (DBusConnection *connection,
void
_dbus_connection_block_pending_call (DBusPendingCall *pending)
{
- long start_tv_sec, start_tv_usec;
- long tv_sec, tv_usec;
+ dbus_int64_t start_tv_sec;
+ long start_tv_usec;
+ dbus_int64_t tv_sec;
+ long tv_usec;
DBusDispatchStatus status;
DBusConnection *connection;
dbus_uint32_t client_serial;
@@ -2411,7 +2427,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending)
{
timeout_milliseconds = dbus_timeout_get_interval (timeout);
- _dbus_verbose ("dbus_connection_send_with_reply_and_block(): will block %d milliseconds for reply serial %u from %ld sec %ld usec\n",
+ _dbus_verbose ("dbus_connection_send_with_reply_and_block(): will block %d milliseconds for reply serial %u from %" DBUS_INT64_MODIFIER "d sec %ld usec\n",
timeout_milliseconds,
client_serial,
start_tv_sec, start_tv_usec);
@@ -4657,10 +4673,14 @@ dbus_connection_dispatch (DBusConnection *connection)
goto out;
}
- result = _dbus_connection_run_builtin_filters_unlocked_no_update (connection, message);
- if (result != DBUS_HANDLER_RESULT_NOT_YET_HANDLED)
- goto out;
-
+ /* If skipping builtin filters, we are probably a monitor. */
+ if (connection->builtin_filters_enabled)
+ {
+ result = _dbus_connection_run_builtin_filters_unlocked_no_update (connection, message);
+ if (result != DBUS_HANDLER_RESULT_NOT_YET_HANDLED)
+ goto out;
+ }
+
if (!_dbus_list_copy (&connection->filter_list, &filter_list_copy))
{
_dbus_connection_release_dispatch (connection);
@@ -5533,6 +5553,38 @@ dbus_connection_set_allow_anonymous (DBusConnection *connection,
}
/**
+ * Enables the builtin filtering of messages.
+ *
+ * Currently the only filtering implemented by libdbus and mandated by the spec
+ * is that of peer messages.
+ *
+ * If #TRUE, #DBusConnection automatically handles all messages to the
+ * org.freedesktop.DBus.Peer interface. For monitors this can break the
+ * specification if the response is sending a message.
+ *
+ * If #FALSE, the result is similar to calling
+ * dbus_connection_set_route_peer_messages() with argument TRUE, but
+ * messages with a NULL destination are also dispatched to the
+ * application instead of being passed to the built-in filters.
+ *
+ * If a normal application disables this flag, it can break things badly. So
+ * only unset this if you are a monitor.
+ *
+ * @param connection the connection
+ * @param value #TRUE to pass through org.freedesktop.DBus.Peer messages
+ */
+void
+dbus_connection_set_builtin_filters_enabled (DBusConnection *connection,
+ dbus_bool_t value)
+{
+ _dbus_return_if_fail (connection != NULL);
+
+ CONNECTION_LOCK (connection);
+ connection->builtin_filters_enabled = value;
+ CONNECTION_UNLOCK (connection);
+}
+
+/**
*
* Normally #DBusConnection automatically handles all messages to the
* org.freedesktop.DBus.Peer interface. However, the message bus wants
diff --git a/dbus/dbus-connection.h b/dbus/dbus-connection.h
index 32d79979..b79fda83 100644
--- a/dbus/dbus-connection.h
+++ b/dbus/dbus-connection.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -286,6 +288,9 @@ DBUS_EXPORT
void dbus_connection_set_allow_anonymous (DBusConnection *connection,
dbus_bool_t value);
DBUS_EXPORT
+void dbus_connection_set_builtin_filters_enabled (DBusConnection *connection,
+ dbus_bool_t value);
+DBUS_EXPORT
void dbus_connection_set_route_peer_messages (DBusConnection *connection,
dbus_bool_t value);
diff --git a/dbus/dbus-credentials.c b/dbus/dbus-credentials.c
index 79f0c770..44cd40bf 100644
--- a/dbus/dbus-credentials.c
+++ b/dbus/dbus-credentials.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2007 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -23,8 +25,17 @@
#include <config.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_SYS_SYSCALL_H
+#include <sys/syscall.h>
+#endif
#include "dbus-credentials.h"
#include "dbus-internals.h"
+#ifdef DBUS_UNIX
+#include "dbus-sysdeps-unix.h"
+#endif
/**
* @defgroup DBusCredentials Credentials provable through authentication
@@ -52,6 +63,7 @@ struct DBusCredentials {
dbus_gid_t *unix_gids;
size_t n_unix_gids;
dbus_pid_t pid;
+ int pid_fd;
char *windows_sid;
char *linux_security_label;
void *adt_audit_data;
@@ -84,6 +96,7 @@ _dbus_credentials_new (void)
creds->unix_gids = NULL;
creds->n_unix_gids = 0;
creds->pid = DBUS_PID_UNSET;
+ creds->pid_fd = -1;
creds->windows_sid = NULL;
creds->linux_security_label = NULL;
creds->adt_audit_data = NULL;
@@ -143,12 +156,22 @@ _dbus_credentials_unref (DBusCredentials *credentials)
dbus_free (credentials->windows_sid);
dbus_free (credentials->linux_security_label);
dbus_free (credentials->adt_audit_data);
+#ifdef DBUS_UNIX
+ if (credentials->pid_fd >= 0)
+ {
+ close (credentials->pid_fd);
+ credentials->pid_fd = -1;
+ }
+#endif
dbus_free (credentials);
}
}
/**
- * Add a UNIX process ID to the credentials.
+ * Add a UNIX process ID to the credentials. If the
+ * process ID FD is set, it will always take
+ * precendence when querying the PID of this
+ * credential.
*
* @param credentials the object
* @param pid the process ID
@@ -163,6 +186,30 @@ _dbus_credentials_add_pid (DBusCredentials *credentials,
}
/**
+ * Add a UNIX process ID FD to the credentials. The
+ * FD is now owned by the credentials object.
+ *
+ * @param credentials the object
+ * @param pid_fd the process ID FD
+ * @returns #FALSE if no memory
+ */
+#ifndef DBUS_UNIX
+_DBUS_GNUC_NORETURN
+#endif
+void
+_dbus_credentials_take_pid_fd (DBusCredentials *credentials,
+ int pid_fd)
+{
+#ifdef DBUS_UNIX
+ if (credentials->pid_fd >= 0)
+ close (credentials->pid_fd);
+ credentials->pid_fd = pid_fd;
+#else
+ _dbus_assert_not_reached ("pidfd never set on non-Unix");
+#endif
+}
+
+/**
* Add a UNIX user ID to the credentials.
*
* @param credentials the object
@@ -321,7 +368,10 @@ _dbus_credentials_include (DBusCredentials *credentials,
switch (type)
{
case DBUS_CREDENTIAL_UNIX_PROCESS_ID:
- return credentials->pid != DBUS_PID_UNSET;
+ return credentials->pid != DBUS_PID_UNSET ||
+ credentials->pid_fd >= 0;
+ case DBUS_CREDENTIAL_UNIX_PROCESS_FD:
+ return credentials->pid_fd >= 0;
case DBUS_CREDENTIAL_UNIX_USER_ID:
return credentials->unix_uid != DBUS_UID_UNSET;
case DBUS_CREDENTIAL_UNIX_GROUP_IDS:
@@ -341,6 +391,8 @@ _dbus_credentials_include (DBusCredentials *credentials,
/**
* Gets the UNIX process ID in the credentials, or #DBUS_PID_UNSET if
* the credentials object doesn't contain a process ID.
+ * If the PID FD is set, it will first try to resolve from it, and
+ * only return the stored PID if that fails.
*
* @param credentials the object
* @returns UNIX process ID
@@ -348,10 +400,36 @@ _dbus_credentials_include (DBusCredentials *credentials,
dbus_pid_t
_dbus_credentials_get_pid (DBusCredentials *credentials)
{
+#ifdef DBUS_UNIX
+ dbus_pid_t pid;
+
+ if (credentials->pid_fd >= 0)
+ {
+ pid = _dbus_resolve_pid_fd (credentials->pid_fd);
+ if (pid > 0)
+ return pid;
+ }
+#endif
+
return credentials->pid;
}
/**
+ * Gets the UNIX process ID FD in the credentials as obtained by 'safe'
+ * means (e.g.: Linux's SO_PEERPIDFD), or -1 if the credentials object
+ * doesn't contain a process ID FD. The file FD is owned by the credentials
+ * object and must not be closed by the caller.
+ *
+ * @param credentials the object
+ * @returns UNIX process ID FD
+ */
+int
+_dbus_credentials_get_pid_fd (DBusCredentials *credentials)
+{
+ return credentials->pid_fd;
+}
+
+/**
* Gets the UNIX user ID in the credentials, or #DBUS_UID_UNSET if
* the credentials object doesn't contain a user ID.
*
@@ -461,6 +539,7 @@ _dbus_credentials_are_empty (DBusCredentials *credentials)
{
return
credentials->pid == DBUS_PID_UNSET &&
+ credentials->pid_fd == -1 &&
credentials->unix_uid == DBUS_UID_UNSET &&
credentials->unix_gids == NULL &&
credentials->n_unix_gids == 0 &&
@@ -497,6 +576,9 @@ _dbus_credentials_add_credentials (DBusCredentials *credentials,
{
return
_dbus_credentials_add_credential (credentials,
+ DBUS_CREDENTIAL_UNIX_PROCESS_FD,
+ other_credentials) &&
+ _dbus_credentials_add_credential (credentials,
DBUS_CREDENTIAL_UNIX_PROCESS_ID,
other_credentials) &&
_dbus_credentials_add_credential (credentials,
@@ -580,6 +662,19 @@ _dbus_credentials_add_credential (DBusCredentials *credentials,
if (!_dbus_credentials_add_adt_audit_data (credentials, other_credentials->adt_audit_data, other_credentials->adt_audit_data_size))
return FALSE;
}
+ /* _dbus_dup() is only available on UNIX platforms. */
+#ifdef DBUS_UNIX
+ else if (which == DBUS_CREDENTIAL_UNIX_PROCESS_FD &&
+ other_credentials->pid_fd >= 0)
+ {
+ int pid_fd = _dbus_dup (other_credentials->pid_fd, NULL);
+
+ if (pid_fd < 0)
+ return FALSE;
+
+ _dbus_credentials_take_pid_fd (credentials, pid_fd);
+ }
+#endif
return TRUE;
}
@@ -593,6 +688,13 @@ void
_dbus_credentials_clear (DBusCredentials *credentials)
{
credentials->pid = DBUS_PID_UNSET;
+#ifdef DBUS_UNIX
+ if (credentials->pid_fd >= 0)
+ {
+ close (credentials->pid_fd);
+ credentials->pid_fd = -1;
+ }
+#endif
credentials->unix_uid = DBUS_UID_UNSET;
dbus_free (credentials->unix_gids);
credentials->unix_gids = NULL;
@@ -675,9 +777,12 @@ _dbus_credentials_to_string_append (DBusCredentials *credentials,
goto oom;
join = TRUE;
}
- if (credentials->pid != DBUS_PID_UNSET)
+ if (credentials->pid != DBUS_PID_UNSET || credentials->pid_fd >= 0)
{
- if (!_dbus_string_append_printf (string, "%spid=" DBUS_PID_FORMAT, join ? " " : "", credentials->pid))
+ if (!_dbus_string_append_printf (string,
+ "%spid=" DBUS_PID_FORMAT,
+ join ? " " : "",
+ _dbus_credentials_get_pid (credentials)))
goto oom;
join = TRUE;
}
@@ -713,6 +818,13 @@ _dbus_credentials_to_string_append (DBusCredentials *credentials,
join = TRUE;
}
+ if (credentials->pid_fd >= 0)
+ {
+ if (!_dbus_string_append_printf (string, "%spidfd=%d", join ? " " : "", credentials->pid_fd))
+ goto oom;
+ join = TRUE;
+ }
+
return TRUE;
oom:
return FALSE;
diff --git a/dbus/dbus-credentials.h b/dbus/dbus-credentials.h
index 92a469f0..407d5cb5 100644
--- a/dbus/dbus-credentials.h
+++ b/dbus/dbus-credentials.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2007 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -36,7 +38,8 @@ typedef enum {
DBUS_CREDENTIAL_UNIX_GROUP_IDS,
DBUS_CREDENTIAL_ADT_AUDIT_DATA_ID,
DBUS_CREDENTIAL_LINUX_SECURITY_LABEL,
- DBUS_CREDENTIAL_WINDOWS_SID
+ DBUS_CREDENTIAL_WINDOWS_SID,
+ DBUS_CREDENTIAL_UNIX_PROCESS_FD,
} DBusCredentialType;
DBUS_PRIVATE_EXPORT
@@ -51,6 +54,9 @@ DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_credentials_add_pid (DBusCredentials *credentials,
dbus_pid_t pid);
DBUS_PRIVATE_EXPORT
+void _dbus_credentials_take_pid_fd (DBusCredentials *credentials,
+ int pid_fd);
+DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_credentials_add_unix_uid (DBusCredentials *credentials,
dbus_uid_t uid);
DBUS_PRIVATE_EXPORT
@@ -71,6 +77,8 @@ dbus_bool_t _dbus_credentials_include (DBusCredentials
DBUS_PRIVATE_EXPORT
dbus_pid_t _dbus_credentials_get_pid (DBusCredentials *credentials);
DBUS_PRIVATE_EXPORT
+int _dbus_credentials_get_pid_fd (DBusCredentials *credentials);
+DBUS_PRIVATE_EXPORT
dbus_uid_t _dbus_credentials_get_unix_uid (DBusCredentials *credentials);
DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_credentials_get_unix_gids (DBusCredentials *credentials,
diff --git a/dbus/dbus-dataslot.c b/dbus/dbus-dataslot.c
index a4503a29..776f9278 100644
--- a/dbus/dbus-dataslot.c
+++ b/dbus/dbus-dataslot.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-dataslot.h b/dbus/dbus-dataslot.h
index dccf6f45..08322c1c 100644
--- a/dbus/dbus-dataslot.h
+++ b/dbus/dbus-dataslot.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-errors.c b/dbus/dbus-errors.c
index 0f228dc1..24e54a82 100644
--- a/dbus/dbus-errors.c
+++ b/dbus/dbus-errors.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2004 Red Hat Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-errors.h b/dbus/dbus-errors.h
index 945ddb4c..003f583b 100644
--- a/dbus/dbus-errors.h
+++ b/dbus/dbus-errors.h
@@ -4,6 +4,8 @@
* Copyright (C) 2002 Red Hat Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-file-unix.c b/dbus/dbus-file-unix.c
index dd7cfbad..d5fa029e 100644
--- a/dbus/dbus-file-unix.c
+++ b/dbus/dbus-file-unix.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003, 2006 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -31,7 +33,13 @@
#include "dbus-sysdeps.h"
#include "dbus-sysdeps-unix.h"
+#ifdef HAVE_LINUX_MAGIC_H
+#include <linux/magic.h>
+#endif
#include <sys/stat.h>
+#ifdef HAVE_SYS_VFS_H
+#include <sys/vfs.h>
+#endif
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
@@ -58,9 +66,14 @@ _dbus_file_get_contents (DBusString *str,
{
int fd;
struct stat sb;
+#ifdef HAVE_FSTATFS
+ struct statfs sfs;
+#endif
int orig_len;
int total;
+ int file_size;
const char *filename_c;
+ dbus_bool_t is_procfs = FALSE;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
@@ -102,17 +115,47 @@ _dbus_file_get_contents (DBusString *str,
_dbus_close (fd, NULL);
return FALSE;
}
+
+ /* procfs has different semantics - most files are 0 size,
+ * we can do only one read, and at most we can read 4M.
+ */
+#ifdef HAVE_FSTATFS
+ if (sb.st_size == 0)
+ {
+ if (fstatfs(fd, &sfs) < 0)
+ {
+ dbus_set_error (error, _dbus_error_from_errno (errno),
+ "Failed to stat \"%s\": %s",
+ filename_c,
+ _dbus_strerror (errno));
+
+ _dbus_verbose ("fstatvfs() failed: %s",
+ _dbus_strerror (errno));
+
+ _dbus_close (fd, NULL);
+
+ return FALSE;
+ }
+ if (sfs.f_type == PROC_SUPER_MAGIC)
+ is_procfs = TRUE;
+ }
+#endif
+
+ if (is_procfs)
+ file_size = _DBUS_ONE_MEGABYTE;
+ else
+ file_size = sb.st_size;
total = 0;
orig_len = _dbus_string_get_length (str);
- if (sb.st_size > 0 && S_ISREG (sb.st_mode))
+ if (file_size > 0 && S_ISREG (sb.st_mode))
{
int bytes_read;
- while (total < (int) sb.st_size)
+ do
{
bytes_read = _dbus_read (fd, str,
- sb.st_size - total);
+ file_size - total);
if (bytes_read <= 0)
{
dbus_set_error (error, _dbus_error_from_errno (errno),
@@ -130,11 +173,12 @@ _dbus_file_get_contents (DBusString *str,
else
total += bytes_read;
}
+ while (total < file_size && !is_procfs);
_dbus_close (fd, NULL);
return TRUE;
}
- else if (sb.st_size != 0)
+ else if (file_size != 0)
{
_dbus_verbose ("Can only open regular files at the moment.\n");
dbus_set_error (error, DBUS_ERROR_FAILED,
diff --git a/dbus/dbus-file-win.c b/dbus/dbus-file-win.c
index 5385f856..a17e0869 100644
--- a/dbus/dbus-file-win.c
+++ b/dbus/dbus-file-win.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003, 2006 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-file.c b/dbus/dbus-file.c
index c0eb1aca..5b122189 100644
--- a/dbus/dbus-file.c
+++ b/dbus/dbus-file.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003, 2006 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-file.h b/dbus/dbus-file.h
index eb149656..90fc5295 100644
--- a/dbus/dbus-file.h
+++ b/dbus/dbus-file.h
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-hash.c b/dbus/dbus-hash.c
index f04b0d11..2635a154 100644
--- a/dbus/dbus-hash.c
+++ b/dbus/dbus-hash.c
@@ -9,6 +9,7 @@
* Copyright 2010 Fridrich Štrba
* Copyright 2016 Ralf Habacker
* Copyright 2017 Endless Mobile, Inc.
+ * SPDX-License-Identifier: (AFL-2.1 OR GPL-2.0-or-later) AND TCL
*
* Hash table implementation based on generic/tclHash.c from the Tcl
* source code. The original Tcl license applies to portions of the
diff --git a/dbus/dbus-hash.h b/dbus/dbus-hash.h
index ea6fef0d..290fb1a2 100644
--- a/dbus/dbus-hash.h
+++ b/dbus/dbus-hash.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -24,9 +26,7 @@
#ifndef DBUS_HASH_H
#define DBUS_HASH_H
-#ifdef HAVE_STDINT_H
#include <stdint.h>
-#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
diff --git a/dbus/dbus-init-win.cpp b/dbus/dbus-init-win.cpp
index 687f248c..56311d8a 100644
--- a/dbus/dbus-init-win.cpp
+++ b/dbus/dbus-init-win.cpp
@@ -3,6 +3,8 @@
*
* Copyright © 2013 Intel Corporation
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -25,7 +27,7 @@
extern "C"
{
-#include "dbus-sysdeps-win.h"
+#include "dbus-init-win.h"
}
class DBusInternalInit
diff --git a/dbus/dbus-init-win.h b/dbus/dbus-init-win.h
new file mode 100644
index 00000000..8a9de8f7
--- /dev/null
+++ b/dbus/dbus-init-win.h
@@ -0,0 +1,17 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright © 2013 Intel Corporation
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
+ * Do not include other private headers in this one, particularly
+ * dbus-sysdeps.h: it gets included into C++ code which is not
+ * compatible with our use of <stdatomic.h>.
+ */
+
+#ifndef DBUS_INIT_WIN_H
+#define DBUS_INIT_WIN_H
+
+void _dbus_threads_windows_init_global (void);
+void _dbus_threads_windows_ensure_ctor_linked (void);
+
+#endif
diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c
index ab498b15..6a23ff5b 100644
--- a/dbus/dbus-internals.c
+++ b/dbus/dbus-internals.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -177,6 +179,35 @@
* Unlocks a global lock
*/
+/* The build system should have checked for DBUS_SIZEOF_VOID_P */
+_DBUS_STATIC_ASSERT (sizeof (void *) == DBUS_SIZEOF_VOID_P);
+
+/* dbus currently assumes that function pointers are essentially
+ * interchangeable with data pointers. There's nothing special about
+ * DBusShutdownFunction, it's just an arbitrary function pointer type.
+ * If this assertion fails on your platform, some porting will be required. */
+_DBUS_STATIC_ASSERT (sizeof (void *) == sizeof (DBusShutdownFunction));
+_DBUS_STATIC_ASSERT (_DBUS_ALIGNOF (void *) == _DBUS_ALIGNOF (DBusShutdownFunction));
+
+/* This is meant to be true by definition. */
+_DBUS_STATIC_ASSERT (sizeof (void *) == sizeof (intptr_t));
+_DBUS_STATIC_ASSERT (sizeof (void *) == sizeof (uintptr_t));
+
+/*
+ * Some frequent assumptions that we should *avoid* making include these,
+ * all of which are false on CHERI (which has 128-bit tagged pointers,
+ * but a 64-bit address space and therefore 64-bit sizes):
+ *
+ * sizeof (void *) <= sizeof (size_t)
+ * sizeof (void *) <= 8
+ * _DBUS_ALIGNOF (void *) <= 8
+ *
+ * We should also avoid making these assumptions, although we don't currently
+ * know a concrete example of platforms where they're false:
+ *
+ * sizeof (ptrdiff_t) == sizeof (size_t)
+ */
+
/**
* Fixed "out of memory" error message, just to avoid
* making up a different string every time and wasting
@@ -195,6 +226,13 @@ static dbus_bool_t warn_initted = FALSE;
static dbus_bool_t fatal_warnings = FALSE;
static dbus_bool_t fatal_warnings_on_check_failed = TRUE;
+static int check_failed_count = 0;
+
+int _dbus_get_check_failed_count (void)
+{
+ return check_failed_count;
+}
+
static void
init_warnings(void)
{
@@ -221,6 +259,8 @@ init_warnings(void)
}
}
+ check_failed_count = 0;
+
warn_initted = TRUE;
}
}
@@ -288,6 +328,8 @@ _dbus_warn_check_failed(const char *format,
fflush (stderr);
_dbus_abort ();
}
+ else
+ check_failed_count++;
}
#ifdef DBUS_ENABLE_VERBOSE_MODE
@@ -323,18 +365,7 @@ _dbus_verbose_init (void)
}
}
-/** @def DBUS_IS_DIR_SEPARATOR(c)
- * macro for checking if character c is a patch separator
- *
- * @todo move to a header file so that others can use this too
- */
-#ifdef DBUS_WIN
-#define DBUS_IS_DIR_SEPARATOR(c) (c == '\\' || c == '/')
-#else
-#define DBUS_IS_DIR_SEPARATOR(c) (c == '/')
-#endif
-
-/**
+/**
remove source root from file path
the source root is determined by
*/
@@ -426,7 +457,8 @@ _dbus_verbose_real (
va_list args;
static dbus_bool_t need_pid = TRUE;
int len;
- long sec, usec;
+ dbus_int64_t sec;
+ long usec;
/* things are written a bit oddly here so that
* in the non-verbose case we just have the one
@@ -442,7 +474,7 @@ _dbus_verbose_real (
_dbus_print_thread ();
}
_dbus_get_real_time (&sec, &usec);
- fprintf (stderr, "%ld.%06ld ", sec, usec);
+ fprintf (stderr, "%" DBUS_INT64_MODIFIER "d.%06ld ", sec, usec);
#endif
/* Only print pid again if the next line is a new line */
@@ -721,7 +753,7 @@ _dbus_generate_uuid (DBusGUID *uuid,
DBusError *error)
{
DBusError rand_error;
- long now;
+ dbus_int64_t now;
dbus_error_init (&rand_error);
diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h
index 73443e23..4aef24ca 100644
--- a/dbus/dbus-internals.h
+++ b/dbus/dbus-internals.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -31,16 +33,11 @@
#include <dbus/dbus-types.h>
#include <dbus/dbus-errors.h>
#include <dbus/dbus-sysdeps.h>
+#include <dbus/dbus-macros-internal.h>
#include <dbus/dbus-threads-internal.h>
DBUS_BEGIN_DECLS
-#ifdef DBUS_ENABLE_EMBEDDED_TESTS
-#define DBUS_EMBEDDED_TESTS_EXPORT DBUS_PRIVATE_EXPORT
-#else
-#define DBUS_EMBEDDED_TESTS_EXPORT /* nothing */
-#endif
-
DBUS_PRIVATE_EXPORT
void _dbus_warn (const char *format,
...) _DBUS_GNUC_PRINTF (1, 2);
@@ -54,6 +51,9 @@ void _dbus_warn_return_if_fail (const char *function,
const char *file,
int line);
+DBUS_EMBEDDED_TESTS_EXPORT
+int _dbus_get_check_failed_count (void);
+
#if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
#define _DBUS_FUNCTION_NAME __func__
#elif defined(__GNUC__) || defined(_MSC_VER)
@@ -104,7 +104,7 @@ void _dbus_warn_return_if_fail (const char *function,
DBUS_PRIVATE_EXPORT
void _dbus_verbose_real (const char *file, const int line, const char *function,
const char *format,...) _DBUS_GNUC_PRINTF (4, 5);
-# define _dbus_verbose(fmt,...) _dbus_verbose_real( __FILE__,__LINE__,__FUNCTION__,fmt, ## __VA_ARGS__)
+# define _dbus_verbose(fmt,...) _dbus_verbose_real( __FILE__,__LINE__,_DBUS_FUNCTION_NAME,fmt, ## __VA_ARGS__)
#else
DBUS_PRIVATE_EXPORT
void _dbus_verbose_real (const char *format,
@@ -193,11 +193,20 @@ void _dbus_real_assert_not_reached (const char *explanation,
#define _DBUS_ZERO(object) (memset (&(object), '\0', sizeof ((object))))
+#ifdef offsetof
+#define _DBUS_STRUCT_OFFSET(struct_type, member) \
+ (offsetof (struct_type, member))
+#else
#define _DBUS_STRUCT_OFFSET(struct_type, member) \
((intptr_t) ((unsigned char*) &((struct_type*) 0)->member))
+#endif
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
+#define _DBUS_ALIGNOF(type) _Alignof(type)
+#else
#define _DBUS_ALIGNOF(type) \
(_DBUS_STRUCT_OFFSET (struct { char _1; type _2; }, _2))
+#endif
#if defined(DBUS_DISABLE_CHECKS) || defined(DBUS_DISABLE_ASSERT)
/* this is an assert and not an error, but in the typical --disable-checks case (you're trying
@@ -274,11 +283,27 @@ _dbus_assert_error_xor_bool (const DBusError *error,
*/
#define _DBUS_ALIGN_VALUE(this, boundary) \
- (( ((uintptr_t)(this)) + (((uintptr_t)(boundary)) -1)) & (~(((uintptr_t)(boundary))-1)))
+ ((((uintptr_t) (this)) + (((size_t) (boundary)) - 1)) & \
+ (~(((size_t) (boundary)) - 1)))
#define _DBUS_ALIGN_ADDRESS(this, boundary) \
((void*)_DBUS_ALIGN_VALUE(this, boundary))
+#define _DBUS_IS_ALIGNED(this, boundary) \
+ ((((size_t) (uintptr_t) (this)) & ((size_t) (boundary) - 1)) == 0)
+
+/**
+ * Aligning a pointer to _DBUS_ALIGNOF(dbus_max_align_t) guarantees that all
+ * scalar types can be loaded/stored from/to such an address without incurring
+ * an alignment fault (or a slow misaligned access).
+ * This is based on C11 max_align_t, but falls back to DBusBasicValue for
+ * older C standards.
+ */
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
+typedef max_align_t dbus_max_align_t;
+#else
+typedef DBusBasicValue dbus_max_align_t;
+#endif
DBUS_PRIVATE_EXPORT
char* _dbus_strdup (const char *str);
@@ -463,6 +488,41 @@ dbus_bool_t _dbus_get_local_machine_uuid_encoded (DBusString *uuid_str,
#define _DBUS_STRINGIFY(x) #x
#define _DBUS_FILE_LINE __FILE__ ":" _DBUS_STRINGIFY(__LINE__)
+#ifndef __has_feature
+# define __has_feature(x) 0
+#endif
+
+/* MSVC defines __SANITIZE_ADDRESS__, but does not provide the special
+ * builtins associated with it. */
+#if ((defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer)) && \
+ !defined(_MSC_VER))
+# include <sanitizer/lsan_interface.h>
+/* Defined if we are building with AddressSanitizer */
+# define _DBUS_ADDRESS_SANITIZER
+/* Ignore memory allocations until the next _DBUS_END_IGNORE_LEAKS when
+ * checking for memory leaks */
+# define _DBUS_BEGIN_IGNORE_LEAKS __lsan_disable ()
+/* End the scope of a previous _DBUS_BEGIN_IGNORE_LEAKS */
+# define _DBUS_END_IGNORE_LEAKS __lsan_enable ()
+#else
+# undef _DBUS_ADDRESS_SANITIZER
+# define _DBUS_BEGIN_IGNORE_LEAKS do { } while (0)
+# define _DBUS_END_IGNORE_LEAKS do { } while (0)
+#endif
+
+/** @def DBUS_IS_DIR_SEPARATOR(c)
+ * macro for checking if character c is a path separator
+ */
+#ifdef DBUS_WIN
+#define DBUS_IS_DIR_SEPARATOR(c) (c == '\\' || c == '/')
+#define DBUS_DIR_SEPARATOR '\\'
+#define DBUS_DIR_SEPARATOR_S "\\"
+#else
+#define DBUS_IS_DIR_SEPARATOR(c) (c == '/')
+#define DBUS_DIR_SEPARATOR '/'
+#define DBUS_DIR_SEPARATOR_S "/"
+#endif
+
DBUS_END_DECLS
#endif /* DBUS_INTERNALS_H */
diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c
index d2df3d86..f55b21a8 100644
--- a/dbus/dbus-keyring.c
+++ b/dbus/dbus-keyring.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003, 2004 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -94,10 +96,7 @@ typedef struct
{
dbus_int32_t id; /**< identifier used to refer to the key */
- long creation_time; /**< when the key was generated,
- * as unix timestamp. signed long
- * matches struct timeval.
- */
+ dbus_int64_t creation_time; /**< when the key was generated, in seconds since 1970-01-01 */
DBusString secret; /**< the actual key */
@@ -284,7 +283,7 @@ add_new_key (DBusKey **keys_p,
DBusKey *new;
DBusString bytes;
int id;
- long timestamp;
+ dbus_int64_t timestamp;
const unsigned char *s;
dbus_bool_t retval;
DBusKey *keys;
@@ -397,7 +396,7 @@ _dbus_keyring_reload (DBusKeyring *keyring,
DBusKey *keys;
int n_keys;
int i;
- long now;
+ dbus_int64_t now;
DBusError tmp_error;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
@@ -463,7 +462,7 @@ _dbus_keyring_reload (DBusKeyring *keyring,
int next;
long val;
int id;
- long timestamp;
+ dbus_int64_t timestamp;
int len;
int end;
DBusKey *new;
@@ -489,7 +488,7 @@ _dbus_keyring_reload (DBusKeyring *keyring,
_dbus_string_skip_blank (&line, next, &next);
- if (!_dbus_string_parse_int (&line, next, &timestamp, &next))
+ if (!_dbus_string_parse_int64 (&line, next, &timestamp, &next))
{
_dbus_verbose ("could not parse secret key timestamp\n");
continue;
@@ -499,7 +498,7 @@ _dbus_keyring_reload (DBusKeyring *keyring,
(now + MAX_TIME_TRAVEL_SECONDS) < timestamp ||
(now - EXPIRE_KEYS_TIMEOUT_SECONDS) > timestamp)
{
- _dbus_verbose ("dropping/ignoring %ld-seconds old key with timestamp %ld as current time is %ld\n",
+ _dbus_verbose ("dropping/ignoring %" DBUS_INT64_MODIFIER "d-seconds old key with timestamp %" DBUS_INT64_MODIFIER "d as current time is %" DBUS_INT64_MODIFIER "d\n",
now - timestamp, timestamp, now);
continue;
}
@@ -574,8 +573,8 @@ _dbus_keyring_reload (DBusKeyring *keyring,
if (!_dbus_string_append_byte (&contents, ' '))
goto nomem;
- if (!_dbus_string_append_int (&contents,
- keys[i].creation_time))
+ if (!_dbus_string_append_printf (&contents, "%" DBUS_INT64_MODIFIER "d",
+ keys[i].creation_time))
goto nomem;
if (!_dbus_string_append_byte (&contents, ' '))
@@ -908,7 +907,8 @@ static DBusKey*
find_recent_key (DBusKeyring *keyring)
{
int i;
- long tv_sec, tv_usec;
+ dbus_int64_t tv_sec;
+ long tv_usec;
_dbus_get_real_time (&tv_sec, &tv_usec);
@@ -917,7 +917,7 @@ find_recent_key (DBusKeyring *keyring)
{
DBusKey *key = &keyring->keys[i];
- _dbus_verbose ("Key %d is %ld seconds old\n",
+ _dbus_verbose ("Key %d is %" DBUS_INT64_MODIFIER "d seconds old\n",
i, tv_sec - key->creation_time);
if ((tv_sec - NEW_KEY_TIMEOUT_SECONDS) < key->creation_time)
@@ -1112,7 +1112,7 @@ _dbus_keyring_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
if (ring1->keys[i].creation_time != ring2->keys[i].creation_time)
{
- fprintf (stderr, "Keyring 1 has first key time %ld and keyring 2 has %ld\n",
+ fprintf (stderr, "Keyring 1 has first key time %" DBUS_INT64_MODIFIER "d and keyring 2 has %" DBUS_INT64_MODIFIER "d\n",
ring1->keys[i].creation_time, ring2->keys[i].creation_time);
goto failure;
}
diff --git a/dbus/dbus-keyring.h b/dbus/dbus-keyring.h
index e7b2de83..fe122b8e 100644
--- a/dbus/dbus-keyring.h
+++ b/dbus/dbus-keyring.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-list.c b/dbus/dbus-list.c
index d3ca20f7..b3b76c75 100644
--- a/dbus/dbus-list.c
+++ b/dbus/dbus-list.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-list.h b/dbus/dbus-list.h
index f59a4a23..49217df2 100644
--- a/dbus/dbus-list.h
+++ b/dbus/dbus-list.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-macros-internal.h b/dbus/dbus-macros-internal.h
new file mode 100644
index 00000000..3d7c0683
--- /dev/null
+++ b/dbus/dbus-macros-internal.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright © 2010-2015 Ralf Habacker
+ * Copyright © 2015-2019 Collabora Ltd.
+ *
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifdef DBUS_INSIDE_DBUS_H
+#error "You can't include dbus-macros-internal.h in the public header dbus.h"
+#endif
+
+#ifndef DBUS_MACROS_INTERNAL_H
+#define DBUS_MACROS_INTERNAL_H
+
+#include <dbus/dbus-macros.h>
+
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
+# define DBUS_EMBEDDED_TESTS_EXPORT DBUS_PRIVATE_EXPORT
+#else
+# define DBUS_EMBEDDED_TESTS_EXPORT /* nothing */
+#endif
+
+#if defined(DBUS_PRIVATE_EXPORT)
+ /* value forced by compiler command line, don't redefine */
+#elif defined(_WIN32)
+# if defined(DBUS_STATIC_BUILD)
+# define DBUS_PRIVATE_EXPORT /* no decoration */
+# elif defined(dbus_1_EXPORTS)
+# define DBUS_PRIVATE_EXPORT __declspec(dllexport)
+# else
+# define DBUS_PRIVATE_EXPORT __declspec(dllimport)
+# endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+# define DBUS_PRIVATE_EXPORT __attribute__ ((__visibility__ ("default")))
+#else
+# define DBUS_PRIVATE_EXPORT /* no decoration */
+#endif
+
+#endif
diff --git a/dbus/dbus-macros.h b/dbus/dbus-macros.h
index 80faed29..5ca7bf0a 100644
--- a/dbus/dbus-macros.h
+++ b/dbus/dbus-macros.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -210,22 +212,6 @@
#define DBUS_EXPORT
#endif
-#if defined(DBUS_PRIVATE_EXPORT)
- /* value forced by compiler command line, don't redefine */
-#elif defined(_WIN32)
-# if defined(DBUS_STATIC_BUILD)
-# define DBUS_PRIVATE_EXPORT /* no decoration */
-# elif defined(dbus_1_EXPORTS)
-# define DBUS_PRIVATE_EXPORT __declspec(dllexport)
-# else
-# define DBUS_PRIVATE_EXPORT __declspec(dllimport)
-# endif
-#elif defined(__GNUC__) && __GNUC__ >= 4
-# define DBUS_PRIVATE_EXPORT __attribute__ ((__visibility__ ("default")))
-#else
-# define DBUS_PRIVATE_EXPORT /* no decoration */
-#endif
-
/* Implementation for dbus_clear_message() etc. This is not API,
* do not use it directly.
*
diff --git a/dbus/dbus-mainloop.c b/dbus/dbus-mainloop.c
index c4b7151b..91030e39 100644
--- a/dbus/dbus-mainloop.c
+++ b/dbus/dbus-mainloop.c
@@ -4,6 +4,8 @@
* Copyright © 2003, 2004 Red Hat, Inc.
* Copyright © 2011 Nokia Corporation
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -55,7 +57,7 @@ struct DBusLoop
typedef struct
{
DBusTimeout *timeout;
- long last_tv_sec;
+ dbus_int64_t last_tv_sec;
long last_tv_usec;
} TimeoutCallback;
@@ -423,16 +425,16 @@ _dbus_loop_remove_timeout (DBusLoop *loop,
* to do this.
*/
static dbus_bool_t
-check_timeout (long tv_sec,
+check_timeout (dbus_int64_t tv_sec,
long tv_usec,
TimeoutCallback *tcb,
int *timeout)
{
- long sec_remaining;
+ dbus_int64_t sec_remaining;
long msec_remaining;
- long expiration_tv_sec;
+ dbus_int64_t expiration_tv_sec;
long expiration_tv_usec;
- long interval_seconds;
+ dbus_int64_t interval_seconds;
long interval_milliseconds;
int interval;
@@ -575,7 +577,7 @@ _dbus_loop_iterate (DBusLoop *loop,
DBusList *link;
int n_ready;
int initial_serial;
- long timeout;
+ int timeout;
int orig_depth;
retval = FALSE;
@@ -594,7 +596,7 @@ _dbus_loop_iterate (DBusLoop *loop,
timeout = -1;
if (loop->timeout_count > 0)
{
- long tv_sec;
+ dbus_int64_t tv_sec;
long tv_usec;
_dbus_get_monotonic_time (&tv_sec, &tv_usec);
@@ -707,7 +709,7 @@ _dbus_loop_iterate (DBusLoop *loop,
if (loop->timeout_count > 0)
{
- long tv_sec;
+ dbus_int64_t tv_sec;
long tv_usec;
_dbus_get_monotonic_time (&tv_sec, &tv_usec);
diff --git a/dbus/dbus-mainloop.h b/dbus/dbus-mainloop.h
index 40350977..4d5994fb 100644
--- a/dbus/dbus-mainloop.h
+++ b/dbus/dbus-mainloop.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-marshal-basic.c b/dbus/dbus-marshal-basic.c
index ab080d0e..64d68dae 100644
--- a/dbus/dbus-marshal-basic.c
+++ b/dbus/dbus-marshal-basic.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002 CodeFactory AB
* Copyright (C) 2003, 2004, 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -30,23 +32,10 @@
#include <string.h>
-#if !defined(PRIx64) && defined(DBUS_WIN)
-#define PRIx64 "I64x"
-#endif
-
-#if defined(__GNUC__) && (__GNUC__ >= 4)
-# define _DBUS_ASSERT_ALIGNMENT(type, op, val) \
- _DBUS_STATIC_ASSERT (__extension__ __alignof__ (type) op val)
-# define _DBUS_ASSERT_CMP_ALIGNMENT(left, op, right) \
- _DBUS_STATIC_ASSERT (__extension__ __alignof__ (left) op __extension__ __alignof__ (right))
-#else
- /* not gcc, so probably no alignof operator: just use a no-op statement
- * that's valid in the same contexts */
-# define _DBUS_ASSERT_ALIGNMENT(type, op, val) \
- _DBUS_STATIC_ASSERT (TRUE)
-# define _DBUS_ASSERT_CMP_ALIGNMENT(left, op, right) \
- _DBUS_STATIC_ASSERT (TRUE)
-#endif
+#define _DBUS_ASSERT_ALIGNMENT(type, op, val) \
+ _DBUS_STATIC_ASSERT (_DBUS_ALIGNOF (type) op val)
+#define _DBUS_ASSERT_CMP_ALIGNMENT(left, op, right) \
+ _DBUS_STATIC_ASSERT (_DBUS_ALIGNOF (left) op _DBUS_ALIGNOF (right))
/* True by definition, but just for completeness... */
_DBUS_STATIC_ASSERT (sizeof (char) == 1);
@@ -106,7 +95,7 @@ _DBUS_ASSERT_ALIGNMENT (DBus8ByteStruct, <=, 8);
static void
pack_2_octets (dbus_uint16_t value,
int byte_order,
- unsigned char *data)
+ void *data)
{
_dbus_assert (_DBUS_ALIGN_ADDRESS (data, 2) == data);
@@ -119,7 +108,7 @@ pack_2_octets (dbus_uint16_t value,
static void
pack_4_octets (dbus_uint32_t value,
int byte_order,
- unsigned char *data)
+ void *data)
{
_dbus_assert (_DBUS_ALIGN_ADDRESS (data, 4) == data);
@@ -132,7 +121,7 @@ pack_4_octets (dbus_uint32_t value,
static void
pack_8_octets (dbus_uint64_t value,
int byte_order,
- unsigned char *data)
+ void *data)
{
_dbus_assert (_DBUS_ALIGN_ADDRESS (data, 8) == data);
@@ -182,9 +171,9 @@ _dbus_unpack_uint16 (int byte_order,
_dbus_assert (_DBUS_ALIGN_ADDRESS (data, 2) == data);
if (byte_order == DBUS_LITTLE_ENDIAN)
- return DBUS_UINT16_FROM_LE (*(dbus_uint16_t*)data);
+ return DBUS_UINT16_FROM_LE (*(dbus_uint16_t *) (void *) data);
else
- return DBUS_UINT16_FROM_BE (*(dbus_uint16_t*)data);
+ return DBUS_UINT16_FROM_BE (*(dbus_uint16_t *) (void *) data);
}
#endif /* _dbus_unpack_uint16 */
@@ -203,9 +192,9 @@ _dbus_unpack_uint32 (int byte_order,
_dbus_assert (_DBUS_ALIGN_ADDRESS (data, 4) == data);
if (byte_order == DBUS_LITTLE_ENDIAN)
- return DBUS_UINT32_FROM_LE (*(dbus_uint32_t*)data);
+ return DBUS_UINT32_FROM_LE (*(dbus_uint32_t *) (void *) data);
else
- return DBUS_UINT32_FROM_BE (*(dbus_uint32_t*)data);
+ return DBUS_UINT32_FROM_BE (*(dbus_uint32_t *) (void *) data);
}
#endif /* _dbus_unpack_uint32 */
@@ -553,7 +542,7 @@ _dbus_marshal_read_basic (const DBusString *str,
{
volatile dbus_uint16_t *vp = value;
pos = _DBUS_ALIGN_VALUE (pos, 2);
- *vp = *(dbus_uint16_t *)(str_data + pos);
+ *vp = *(dbus_uint16_t *) (void *) (str_data + pos);
if (byte_order != DBUS_COMPILER_BYTE_ORDER)
*vp = DBUS_UINT16_SWAP_LE_BE (*vp);
pos += 2;
@@ -566,7 +555,7 @@ _dbus_marshal_read_basic (const DBusString *str,
{
volatile dbus_uint32_t *vp = value;
pos = _DBUS_ALIGN_VALUE (pos, 4);
- *vp = *(dbus_uint32_t *)(str_data + pos);
+ *vp = *(dbus_uint32_t *) (void *) (str_data + pos);
if (byte_order != DBUS_COMPILER_BYTE_ORDER)
*vp = DBUS_UINT32_SWAP_LE_BE (*vp);
pos += 4;
@@ -579,9 +568,10 @@ _dbus_marshal_read_basic (const DBusString *str,
volatile dbus_uint64_t *vp = value;
pos = _DBUS_ALIGN_VALUE (pos, 8);
if (byte_order != DBUS_COMPILER_BYTE_ORDER)
- *vp = DBUS_UINT64_SWAP_LE_BE (*(dbus_uint64_t*)(str_data + pos));
+ *vp = DBUS_UINT64_SWAP_LE_BE (
+ *(dbus_uint64_t *) (void *) (str_data + pos));
else
- *vp = *(dbus_uint64_t*)(str_data + pos);
+ *vp = *(dbus_uint64_t *) (void *) (str_data + pos);
pos += 8;
}
break;
@@ -938,8 +928,8 @@ _dbus_swap_array (unsigned char *data,
int n_elements,
int alignment)
{
- unsigned char *d;
- unsigned char *end;
+ void *d;
+ void *end;
_dbus_assert (_DBUS_ALIGN_ADDRESS (data, alignment) == data);
@@ -947,14 +937,14 @@ _dbus_swap_array (unsigned char *data,
* for the unit tests. don't ask.
*/
d = data;
- end = d + (n_elements * alignment);
+ end = data + (n_elements * alignment);
if (alignment == 8)
{
while (d != end)
{
*((dbus_uint64_t*)d) = DBUS_UINT64_SWAP_LE_BE (*((dbus_uint64_t*)d));
- d += 8;
+ d = ((unsigned char *) d) + 8;
}
}
else if (alignment == 4)
@@ -962,7 +952,7 @@ _dbus_swap_array (unsigned char *data,
while (d != end)
{
*((dbus_uint32_t*)d) = DBUS_UINT32_SWAP_LE_BE (*((dbus_uint32_t*)d));
- d += 4;
+ d = ((unsigned char *) d) + 4;
}
}
else
@@ -972,7 +962,7 @@ _dbus_swap_array (unsigned char *data,
while (d != end)
{
*((dbus_uint16_t*)d) = DBUS_UINT16_SWAP_LE_BE (*((dbus_uint16_t*)d));
- d += 2;
+ d = ((unsigned char *) d) + 2;
}
}
}
@@ -1152,6 +1142,7 @@ _dbus_marshal_skip_basic (const DBusString *str,
break;
case DBUS_TYPE_INT16:
case DBUS_TYPE_UINT16:
+ /* Advance to the next suitably-aligned position >= *pos */
*pos = _DBUS_ALIGN_VALUE (*pos, 2);
*pos += 2;
break;
@@ -1173,6 +1164,8 @@ _dbus_marshal_skip_basic (const DBusString *str,
{
int len;
+ /* Let len be the number of bytes of string data, and advance
+ * *pos to just after the length */
len = _dbus_marshal_read_uint32 (str, *pos, byte_order, pos);
*pos += len + 1; /* length plus nul */
@@ -1193,6 +1186,10 @@ _dbus_marshal_skip_basic (const DBusString *str,
_dbus_assert_not_reached ("not a basic type");
break;
}
+
+ /* We had better still be in-bounds at this point (pointing either into
+ * the content of the string, or 1 past the logical length of the string) */
+ _dbus_assert (*pos <= _dbus_string_get_length (str));
}
/**
@@ -1214,23 +1211,34 @@ _dbus_marshal_skip_array (const DBusString *str,
int i;
int alignment;
+ /* Advance to the next 4-byte-aligned position >= *pos */
i = _DBUS_ALIGN_VALUE (*pos, 4);
+ /* Let array_len be the number of bytes of array data, and advance
+ * i to just after the length */
array_len = _dbus_marshal_read_uint32 (str, i, byte_order, &i);
+ /* If the element type is more strictly-aligned than the length,
+ * advance i to the next suitably-aligned position
+ * (in other words, skip the padding) */
alignment = _dbus_type_get_alignment (element_type);
i = _DBUS_ALIGN_VALUE (i, alignment);
+ /* Skip the actual array data */
*pos = i + array_len;
+
+ /* We had better still be in-bounds at this point (pointing either into
+ * the content of the string, or 1 past the logical length of the string) */
+ _dbus_assert (*pos <= _dbus_string_get_length (str));
}
/**
* Gets the alignment requirement for the given type;
- * will be 1, 4, or 8.
+ * will be 1, 2, 4, or 8.
*
* @param typecode the type
- * @returns alignment of 1, 4, or 8
+ * @returns alignment of 1, 2, 4, or 8
*/
int
_dbus_type_get_alignment (int typecode)
@@ -1397,10 +1405,9 @@ _dbus_verbose_bytes (const unsigned char *data,
if (i > 7 &&
_DBUS_ALIGN_ADDRESS (&data[i], 8) == &data[i])
{
- _dbus_verbose (" u64: 0x%" PRIx64,
- *(dbus_uint64_t*)&data[i-8]);
- _dbus_verbose (" dbl: %g",
- *(double*)&data[i-8]);
+ _dbus_verbose (" u64: 0x%" DBUS_INT64_MODIFIER "x",
+ *(dbus_uint64_t *) (void *) &data[i - 8]);
+ _dbus_verbose (" dbl: %g", *(double *) (void *) &data[i - 8]);
}
_dbus_verbose ("\n");
diff --git a/dbus/dbus-marshal-basic.h b/dbus/dbus-marshal-basic.h
index 15971b32..48b90d6a 100644
--- a/dbus/dbus-marshal-basic.h
+++ b/dbus/dbus-marshal-basic.h
@@ -4,6 +4,8 @@
* Copyright (C) 2002 CodeFactory AB
* Copyright (C) 2004, 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-marshal-byteswap.c b/dbus/dbus-marshal-byteswap.c
index 27695aaf..1aea5d07 100644
--- a/dbus/dbus-marshal-byteswap.c
+++ b/dbus/dbus-marshal-byteswap.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -53,7 +55,8 @@ byteswap_body_helper (DBusTypeReader *reader,
case DBUS_TYPE_UINT16:
{
p = _DBUS_ALIGN_ADDRESS (p, 2);
- *((dbus_uint16_t*)p) = DBUS_UINT16_SWAP_LE_BE (*((dbus_uint16_t*)p));
+ *((dbus_uint16_t *) (void *) p) =
+ DBUS_UINT16_SWAP_LE_BE (*((dbus_uint16_t *) (void *) p));
p += 2;
}
break;
@@ -61,9 +64,11 @@ byteswap_body_helper (DBusTypeReader *reader,
case DBUS_TYPE_BOOLEAN:
case DBUS_TYPE_INT32:
case DBUS_TYPE_UINT32:
+ case DBUS_TYPE_UNIX_FD:
{
p = _DBUS_ALIGN_ADDRESS (p, 4);
- *((dbus_uint32_t*)p) = DBUS_UINT32_SWAP_LE_BE (*((dbus_uint32_t*)p));
+ *((dbus_uint32_t *) (void *) p) =
+ DBUS_UINT32_SWAP_LE_BE (*((dbus_uint32_t *) (void *) p));
p += 4;
}
break;
@@ -73,7 +78,8 @@ byteswap_body_helper (DBusTypeReader *reader,
case DBUS_TYPE_DOUBLE:
{
p = _DBUS_ALIGN_ADDRESS (p, 8);
- *((dbus_uint64_t*)p) = DBUS_UINT64_SWAP_LE_BE (*((dbus_uint64_t*)p));
+ *((dbus_uint64_t *) (void *) p) =
+ DBUS_UINT64_SWAP_LE_BE (*((dbus_uint64_t *) (void *) p));
p += 8;
}
break;
@@ -88,7 +94,8 @@ byteswap_body_helper (DBusTypeReader *reader,
array_len = _dbus_unpack_uint32 (old_byte_order, p);
- *((dbus_uint32_t*)p) = DBUS_UINT32_SWAP_LE_BE (*((dbus_uint32_t*)p));
+ *((dbus_uint32_t *) (void *) p) =
+ DBUS_UINT32_SWAP_LE_BE (*((dbus_uint32_t *) (void *) p));
p += 4;
if (current_type == DBUS_TYPE_ARRAY)
@@ -188,11 +195,6 @@ byteswap_body_helper (DBusTypeReader *reader,
}
break;
- case DBUS_TYPE_UNIX_FD:
- /* fds can only be passed on a local machine, so byte order must always match */
- _dbus_assert_not_reached("attempted to byteswap unix fds which makes no sense");
- break;
-
default:
_dbus_assert_not_reached ("invalid typecode in supposedly-validated signature");
break;
diff --git a/dbus/dbus-marshal-byteswap.h b/dbus/dbus-marshal-byteswap.h
index f66f2e21..b64ba385 100644
--- a/dbus/dbus-marshal-byteswap.h
+++ b/dbus/dbus-marshal-byteswap.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-marshal-header.c b/dbus/dbus-marshal-header.c
index b2461749..30636d79 100644
--- a/dbus/dbus-marshal-header.c
+++ b/dbus/dbus-marshal-header.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-marshal-header.h b/dbus/dbus-marshal-header.h
index b838e039..c59033ad 100644
--- a/dbus/dbus-marshal-header.h
+++ b/dbus/dbus-marshal-header.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-marshal-recursive.c b/dbus/dbus-marshal-recursive.c
index 6ad49ace..a85aabd8 100644
--- a/dbus/dbus-marshal-recursive.c
+++ b/dbus/dbus-marshal-recursive.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2004, 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -304,15 +306,12 @@ variant_reader_recurse (DBusTypeReader *sub,
#endif
}
+/* return true if no more elements remain */
static dbus_bool_t
array_reader_check_finished (const DBusTypeReader *reader)
{
int end_pos;
- /* return the array element type if elements remain, and
- * TYPE_INVALID otherwise
- */
-
end_pos = reader->u.array.start_pos + array_reader_get_array_len (reader);
_dbus_assert (reader->value_pos <= end_pos);
diff --git a/dbus/dbus-marshal-recursive.h b/dbus/dbus-marshal-recursive.h
index c3b96819..4aa61ba1 100644
--- a/dbus/dbus-marshal-recursive.h
+++ b/dbus/dbus-marshal-recursive.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2004, 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -38,18 +40,19 @@ typedef struct DBusArrayLenFixup DBusArrayLenFixup;
*/
struct DBusTypeReader
{
+ const DBusTypeReaderClass *klass; /**< the vtable for the reader */
+ const DBusString *type_str; /**< string containing signature of block */
+ const DBusString *value_str; /**< string containing values of block */
+
dbus_uint32_t byte_order : 8; /**< byte order of the block */
dbus_uint32_t finished : 1; /**< marks we're at end iterator for cases
* where we don't have another way to tell
*/
dbus_uint32_t array_len_offset : 3; /**< bytes back from start_pos that len ends */
- const DBusString *type_str; /**< string containing signature of block */
int type_pos; /**< current position in signature */
- const DBusString *value_str; /**< string containing values of block */
int value_pos; /**< current position in values */
- const DBusTypeReaderClass *klass; /**< the vtable for the reader */
union
{
struct {
@@ -63,6 +66,8 @@ struct DBusTypeReader
*/
struct DBusTypeWriter
{
+ DBusString *type_str; /**< where to write typecodes (or read type expectations) */
+ DBusString *value_str; /**< where to write values */
dbus_uint32_t byte_order : 8; /**< byte order to write values with */
dbus_uint32_t container_type : 8; /**< what are we inside? (e.g. struct, variant, array) */
@@ -71,9 +76,7 @@ struct DBusTypeWriter
dbus_uint32_t enabled : 1; /**< whether to write values */
- DBusString *type_str; /**< where to write typecodes (or read type expectations) */
int type_pos; /**< current pos in type_str */
- DBusString *value_str; /**< where to write values */
int value_pos; /**< next position to write */
union
diff --git a/dbus/dbus-marshal-validate.c b/dbus/dbus-marshal-validate.c
index 4d492f3f..53378b61 100644
--- a/dbus/dbus-marshal-validate.c
+++ b/dbus/dbus-marshal-validate.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -62,6 +64,8 @@ _dbus_validate_signature_with_reason (const DBusString *type_str,
int element_count;
DBusList *element_count_stack;
+ char opened_brackets[DBUS_MAXIMUM_TYPE_RECURSION_DEPTH * 2 + 1] = { '\0' };
+ char last_bracket;
result = DBUS_VALID;
element_count_stack = NULL;
@@ -93,6 +97,10 @@ _dbus_validate_signature_with_reason (const DBusString *type_str,
while (p != end)
{
+ _dbus_assert (struct_depth + dict_entry_depth >= 0);
+ _dbus_assert (struct_depth + dict_entry_depth < _DBUS_N_ELEMENTS (opened_brackets));
+ _dbus_assert (opened_brackets[struct_depth + dict_entry_depth] == '\0');
+
switch (*p)
{
case DBUS_TYPE_BYTE:
@@ -136,6 +144,10 @@ _dbus_validate_signature_with_reason (const DBusString *type_str,
goto out;
}
+ _dbus_assert (struct_depth + dict_entry_depth >= 1);
+ _dbus_assert (struct_depth + dict_entry_depth < _DBUS_N_ELEMENTS (opened_brackets));
+ _dbus_assert (opened_brackets[struct_depth + dict_entry_depth - 1] == '\0');
+ opened_brackets[struct_depth + dict_entry_depth - 1] = DBUS_STRUCT_BEGIN_CHAR;
break;
case DBUS_STRUCT_END_CHAR:
@@ -151,9 +163,20 @@ _dbus_validate_signature_with_reason (const DBusString *type_str,
goto out;
}
+ _dbus_assert (struct_depth + dict_entry_depth >= 1);
+ _dbus_assert (struct_depth + dict_entry_depth < _DBUS_N_ELEMENTS (opened_brackets));
+ last_bracket = opened_brackets[struct_depth + dict_entry_depth - 1];
+
+ if (last_bracket != DBUS_STRUCT_BEGIN_CHAR)
+ {
+ result = DBUS_INVALID_STRUCT_ENDED_BUT_NOT_STARTED;
+ goto out;
+ }
+
_dbus_list_pop_last (&element_count_stack);
struct_depth -= 1;
+ opened_brackets[struct_depth + dict_entry_depth] = '\0';
break;
case DBUS_DICT_ENTRY_BEGIN_CHAR:
@@ -178,6 +201,10 @@ _dbus_validate_signature_with_reason (const DBusString *type_str,
goto out;
}
+ _dbus_assert (struct_depth + dict_entry_depth >= 1);
+ _dbus_assert (struct_depth + dict_entry_depth < _DBUS_N_ELEMENTS (opened_brackets));
+ _dbus_assert (opened_brackets[struct_depth + dict_entry_depth - 1] == '\0');
+ opened_brackets[struct_depth + dict_entry_depth - 1] = DBUS_DICT_ENTRY_BEGIN_CHAR;
break;
case DBUS_DICT_ENTRY_END_CHAR:
@@ -186,8 +213,19 @@ _dbus_validate_signature_with_reason (const DBusString *type_str,
result = DBUS_INVALID_DICT_ENTRY_ENDED_BUT_NOT_STARTED;
goto out;
}
-
+
+ _dbus_assert (struct_depth + dict_entry_depth >= 1);
+ _dbus_assert (struct_depth + dict_entry_depth < _DBUS_N_ELEMENTS (opened_brackets));
+ last_bracket = opened_brackets[struct_depth + dict_entry_depth - 1];
+
+ if (last_bracket != DBUS_DICT_ENTRY_BEGIN_CHAR)
+ {
+ result = DBUS_INVALID_DICT_ENTRY_ENDED_BUT_NOT_STARTED;
+ goto out;
+ }
+
dict_entry_depth -= 1;
+ opened_brackets[struct_depth + dict_entry_depth] = '\0';
element_count =
_DBUS_POINTER_TO_INT (_dbus_list_pop_last (&element_count_stack));
@@ -332,10 +370,12 @@ validate_body_helper (DBusTypeReader *reader,
switch (current_type)
{
+ /* Special case of fixed-length types: every byte is valid */
case DBUS_TYPE_BYTE:
++p;
break;
+ /* Multi-byte fixed-length types require padding to their alignment */
case DBUS_TYPE_BOOLEAN:
case DBUS_TYPE_INT16:
case DBUS_TYPE_UINT16:
@@ -372,6 +412,7 @@ validate_body_helper (DBusTypeReader *reader,
p += alignment;
break;
+ /* Types that start with a 4-byte length */
case DBUS_TYPE_ARRAY:
case DBUS_TYPE_STRING:
case DBUS_TYPE_OBJECT_PATH:
@@ -394,6 +435,10 @@ validate_body_helper (DBusTypeReader *reader,
/* p may now be == end */
_dbus_assert (p <= end);
+ /* Arrays have padding between the length and the first
+ * array item, if it's necessary for the array's element type.
+ * This padding is not counted as part of the length
+ * claimed_len. */
if (current_type == DBUS_TYPE_ARRAY)
{
int array_elem_type = _dbus_type_reader_get_element_type (reader);
@@ -459,6 +504,9 @@ validate_body_helper (DBusTypeReader *reader,
_dbus_type_reader_recurse (reader, &sub);
array_end = p + claimed_len;
+ /* We effectively already checked this, by checking that
+ * claimed_len <= (end - p) */
+ _dbus_assert (array_end <= end);
array_elem_type = _dbus_type_reader_get_element_type (reader);
@@ -467,13 +515,24 @@ validate_body_helper (DBusTypeReader *reader,
*/
if (dbus_type_is_fixed (array_elem_type))
{
+ /* Note that fixed-size types all have sizes equal to
+ * their alignments, so this is really the item size. */
+ alignment = _dbus_type_get_alignment (array_elem_type);
+ _dbus_assert (alignment == 1 || alignment == 2 ||
+ alignment == 4 || alignment == 8);
+
+ /* Because the alignment is a power of 2, this is
+ * equivalent to: (claimed_len % alignment) != 0,
+ * but avoids slower integer division */
+ if ((claimed_len & (alignment - 1)) != 0)
+ return DBUS_INVALID_ARRAY_LENGTH_INCORRECT;
+
/* bools need to be handled differently, because they can
* have an invalid value
*/
if (array_elem_type == DBUS_TYPE_BOOLEAN)
{
dbus_uint32_t v;
- alignment = _dbus_type_get_alignment (array_elem_type);
while (p < array_end)
{
diff --git a/dbus/dbus-marshal-validate.h b/dbus/dbus-marshal-validate.h
index bc7c8174..94737872 100644
--- a/dbus/dbus-marshal-validate.h
+++ b/dbus/dbus-marshal-validate.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c
index 96df2357..be7e4ef6 100644
--- a/dbus/dbus-memory.c
+++ b/dbus/dbus-memory.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -255,18 +257,6 @@ dbus_bool_t
_dbus_decrement_fail_alloc_counter (void)
{
_dbus_initialize_malloc_debug ();
-#ifdef DBUS_WIN
- {
- static dbus_bool_t called = 0;
-
- if (!called)
- {
- _dbus_verbose_raw ("TODO: memory allocation testing errors disabled for now\n");
- called = 1;
- }
- return FALSE;
- }
-#endif
if (fail_alloc_counter <= 0)
{
@@ -349,8 +339,8 @@ check_guards (void *free_block,
if (free_block != NULL)
{
unsigned char *block = ((unsigned char*)free_block) - GUARD_START_OFFSET;
- size_t requested_bytes = *(dbus_uint32_t*)block;
- BlockSource source = *(dbus_uint32_t*)(block + 4);
+ size_t requested_bytes = *(dbus_uint32_t *) (void *) block;
+ BlockSource source = *(dbus_uint32_t *) (void *) (block + 4);
unsigned int i;
dbus_bool_t failed;
@@ -364,7 +354,7 @@ check_guards (void *free_block,
i = GUARD_INFO_SIZE;
while (i < GUARD_START_OFFSET)
{
- dbus_uint32_t value = *(dbus_uint32_t*) &block[i];
+ dbus_uint32_t value = *(dbus_uint32_t *) (void *) &block[i];
if (value != GUARD_VALUE)
{
_dbus_warn ("Block of %lu bytes from %s had start guard value 0x%ux at %d expected 0x%x",
@@ -379,7 +369,7 @@ check_guards (void *free_block,
i = GUARD_START_OFFSET + requested_bytes;
while (i < (GUARD_START_OFFSET + requested_bytes + GUARD_END_PAD))
{
- dbus_uint32_t value = *(dbus_uint32_t*) &block[i];
+ dbus_uint32_t value = *(dbus_uint32_t *) (void *) &block[i];
if (value != GUARD_VALUE)
{
_dbus_warn ("Block of %lu bytes from %s had end guard value 0x%ux at %d expected 0x%x",
@@ -412,23 +402,23 @@ set_guards (void *real_block,
return NULL;
_dbus_assert (GUARD_START_OFFSET + GUARD_END_PAD == GUARD_EXTRA_SIZE);
-
- *((dbus_uint32_t*)block) = requested_bytes;
- *((dbus_uint32_t*)(block + 4)) = source;
+
+ *((dbus_uint32_t *) (void *) block) = requested_bytes;
+ *((dbus_uint32_t *) (void *) (block + 4)) = source;
i = GUARD_INFO_SIZE;
while (i < GUARD_START_OFFSET)
{
- (*(dbus_uint32_t*) &block[i]) = GUARD_VALUE;
-
+ (*(dbus_uint32_t *) (void *) &block[i]) = GUARD_VALUE;
+
i += 4;
}
i = GUARD_START_OFFSET + requested_bytes;
while (i < (GUARD_START_OFFSET + requested_bytes + GUARD_END_PAD))
{
- (*(dbus_uint32_t*) &block[i]) = GUARD_VALUE;
-
+ (*(dbus_uint32_t *) (void *) &block[i]) = GUARD_VALUE;
+
i += 4;
}
diff --git a/dbus/dbus-memory.h b/dbus/dbus-memory.h
index 4dcf2f92..5b5a41e1 100644
--- a/dbus/dbus-memory.h
+++ b/dbus/dbus-memory.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-mempool.c b/dbus/dbus-mempool.c
index 83aa2722..5bc4a97b 100644
--- a/dbus/dbus-mempool.c
+++ b/dbus/dbus-mempool.c
@@ -5,6 +5,8 @@
* Copyright (C) 2003 CodeFactory AB
* Copyright (C) 2011-2012 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -66,12 +68,6 @@ struct DBusFreedElement
};
/**
- * The dummy size of the variable-length "elements"
- * field in DBusMemBlock
- */
-#define ELEMENT_PADDING 4
-
-/**
* Typedef for DBusMemBlock so the struct can recursively
* point to itself.
*/
@@ -88,19 +84,31 @@ struct DBusMemBlock
* when we free the mem pool.
*/
- /* this is a long so that "elements" is aligned */
- long used_so_far; /**< bytes of this block already allocated as elements. */
-
- unsigned char elements[ELEMENT_PADDING]; /**< the block data, actually allocated to required size */
+ size_t used_so_far; /**< bytes of this block already allocated as elements. */
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
+ /*
+ * Ensure that elements is aligned correctly. For all supported pre-C11
+ * targets, the size_t above should ensure that the elements array is
+ * sufficiently aligned (this is checked in the static assert below).
+ */
+ _Alignas (dbus_max_align_t)
+#endif
+ unsigned char elements[]; /**< the block data, actually allocated to required size */
};
+_DBUS_STATIC_ASSERT (_DBUS_IS_ALIGNED (sizeof (struct DBusMemBlock),
+ _DBUS_ALIGNOF (dbus_max_align_t)));
+_DBUS_STATIC_ASSERT (_DBUS_IS_ALIGNED (offsetof (struct DBusMemBlock,
+ elements),
+ _DBUS_ALIGNOF (dbus_max_align_t)));
+
/**
* Internals fields of DBusMemPool
*/
struct DBusMemPool
{
- int element_size; /**< size of a single object in the pool */
- int block_size; /**< size of most recently allocated block */
+ size_t element_size; /**< size of a single object in the pool */
+ size_t block_size; /**< size of most recently allocated block */
unsigned int zero_elements : 1; /**< whether to zero-init allocated elements */
DBusFreedElement *free_elements; /**< a free list of elements to recycle */
@@ -149,17 +157,20 @@ _dbus_mem_pool_new (int element_size,
/* Make the element size at least 8 bytes. */
if (element_size < 8)
element_size = 8;
-
+ if (element_size < (int) sizeof (void *))
+ element_size = sizeof (void *);
+
/* these assertions are equivalent but the first is more clear
* to programmers that see it fail.
*/
_dbus_assert (element_size >= (int) sizeof (void*));
_dbus_assert (element_size >= (int) sizeof (DBusFreedElement));
- /* align the element size to a pointer boundary so we won't get bus
- * errors under other architectures.
+ /* align the element size to be suitable for the most-aligned type
+ * that we care about (in practice usually a pointer).
*/
- pool->element_size = _DBUS_ALIGN_VALUE (element_size, sizeof (void *));
+ pool->element_size =
+ _DBUS_ALIGN_VALUE (element_size, _DBUS_ALIGNOF (dbus_max_align_t));
pool->zero_elements = zero_elements != FALSE;
@@ -219,7 +230,7 @@ _dbus_mem_pool_alloc (DBusMemPool *pool)
if (_dbus_disable_mem_pools ())
{
DBusMemBlock *block;
- int alloc_size;
+ size_t alloc_size;
/* This is obviously really silly, but it's
* debug-mode-only code that is compiled out
@@ -227,10 +238,9 @@ _dbus_mem_pool_alloc (DBusMemPool *pool)
* is a constant expression FALSE so this block
* should vanish)
*/
-
- alloc_size = sizeof (DBusMemBlock) - ELEMENT_PADDING +
- pool->element_size;
-
+
+ alloc_size = sizeof (DBusMemBlock) + pool->element_size;
+
if (pool->zero_elements)
block = dbus_malloc0 (alloc_size);
else
@@ -244,6 +254,8 @@ _dbus_mem_pool_alloc (DBusMemPool *pool)
VALGRIND_MEMPOOL_ALLOC (pool, (void *) &block->elements[0],
pool->element_size);
+ _dbus_assert (_DBUS_IS_ALIGNED (&block->elements[0],
+ _DBUS_ALIGNOF (dbus_max_align_t)));
return (void*) &block->elements[0];
}
else
@@ -269,7 +281,8 @@ _dbus_mem_pool_alloc (DBusMemPool *pool)
memset (element, '\0', pool->element_size);
pool->allocated_elements += 1;
-
+ _dbus_assert (
+ _DBUS_IS_ALIGNED (element, _DBUS_ALIGNOF (dbus_max_align_t)));
return element;
}
else
@@ -281,7 +294,7 @@ _dbus_mem_pool_alloc (DBusMemPool *pool)
{
/* Need a new block */
DBusMemBlock *block;
- int alloc_size;
+ size_t alloc_size;
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
int saved_counter;
#endif
@@ -294,7 +307,7 @@ _dbus_mem_pool_alloc (DBusMemPool *pool)
pool->element_size) == 0);
}
- alloc_size = sizeof (DBusMemBlock) - ELEMENT_PADDING + pool->block_size;
+ alloc_size = sizeof (DBusMemBlock) + pool->block_size;
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
/* We save/restore the counter, so that memory pools won't
@@ -311,6 +324,8 @@ _dbus_mem_pool_alloc (DBusMemPool *pool)
block = dbus_malloc0 (alloc_size);
else
block = dbus_malloc (alloc_size);
+ _dbus_assert (
+ _DBUS_IS_ALIGNED (block, _DBUS_ALIGNOF (dbus_max_align_t)));
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
_dbus_set_fail_alloc_counter (saved_counter);
@@ -324,14 +339,16 @@ _dbus_mem_pool_alloc (DBusMemPool *pool)
block->next = pool->blocks;
pool->blocks = block;
}
-
+
element = &pool->blocks->elements[pool->blocks->used_so_far];
-
+
pool->blocks->used_so_far += pool->element_size;
pool->allocated_elements += 1;
VALGRIND_MEMPOOL_ALLOC (pool, element, pool->element_size);
+ _dbus_assert (
+ _DBUS_IS_ALIGNED (element, _DBUS_ALIGNOF (dbus_max_align_t)));
return element;
}
}
diff --git a/dbus/dbus-mempool.h b/dbus/dbus-mempool.h
index 8ec3acd5..fe7efd1d 100644
--- a/dbus/dbus-mempool.h
+++ b/dbus/dbus-mempool.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-message-internal.h b/dbus/dbus-message-internal.h
index adc07f98..55f473f4 100644
--- a/dbus/dbus-message-internal.h
+++ b/dbus/dbus-message-internal.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-message-private.h b/dbus/dbus-message-private.h
index fed06ce0..eb52f44f 100644
--- a/dbus/dbus-message-private.h
+++ b/dbus/dbus-message-private.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2005 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-message-util.c b/dbus/dbus-message-util.c
index be8b63d4..f48f8625 100644
--- a/dbus/dbus-message-util.c
+++ b/dbus/dbus-message-util.c
@@ -3,6 +3,8 @@
*
* Copyright 2017 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c
index 45b1adfd..b47a8638 100644
--- a/dbus/dbus-message.c
+++ b/dbus/dbus-message.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003, 2004, 2005 Red Hat Inc.
* Copyright (C) 2002, 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -136,6 +138,15 @@ struct DBusMessageRealIter
} u; /**< the type writer or reader that does all the work */
};
+#if DBUS_SIZEOF_VOID_P > 8
+/*
+ * Architectures with 128-bit pointers were not supported in DBus 1.10, so we
+ * do no check for DBus 1.10 structure layout compatibility for such
+ * architectures (e.g. Arm Morello).
+ */
+#define CHECK_DBUS_1_10_BINARY_COMPATIBILITY 0
+#else
+#define CHECK_DBUS_1_10_BINARY_COMPATIBILITY 1
/**
* Layout of a DBusMessageIter on the stack in dbus 1.10.0. This is no
* longer used, but for ABI compatibility we need to assert that the
@@ -158,6 +169,7 @@ typedef struct
int pad2;
void *pad3;
} DBusMessageIter_1_10_0;
+#endif
static void
get_const_signature (DBusHeader *header,
@@ -843,7 +855,7 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter,
/* copy var_args first, then we can do another iteration over it to
* free memory and close unix fds if parse failed at some point.
*/
- DBUS_VA_COPY (copy_args, var_args);
+ va_copy (copy_args, var_args);
while (spec_type != DBUS_TYPE_INVALID)
{
@@ -2069,17 +2081,23 @@ _dbus_message_iter_init_common (DBusMessage *message,
_DBUS_STATIC_ASSERT (sizeof (DBusMessageRealIter) <= sizeof (DBusMessageIter));
_DBUS_STATIC_ASSERT (_DBUS_ALIGNOF (DBusMessageRealIter) <=
_DBUS_ALIGNOF (DBusMessageIter));
+#if CHECK_DBUS_1_10_BINARY_COMPATIBILITY
/* A failure of these two assertions would indicate that we've broken
* ABI on this platform since 1.10.0. */
_DBUS_STATIC_ASSERT (sizeof (DBusMessageIter_1_10_0) ==
sizeof (DBusMessageIter));
_DBUS_STATIC_ASSERT (_DBUS_ALIGNOF (DBusMessageIter_1_10_0) ==
_DBUS_ALIGNOF (DBusMessageIter));
+#endif
/* If this static assertion fails, it means the DBusMessageIter struct
* is not "packed", which might result in "iter = other_iter" not copying
* every byte. */
+#if DBUS_SIZEOF_VOID_P > 8
+ _DBUS_STATIC_ASSERT (sizeof (DBusMessageIter) == 16 * sizeof (void *));
+#else
_DBUS_STATIC_ASSERT (sizeof (DBusMessageIter) ==
4 * sizeof (void *) + sizeof (dbus_uint32_t) + 9 * sizeof (int));
+#endif
/* Since the iterator will read or write who-knows-what from the
* message, we need to get in the right byte order
@@ -2275,7 +2293,7 @@ dbus_message_iter_get_signature (DBusMessageIter *iter)
{
const DBusString *sig;
DBusString retstr;
- char *ret;
+ char *ret = NULL;
int start, len;
DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
@@ -2289,9 +2307,13 @@ dbus_message_iter_get_signature (DBusMessageIter *iter)
if (!_dbus_string_append_len (&retstr,
_dbus_string_get_const_data (sig) + start,
len))
- return NULL;
- if (!_dbus_string_steal_data (&retstr, &ret))
- return NULL;
+ goto oom;
+
+ /* This is correct whether it succeeds or fails: on success it sets `ret`,
+ * and on failure it leaves `ret` set to NULL. */
+ _dbus_string_steal_data (&retstr, &ret);
+
+oom:
_dbus_string_free (&retstr);
return ret;
}
@@ -2675,7 +2697,7 @@ _dbus_message_iter_abandon_signature (DBusMessageRealIter *real)
dbus_free (str);
}
-#ifndef DBUS_DISABLE_CHECKS
+#if defined(DBUS_ENABLE_CHECKS) || defined(DBUS_ENABLE_ASSERT)
static dbus_bool_t
_dbus_message_iter_append_check (DBusMessageRealIter *iter)
{
@@ -2690,7 +2712,7 @@ _dbus_message_iter_append_check (DBusMessageRealIter *iter)
return TRUE;
}
-#endif /* DBUS_DISABLE_CHECKS */
+#endif
#ifdef HAVE_UNIX_FD_PASSING
static int *
@@ -5185,6 +5207,9 @@ dbus_message_demarshal (const char *str,
return msg;
fail_corrupt:
+ if (loader->corruption_reason == DBUS_VALIDITY_UNKNOWN_OOM_ERROR)
+ goto fail_oom;
+
dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, "Message is corrupted (%s)",
_dbus_validity_to_error_message (loader->corruption_reason));
_dbus_message_loader_unref (loader);
@@ -5459,14 +5484,18 @@ oom:
const char *
_dbus_variant_get_signature (DBusVariant *self)
{
- unsigned char len;
const char *ret;
+#ifndef DBUS_DISABLE_ASSERT
+ unsigned char len;
+#endif
_dbus_assert (self != NULL);
+#ifndef DBUS_DISABLE_ASSERT
/* Here we make use of the fact that the serialization of a variant starts
* with the 1-byte length, then that many bytes of signature, then \0. */
len = _dbus_string_get_byte (&self->data, 0);
+#endif
ret = _dbus_string_get_const_data_len (&self->data, 1, len);
_dbus_assert (strlen (ret) == len);
return ret;
diff --git a/dbus/dbus-message.h b/dbus/dbus-message.h
index da2f2d9d..0bbad3d1 100644
--- a/dbus/dbus-message.h
+++ b/dbus/dbus-message.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003, 2005 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -59,7 +61,10 @@ typedef struct DBusMessageIter DBusMessageIter;
* DBusMessageIter struct; contains no public fields.
*/
struct DBusMessageIter
-{
+{
+#if DBUS_SIZEOF_VOID_P > 8
+ void *dummy[16]; /**< Don't use this */
+#else
void *dummy1; /**< Don't use this */
void *dummy2; /**< Don't use this */
dbus_uint32_t dummy3; /**< Don't use this */
@@ -74,12 +79,24 @@ struct DBusMessageIter
int pad1; /**< Don't use this */
void *pad2; /**< Don't use this */
void *pad3; /**< Don't use this */
+#endif
};
/**
* A message iterator for which dbus_message_iter_abandon_container_if_open()
* is the only valid operation.
*/
+#if DBUS_SIZEOF_VOID_P > 8
+#define DBUS_MESSAGE_ITER_INIT_CLOSED \
+{ \
+ { \
+ NULL, NULL, NULL, NULL, \
+ NULL, NULL, NULL, NULL, \
+ NULL, NULL, NULL, NULL, \
+ NULL, NULL, NULL, NULL \
+ } \
+}
+#else
#define DBUS_MESSAGE_ITER_INIT_CLOSED \
{ \
NULL, /* dummy1 */ \
@@ -97,6 +114,7 @@ struct DBusMessageIter
NULL, /* pad2 */ \
NULL /* pad3 */ \
}
+#endif
DBUS_EXPORT
DBusMessage* dbus_message_new (int message_type);
diff --git a/dbus/dbus-misc.c b/dbus/dbus-misc.c
index 67a28403..0f6c2e6d 100644
--- a/dbus/dbus-misc.c
+++ b/dbus/dbus-misc.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2006 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-misc.h b/dbus/dbus-misc.h
index ff2a7e4b..3442ab78 100644
--- a/dbus/dbus-misc.h
+++ b/dbus/dbus-misc.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2006 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c
index ef5eb617..5ac9a013 100644
--- a/dbus/dbus-nonce.c
+++ b/dbus/dbus-nonce.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2009 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.net
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -194,8 +196,7 @@ _dbus_accept_with_noncefile (DBusSocket listen_fd, const DBusNonceFile *noncefil
if (do_check_nonce(fd, &nonce, NULL) != TRUE) {
_dbus_verbose ("nonce check failed. Closing socket.\n");
- _dbus_close_socket(fd, NULL);
- _dbus_socket_invalidate (&fd);
+ _dbus_close_socket (&fd, NULL);
goto out;
}
diff --git a/dbus/dbus-nonce.h b/dbus/dbus-nonce.h
index bf32af80..d26dc397 100644
--- a/dbus/dbus-nonce.h
+++ b/dbus/dbus-nonce.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2009 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.net
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c
index 6038a63c..bb7d5479 100644
--- a/dbus/dbus-object-tree.c
+++ b/dbus/dbus-object-tree.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003, 2005 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-object-tree.h b/dbus/dbus-object-tree.h
index 1cba2a04..245f9336 100644
--- a/dbus/dbus-object-tree.h
+++ b/dbus/dbus-object-tree.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-pending-call-internal.h b/dbus/dbus-pending-call-internal.h
index dc53003d..a3734937 100644
--- a/dbus/dbus-pending-call-internal.h
+++ b/dbus/dbus-pending-call-internal.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-pending-call.c b/dbus/dbus-pending-call.c
index 84fdcb58..f0b39d90 100644
--- a/dbus/dbus-pending-call.c
+++ b/dbus/dbus-pending-call.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-pending-call.h b/dbus/dbus-pending-call.h
index f5122f19..3539a1f2 100644
--- a/dbus/dbus-pending-call.h
+++ b/dbus/dbus-pending-call.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-pipe-unix.c b/dbus/dbus-pipe-unix.c
index cbf793fb..314c7293 100644
--- a/dbus/dbus-pipe-unix.c
+++ b/dbus/dbus-pipe-unix.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003, 2006 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-pipe-win.c b/dbus/dbus-pipe-win.c
index f12e834a..5667ad91 100644
--- a/dbus/dbus-pipe-win.c
+++ b/dbus/dbus-pipe-win.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003, 2006 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-pipe.c b/dbus/dbus-pipe.c
index c9b78c7e..f1fb19ff 100644
--- a/dbus/dbus-pipe.c
+++ b/dbus/dbus-pipe.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003, 2006 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-pipe.h b/dbus/dbus-pipe.h
index 637d29ea..1e579aa4 100644
--- a/dbus/dbus-pipe.h
+++ b/dbus/dbus-pipe.h
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -25,9 +27,7 @@
#ifndef DBUS_PIPE_H
#define DBUS_PIPE_H
-#ifdef HAVE_STDINT_H
#include <stdint.h>
-#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
diff --git a/dbus/dbus-pollable-set-epoll.c b/dbus/dbus-pollable-set-epoll.c
index 7bd200b3..24f00935 100644
--- a/dbus/dbus-pollable-set-epoll.c
+++ b/dbus/dbus-pollable-set-epoll.c
@@ -3,6 +3,8 @@
*
* Copyright © 2011 Nokia Corporation
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-pollable-set-poll.c b/dbus/dbus-pollable-set-poll.c
index 24c2c961..46a31fc2 100644
--- a/dbus/dbus-pollable-set-poll.c
+++ b/dbus/dbus-pollable-set-poll.c
@@ -3,6 +3,8 @@
*
* Copyright © 2011 Nokia Corporation
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-pollable-set.c b/dbus/dbus-pollable-set.c
index e3aaedc5..862ae25a 100644
--- a/dbus/dbus-pollable-set.c
+++ b/dbus/dbus-pollable-set.c
@@ -4,6 +4,8 @@
*
* Copyright © 2011 Nokia Corporation
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-pollable-set.h b/dbus/dbus-pollable-set.h
index b92d776a..5335cdfc 100644
--- a/dbus/dbus-pollable-set.h
+++ b/dbus/dbus-pollable-set.h
@@ -4,6 +4,8 @@
*
* Copyright © 2011 Nokia Corporation
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-protocol.h b/dbus/dbus-protocol.h
index b3db8c61..33e39df3 100644
--- a/dbus/dbus-protocol.h
+++ b/dbus/dbus-protocol.h
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003 CodeFactory AB
* Copyright (C) 2004, 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-resources.c b/dbus/dbus-resources.c
index 9ed663ad..7e1c3e55 100644
--- a/dbus/dbus-resources.c
+++ b/dbus/dbus-resources.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -273,7 +275,11 @@ _dbus_counter_adjust_unix_fd (DBusCounter *counter,
long
_dbus_counter_get_size_value (DBusCounter *counter)
{
- return counter->size_value;
+ long result;
+ _dbus_rmutex_lock (counter->mutex);
+ result = counter->size_value;
+ _dbus_rmutex_unlock (counter->mutex);
+ return result;
}
/**
@@ -285,7 +291,11 @@ _dbus_counter_get_size_value (DBusCounter *counter)
long
_dbus_counter_get_unix_fd_value (DBusCounter *counter)
{
- return counter->unix_fd_value;
+ long result;
+ _dbus_rmutex_lock (counter->mutex);
+ result = counter->unix_fd_value;
+ _dbus_rmutex_unlock (counter->mutex);
+ return result;
}
/**
diff --git a/dbus/dbus-resources.h b/dbus/dbus-resources.h
index 9ac4d334..2df56322 100644
--- a/dbus/dbus-resources.h
+++ b/dbus/dbus-resources.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -24,6 +26,7 @@
#define DBUS_RESOURCES_H
#include <dbus/dbus-macros.h>
+#include <dbus/dbus-macros-internal.h>
#include <dbus/dbus-errors.h>
#include <dbus/dbus-connection.h>
@@ -33,17 +36,22 @@ typedef struct DBusCounter DBusCounter;
typedef void (* DBusCounterNotifyFunction) (DBusCounter *counter,
void *user_data);
-
+DBUS_EMBEDDED_TESTS_EXPORT
DBusCounter* _dbus_counter_new (void);
DBusCounter* _dbus_counter_ref (DBusCounter *counter);
+DBUS_EMBEDDED_TESTS_EXPORT
void _dbus_counter_unref (DBusCounter *counter);
+DBUS_EMBEDDED_TESTS_EXPORT
void _dbus_counter_adjust_size (DBusCounter *counter,
long delta);
+DBUS_EMBEDDED_TESTS_EXPORT
void _dbus_counter_adjust_unix_fd (DBusCounter *counter,
long delta);
void _dbus_counter_notify (DBusCounter *counter);
+DBUS_EMBEDDED_TESTS_EXPORT
long _dbus_counter_get_size_value (DBusCounter *counter);
+DBUS_EMBEDDED_TESTS_EXPORT
long _dbus_counter_get_unix_fd_value (DBusCounter *counter);
void _dbus_counter_set_notify (DBusCounter *counter,
diff --git a/dbus/dbus-server-debug-pipe.c b/dbus/dbus-server-debug-pipe.c
index c396bc82..bf91939a 100644
--- a/dbus/dbus-server-debug-pipe.c
+++ b/dbus/dbus-server-debug-pipe.c
@@ -4,6 +4,8 @@
* Copyright (C) 2003 CodeFactory AB
* Copyright (C) 2003, 2004 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -260,8 +262,8 @@ _dbus_transport_debug_pipe_new (const char *server_name,
NULL, &address);
if (client_transport == NULL)
{
- _dbus_close_socket (client_fd, NULL);
- _dbus_close_socket (server_fd, NULL);
+ _dbus_close_socket (&client_fd, NULL);
+ _dbus_close_socket (&server_fd, NULL);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
_dbus_string_free (&address);
return NULL;
@@ -276,7 +278,7 @@ _dbus_transport_debug_pipe_new (const char *server_name,
if (server_transport == NULL)
{
_dbus_transport_unref (client_transport);
- _dbus_close_socket (server_fd, NULL);
+ _dbus_close_socket (&server_fd, NULL);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
return NULL;
}
diff --git a/dbus/dbus-server-debug-pipe.h b/dbus/dbus-server-debug-pipe.h
index 68490391..4284dc57 100644
--- a/dbus/dbus-server-debug-pipe.h
+++ b/dbus/dbus-server-debug-pipe.h
@@ -4,6 +4,8 @@
* Copyright (C) 2003 CodeFactory AB
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-server-launchd.c b/dbus/dbus-server-launchd.c
index 21292973..b28b4576 100644
--- a/dbus/dbus-server-launchd.c
+++ b/dbus/dbus-server-launchd.c
@@ -3,6 +3,7 @@
* Copyright (C) 2008, Colin Walters <walters@verbum.org>
* Copyright (C) 2008-2009, Benjamin Reed <rangerrick@befunk.com>
* Copyright (C) 2009, Jonas Bähr <jonas.baehr@web.de>
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -39,6 +40,7 @@
#ifdef DBUS_ENABLE_LAUNCHD
#include <launch.h>
#include <errno.h>
+#include <unistd.h>
#include "dbus-misc.h"
#include "dbus-server-socket.h"
diff --git a/dbus/dbus-server-launchd.h b/dbus/dbus-server-launchd.h
index 269b9143..51c9628e 100644
--- a/dbus/dbus-server-launchd.h
+++ b/dbus/dbus-server-launchd.h
@@ -1,5 +1,6 @@
/* dbus-server-launchd.h Server methods for interacting with launchd.
* Copyright (C) 2008, Benjamin Reed <rangerrick@befunk.com>
+* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
diff --git a/dbus/dbus-server-protected.h b/dbus/dbus-server-protected.h
index 650963f1..d5aee150 100644
--- a/dbus/dbus-server-protected.h
+++ b/dbus/dbus-server-protected.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -126,6 +128,10 @@ typedef enum
DBUS_SERVER_LISTEN_ADDRESS_ALREADY_USED /**< address is already used */
} DBusServerListenResult;
+DBusServerListenResult _dbus_server_listen_unix_socket (DBusAddressEntry *entry,
+ DBusServer **server_p,
+ DBusError *error);
+
DBusServerListenResult _dbus_server_listen_platform_specific (DBusAddressEntry *entry,
DBusServer **server_p,
DBusError *error);
diff --git a/dbus/dbus-server-socket.c b/dbus/dbus-server-socket.c
index bc5e3a9d..5dc1b54e 100644
--- a/dbus/dbus-server-socket.c
+++ b/dbus/dbus-server-socket.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003, 2004, 2006 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -103,7 +105,7 @@ handle_new_client_fd_and_unlock (DBusServer *server,
transport = _dbus_transport_new_for_socket (client_fd, &server->guid_hex, NULL);
if (transport == NULL)
{
- _dbus_close_socket (client_fd, NULL);
+ _dbus_close_socket (&client_fd, NULL);
SERVER_UNLOCK (server);
return FALSE;
}
@@ -172,7 +174,10 @@ socket_handle_watch (DBusWatch *watch,
for (i = 0 ; i < socket_server->n_fds ; i++)
{
if (socket_server->watch[i] == watch)
- found = TRUE;
+ {
+ found = TRUE;
+ break;
+ }
}
_dbus_assert (found);
#endif
@@ -242,10 +247,7 @@ socket_disconnect (DBusServer *server)
}
if (_dbus_socket_is_valid (socket_server->fds[i]))
- {
- _dbus_close_socket (socket_server->fds[i], NULL);
- _dbus_socket_invalidate (&socket_server->fds[i]);
- }
+ _dbus_close_socket (&socket_server->fds[i], NULL);
}
if (socket_server->socket_name != NULL)
@@ -513,7 +515,7 @@ failed:
if (listen_fds != NULL)
{
for (i = 0; i < nlisten_fds; i++)
- _dbus_close_socket (listen_fds[i], NULL);
+ _dbus_close_socket (&listen_fds[i], NULL);
dbus_free (listen_fds);
}
@@ -596,5 +598,287 @@ _dbus_server_socket_own_filename (DBusServer *server,
socket_server->socket_name = filename;
}
+/**
+ * Creates a new server listening on the given Unix domain socket.
+ *
+ * @param path the path for the domain socket.
+ * @param abstract #TRUE to use abstract socket namespace
+ * @param error location to store reason for failure.
+ * @returns the new server, or #NULL on failure.
+ */
+DBusServer*
+_dbus_server_new_for_domain_socket (const char *path,
+ dbus_bool_t abstract,
+ DBusError *error)
+{
+ DBusServer *server;
+ DBusSocket listen_fd;
+ DBusString address;
+ char *path_copy;
+ DBusString path_str;
+
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ if (!_dbus_string_init (&address))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
+
+ _dbus_string_init_const (&path_str, path);
+ if ((abstract &&
+ !_dbus_string_append (&address, "unix:abstract=")) ||
+ (!abstract &&
+ !_dbus_string_append (&address, "unix:path=")) ||
+ !_dbus_address_append_escaped (&address, &path_str))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ goto failed_0;
+ }
+
+ if (abstract)
+ {
+ path_copy = NULL;
+ }
+ else
+ {
+ path_copy = _dbus_strdup (path);
+ if (path_copy == NULL)
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ goto failed_0;
+ }
+ }
+
+ listen_fd = _dbus_listen_unix_socket (path, abstract, error);
+
+ if (!_dbus_socket_is_valid (listen_fd))
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ goto failed_1;
+ }
+
+ server = _dbus_server_new_for_socket (&listen_fd, 1, &address, 0, error);
+ if (server == NULL)
+ {
+ goto failed_2;
+ }
+
+ if (path_copy != NULL)
+ _dbus_server_socket_own_filename(server, path_copy);
+
+ _dbus_string_free (&address);
+
+ return server;
+
+ failed_2:
+ _dbus_close_socket (&listen_fd, NULL);
+ failed_1:
+ dbus_free (path_copy);
+ failed_0:
+ _dbus_string_free (&address);
+
+ return NULL;
+}
+
+/**
+ * Creates a new Unix domain socket server listening under the given directory.
+ * This function is used for "unix:dir/tmpdir" kind of addresses.
+ *
+ * @param dir the path to a directory.
+ * @param error location to store reason for failure.
+ * @returns the new server, or #NULL on failure.
+ */
+static DBusServer *
+_dbus_server_new_for_dir (const char *dir,
+ DBusError *error)
+{
+ DBusServer *server;
+ DBusString full_path;
+ DBusString filename;
+
+ if (!_dbus_string_init (&full_path))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
+
+ if (!_dbus_string_init (&filename))
+ {
+ _dbus_string_free (&full_path);
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
+
+ if (!_dbus_string_append (&filename, "dbus-"))
+ {
+ _dbus_string_free (&full_path);
+ _dbus_string_free (&filename);
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
+
+ if (!_dbus_generate_random_ascii (&filename, 10, error))
+ {
+ _dbus_string_free (&full_path);
+ _dbus_string_free (&filename);
+ return NULL;
+ }
+
+ if (!_dbus_string_append (&full_path, dir) ||
+ !_dbus_concat_dir_and_file (&full_path, &filename))
+ {
+ _dbus_string_free (&full_path);
+ _dbus_string_free (&filename);
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
+
+ server =
+ _dbus_server_new_for_domain_socket (_dbus_string_get_const_data (&full_path),
+ FALSE, /* not abstract */
+ error);
+
+ _dbus_string_free (&full_path);
+ _dbus_string_free (&filename);
+
+ return server;
+}
+
+/**
+ * Tries to interpret the address entry for UNIX socket
+ * addresses.
+ *
+ * Sets error if the result is not OK.
+ *
+ * @param entry an address entry
+ * @param server_p location to store a new DBusServer, or #NULL on failure.
+ * @param error location to store rationale for failure on bad address
+ * @returns the outcome
+ *
+ */
+DBusServerListenResult
+_dbus_server_listen_unix_socket (DBusAddressEntry *entry,
+ DBusServer **server_p,
+ DBusError *error)
+{
+ const char *method;
+
+ *server_p = NULL;
+
+ method = dbus_address_entry_get_method (entry);
+
+ if (strcmp (method, "unix") == 0)
+ {
+ const char *path = dbus_address_entry_get_value (entry, "path");
+ const char *dir = dbus_address_entry_get_value (entry, "dir");
+ const char *tmpdir = dbus_address_entry_get_value (entry, "tmpdir");
+ const char *abstract = dbus_address_entry_get_value (entry, "abstract");
+ const char *runtime = dbus_address_entry_get_value (entry, "runtime");
+ int mutually_exclusive_modes = 0;
+
+ mutually_exclusive_modes = (path != NULL) + (tmpdir != NULL) +
+ (abstract != NULL) + (runtime != NULL) + (dir != NULL);
+
+ if (mutually_exclusive_modes < 1)
+ {
+ _dbus_set_bad_address(error, "unix",
+ "path or tmpdir or abstract or runtime or dir",
+ NULL);
+ return DBUS_SERVER_LISTEN_BAD_ADDRESS;
+ }
+
+ if (mutually_exclusive_modes > 1)
+ {
+ _dbus_set_bad_address(error, NULL, NULL,
+ "cannot specify two of \"path\", \"tmpdir\", \"abstract\", \"runtime\" and \"dir\" at the same time");
+ return DBUS_SERVER_LISTEN_BAD_ADDRESS;
+ }
+
+ if (runtime != NULL)
+ {
+ DBusString full_path;
+ DBusString filename;
+ const char *runtimedir;
+
+ if (strcmp (runtime, "yes") != 0)
+ {
+ _dbus_set_bad_address(error, NULL, NULL,
+ "if given, the only value allowed for \"runtime\" is \"yes\"");
+ return DBUS_SERVER_LISTEN_BAD_ADDRESS;
+ }
+
+ runtimedir = _dbus_getenv ("XDG_RUNTIME_DIR");
+
+ if (runtimedir == NULL)
+ {
+ dbus_set_error (error,
+ DBUS_ERROR_NOT_SUPPORTED, "\"XDG_RUNTIME_DIR\" is not set");
+ return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
+ }
+
+ _dbus_string_init_const (&filename, "bus");
+
+ if (!_dbus_string_init (&full_path))
+ {
+ _DBUS_SET_OOM (error);
+ return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
+ }
+
+ if (!_dbus_string_append (&full_path, runtimedir) ||
+ !_dbus_concat_dir_and_file (&full_path, &filename))
+ {
+ _dbus_string_free (&full_path);
+ _DBUS_SET_OOM (error);
+ return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
+ }
+
+ /* We can safely use filesystem sockets in the runtime directory,
+ * and they are preferred because they can be bind-mounted between
+ * Linux containers. */
+ *server_p = _dbus_server_new_for_domain_socket (
+ _dbus_string_get_const_data (&full_path),
+ FALSE, error);
+
+ _dbus_string_free (&full_path);
+ }
+ else if (tmpdir != NULL || dir != NULL)
+ {
+ /* tmpdir is now equivalent to dir. Previously it would try to
+ * use an abstract socket. */
+ if (tmpdir != NULL)
+ dir = tmpdir;
+
+ *server_p = _dbus_server_new_for_dir (dir, error);
+ }
+ else
+ {
+ if (path)
+ *server_p = _dbus_server_new_for_domain_socket (path, FALSE, error);
+ else
+ *server_p = _dbus_server_new_for_domain_socket (abstract, TRUE, error);
+ }
+
+ if (*server_p != NULL)
+ {
+ _DBUS_ASSERT_ERROR_IS_CLEAR(error);
+ return DBUS_SERVER_LISTEN_OK;
+ }
+ else
+ {
+ _DBUS_ASSERT_ERROR_IS_SET(error);
+ return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
+ }
+ }
+ else
+ {
+ /* If we don't handle the method, we return NULL with the
+ * error unset
+ */
+ _DBUS_ASSERT_ERROR_IS_CLEAR(error);
+ return DBUS_SERVER_LISTEN_NOT_HANDLED;
+ }
+}
+
/** @} */
diff --git a/dbus/dbus-server-socket.h b/dbus/dbus-server-socket.h
index ee5bf45f..31b086e8 100644
--- a/dbus/dbus-server-socket.h
+++ b/dbus/dbus-server-socket.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2006 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -51,6 +53,9 @@ DBusServerListenResult _dbus_server_listen_socket (DBusAddressEntry *entry,
void _dbus_server_socket_own_filename (DBusServer *server,
char *filename);
+DBusServer* _dbus_server_new_for_domain_socket (const char *path,
+ dbus_bool_t abstract,
+ DBusError *error);
DBUS_END_DECLS
#endif /* DBUS_SERVER_SOCKET_H */
diff --git a/dbus/dbus-server-unix.c b/dbus/dbus-server-unix.c
index c7ace2bc..dd1cb525 100644
--- a/dbus/dbus-server-unix.c
+++ b/dbus/dbus-server-unix.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003, 2004 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -23,7 +25,6 @@
#include <config.h>
#include "dbus-internals.h"
-#include "dbus-server-unix.h"
#include "dbus-server-socket.h"
#include "dbus-server-launchd.h"
#include "dbus-transport-unix.h"
@@ -60,164 +61,7 @@ _dbus_server_listen_platform_specific (DBusAddressEntry *entry,
*server_p = NULL;
method = dbus_address_entry_get_method (entry);
-
- if (strcmp (method, "unix") == 0)
- {
- const char *path = dbus_address_entry_get_value (entry, "path");
- const char *dir = dbus_address_entry_get_value (entry, "dir");
- const char *tmpdir = dbus_address_entry_get_value (entry, "tmpdir");
- const char *abstract = dbus_address_entry_get_value (entry, "abstract");
- const char *runtime = dbus_address_entry_get_value (entry, "runtime");
- int mutually_exclusive_modes = 0;
-
- mutually_exclusive_modes = (path != NULL) + (tmpdir != NULL) +
- (abstract != NULL) + (runtime != NULL) + (dir != NULL);
-
- if (mutually_exclusive_modes < 1)
- {
- _dbus_set_bad_address(error, "unix",
- "path or tmpdir or abstract or runtime or dir",
- NULL);
- return DBUS_SERVER_LISTEN_BAD_ADDRESS;
- }
-
- if (mutually_exclusive_modes > 1)
- {
- _dbus_set_bad_address(error, NULL, NULL,
- "cannot specify two of \"path\", \"tmpdir\", \"abstract\", \"runtime\" and \"dir\" at the same time");
- return DBUS_SERVER_LISTEN_BAD_ADDRESS;
- }
-
- if (runtime != NULL)
- {
- DBusString full_path;
- DBusString filename;
- const char *runtimedir;
-
- if (strcmp (runtime, "yes") != 0)
- {
- _dbus_set_bad_address(error, NULL, NULL,
- "if given, the only value allowed for \"runtime\" is \"yes\"");
- return DBUS_SERVER_LISTEN_BAD_ADDRESS;
- }
-
- runtimedir = _dbus_getenv ("XDG_RUNTIME_DIR");
-
- if (runtimedir == NULL)
- {
- dbus_set_error (error,
- DBUS_ERROR_NOT_SUPPORTED, "\"XDG_RUNTIME_DIR\" is not set");
- return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
- }
-
- _dbus_string_init_const (&filename, "bus");
-
- if (!_dbus_string_init (&full_path))
- {
- _DBUS_SET_OOM (error);
- return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
- }
-
- if (!_dbus_string_append (&full_path, runtimedir) ||
- !_dbus_concat_dir_and_file (&full_path, &filename))
- {
- _dbus_string_free (&full_path);
- _DBUS_SET_OOM (error);
- return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
- }
-
- /* We can safely use filesystem sockets in the runtime directory,
- * and they are preferred because they can be bind-mounted between
- * Linux containers. */
- *server_p = _dbus_server_new_for_domain_socket (
- _dbus_string_get_const_data (&full_path),
- FALSE, error);
-
- _dbus_string_free (&full_path);
- }
- else if (tmpdir != NULL || dir != NULL)
- {
- DBusString full_path;
- DBusString filename;
- dbus_bool_t use_abstract = FALSE;
-
- if (tmpdir != NULL)
- {
- dir = tmpdir;
-
-#ifdef __linux__
- /* Use abstract sockets for tmpdir if supported, so that it
- * never needs to be cleaned up. Use dir instead if you want a
- * path-based socket. */
- use_abstract = TRUE;
-#endif
- }
-
- if (!_dbus_string_init (&full_path))
- {
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
- }
-
- if (!_dbus_string_init (&filename))
- {
- _dbus_string_free (&full_path);
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
- }
-
- if (!_dbus_string_append (&filename, "dbus-"))
- {
- _dbus_string_free (&full_path);
- _dbus_string_free (&filename);
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
- }
-
- if (!_dbus_generate_random_ascii (&filename, 10, error))
- {
- _dbus_string_free (&full_path);
- _dbus_string_free (&filename);
- return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
- }
-
- if (!_dbus_string_append (&full_path, dir) ||
- !_dbus_concat_dir_and_file (&full_path, &filename))
- {
- _dbus_string_free (&full_path);
- _dbus_string_free (&filename);
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
- }
-
- *server_p =
- _dbus_server_new_for_domain_socket (_dbus_string_get_const_data (&full_path),
- use_abstract,
- error);
-
- _dbus_string_free (&full_path);
- _dbus_string_free (&filename);
- }
- else
- {
- if (path)
- *server_p = _dbus_server_new_for_domain_socket (path, FALSE, error);
- else
- *server_p = _dbus_server_new_for_domain_socket (abstract, TRUE, error);
- }
-
- if (*server_p != NULL)
- {
- _DBUS_ASSERT_ERROR_IS_CLEAR(error);
- return DBUS_SERVER_LISTEN_OK;
- }
- else
- {
- _DBUS_ASSERT_ERROR_IS_SET(error);
- return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
- }
- }
- else if (strcmp (method, "systemd") == 0)
+ if (strcmp (method, "systemd") == 0)
{
int i, n;
DBusSocket *fds;
@@ -258,7 +102,7 @@ _dbus_server_listen_platform_specific (DBusAddressEntry *entry,
systemd_err:
for (i = 0; i < n; i++)
{
- _dbus_close_socket (fds[i], NULL);
+ _dbus_close_socket (&fds[i], NULL);
}
dbus_free (fds);
_dbus_string_free (&address);
@@ -298,87 +142,4 @@ _dbus_server_listen_platform_specific (DBusAddressEntry *entry,
}
}
-/**
- * Creates a new server listening on the given Unix domain socket.
- *
- * @param path the path for the domain socket.
- * @param abstract #TRUE to use abstract socket namespace
- * @param error location to store reason for failure.
- * @returns the new server, or #NULL on failure.
- */
-DBusServer*
-_dbus_server_new_for_domain_socket (const char *path,
- dbus_bool_t abstract,
- DBusError *error)
-{
- DBusServer *server;
- DBusSocket listen_fd;
- DBusString address;
- char *path_copy;
- DBusString path_str;
-
- _DBUS_ASSERT_ERROR_IS_CLEAR (error);
-
- if (!_dbus_string_init (&address))
- {
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- return NULL;
- }
-
- _dbus_string_init_const (&path_str, path);
- if ((abstract &&
- !_dbus_string_append (&address, "unix:abstract=")) ||
- (!abstract &&
- !_dbus_string_append (&address, "unix:path=")) ||
- !_dbus_address_append_escaped (&address, &path_str))
- {
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- goto failed_0;
- }
-
- if (abstract)
- {
- path_copy = NULL;
- }
- else
- {
- path_copy = _dbus_strdup (path);
- if (path_copy == NULL)
- {
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- goto failed_0;
- }
- }
-
- listen_fd.fd = _dbus_listen_unix_socket (path, abstract, error);
-
- if (listen_fd.fd < 0)
- {
- _DBUS_ASSERT_ERROR_IS_SET (error);
- goto failed_1;
- }
-
- server = _dbus_server_new_for_socket (&listen_fd, 1, &address, 0, error);
- if (server == NULL)
- {
- goto failed_2;
- }
-
- if (path_copy != NULL)
- _dbus_server_socket_own_filename(server, path_copy);
-
- _dbus_string_free (&address);
-
- return server;
-
- failed_2:
- _dbus_close_socket (listen_fd, NULL);
- failed_1:
- dbus_free (path_copy);
- failed_0:
- _dbus_string_free (&address);
-
- return NULL;
-}
-
/** @} */
diff --git a/dbus/dbus-server-win.c b/dbus/dbus-server-win.c
index 890ee328..af0b697e 100644
--- a/dbus/dbus-server-win.c
+++ b/dbus/dbus-server-win.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003, 2004 Red Hat Inc.
* Copyright (C) 2007 Ralf Habacker <ralf.habacker@freenet.de>
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-server-win.h b/dbus/dbus-server-win.h
index df7bf0d1..e690404d 100644
--- a/dbus/dbus-server-win.h
+++ b/dbus/dbus-server-win.h
@@ -4,6 +4,8 @@
* Copyright (C) 2002 Red Hat Inc.
* Copyright (C) 2007 Ralf Habacker <ralf.habacker@freenet.de>
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-server.c b/dbus/dbus-server.c
index cde3c986..27c31477 100644
--- a/dbus/dbus-server.c
+++ b/dbus/dbus-server.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003, 2004, 2005 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -23,7 +25,6 @@
#include <config.h>
#include "dbus-server.h"
-#include "dbus-server-unix.h"
#include "dbus-server-socket.h"
#include "dbus-string.h"
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
@@ -527,6 +528,7 @@ static const struct {
DBusError *error);
} listen_funcs[] = {
{ _dbus_server_listen_socket }
+ , { _dbus_server_listen_unix_socket }
, { _dbus_server_listen_platform_specific }
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
, { _dbus_server_listen_debug_pipe }
diff --git a/dbus/dbus-server.h b/dbus/dbus-server.h
index 0d84f796..1f8c5949 100644
--- a/dbus/dbus-server.h
+++ b/dbus/dbus-server.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-sha.c b/dbus/dbus-sha.c
index 6ff2f077..effce82c 100644
--- a/dbus/dbus-sha.c
+++ b/dbus/dbus-sha.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2003 Red Hat Inc.
* Copyright (C) 1995 A. M. Kuchling
+ * SPDX-License-Identifier: (AFL-2.1 OR GPL-2.0-or-later) AND LicenseRef-pycrypto-orig
*
* Licensed under the Academic Free License version 2.1
*
diff --git a/dbus/dbus-sha.h b/dbus/dbus-sha.h
index 988cd5a9..e0677844 100644
--- a/dbus/dbus-sha.h
+++ b/dbus/dbus-sha.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-shared.h b/dbus/dbus-shared.h
index 14879ea7..87c0bd84 100644
--- a/dbus/dbus-shared.h
+++ b/dbus/dbus-shared.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2004 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -86,8 +88,6 @@ typedef enum
*/
/** The interface exported by the object with #DBUS_SERVICE_DBUS and #DBUS_PATH_DBUS */
#define DBUS_INTERFACE_DBUS "org.freedesktop.DBus"
-/** The restricted container interface exported by the dbus-daemon */
-#define DBUS_INTERFACE_CONTAINERS1 "org.freedesktop.DBus.Containers1"
/** The monitoring interface exported by the dbus-daemon */
#define DBUS_INTERFACE_MONITORING "org.freedesktop.DBus.Monitoring"
diff --git a/dbus/dbus-shell.c b/dbus/dbus-shell.c
index fb00523f..50e8909c 100644
--- a/dbus/dbus-shell.c
+++ b/dbus/dbus-shell.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-shell.h b/dbus/dbus-shell.h
index e6f6b595..49eddc0b 100644
--- a/dbus/dbus-shell.h
+++ b/dbus/dbus-shell.h
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-signature.c b/dbus/dbus-signature.c
index 01a456bc..85d4fc49 100644
--- a/dbus/dbus-signature.c
+++ b/dbus/dbus-signature.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-signature.h b/dbus/dbus-signature.h
index c9571cd0..a8a0486b 100644
--- a/dbus/dbus-signature.h
+++ b/dbus/dbus-signature.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2005 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-sockets-win.h b/dbus/dbus-sockets-win.h
index 50d59a53..0924179c 100644
--- a/dbus/dbus-sockets-win.h
+++ b/dbus/dbus-sockets-win.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2005 Novell, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-spawn-unix.c b/dbus/dbus-spawn-unix.c
index 5550ffac..0bf476bd 100644
--- a/dbus/dbus-spawn-unix.c
+++ b/dbus/dbus-spawn-unix.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003, 2004 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -560,7 +562,7 @@ close_socket_to_babysitter (DBusBabysitter *sitter)
if (sitter->socket_to_babysitter.fd >= 0)
{
- _dbus_close_socket (sitter->socket_to_babysitter, NULL);
+ _dbus_close_socket (&sitter->socket_to_babysitter, NULL);
sitter->socket_to_babysitter.fd = -1;
}
}
@@ -1443,27 +1445,13 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p,
_dbus_assert_not_reached ("Got to code after write_err_and_exit()");
}
else if (grandchild_pid == 0)
- {
-#ifdef __linux__
- int fd = -1;
-
-#ifdef O_CLOEXEC
- fd = open ("/proc/self/oom_score_adj", O_WRONLY | O_CLOEXEC);
-#endif
-
- if (fd < 0)
- {
- fd = open ("/proc/self/oom_score_adj", O_WRONLY);
- _dbus_fd_set_close_on_exec (fd);
- }
+ {
+ /* This might not succeed in a dbus-daemon that started as root
+ * and dropped privileges, so don't log an error on failure.
+ * (Also, we can't safely log errors here anyway, because logging
+ * is not async-signal safe). */
+ _dbus_reset_oom_score_adj (NULL);
- if (fd >= 0)
- {
- if (write (fd, "0", sizeof (char)) < 0)
- _dbus_warn ("writing oom_score_adj error: %s", strerror (errno));
- _dbus_close (fd, NULL);
- }
-#endif
/* Go back to ignoring SIGPIPE, since it's evil
*/
signal (SIGPIPE, SIG_IGN);
diff --git a/dbus/dbus-spawn-win.c b/dbus/dbus-spawn-win.c
index ca796055..5ad4fe5f 100644
--- a/dbus/dbus-spawn-win.c
+++ b/dbus/dbus-spawn-win.c
@@ -5,7 +5,7 @@
#if !defined(SPAWN_DEBUG) || defined(_MSC_VER)
#define PING()
#else
-#define PING() fprintf (stderr, "%s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__); fflush (stderr)
+#define PING() fprintf (stderr, "%s:%s:%d\n", __FILE__, _DBUS_FUNCTION_NAME, __LINE__); fflush (stderr)
#endif
#include <stdio.h>
@@ -17,6 +17,8 @@
* Copyright (C) 2003 CodeFactory AB
* Copyright (C) 2005 Novell, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -105,7 +107,7 @@ _dbus_babysitter_new (void)
old_refcount = _dbus_atomic_inc (&sitter->refcount);
- _dbus_babysitter_trace_ref (sitter, old_refcount, old_refcount+1, __FUNCTION__);
+ _dbus_babysitter_trace_ref (sitter, old_refcount, old_refcount+1, _DBUS_FUNCTION_NAME);
sitter->child_handle = NULL;
@@ -139,7 +141,7 @@ _dbus_babysitter_ref (DBusBabysitter *sitter)
old_refcount = _dbus_atomic_inc (&sitter->refcount);
_dbus_assert (old_refcount > 0);
- _dbus_babysitter_trace_ref (sitter, old_refcount, old_refcount+1, __FUNCTION__);
+ _dbus_babysitter_trace_ref (sitter, old_refcount, old_refcount+1, _DBUS_FUNCTION_NAME);
return sitter;
}
@@ -160,7 +162,7 @@ close_socket_to_babysitter (DBusBabysitter *sitter)
if (sitter->socket_to_babysitter.sock != INVALID_SOCKET)
{
- _dbus_close_socket (sitter->socket_to_babysitter, NULL);
+ _dbus_close_socket (&sitter->socket_to_babysitter, NULL);
sitter->socket_to_babysitter.sock = INVALID_SOCKET;
}
}
@@ -180,7 +182,7 @@ _dbus_babysitter_unref (DBusBabysitter *sitter)
old_refcount = _dbus_atomic_dec (&sitter->refcount);
_dbus_assert (old_refcount > 0);
- _dbus_babysitter_trace_ref (sitter, old_refcount, old_refcount-1, __FUNCTION__);
+ _dbus_babysitter_trace_ref (sitter, old_refcount, old_refcount-1, _DBUS_FUNCTION_NAME);
if (old_refcount == 1)
{
@@ -188,7 +190,7 @@ _dbus_babysitter_unref (DBusBabysitter *sitter)
if (sitter->socket_to_main.sock != INVALID_SOCKET)
{
- _dbus_close_socket (sitter->socket_to_main, NULL);
+ _dbus_close_socket (&sitter->socket_to_main, NULL);
sitter->socket_to_main.sock = INVALID_SOCKET;
}
@@ -368,15 +370,16 @@ protect_argv (char * const *argv,
{
int i;
int argc = 0;
+ char **args = NULL;
while (argv[argc])
++argc;
- *new_argv = dbus_malloc ((argc + 1) * sizeof (char *));
- if (*new_argv == NULL)
+ args = dbus_malloc ((argc + 1) * sizeof (char *));
+ if (args == NULL)
return -1;
for (i = 0; i < argc; i++)
- (*new_argv)[i] = NULL;
+ (args)[i] = NULL;
/* Quote each argv element if necessary, so that it will get
* reconstructed correctly in the C runtime startup code. Note that
@@ -413,11 +416,13 @@ protect_argv (char * const *argv,
p++;
}
- q = (*new_argv)[i] = dbus_malloc (len + need_dblquotes*2 + 1);
+ q = args[i] = dbus_malloc (len + need_dblquotes*2 + 1);
if (q == NULL)
- return -1;
-
+ {
+ dbus_free_string_array (args);
+ return -1;
+ }
p = argv[i];
@@ -443,106 +448,155 @@ protect_argv (char * const *argv,
if (need_dblquotes)
*q++ = '"';
*q++ = '\0';
- /* printf ("argv[%d]:%s, need_dblquotes:%s len:%d => %s\n", i, argv[i], need_dblquotes?"TRUE":"FALSE", len, (*new_argv)[i]); */
+ /* printf ("argv[%d]:%s, need_dblquotes:%s len:%d => %s\n", i, argv[i], need_dblquotes?"TRUE":"FALSE", len, (args)[i]); */
}
- (*new_argv)[argc] = NULL;
+ args[argc] = NULL;
+ *new_argv = args;
return argc;
}
-
-/* From GPGME, relicensed by g10 Code GmbH. */
-static char *
-compose_string (char **strings, char separator)
+static dbus_bool_t
+build_commandline (char **argv, DBusString *result)
{
- int i;
- int n = 0;
- char *buf;
- char *p;
-
- if (!strings || !strings[0])
- return 0;
- for (i = 0; strings[i]; i++)
- n += strlen (strings[i]) + 1;
- n++;
-
- buf = p = malloc (n);
- if (!buf)
- return NULL;
- for (i = 0; strings[i]; i++)
- {
- strcpy (p, strings[i]);
- p += strlen (strings[i]);
- *(p++) = separator;
- }
- p--;
- *(p++) = '\0';
- *p = '\0';
-
- return buf;
+ return _dbus_string_append_strings (result, argv, ' ');
}
-static char *
-build_commandline (char **argv)
+static dbus_bool_t
+build_env_block (char** envp, DBusString *result)
{
- return compose_string (argv, ' ');
-}
+ if (!_dbus_string_append_strings (result, envp, '\0'))
+ return FALSE;
-static char *
-build_env_string (char** envp)
-{
- return compose_string (envp, '\0');
+ /* We need a double `\0` to terminate the environment block.
+ * DBusString provides one `\0` after the length-counted data,
+ * so add one more. */
+ if (!_dbus_string_append_byte (result, '\0'))
+ return FALSE;
+
+ return TRUE;
}
+/**
+ * Creates a process with arguments and environment variables
+ *
+ * @param name name of the program
+ * @param argv list of char* pointers for the arguments
+ * @param envp list of char pointers for the environment
+ * @param inherit_handles specifies whether handles should be inherited by the child process
+ * @param error the error to set, if NULL no error will be set
+ * @return #NULL if an error occurred, the reason is returned in \p error
+ * @note The call to GetLastError() after this function may not return the expected value.
+ */
HANDLE
_dbus_spawn_program (const char *name,
char **argv,
- char **envp)
+ char **envp,
+ dbus_bool_t inherit_handles,
+ DBusError *error)
{
PROCESS_INFORMATION pi = { NULL, 0, 0, 0 };
STARTUPINFOA si;
- char *arg_string, *env_string;
- BOOL result;
+ DBusString arg_string = _DBUS_STRING_INIT_INVALID;
+ DBusString env_block = _DBUS_STRING_INIT_INVALID;
+ BOOL result = FALSE;
+ char *env = NULL;
+
+ if (!_dbus_string_init (&arg_string) || !_dbus_string_init (&env_block))
+ {
+ _DBUS_SET_OOM (error);
+ goto out;
+ }
#ifdef DBUS_WINCE
if (argv && argv[0])
- arg_string = build_commandline (argv + 1);
- else
- arg_string = NULL;
+ {
+ if (!build_commandline (argv + 1, &arg_string))
+ _DBUS_SET_OOM (error);
+ goto out;
+ }
#else
- arg_string = build_commandline (argv);
+ if (!build_commandline (argv, &arg_string))
+ {
+ _DBUS_SET_OOM (error);
+ goto out;
+ }
#endif
- if (!arg_string)
- return INVALID_HANDLE_VALUE;
+ if (_dbus_string_get_length (&arg_string) == 0)
+ {
+ dbus_set_error (error, DBUS_ERROR_FAILED, "No arguments given to start '%s'", name);
+ goto out;
+ }
- env_string = build_env_string(envp);
+ if (envp != NULL)
+ {
+ if (!build_env_block (envp, &env_block))
+ {
+ _DBUS_SET_OOM (error);
+ goto out;
+ }
+ /* env_block consists of '0' terminated strings */
+ env = _dbus_string_get_data (&env_block);
+ }
memset (&si, 0, sizeof (si));
si.cb = sizeof (si);
#ifdef DBUS_ENABLE_VERBOSE_MODE
{
- char *s = compose_string (envp, ';');
- _dbus_verbose ("spawning '%s'' with args: '%s' env: '%s'\n", name, arg_string, s);
- free (s);
+ DBusString temp = _DBUS_STRING_INIT_INVALID;
+
+ if (!_dbus_string_init (&temp))
+ {
+ _DBUS_SET_OOM (error);
+ goto out;
+ }
+
+ if (!_dbus_string_append_strings (&temp, envp, ';'))
+ {
+ _dbus_string_free (&temp);
+ _DBUS_SET_OOM (error);
+ goto out;
+ }
+
+ _dbus_verbose ("spawning '%s'' with args: '%s' env: '%s'\n", name,
+ _dbus_string_get_const_data (&arg_string),
+ _dbus_string_get_const_data (&temp));
+ _dbus_string_free (&temp);
}
#endif
#ifdef DBUS_WINCE
- result = CreateProcessA (name, arg_string, NULL, NULL, FALSE, 0,
+ result = CreateProcessA (name, _dbus_string_get_const_data (&arg_string), NULL, NULL, FALSE, 0,
#else
- result = CreateProcessA (NULL, arg_string, NULL, NULL, FALSE, 0,
+ result = CreateProcessA (NULL, /* no application name */
+ _dbus_string_get_data (&arg_string),
+ NULL, /* no process attributes */
+ NULL, /* no thread attributes */
+ inherit_handles, /* inherit handles */
+ 0, /* flags */
#endif
- (LPVOID)env_string, NULL, &si, &pi);
- free (arg_string);
- if (env_string)
- free (env_string);
-
+ env, NULL, &si, &pi);
if (!result)
- return INVALID_HANDLE_VALUE;
+ {
+ _dbus_win_set_error_from_last_error (error, "Unable to start '%s' with arguments '%s'",
+ name, _dbus_string_get_const_data (&arg_string));
+ goto out;
+ }
+
+out:
+ _DBUS_ASSERT_ERROR_XOR_BOOL (error, result);
- CloseHandle (pi.hThread);
- return pi.hProcess;
+ _dbus_string_free (&arg_string);
+ _dbus_string_free (&env_block);
+
+ if (result)
+ {
+ CloseHandle (pi.hThread);
+ return pi.hProcess;
+ }
+
+ return NULL;
}
@@ -596,6 +650,7 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p,
HANDLE handle;
int argc;
char **my_argv = NULL;
+ DBusError local_error = DBUS_ERROR_INIT;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
_dbus_assert (argv[0] != NULL);
@@ -666,7 +721,7 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p,
_dbus_verbose ("babysitter: spawn child '%s'\n", my_argv[0]);
PING();
- handle = _dbus_spawn_program (sitter->log_name, my_argv, (char **) envp);
+ handle = _dbus_spawn_program (sitter->log_name, my_argv, (char **) envp, FALSE, &local_error);
if (my_argv != NULL)
{
@@ -674,15 +729,28 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p,
}
PING();
- if (handle == INVALID_HANDLE_VALUE)
+ if (handle == NULL)
{
- sitter->child_handle = NULL;
- sitter->have_spawn_errno = TRUE;
- sitter->spawn_errno = GetLastError();
- dbus_set_error_const (error, DBUS_ERROR_SPAWN_EXEC_FAILED,
- "Failed to spawn child");
+ if (dbus_error_has_name (&local_error, DBUS_ERROR_NO_MEMORY))
+ {
+ sitter->child_handle = NULL;
+ sitter->have_spawn_errno = TRUE;
+ sitter->spawn_errno = ERROR_NOT_ENOUGH_MEMORY;
+ dbus_move_error (&local_error, error);
+ }
+ else
+ {
+ sitter->child_handle = NULL;
+ sitter->have_spawn_errno = TRUE;
+ sitter->spawn_errno = GetLastError();
+ dbus_set_error (error, DBUS_ERROR_SPAWN_EXEC_FAILED,
+ "Failed to spawn child: %s", local_error.message);
+ }
+ dbus_error_free (&local_error);
goto out0;
}
+ else
+ dbus_error_free (&local_error);
sitter->child_handle = handle;
diff --git a/dbus/dbus-spawn.h b/dbus/dbus-spawn.h
index 03458d0a..56059b7f 100644
--- a/dbus/dbus-spawn.h
+++ b/dbus/dbus-spawn.h
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-string-private.h b/dbus/dbus-string-private.h
index 0524849d..24e1e610 100644
--- a/dbus/dbus-string-private.h
+++ b/dbus/dbus-string-private.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-string-util.c b/dbus/dbus-string-util.c
index 5b433102..2c627c17 100644
--- a/dbus/dbus-string-util.c
+++ b/dbus/dbus-string-util.c
@@ -10,6 +10,8 @@
* Copyright 2011 Roberto Guido
* Copyright 2016-2018 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c
index d620067e..29210de7 100644
--- a/dbus/dbus-string.c
+++ b/dbus/dbus-string.c
@@ -11,6 +11,8 @@
* Copyright 2011 Roberto Guido
* Copyright 2013 Chengwei Yang / Intel
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -41,8 +43,6 @@
#include "dbus-marshal-basic.h" /* probably should be removed by moving the usage of DBUS_TYPE
* into the marshaling-related files
*/
-/* for DBUS_VA_COPY */
-#include "dbus-sysdeps.h"
/**
* @defgroup DBusString DBusString class
@@ -241,8 +241,10 @@ _dbus_string_init_const_len (DBusString *str,
}
/**
- * Initializes a string from another string. The
- * string must eventually be freed with _dbus_string_free().
+ * Initializes a string from another string
+ *
+ * The string must be freed with _dbus_string_free() in case of success.
+ * In case of error the string is freed by this function itself.
*
* @param str memory to hold the string
* @param from instance from which the string is initialized
@@ -252,9 +254,14 @@ dbus_bool_t
_dbus_string_init_from_string(DBusString *str,
const DBusString *from)
{
- if (!_dbus_string_init (str))
- return FALSE;
- return _dbus_string_append (str, _dbus_string_get_const_data (from));
+ if (!_dbus_string_init (str))
+ return FALSE;
+ if (!_dbus_string_append (str, _dbus_string_get_const_data (from)))
+ {
+ _dbus_string_free (str);
+ return FALSE;
+ }
+ return TRUE;
}
/**
@@ -459,6 +466,20 @@ open_gap (int len,
return TRUE;
}
+/**
+ * Returns the allocated size of the string
+ *
+ * @param str the string
+ * @returns the allocated size
+ */
+int
+_dbus_string_get_allocated_size (const DBusString *str)
+{
+ DBUS_CONST_STRING_PREAMBLE (str);
+
+ return real->allocated;
+}
+
#ifndef _dbus_string_get_data
/**
* Gets the raw character buffer from the string. The returned buffer
@@ -971,18 +992,6 @@ _dbus_string_append (DBusString *str,
return append (real, buffer, buffer_len);
}
-/** assign 2 bytes from one string to another */
-#define ASSIGN_2_OCTETS(p, octets) \
- *((dbus_uint16_t*)(p)) = *((dbus_uint16_t*)(octets));
-
-/** assign 4 bytes from one string to another */
-#define ASSIGN_4_OCTETS(p, octets) \
- *((dbus_uint32_t*)(p)) = *((dbus_uint32_t*)(octets));
-
-/** assign 8 bytes from one string to another */
-#define ASSIGN_8_OCTETS(p, octets) \
- *((dbus_uint64_t*)(p)) = *((dbus_uint64_t*)(octets));
-
/**
* Inserts 2 bytes aligned on a 2 byte boundary
* with any alignment padding initialized to 0.
@@ -1002,7 +1011,7 @@ _dbus_string_insert_2_aligned (DBusString *str,
if (!align_insert_point_then_open_gap (str, &insert_at, 2, 2))
return FALSE;
- ASSIGN_2_OCTETS (real->str + insert_at, octets);
+ memcpy (real->str + insert_at, octets, 2);
return TRUE;
}
@@ -1026,7 +1035,7 @@ _dbus_string_insert_4_aligned (DBusString *str,
if (!align_insert_point_then_open_gap (str, &insert_at, 4, 4))
return FALSE;
- ASSIGN_4_OCTETS (real->str + insert_at, octets);
+ memcpy (real->str + insert_at, octets, 4);
return TRUE;
}
@@ -1051,8 +1060,8 @@ _dbus_string_insert_8_aligned (DBusString *str,
return FALSE;
_dbus_assert (_DBUS_ALIGN_VALUE (insert_at, 8) == (unsigned) insert_at);
-
- ASSIGN_8_OCTETS (real->str + insert_at, octets);
+
+ memcpy (real->str + insert_at, octets, 8);
return TRUE;
}
@@ -1103,7 +1112,7 @@ _dbus_string_append_printf_valist (DBusString *str,
DBUS_STRING_PREAMBLE (str);
- DBUS_VA_COPY (args_copy, args);
+ va_copy (args_copy, args);
/* Measure the message length without terminating nul */
len = _dbus_printf_string_upper_bound (format, args);
@@ -1191,6 +1200,35 @@ _dbus_string_append_byte (DBusString *str,
return TRUE;
}
+/**
+ * Append vector with \p strings connected by \p separator
+ *
+ * @param str the string
+ * @param strings vector with char* pointer for merging
+ * @param separator separator to merge the vector
+ * @return #FALSE if not enough memory
+ * @return #TRUE success or empty string vector
+ */
+dbus_bool_t
+_dbus_string_append_strings (DBusString *str, char **strings, char separator)
+{
+ int i;
+
+ if (strings == NULL)
+ return TRUE;
+
+ for (i = 0; strings[i]; i++)
+ {
+ if (i > 0 && !_dbus_string_append_byte (str, (unsigned char) separator))
+ return FALSE;
+
+ if (!_dbus_string_append (str, strings[i]))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static void
delete (DBusRealString *real,
int start,
@@ -1842,7 +1880,7 @@ _dbus_string_skip_blank (const DBusString *str,
++i;
}
- _dbus_assert (i == real->len || !DBUS_IS_ASCII_WHITE (real->str[i]));
+ _dbus_assert (i == real->len || !DBUS_IS_ASCII_BLANK (real->str[i]));
if (end)
*end = i;
@@ -2295,6 +2333,41 @@ _dbus_string_append_byte_as_hex (DBusString *str,
return TRUE;
}
+/* Currently only used when embedded tests are enabled */
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
+/**
+ * Appends \p size bytes from the buffer \p buf as hex digits to the string \p str
+ *
+ * If \p size is nonzero, then \p buf must be non-NULL.
+ *
+ * @param str the string
+ * @param buf the buffer to add bytes from
+ * @param size the number of bytes to add
+ * @returns #FALSE if no memory
+ */
+dbus_bool_t
+_dbus_string_append_buffer_as_hex (DBusString *str,
+ void *buf,
+ int size)
+{
+ unsigned char *p;
+ int i;
+
+ _dbus_assert (size >= 0);
+ _dbus_assert (size == 0 || buf != NULL);
+
+ p = (unsigned char *) buf;
+
+ for (i = 0; i < size; i++)
+ {
+ if (!_dbus_string_append_byte_as_hex (str, p[i]))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+#endif
+
/**
* Encodes a string in hex, the way MD5 and SHA-1 are usually
* encoded. (Each byte is two hex digits.)
diff --git a/dbus/dbus-string.h b/dbus/dbus-string.h
index 7ac32d38..be2434db 100644
--- a/dbus/dbus-string.h
+++ b/dbus/dbus-string.h
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003 Red Hat, Inc.
* Copyright (C) 2006 Ralf Habacker <ralf.habacker@freenet.de>
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -31,6 +33,8 @@
#include <stdarg.h>
+#include <dbus/dbus-macros-internal.h>
+
DBUS_BEGIN_DECLS
/**
@@ -105,6 +109,8 @@ void _dbus_string_lock (DBusString *str);
DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_string_compact (DBusString *str,
int max_waste);
+DBUS_PRIVATE_EXPORT
+int _dbus_string_get_allocated_size (const DBusString *str);
#ifndef _dbus_string_get_data
DBUS_PRIVATE_EXPORT
char* _dbus_string_get_data (DBusString *str);
@@ -215,6 +221,10 @@ DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_string_append_byte (DBusString *str,
unsigned char byte);
DBUS_PRIVATE_EXPORT
+dbus_bool_t _dbus_string_append_strings (DBusString *str,
+ char **strings,
+ char separator);
+DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_string_append_printf (DBusString *str,
const char *format,
...) _DBUS_GNUC_PRINTF (2, 3);
@@ -282,6 +292,11 @@ dbus_bool_t _dbus_string_parse_uint (const DBusString *str,
unsigned long *value_return,
int *end_return);
DBUS_PRIVATE_EXPORT
+dbus_bool_t _dbus_string_parse_int64 (const DBusString *str,
+ int start,
+ dbus_int64_t *value_return,
+ int *end_return);
+DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_string_find (const DBusString *str,
int start,
const char *substr,
@@ -352,6 +367,10 @@ DBUS_PRIVATE_EXPORT
void _dbus_string_chop_white (DBusString *str);
dbus_bool_t _dbus_string_append_byte_as_hex (DBusString *str,
unsigned char byte);
+DBUS_EMBEDDED_TESTS_EXPORT
+dbus_bool_t _dbus_string_append_buffer_as_hex (DBusString *str,
+ void *buf,
+ int size);
DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_string_hex_encode (const DBusString *source,
int start,
diff --git a/dbus/dbus-syntax.c b/dbus/dbus-syntax.c
index 7ef659cb..288824fe 100644
--- a/dbus/dbus-syntax.c
+++ b/dbus/dbus-syntax.c
@@ -4,6 +4,8 @@
* Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Copyright © 2011 Nokia Corporation
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-syntax.h b/dbus/dbus-syntax.h
index daf20f06..57459b17 100644
--- a/dbus/dbus-syntax.h
+++ b/dbus/dbus-syntax.h
@@ -4,6 +4,8 @@
* Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Copyright © 2011 Nokia Corporation
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-sysdeps-pthread.c b/dbus/dbus-sysdeps-pthread.c
index 3199e31d..f9c25604 100644
--- a/dbus/dbus-sysdeps-pthread.c
+++ b/dbus/dbus-sysdeps-pthread.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003, 2006 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-sysdeps-thread-win.c b/dbus/dbus-sysdeps-thread-win.c
index 3b600fa9..9f1818f9 100644
--- a/dbus/dbus-sysdeps-thread-win.c
+++ b/dbus/dbus-sysdeps-thread-win.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2006 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -22,6 +24,7 @@
*/
#include <config.h>
+#include "dbus-init-win.h"
#include "dbus-internals.h"
#include "dbus-sysdeps.h"
#include "dbus-sysdeps-win.h"
@@ -32,6 +35,18 @@
#include <windows.h>
+#ifdef DBUS_DISABLE_ASSERT
+#define THREAD_CHECK_TRUE(func_name, result_or_call) \
+ do { if (!(result_or_call)) { /* ignore */ } } while (0)
+#else
+#define THREAD_CHECK_TRUE(func_name, result_or_call) do { \
+ if (!(result_or_call)) { \
+ _dbus_warn_check_failed ("thread function %s failed (windows error code=%ld) in %s", \
+ func_name, GetLastError (), _DBUS_FUNCTION_NAME); \
+ } \
+} while (0)
+#endif /* !DBUS_DISABLE_ASSERT */
+
/* Protected by DllMain lock, effectively */
static dbus_bool_t global_init_done = FALSE;
static CRITICAL_SECTION init_lock;
@@ -113,6 +128,7 @@ _dbus_platform_cmutex_new (void)
{
HANDLE handle;
handle = CreateMutex (NULL, FALSE, NULL);
+ THREAD_CHECK_TRUE ("CreateMutex", handle);
return (DBusCMutex *) handle;
}
@@ -121,43 +137,53 @@ _dbus_platform_rmutex_new (void)
{
HANDLE handle;
handle = CreateMutex (NULL, FALSE, NULL);
+ THREAD_CHECK_TRUE ("CreateMutex", handle);
+ return (DBusRMutex *) handle;
+}
+
+DBusRMutex *
+_dbus_win_rmutex_named_new (const char *name)
+{
+ HANDLE handle;
+ handle = CreateMutex (NULL, FALSE, name);
+ THREAD_CHECK_TRUE ("CreateMutex", handle);
return (DBusRMutex *) handle;
}
void
_dbus_platform_cmutex_free (DBusCMutex *mutex)
{
- CloseHandle ((HANDLE *) mutex);
+ THREAD_CHECK_TRUE ("CloseHandle", CloseHandle ((HANDLE *) mutex));
}
void
_dbus_platform_rmutex_free (DBusRMutex *mutex)
{
- CloseHandle ((HANDLE *) mutex);
+ THREAD_CHECK_TRUE ("CloseHandle", CloseHandle ((HANDLE *) mutex));
}
void
_dbus_platform_cmutex_lock (DBusCMutex *mutex)
{
- WaitForSingleObject ((HANDLE *) mutex, INFINITE);
+ THREAD_CHECK_TRUE ("WaitForSingleObject", WaitForSingleObject ((HANDLE *) mutex, INFINITE) == WAIT_OBJECT_0);
}
void
_dbus_platform_rmutex_lock (DBusRMutex *mutex)
{
- WaitForSingleObject ((HANDLE *) mutex, INFINITE);
+ THREAD_CHECK_TRUE ("WaitForSingleObject", WaitForSingleObject ((HANDLE *) mutex, INFINITE) == WAIT_OBJECT_0);
}
void
_dbus_platform_cmutex_unlock (DBusCMutex *mutex)
{
- ReleaseMutex ((HANDLE *) mutex);
+ THREAD_CHECK_TRUE ("ReleaseMutex", ReleaseMutex ((HANDLE *) mutex));
}
void
_dbus_platform_rmutex_unlock (DBusRMutex *mutex)
{
- ReleaseMutex ((HANDLE *) mutex);
+ THREAD_CHECK_TRUE ("ReleaseMutex", ReleaseMutex ((HANDLE *) mutex));
}
DBusCondVar *
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index e585136f..cf99616d 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003, 2006 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -37,6 +39,7 @@
#include "dbus-credentials.h"
#include "dbus-nonce.h"
+#include <limits.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
@@ -62,6 +65,9 @@
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
+#ifdef HAVE_LINUX_CLOSE_RANGE_H
+#include <linux/close_range.h>
+#endif
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif
@@ -80,6 +86,9 @@
#ifdef HAVE_SYS_RANDOM_H
#include <sys/random.h>
#endif
+#ifdef HAVE_SYS_SYSCALL_H
+#include <sys/syscall.h>
+#endif
#ifdef HAVE_ADT
#include <bsm/adt.h>
@@ -89,7 +98,7 @@
#include <systemd/sd-daemon.h>
#endif
-#if !DBUS_USE_SYNC
+#if !defined(HAVE_STDATOMIC_H) && !DBUS_USE_SYNC
#include <pthread.h>
#endif
@@ -137,6 +146,21 @@
#endif /* Solaris */
+#if defined(__linux__) && defined(__NR_close_range) && !defined(HAVE_CLOSE_RANGE)
+/* The kernel headers are new enough to have the close_range syscall,
+ * but glibc isn't new enough to have the syscall wrapper, so call the
+ * syscall directly. */
+static inline int
+close_range (unsigned int first,
+ unsigned int last,
+ int flags)
+{
+ return syscall (__NR_close_range, first, last, flags);
+}
+/* Now we can call that inline wrapper as though it was provided by glibc. */
+#define HAVE_CLOSE_RANGE
+#endif
+
/**
* Ensure that the standard file descriptors stdin, stdout and stderr
* are open, by opening /dev/null if necessary.
@@ -271,22 +295,34 @@ static dbus_bool_t
_dbus_open_unix_socket (int *fd,
DBusError *error)
{
- return _dbus_open_socket(fd, PF_UNIX, SOCK_STREAM, 0, error);
+ return _dbus_open_socket(fd, AF_UNIX, SOCK_STREAM, 0, error);
}
/**
- * Closes a socket. Should not be used on non-socket
- * file descriptors or handles.
+ * Closes a socket and invalidates it. Should not be used on non-socket file
+ * descriptors or handles.
+ *
+ * If an error is detected, this function returns #FALSE and sets the error, but
+ * the socket is still closed and invalidated. Callers can use the error in a
+ * diagnostic message, but should not retry closing the socket.
*
* @param fd the socket
* @param error return location for an error
* @returns #FALSE if error is set
*/
dbus_bool_t
-_dbus_close_socket (DBusSocket fd,
+_dbus_close_socket (DBusSocket *fd,
DBusError *error)
{
- return _dbus_close (fd.fd, error);
+ dbus_bool_t rv;
+
+ _dbus_assert (fd != NULL);
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ rv = _dbus_close (fd->fd, error);
+ _dbus_socket_invalidate (fd);
+
+ return rv;
}
/**
@@ -439,7 +475,7 @@ _dbus_read_socket_with_unix_fds (DBusSocket fd,
if (cm->cmsg_level == SOL_SOCKET && cm->cmsg_type == SCM_RIGHTS)
{
size_t i;
- int *payload = (int *) CMSG_DATA (cm);
+ int *payload = (int *) (void *) CMSG_DATA (cm);
size_t payload_len_bytes = (cm->cmsg_len - CMSG_LEN (0));
size_t payload_len_fds;
size_t fds_to_use;
@@ -901,21 +937,6 @@ _dbus_write_two (int fd,
#endif /* !HAVE_WRITEV */
}
-#define _DBUS_MAX_SUN_PATH_LENGTH 99
-
-/**
- * @def _DBUS_MAX_SUN_PATH_LENGTH
- *
- * Maximum length of the path to a UNIX domain socket,
- * sockaddr_un::sun_path member. POSIX requires that all systems
- * support at least 100 bytes here, including the nul termination.
- * We use 99 for the max value to allow for the nul.
- *
- * We could probably also do sizeof (addr.sun_path)
- * but this way we are the same on all platforms
- * which is probably a good idea.
- */
-
/**
* Creates a socket and connects it to the UNIX domain socket at the
* given path. The connection fd is returned, and is set up as
@@ -930,14 +951,14 @@ _dbus_write_two (int fd,
* @param path the path to UNIX domain socket
* @param abstract #TRUE to use abstract namespace
* @param error return location for error code
- * @returns connection file descriptor or -1 on error
+ * @returns a valid socket on success or an invalid socket on error
*/
-int
+DBusSocket
_dbus_connect_unix_socket (const char *path,
dbus_bool_t abstract,
DBusError *error)
{
- int fd;
+ DBusSocket fd = DBUS_SOCKET_INIT;
size_t path_len;
struct sockaddr_un addr;
_DBUS_STATIC_ASSERT (sizeof (addr.sun_path) > _DBUS_MAX_SUN_PATH_LENGTH);
@@ -948,10 +969,10 @@ _dbus_connect_unix_socket (const char *path,
path, abstract);
- if (!_dbus_open_unix_socket (&fd, error))
+ if (!_dbus_open_unix_socket (&fd.fd, error))
{
_DBUS_ASSERT_ERROR_IS_SET(error);
- return -1;
+ return fd;
}
_DBUS_ASSERT_ERROR_IS_CLEAR(error);
@@ -969,8 +990,8 @@ _dbus_connect_unix_socket (const char *path,
{
dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
"Abstract socket name too long\n");
- _dbus_close (fd, NULL);
- return -1;
+ _dbus_close_socket (&fd, NULL);
+ return fd;
}
strncpy (&addr.sun_path[1], path, sizeof (addr.sun_path) - 2);
@@ -978,8 +999,8 @@ _dbus_connect_unix_socket (const char *path,
#else /* !__linux__ */
dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
"Operating system does not support abstract socket namespace\n");
- _dbus_close (fd, NULL);
- return -1;
+ _dbus_close_socket (&fd, NULL);
+ return fd;
#endif /* !__linux__ */
}
else
@@ -988,30 +1009,30 @@ _dbus_connect_unix_socket (const char *path,
{
dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
"Socket name too long\n");
- _dbus_close (fd, NULL);
- return -1;
+ _dbus_close_socket (&fd, NULL);
+ return fd;
}
strncpy (addr.sun_path, path, sizeof (addr.sun_path) - 1);
}
- if (connect (fd, (struct sockaddr*) &addr, _DBUS_STRUCT_OFFSET (struct sockaddr_un, sun_path) + path_len) < 0)
+ if (connect (fd.fd, (struct sockaddr*) &addr, _DBUS_STRUCT_OFFSET (struct sockaddr_un, sun_path) + path_len) < 0)
{
dbus_set_error (error,
_dbus_error_from_errno (errno),
"Failed to connect to socket %s: %s",
path, _dbus_strerror (errno));
- _dbus_close (fd, NULL);
- return -1;
+ _dbus_close_socket (&fd, NULL);
+ return fd;
}
- if (!_dbus_set_fd_nonblocking (fd, error))
+ if (!_dbus_set_fd_nonblocking (fd.fd, error))
{
_DBUS_ASSERT_ERROR_IS_SET (error);
- _dbus_close (fd, NULL);
- return -1;
+ _dbus_close_socket (&fd, NULL);
+ return fd;
}
return fd;
@@ -1027,13 +1048,14 @@ _dbus_connect_unix_socket (const char *path,
* @param argv the argument list for the process to execute.
* argv[0] typically is identical to the path of the executable
* @param error return location for error code
- * @returns connection file descriptor or -1 on error
+ * @returns a valid socket on success or an invalid socket on error
*/
-int
+DBusSocket
_dbus_connect_exec (const char *path,
char *const argv[],
DBusError *error)
{
+ DBusSocket s = DBUS_SOCKET_INIT;
int fds[2];
pid_t pid;
int retval;
@@ -1059,7 +1081,8 @@ _dbus_connect_exec (const char *path,
_dbus_error_from_errno (errno),
"Failed to create socket pair: %s",
_dbus_strerror (errno));
- return -1;
+ _dbus_assert (!_dbus_socket_is_valid (s));
+ return s;
}
if (!cloexec_done)
@@ -1082,7 +1105,8 @@ _dbus_connect_exec (const char *path,
path, _dbus_strerror (errno));
close (fds[0]);
close (fds[1]);
- return -1;
+ _dbus_assert (!_dbus_socket_is_valid (s));
+ return s;
}
if (pid == 0)
@@ -1117,10 +1141,12 @@ _dbus_connect_exec (const char *path,
_DBUS_ASSERT_ERROR_IS_SET (error);
close (fds[0]);
- return -1;
+ _dbus_assert (!_dbus_socket_is_valid (s));
+ return s;
}
- return fds[0];
+ s.fd = fds[0];
+ return s;
}
/**
@@ -1138,13 +1164,14 @@ _dbus_connect_exec (const char *path,
* @param path the socket name
* @param abstract #TRUE to use abstract namespace
* @param error return location for errors
- * @returns the listening file descriptor or -1 on error
+ * @returns a valid socket on success or an invalid socket on error
*/
-int
+DBusSocket
_dbus_listen_unix_socket (const char *path,
dbus_bool_t abstract,
DBusError *error)
{
+ DBusSocket s = DBUS_SOCKET_INIT;
int listen_fd;
struct sockaddr_un addr;
size_t path_len;
@@ -1158,7 +1185,7 @@ _dbus_listen_unix_socket (const char *path,
if (!_dbus_open_unix_socket (&listen_fd, error))
{
_DBUS_ASSERT_ERROR_IS_SET(error);
- return -1;
+ return s;
}
_DBUS_ASSERT_ERROR_IS_CLEAR(error);
@@ -1180,7 +1207,7 @@ _dbus_listen_unix_socket (const char *path,
dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
"Abstract socket name too long\n");
_dbus_close (listen_fd, NULL);
- return -1;
+ return s;
}
strncpy (&addr.sun_path[1], path, sizeof (addr.sun_path) - 2);
@@ -1189,7 +1216,7 @@ _dbus_listen_unix_socket (const char *path,
dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
"Operating system does not support abstract socket namespace\n");
_dbus_close (listen_fd, NULL);
- return -1;
+ return s;
#endif /* !__linux__ */
}
else
@@ -1217,8 +1244,8 @@ _dbus_listen_unix_socket (const char *path,
dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
"Socket name too long\n");
_dbus_close (listen_fd, NULL);
- return -1;
- }
+ return s;
+ }
strncpy (addr.sun_path, path, sizeof (addr.sun_path) - 1);
}
@@ -1229,7 +1256,7 @@ _dbus_listen_unix_socket (const char *path,
"Failed to bind socket \"%s\": %s",
path, _dbus_strerror (errno));
_dbus_close (listen_fd, NULL);
- return -1;
+ return s;
}
if (listen (listen_fd, SOMAXCONN /* backlog */) < 0)
@@ -1238,14 +1265,14 @@ _dbus_listen_unix_socket (const char *path,
"Failed to listen on socket \"%s\": %s",
path, _dbus_strerror (errno));
_dbus_close (listen_fd, NULL);
- return -1;
+ return s;
}
if (!_dbus_set_fd_nonblocking (listen_fd, error))
{
_DBUS_ASSERT_ERROR_IS_SET (error);
_dbus_close (listen_fd, NULL);
- return -1;
+ return s;
}
/* Try opening up the permissions, but if we can't, just go ahead
@@ -1254,7 +1281,8 @@ _dbus_listen_unix_socket (const char *path,
if (!abstract && chmod (path, 0777) < 0)
_dbus_warn ("Could not set mode 0777 on socket %s", path);
- return listen_fd;
+ s.fd = listen_fd;
+ return s;
}
/**
@@ -1469,7 +1497,6 @@ _dbus_connect_tcp_socket_with_nonce (const char *host,
_dbus_error_from_gai (res, errno),
"Failed to lookup host/port: \"%s:%s\": %s (%d)",
host, port, gai_strerror(res), res);
- _dbus_socket_invalidate (&fd);
goto out;
}
@@ -1487,8 +1514,7 @@ _dbus_connect_tcp_socket_with_nonce (const char *host,
if (connect (fd.fd, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) < 0)
{
saved_errno = errno;
- _dbus_close (fd.fd, NULL);
- _dbus_socket_invalidate (&fd);
+ _dbus_close_socket (&fd, NULL);
connect_error = dbus_new0 (DBusError, 1);
@@ -1535,16 +1561,14 @@ _dbus_connect_tcp_socket_with_nonce (const char *host,
if (!ret)
{
- _dbus_close (fd.fd, NULL);
- _dbus_socket_invalidate (&fd);
+ _dbus_close_socket (&fd, NULL);
goto out;
}
}
if (!_dbus_set_fd_nonblocking (fd.fd, error))
{
- _dbus_close (fd.fd, NULL);
- _dbus_socket_invalidate (&fd);
+ _dbus_close_socket (&fd, NULL);
goto out;
}
@@ -1932,6 +1956,8 @@ add_groups_to_credentials (int client_fd,
{
#if defined(__linux__) && defined(SO_PEERGROUPS)
_DBUS_STATIC_ASSERT (sizeof (gid_t) <= sizeof (dbus_gid_t));
+ /* This function assumes socklen_t is unsigned, which is true on Linux */
+ _DBUS_STATIC_ASSERT (((socklen_t) -1) > 0);
gid_t *buf = NULL;
socklen_t len = 1024;
dbus_bool_t oom = FALSE;
@@ -1977,13 +2003,6 @@ add_groups_to_credentials (int client_fd,
_dbus_verbose ("will try again with %lu\n", (unsigned long) len);
}
- if (len <= 0)
- {
- _dbus_verbose ("getsockopt(SO_PEERGROUPS) yielded <= 0 bytes: %ld\n",
- (long) len);
- goto out;
- }
-
if (len > n_gids * sizeof (gid_t))
{
_dbus_verbose ("%lu > %zu", (unsigned long) len, n_gids * sizeof (gid_t));
@@ -2198,6 +2217,7 @@ _dbus_read_credentials_socket (DBusSocket client_fd,
dbus_gid_t primary_gid_read;
dbus_pid_t pid_read;
int bytes_read;
+ int pid_fd_read;
#ifdef HAVE_CMSGCRED
union {
@@ -2217,6 +2237,7 @@ _dbus_read_credentials_socket (DBusSocket client_fd,
uid_read = DBUS_UID_UNSET;
primary_gid_read = DBUS_GID_UNSET;
pid_read = DBUS_PID_UNSET;
+ pid_fd_read = -1;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
@@ -2309,6 +2330,24 @@ _dbus_read_credentials_socket (DBusSocket client_fd,
primary_gid_read = cr.gid;
#endif
}
+
+#ifdef SO_PEERPIDFD
+ /* If we have SO_PEERCRED we might also have SO_PEERPIDFD, which
+ * allows to pin the process ID, and is available on Linux since v6.5. */
+ cr_len = sizeof (int);
+
+ if (getsockopt (client_fd.fd, SOL_SOCKET, SO_PEERPIDFD, &pid_fd_read, &cr_len) != 0)
+ {
+ _dbus_verbose ("Failed to getsockopt(SO_PEERPIDFD): %s\n",
+ _dbus_strerror (errno));
+ }
+ else if (cr_len != sizeof (int))
+ {
+ _dbus_verbose ("Failed to getsockopt(SO_PEERPIDFD), returned %d bytes, expected %d\n",
+ cr_len, (int) sizeof (int));
+ }
+#endif
+
#elif defined(HAVE_UNPCBID) && defined(LOCAL_PEEREID)
/* Another variant of the above - used on NetBSD
*/
@@ -2350,7 +2389,7 @@ _dbus_read_credentials_socket (DBusSocket client_fd,
cmsgp->cmsg_level == SOL_SOCKET &&
cmsgp->cmsg_len >= CMSG_LEN (sizeof (struct cmsgcred)))
{
- cred = (struct cmsgcred *) CMSG_DATA (cmsgp);
+ cred = (struct cmsgcred *) (void *) CMSG_DATA (cmsgp);
pid_read = cred->cmcred_pid;
uid_read = cred->cmcred_euid;
break;
@@ -2440,7 +2479,7 @@ _dbus_read_credentials_socket (DBusSocket client_fd,
#else /* no supported mechanism */
#warning Socket credentials not supported on this Unix OS
-#warning Please tell https://bugs.freedesktop.org/enter_bug.cgi?product=DBus
+#warning Please tell https://gitlab.freedesktop.org/dbus/dbus/-/issues/new
/* Please add other operating systems known to support at least one of
* the mechanisms above to this list, keeping alphabetical order.
@@ -2464,6 +2503,11 @@ _dbus_read_credentials_socket (DBusSocket client_fd,
pid_read,
uid_read);
+ /* Assign this first, so we don't have to close it manually in case one of
+ * the next steps fails. */
+ if (pid_fd_read >= 0)
+ _dbus_credentials_take_pid_fd (credentials, pid_fd_read);
+
if (pid_read != DBUS_PID_UNSET)
{
if (!_dbus_credentials_add_pid (credentials, pid_read))
@@ -2683,12 +2727,12 @@ fill_user_info (DBusUserInfo *info,
* checks
*/
-#ifdef HAVE_GETPWNAM_R
{
struct passwd *p;
+ char *buf = NULL;
int result;
+#ifdef HAVE_GETPWNAM_R
size_t buflen;
- char *buf;
struct passwd p_str;
/* retrieve maximum needed size for buf */
@@ -2729,54 +2773,69 @@ fill_user_info (DBusUserInfo *info,
break;
}
}
- if (result == 0 && p == &p_str)
- {
- if (!fill_user_info_from_passwd (p, info, error))
- {
- dbus_free (buf);
- return FALSE;
- }
- dbus_free (buf);
- }
- else
- {
- dbus_set_error (error, _dbus_error_from_errno (errno),
- "User \"%s\" unknown or no memory to allocate password entry\n",
- username_c ? username_c : "???");
- _dbus_verbose ("User %s unknown\n", username_c ? username_c : "???");
- dbus_free (buf);
- return FALSE;
- }
- }
+
+ /* There are three possibilities:
+ * - an error: result is a nonzero error code, p should be NULL
+ * - name or uid not found: result is 0, p is NULL
+ * - success: result is 0, p should be &p_str
+ *
+ * Ensure that in all failure cases, p is set to NULL, matching the
+ * getpwuid/getpwnam interface. */
+ if (result != 0 || p != &p_str)
+ p = NULL;
+
#else /* ! HAVE_GETPWNAM_R */
- {
/* I guess we're screwed on thread safety here */
- struct passwd *p;
-
#warning getpwnam_r() not available, please report this to the dbus maintainers with details of your OS
+ /* It is unspecified whether "failed to find" counts as an error,
+ * or whether it's reported as p == NULL without touching errno.
+ * Reset errno so we can distinguish. */
+ errno = 0;
+
if (uid != DBUS_UID_UNSET)
p = getpwuid (uid);
else
p = getpwnam (username_c);
+ /* Always initialized, but only meaningful if p is NULL */
+ result = errno;
+#endif /* ! HAVE_GETPWNAM_R */
+
if (p != NULL)
{
if (!fill_user_info_from_passwd (p, info, error))
{
+ dbus_free (buf);
return FALSE;
}
+ dbus_free (buf);
}
else
{
- dbus_set_error (error, _dbus_error_from_errno (errno),
- "User \"%s\" unknown or no memory to allocate password entry\n",
- username_c ? username_c : "???");
- _dbus_verbose ("User %s unknown\n", username_c ? username_c : "???");
+ DBusError local_error = DBUS_ERROR_INIT;
+ const char *error_str;
+
+ if (result == 0)
+ error_str = "not found";
+ else
+ error_str = _dbus_strerror (result);
+
+ if (uid != DBUS_UID_UNSET)
+ dbus_set_error (&local_error, _dbus_error_from_errno (result),
+ "Looking up user ID " DBUS_UID_FORMAT ": %s",
+ uid, error_str);
+ else
+ dbus_set_error (&local_error, _dbus_error_from_errno (result),
+ "Looking up user \"%s\": %s",
+ username_c ? username_c : "???", error_str);
+
+ _dbus_verbose ("%s", local_error.message);
+ dbus_move_error (&local_error, error);
+ dbus_free (buf);
return FALSE;
}
}
-#endif /* ! HAVE_GETPWNAM_R */
/* Fill this in so we can use it to get groups */
username_c = info->username;
@@ -2941,6 +3000,8 @@ _dbus_user_info_fill_uid (DBusUserInfo *info,
dbus_bool_t
_dbus_credentials_add_from_current_process (DBusCredentials *credentials)
{
+ dbus_pid_t pid = _dbus_getpid ();
+
/* The POSIX spec certainly doesn't promise this, but
* we need these assertions to fail as soon as we're wrong about
* it so we can do the porting fixups
@@ -2949,7 +3010,14 @@ _dbus_credentials_add_from_current_process (DBusCredentials *credentials)
_DBUS_STATIC_ASSERT (sizeof (uid_t) <= sizeof (dbus_uid_t));
_DBUS_STATIC_ASSERT (sizeof (gid_t) <= sizeof (dbus_gid_t));
- if (!_dbus_credentials_add_pid(credentials, _dbus_getpid()))
+#if HAVE_DECL_SYS_PIDFD_OPEN
+ /* Normally this syscall would have a race condition, but we can trust
+ * that our own process isn't going to exit, so the pid won't get reused. */
+ int pid_fd = (int) syscall (SYS_pidfd_open, pid, 0);
+ if (pid_fd >= 0)
+ _dbus_credentials_take_pid_fd (credentials, pid_fd);
+#endif
+ if (!_dbus_credentials_add_pid (credentials, pid))
return FALSE;
if (!_dbus_credentials_add_unix_uid(credentials, _dbus_geteuid()))
return FALSE;
@@ -2958,6 +3026,79 @@ _dbus_credentials_add_from_current_process (DBusCredentials *credentials)
}
/**
+ * Resolve the PID from the PID FD, if any. This allows us to avoid
+ * PID reuse attacks. Returns DBUS_PID_UNSET if the PID could not be resolved.
+ * Note that this requires being able to read /proc/self/fdinfo/<FD>,
+ * which is created as 600 and owned by the original UID that the
+ * process started as. So it cannot work when the start as root and
+ * drop privileges mechanism is in use (the systemd unit no longer
+ * does this, but third-party init-scripts might).
+ *
+ * @param pid_fd the PID FD
+ * @returns the resolved PID if found, DBUS_PID_UNSET otherwise
+ */
+dbus_pid_t
+_dbus_resolve_pid_fd (int pid_fd)
+{
+#ifdef __linux__
+ DBusError error = DBUS_ERROR_INIT;
+ DBusString content = _DBUS_STRING_INIT_INVALID;
+ DBusString filename = _DBUS_STRING_INIT_INVALID;
+ dbus_pid_t result = DBUS_PID_UNSET;
+ int pid_index;
+
+ if (pid_fd < 0)
+ goto out;
+
+ if (!_dbus_string_init (&content))
+ goto out;
+
+ if (!_dbus_string_init (&filename))
+ goto out;
+
+ if (!_dbus_string_append_printf (&filename, "/proc/self/fdinfo/%d", pid_fd))
+ goto out;
+
+ if (!_dbus_file_get_contents (&content, &filename, &error))
+ {
+ _dbus_verbose ("Cannot read '/proc/self/fdinfo/%d', unable to resolve PID, %s: %s\n",
+ pid_fd, error.name, error.message);
+ goto out;
+ }
+
+ /* Ensure we are not reading PPid, either it's the first line of the file or
+ * there's a newline before it. */
+ if (!_dbus_string_find (&content, 0, "Pid:", &pid_index) ||
+ (pid_index > 0 && _dbus_string_get_byte (&content, pid_index - 1) != '\n'))
+ {
+ _dbus_verbose ("Cannot find 'Pid:' in '/proc/self/fdinfo/%d', unable to resolve PID\n",
+ pid_fd);
+ goto out;
+ }
+
+ if (!_dbus_string_parse_uint (&content, pid_index + strlen ("Pid:"), &result, NULL))
+ {
+ _dbus_verbose ("Cannot parse 'Pid:' from '/proc/self/fdinfo/%d', unable to resolve PID\n",
+ pid_fd);
+ goto out;
+ }
+
+out:
+ _dbus_string_free (&content);
+ _dbus_string_free (&filename);
+ dbus_error_free (&error);
+
+ if (result <= 0)
+ return DBUS_PID_UNSET;
+
+ return result;
+#else
+ return DBUS_PID_UNSET;
+#endif
+
+}
+
+/**
* Append to the string the identity we would like to have when we
* authenticate, on UNIX this is the current process UID and on
* Windows something else, probably a Windows SID string. No escaping
@@ -3015,7 +3156,7 @@ _dbus_pid_for_log (void)
return getpid ();
}
-#if !DBUS_USE_SYNC
+#if !defined(HAVE_STDATOMIC_H) && !DBUS_USE_SYNC
/* To be thread-safe by default on platforms that don't necessarily have
* atomic operations (notably Debian armel, which is armv4t), we must
* use a mutex that can be initialized statically, like this.
@@ -3033,7 +3174,11 @@ static pthread_mutex_t atomic_mutex = PTHREAD_MUTEX_INITIALIZER;
dbus_int32_t
_dbus_atomic_inc (DBusAtomic *atomic)
{
-#if DBUS_USE_SYNC
+#ifdef HAVE_STDATOMIC_H
+ /* Atomic version of "old = *atomic; *atomic += 1; return old" */
+ return atomic_fetch_add (&atomic->value, 1);
+#elif DBUS_USE_SYNC
+ /* Atomic version of "*atomic += 1; return *atomic - 1" */
return __sync_add_and_fetch(&atomic->value, 1)-1;
#else
dbus_int32_t res;
@@ -3056,7 +3201,11 @@ _dbus_atomic_inc (DBusAtomic *atomic)
dbus_int32_t
_dbus_atomic_dec (DBusAtomic *atomic)
{
-#if DBUS_USE_SYNC
+#ifdef HAVE_STDATOMIC_H
+ /* Atomic version of "old = *atomic; *atomic -= 1; return old" */
+ return atomic_fetch_sub (&atomic->value, 1);
+#elif DBUS_USE_SYNC
+ /* Atomic version of "*atomic -= 1; return *atomic + 1" */
return __sync_sub_and_fetch(&atomic->value, 1)+1;
#else
dbus_int32_t res;
@@ -3080,7 +3229,10 @@ _dbus_atomic_dec (DBusAtomic *atomic)
dbus_int32_t
_dbus_atomic_get (DBusAtomic *atomic)
{
-#if DBUS_USE_SYNC
+#ifdef HAVE_STDATOMIC_H
+ /* Atomic version of "return *atomic" */
+ return atomic_load (&atomic->value);
+#elif DBUS_USE_SYNC
__sync_synchronize ();
return atomic->value;
#else
@@ -3102,7 +3254,10 @@ _dbus_atomic_get (DBusAtomic *atomic)
void
_dbus_atomic_set_zero (DBusAtomic *atomic)
{
-#if DBUS_USE_SYNC
+#ifdef HAVE_STDATOMIC_H
+ /* Atomic version of "*atomic = 0" */
+ atomic_store (&atomic->value, 0);
+#elif DBUS_USE_SYNC
/* Atomic version of "*atomic &= 0; return *atomic" */
__sync_and_and_fetch (&atomic->value, 0);
#else
@@ -3120,7 +3275,10 @@ _dbus_atomic_set_zero (DBusAtomic *atomic)
void
_dbus_atomic_set_nonzero (DBusAtomic *atomic)
{
-#if DBUS_USE_SYNC
+#ifdef HAVE_STDATOMIC_H
+ /* Atomic version of "*atomic = 1" */
+ atomic_store (&atomic->value, 1);
+#elif DBUS_USE_SYNC
/* Atomic version of "*atomic |= 1; return *atomic" */
__sync_or_and_fetch (&atomic->value, 1);
#else
@@ -3217,7 +3375,7 @@ _dbus_poll (DBusPollFD *fds,
* @param tv_usec return location for number of microseconds
*/
void
-_dbus_get_monotonic_time (long *tv_sec,
+_dbus_get_monotonic_time (dbus_int64_t *tv_sec,
long *tv_usec)
{
#ifdef HAVE_MONOTONIC_CLOCK
@@ -3248,7 +3406,7 @@ _dbus_get_monotonic_time (long *tv_sec,
* @param tv_usec return location for number of microseconds
*/
void
-_dbus_get_real_time (long *tv_sec,
+_dbus_get_real_time (dbus_int64_t *tv_sec,
long *tv_usec)
{
struct timeval t;
@@ -3803,7 +3961,7 @@ _dbus_printf_string_upper_bound (const char *format,
int len;
va_list args_copy;
- DBUS_VA_COPY (args_copy, args);
+ va_copy (args_copy, args);
len = vsnprintf (static_buf, bufsize, format, args_copy);
va_end (args_copy);
@@ -3821,7 +3979,7 @@ _dbus_printf_string_upper_bound (const char *format,
* or the real length could be coincidentally the same. Which is it?
* If vsnprintf returns the truncated length, we'll go to the slow
* path. */
- DBUS_VA_COPY (args_copy, args);
+ va_copy (args_copy, args);
if (vsnprintf (static_buf, 1, format, args_copy) == 1)
len = -1;
@@ -3842,7 +4000,7 @@ _dbus_printf_string_upper_bound (const char *format,
if (buf == NULL)
return -1;
- DBUS_VA_COPY (args_copy, args);
+ va_copy (args_copy, args);
len = vsnprintf (buf, bufsize, format, args_copy);
va_end (args_copy);
@@ -4424,7 +4582,7 @@ _dbus_lookup_session_address_launchd (DBusString *address, DBusError *error)
}
#endif
-dbus_bool_t
+static dbus_bool_t
_dbus_lookup_user_bus (dbus_bool_t *supported,
DBusString *address,
DBusError *error)
@@ -4632,19 +4790,11 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory,
return FALSE;
}
-//PENDING(kdab) docs
+/* Documented in dbus-sysdeps-win.c, does nothing on Unix */
dbus_bool_t
-_dbus_daemon_publish_session_bus_address (const char* addr,
- const char *scope)
-{
- return TRUE;
-}
-
-//PENDING(kdab) docs
-void
_dbus_daemon_unpublish_session_bus_address (void)
{
-
+ return TRUE;
}
/**
@@ -4727,12 +4877,6 @@ _dbus_socket_can_pass_unix_fd (DBusSocket fd)
#endif
}
-static void
-close_ignore_error (int fd)
-{
- close (fd);
-}
-
/*
* Similar to Solaris fdwalk(3), but without the ability to stop iteration,
* and may call func for integers that are not actually valid fds.
@@ -4798,6 +4942,25 @@ act_on_fds_3_and_up (void (*func) (int fd))
func (i);
}
+/* Some library implementations of closefrom() are not async-signal-safe,
+ * and we call _dbus_close_all() after forking, so we only do this on
+ * operating systems where we know that closefrom() is a system call */
+#if defined(HAVE_CLOSEFROM) && ( \
+ defined(__FreeBSD__) || \
+ defined(__NetBSD__) || \
+ defined(__OpenBSD__) || \
+ defined(__sun__) && defined(F_CLOSEFROM) \
+)
+#define CLOSEFROM_SIGNAL_SAFE 1
+#else
+#define CLOSEFROM_SIGNAL_SAFE 0
+static void
+close_ignore_error (int fd)
+{
+ close (fd);
+}
+#endif
+
/**
* Closes all file descriptors except the first three (i.e. stdin,
* stdout, stderr).
@@ -4805,7 +4968,16 @@ act_on_fds_3_and_up (void (*func) (int fd))
void
_dbus_close_all (void)
{
+#ifdef HAVE_CLOSE_RANGE
+ if (close_range (3, INT_MAX, 0) == 0)
+ return;
+#endif
+
+#if CLOSEFROM_SIGNAL_SAFE
+ closefrom (3);
+#else
act_on_fds_3_and_up (close_ignore_error);
+#endif
}
/**
@@ -4815,6 +4987,11 @@ _dbus_close_all (void)
void
_dbus_fd_set_all_close_on_exec (void)
{
+#if defined(HAVE_CLOSE_RANGE) && defined(CLOSE_RANGE_CLOEXEC)
+ if (close_range (3, INT_MAX, CLOSE_RANGE_CLOEXEC) == 0)
+ return;
+#endif
+
act_on_fds_3_and_up (_dbus_fd_set_close_on_exec);
}
@@ -5061,7 +5238,7 @@ _dbus_logv (DBusSystemLogSeverity severity,
_dbus_assert_not_reached ("invalid log severity");
}
- DBUS_VA_COPY (tmp, args);
+ va_copy (tmp, args);
vsyslog (flags, msg, tmp);
va_end (tmp);
}
@@ -5071,7 +5248,7 @@ _dbus_logv (DBusSystemLogSeverity severity,
if (log_flags & DBUS_LOG_FLAGS_STDERR)
#endif
{
- DBUS_VA_COPY (tmp, args);
+ va_copy (tmp, args);
fprintf (stderr, "%s[" DBUS_PID_FORMAT "]: ", syslog_tag, _dbus_getpid ());
vfprintf (stderr, msg, tmp);
fputc ('\n', stderr);
diff --git a/dbus/dbus-sysdeps-unix.h b/dbus/dbus-sysdeps-unix.h
index e86de6d9..b400cf86 100644
--- a/dbus/dbus-sysdeps-unix.h
+++ b/dbus/dbus-sysdeps-unix.h
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003, 2006 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -66,17 +68,6 @@ _dbus_write_two (int fd,
int start2,
int len2);
-int _dbus_connect_unix_socket (const char *path,
- dbus_bool_t abstract,
- DBusError *error);
-int _dbus_listen_unix_socket (const char *path,
- dbus_bool_t abstract,
- DBusError *error);
-
-int _dbus_connect_exec (const char *path,
- char *const argv[],
- DBusError *error);
-
int _dbus_listen_systemd_sockets (DBusSocket **fd,
DBusError *error);
@@ -90,11 +81,6 @@ dbus_bool_t _dbus_lookup_launchd_socket (DBusString *socket_path,
const char *launchd_env_var,
DBusError *error);
-DBUS_PRIVATE_EXPORT
-dbus_bool_t _dbus_lookup_user_bus (dbus_bool_t *supported,
- DBusString *address,
- DBusError *error);
-
/** Information about a UNIX user */
typedef struct DBusUserInfo DBusUserInfo;
/** Information about a UNIX group */
@@ -174,6 +160,8 @@ typedef void (* DBusSignalHandler) (int sig);
void _dbus_set_signal_handler (int sig,
DBusSignalHandler handler);
+dbus_bool_t _dbus_reset_oom_score_adj (const char **error_str_p);
+
/** @} */
DBUS_END_DECLS
diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c
index 878ca2ea..49367d43 100644
--- a/dbus/dbus-sysdeps-util-unix.c
+++ b/dbus/dbus-sysdeps-util-unix.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -43,6 +45,7 @@
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
+#include <limits.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
@@ -56,10 +59,6 @@
#include <sys/prctl.h>
#endif
-#ifdef HAVE_SYS_SYSLIMITS_H
-#include <sys/syslimits.h>
-#endif
-
#ifdef HAVE_SYSTEMD
#include <systemd/sd-daemon.h>
#endif
@@ -568,53 +567,6 @@ _dbus_file_exists (const char *file)
return (access (file, F_OK) == 0);
}
-/** Checks if user is at the console
-*
-* @param username user to check
-* @param error return location for errors
-* @returns #TRUE is the user is at the consolei and there are no errors
-*/
-dbus_bool_t
-_dbus_user_at_console (const char *username,
- DBusError *error)
-{
-#ifdef DBUS_CONSOLE_AUTH_DIR
- DBusString u, f;
- dbus_bool_t result;
-
- result = FALSE;
- if (!_dbus_string_init (&f))
- {
- _DBUS_SET_OOM (error);
- return FALSE;
- }
-
- if (!_dbus_string_append (&f, DBUS_CONSOLE_AUTH_DIR))
- {
- _DBUS_SET_OOM (error);
- goto out;
- }
-
- _dbus_string_init_const (&u, username);
-
- if (!_dbus_concat_dir_and_file (&f, &u))
- {
- _DBUS_SET_OOM (error);
- goto out;
- }
-
- result = _dbus_file_exists (_dbus_string_get_const_data (&f));
-
- out:
- _dbus_string_free (&f);
-
- return result;
-#else
- return FALSE;
-#endif
-}
-
-
/**
* Checks whether the filename is an absolute path
*
@@ -995,14 +947,16 @@ _dbus_parse_unix_group_from_config (const DBusString *groupname,
* @param uid the UID
* @param group_ids return location for array of group IDs
* @param n_group_ids return location for length of returned array
+ * @param error error location
* @returns #TRUE if the UID existed and we got some credentials
*/
dbus_bool_t
_dbus_unix_groups_from_uid (dbus_uid_t uid,
dbus_gid_t **group_ids,
- int *n_group_ids)
+ int *n_group_ids,
+ DBusError *error)
{
- return _dbus_groups_from_uid (uid, group_ids, n_group_ids);
+ return _dbus_groups_from_uid (uid, group_ids, n_group_ids, error);
}
/**
@@ -1603,3 +1557,139 @@ _dbus_daemon_report_stopping (void)
sd_notify (0, "STOPPING=1");
#endif
}
+
+/**
+ * If the current process has been protected from the Linux OOM killer
+ * (the oom_score_adj process parameter is negative), reset it to the
+ * default level of protection from the OOM killer (set oom_score_adj
+ * to zero).
+ *
+ * This function does not use DBusError, to avoid calling malloc(), so
+ * that it can be used in contexts where an async-signal-safe function
+ * is required (for example after fork()). Instead, on failure it sets
+ * errno and returns something like "Failed to open /dev/null" in
+ * *error_str_p. Callers are expected to combine *error_str_p
+ * with _dbus_strerror (errno) to get a full error report.
+ */
+dbus_bool_t
+_dbus_reset_oom_score_adj (const char **error_str_p)
+{
+#ifdef __linux__
+ int fd = -1;
+ dbus_bool_t ret = FALSE;
+ int saved_errno = 0;
+ const char *error_str = NULL;
+
+#ifdef O_CLOEXEC
+ fd = open ("/proc/self/oom_score_adj", O_RDONLY | O_CLOEXEC);
+#endif
+
+ if (fd < 0)
+ {
+ fd = open ("/proc/self/oom_score_adj", O_RDONLY);
+ if (fd >= 0)
+ _dbus_fd_set_close_on_exec (fd);
+ }
+
+ if (fd >= 0)
+ {
+ ssize_t read_result = -1;
+ /* It doesn't actually matter whether we read the whole file,
+ * as long as we get the presence or absence of the minus sign */
+ char first_char = '\0';
+
+ read_result = read (fd, &first_char, 1);
+
+ if (read_result < 0)
+ {
+ /* This probably can't actually happen in practice: if we can
+ * open it, then we can hopefully read from it */
+ ret = FALSE;
+ error_str = "failed to read from /proc/self/oom_score_adj";
+ saved_errno = errno;
+ goto out;
+ }
+
+ /* If we are running with protection from the OOM killer
+ * (typical for the system dbus-daemon under systemd), then
+ * oom_score_adj will be negative. Drop that protection,
+ * returning to oom_score_adj = 0.
+ *
+ * Conversely, if we are running with increased susceptibility
+ * to the OOM killer (as user sessions typically do in
+ * systemd >= 250), oom_score_adj will be strictly positive,
+ * and we are not allowed to decrease it to 0 without privileges.
+ *
+ * If it's exactly 0 (typical for non-systemd systems, and
+ * user processes on older systemd) then there's no need to
+ * alter it.
+ *
+ * We shouldn't get an empty result, but if we do, assume it
+ * means zero and don't try to change it. */
+ if (read_result == 0 || first_char != '-')
+ {
+ /* Nothing needs to be done: the OOM score adjustment is
+ * non-negative */
+ ret = TRUE;
+ goto out;
+ }
+
+ close (fd);
+#ifdef O_CLOEXEC
+ fd = open ("/proc/self/oom_score_adj", O_WRONLY | O_CLOEXEC);
+
+ if (fd < 0)
+#endif
+ {
+ fd = open ("/proc/self/oom_score_adj", O_WRONLY);
+ if (fd >= 0)
+ _dbus_fd_set_close_on_exec (fd);
+ }
+
+ if (fd < 0)
+ {
+ ret = FALSE;
+ error_str = "open(/proc/self/oom_score_adj) for writing";
+ saved_errno = errno;
+ goto out;
+ }
+
+ if (pwrite (fd, "0", sizeof (char), 0) < 0)
+ {
+ ret = FALSE;
+ error_str = "writing oom_score_adj error";
+ saved_errno = errno;
+ goto out;
+ }
+
+ /* Success */
+ ret = TRUE;
+ }
+ else if (errno == ENOENT)
+ {
+ /* If /proc/self/oom_score_adj doesn't exist, assume the kernel
+ * doesn't support this feature and ignore it. */
+ ret = TRUE;
+ }
+ else
+ {
+ ret = FALSE;
+ error_str = "open(/proc/self/oom_score_adj) for reading";
+ saved_errno = errno;
+ goto out;
+ }
+
+out:
+ if (fd >= 0)
+ _dbus_close (fd, NULL);
+
+ if (error_str_p != NULL)
+ *error_str_p = error_str;
+
+ errno = saved_errno;
+ return ret;
+#else
+ /* nothing to do on this platform */
+ return TRUE;
+#endif
+}
diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c
index 639164ff..befe1ba2 100644
--- a/dbus/dbus-sysdeps-util-win.c
+++ b/dbus/dbus-sysdeps-util-win.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -426,6 +428,7 @@ _dbus_directory_open (const DBusString *filename,
{
if (!_dbus_string_append (&filespec, "*"))
{
+ _dbus_string_free (&filespec);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
"Could not append filename wildcard");
return NULL;
@@ -435,6 +438,7 @@ _dbus_directory_open (const DBusString *filename,
{
if (!_dbus_string_append (&filespec, "\\*"))
{
+ _dbus_string_free (&filespec);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
"Could not append filename wildcard 2");
return NULL;
@@ -464,7 +468,7 @@ _dbus_directory_open (const DBusString *filename,
"Failed to read directory \"%s\": %s",
_dbus_string_get_const_data (filename), emsg);
_dbus_win_free_error_string (emsg);
- dbus_free ( iter );
+ dbus_free (iter);
_dbus_string_free (&filespec);
return NULL;
}
@@ -647,6 +651,13 @@ dbus_bool_t _dbus_windows_user_is_process_owner (const char *windows_sid)
unix emulation functions - should be removed sometime in the future
=====================================================================*/
+static void
+set_unix_uid_unsupported (DBusError *error)
+{
+ dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
+ "UNIX user IDs not supported on Windows");
+}
+
/**
* Checks to see if the UNIX user ID is at the console.
* Should always fail on Windows (set the error to
@@ -660,8 +671,7 @@ dbus_bool_t
_dbus_unix_user_is_at_console (dbus_uid_t uid,
DBusError *error)
{
- dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
- "UNIX user IDs not supported on Windows\n");
+ set_unix_uid_unsupported (error);
return FALSE;
}
@@ -705,13 +715,16 @@ _dbus_parse_unix_user_from_config (const DBusString *username,
* @param uid the UID
* @param group_ids return location for array of group IDs
* @param n_group_ids return location for length of returned array
+ * @param error error location
* @returns #TRUE if the UID existed and we got some credentials
*/
dbus_bool_t
_dbus_unix_groups_from_uid (dbus_uid_t uid,
dbus_gid_t **group_ids,
- int *n_group_ids)
+ int *n_group_ids,
+ DBusError *error)
{
+ set_unix_uid_unsupported (error);
return FALSE;
}
@@ -1674,16 +1687,3 @@ void
_dbus_daemon_report_stopping (void)
{
}
-
-void
-_dbus_win_stderr_win_error (const char *app,
- const char *message,
- unsigned long code)
-{
- DBusError error;
-
- dbus_error_init (&error);
- _dbus_win_set_error_from_win_error (&error, code);
- fprintf (stderr, "%s: %s: %s\n", app, message, error.message);
- dbus_error_free (&error);
-}
diff --git a/dbus/dbus-sysdeps-util.c b/dbus/dbus-sysdeps-util.c
index 66af910e..a9ed47d6 100644
--- a/dbus/dbus-sysdeps-util.c
+++ b/dbus/dbus-sysdeps-util.c
@@ -7,6 +7,8 @@
* Copyright 2006 Sjoerd Simons
* Copyright 2016-2018 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c
index d2be1e57..d44dc0a9 100644
--- a/dbus/dbus-sysdeps-win.c
+++ b/dbus/dbus-sysdeps-win.c
@@ -6,7 +6,9 @@
* Copyright (C) 2005 Novell, Inc.
* Copyright (C) 2006 Peter Kümmel <syntheticpp@gmx.net>
* Copyright (C) 2006 Christian Ehrlicher <ch.ehrlicher@gmx.de>
- * Copyright (C) 2006-2013 Ralf Habacker <ralf.habacker@freenet.de>
+ * Copyright (C) 2006-2021 Ralf Habacker <ralf.habacker@freenet.de>
+ *
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
*
* Licensed under the Academic Free License version 2.1
*
@@ -23,7 +25,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
*/
#include <config.h>
@@ -48,6 +49,9 @@
#include <windows.h>
#include <wincrypt.h>
#include <iphlpapi.h>
+#ifdef HAVE_AFUNIX_H
+#include <afunix.h>
+#endif
/* Declarations missing in mingw's and windows sdk 7.0 headers */
extern BOOL WINAPI ConvertStringSidToSidA (LPCSTR StringSid, PSID *Sid);
@@ -126,7 +130,7 @@ load_ex_ip_helper_procedures(void)
return FALSE;
}
- lpfnAllocateAndGetTcpExTableFromStack = (ProcAllocateAndGetTcpExtTableFromStack)GetProcAddress (hModule, "AllocateAndGetTcpExTableFromStack");
+ lpfnAllocateAndGetTcpExTableFromStack = (ProcAllocateAndGetTcpExtTableFromStack) (void (*)(void))GetProcAddress (hModule, "AllocateAndGetTcpExTableFromStack");
if (lpfnAllocateAndGetTcpExTableFromStack == NULL)
{
_dbus_verbose ("could not find function AllocateAndGetTcpExTableFromStack in iphlpapi.dll\n");
@@ -483,20 +487,21 @@ _dbus_write_socket (DBusSocket fd,
/**
- * Closes a file descriptor.
+ * Closes a socket and invalidates it.
*
* @param fd the file descriptor
* @param error error object
* @returns #FALSE if error set
*/
dbus_bool_t
-_dbus_close_socket (DBusSocket fd,
- DBusError *error)
+_dbus_close_socket (DBusSocket *fd,
+ DBusError *error)
{
+ _dbus_assert (fd != NULL);
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
again:
- if (closesocket (fd.sock) == SOCKET_ERROR)
+ if (closesocket (fd->sock) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
@@ -505,11 +510,13 @@ _dbus_close_socket (DBusSocket fd,
dbus_set_error (error, _dbus_error_from_errno (errno),
"Could not close socket: socket=%Iu, , %s",
- fd.sock, _dbus_strerror_from_errno ());
+ fd->sock, _dbus_strerror_from_errno ());
+ _dbus_socket_invalidate (fd);
return FALSE;
}
- _dbus_verbose ("socket=%Iu, \n", fd.sock);
+ _dbus_verbose ("socket=%Iu, \n", fd->sock);
+ _dbus_socket_invalidate (fd);
return TRUE;
}
@@ -738,7 +745,7 @@ int _dbus_printf_string_upper_bound (const char *format,
va_list args_copy;
bufsize = sizeof (buf);
- DBUS_VA_COPY (args_copy, args);
+ va_copy (args_copy, args);
len = _vsnprintf (buf, bufsize - 1, format, args_copy);
va_end (args_copy);
@@ -753,7 +760,7 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- DBUS_VA_COPY (args_copy, args);
+ va_copy (args_copy, args);
len = _vsnprintf (p, bufsize - 1, format, args_copy);
va_end (args_copy);
free (p);
@@ -960,10 +967,10 @@ is_winxp_sp3_or_lower (void)
// Initialize the condition mask.
- VER_SET_CONDITION( dwlConditionMask, VER_MAJORVERSION, op );
- VER_SET_CONDITION( dwlConditionMask, VER_MINORVERSION, op );
- VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMAJOR, op );
- VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMINOR, op );
+ VER_SET_CONDITION (dwlConditionMask, VER_MAJORVERSION, op);
+ VER_SET_CONDITION (dwlConditionMask, VER_MINORVERSION, op);
+ VER_SET_CONDITION (dwlConditionMask, VER_SERVICEPACKMAJOR, op);
+ VER_SET_CONDITION (dwlConditionMask, VER_SERVICEPACKMINOR, op);
// Perform the test.
@@ -1012,12 +1019,12 @@ _dbus_getsid(char **sid, dbus_pid_t process_id)
psid = token_user->User.Sid;
if (!IsValidSid (psid))
{
- _dbus_verbose("%s invalid sid\n",__FUNCTION__);
+ _dbus_verbose("invalid sid\n");
goto failed;
}
if (!ConvertSidToStringSidA (psid, sid))
{
- _dbus_verbose("%s invalid sid\n",__FUNCTION__);
+ _dbus_verbose("invalid sid\n");
goto failed;
}
//okay:
@@ -1431,10 +1438,7 @@ _dbus_poll_select (DBusPollFD *fds,
#ifdef DBUS_ENABLE_VERBOSE_MODE
_dbus_verbose("_dbus_poll: to=%d\n", timeout_milliseconds);
if (!_dbus_dump_fd_events (fds, n_fds))
- {
- ready = -1;
- goto oom;
- }
+ return -1;
#endif
for (i = 0; i < n_fds; i++)
@@ -1474,8 +1478,7 @@ _dbus_poll_select (DBusPollFD *fds,
if (!_dbus_dump_fdset (fds, n_fds, &read_set, &write_set, &err_set))
{
_dbus_win_set_errno (ENOMEM);
- ready = -1;
- goto oom;
+ return -1;
}
#endif
for (i = 0; i < n_fds; i++)
@@ -1494,7 +1497,6 @@ _dbus_poll_select (DBusPollFD *fds,
fdp->revents |= _DBUS_POLLERR;
}
}
-oom:
return ready;
}
#endif
@@ -1647,7 +1649,7 @@ _dbus_connect_tcp_socket_with_nonce (const char *host,
_dbus_error_from_errno (saved_errno),
"Failed to open socket: %s",
_dbus_strerror (saved_errno));
- _dbus_socket_invalidate (&fd);
+ _dbus_assert (!_dbus_socket_is_valid (fd));
goto out;
}
_DBUS_ASSERT_ERROR_IS_CLEAR(error);
@@ -1655,8 +1657,7 @@ _dbus_connect_tcp_socket_with_nonce (const char *host,
if (connect (fd.sock, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) == SOCKET_ERROR)
{
saved_errno = _dbus_get_low_level_socket_errno ();
- closesocket(fd.sock);
- _dbus_socket_invalidate (&fd);
+ _dbus_close_socket (&fd, NULL);
connect_error = dbus_new0 (DBusError, 1);
@@ -1703,8 +1704,7 @@ _dbus_connect_tcp_socket_with_nonce (const char *host,
if (!ret)
{
- closesocket (fd.sock);
- _dbus_socket_invalidate (&fd);
+ _dbus_close_socket (&fd, NULL);
goto out;
}
}
@@ -1714,8 +1714,7 @@ _dbus_connect_tcp_socket_with_nonce (const char *host,
if (!_dbus_set_socket_nonblocking (fd, error))
{
- closesocket (fd.sock);
- _dbus_socket_invalidate (&fd);
+ _dbus_close_socket (&fd, NULL);
goto out;
}
@@ -1833,6 +1832,7 @@ _dbus_listen_tcp_socket (const char *host,
_dbus_error_from_errno (saved_errno),
"Failed to open socket: %s",
_dbus_strerror (saved_errno));
+ _dbus_assert (!_dbus_socket_is_valid (fd));
goto failed;
}
_DBUS_ASSERT_ERROR_IS_CLEAR(error);
@@ -1853,7 +1853,7 @@ _dbus_listen_tcp_socket (const char *host,
host ? host : "*", port, _dbus_strerror (saved_errno));
}
- if (bind (fd.sock, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) == SOCKET_ERROR)
+ if (bind (fd.sock, (struct sockaddr *) tmp->ai_addr, tmp->ai_addrlen) == SOCKET_ERROR)
{
saved_errno = _dbus_get_low_level_socket_errno ();
closesocket (fd.sock);
@@ -2117,6 +2117,56 @@ again:
return TRUE;
}
+#ifdef HAVE_AFUNIX_H
+/*
+ * Returns false with no error set if the socket is non-AF_UNIX
+ * (contrary to our usual convention).
+ *
+ * Returns false with an error set on failure to identify it.
+ */
+static dbus_bool_t
+_dbus_socket_is_af_unix (DBusSocket s,
+ DBusError *error)
+{
+ struct sockaddr_un saddr;
+ int len;
+
+ len = sizeof (saddr);
+ if (getsockname (s.sock, (struct sockaddr *)&saddr, &len) == SOCKET_ERROR)
+ {
+ DBUS_SOCKET_SET_ERRNO ();
+ dbus_set_error (error, _dbus_error_from_errno (errno),
+ "Failed to getsockname: %s",
+ _dbus_strerror_from_errno ());
+ return FALSE;
+ }
+
+ return saddr.sun_family == AF_UNIX;
+}
+
+/**
+ * @brief return peer process id from Unix domain socket handle
+ * @param handle AF_UNIX socket descriptor
+ * @return process id or 0 in case the process id could not be fetched
+ */
+static dbus_pid_t
+_dbus_get_peer_pid_from_uds_handle (int handle)
+{
+ DWORD pid, drc;
+
+ if (WSAIoctl (handle, SIO_AF_UNIX_GETPEERPID,
+ NULL, 0U,
+ &pid, sizeof (pid), &drc,
+ NULL, NULL) == SOCKET_ERROR)
+ {
+ _dbus_verbose ("failed to get peer's pid\n");
+ return 0;
+ }
+
+ return pid;
+}
+#endif
+
/**
* Reads a single byte which must be nul (an error occurs otherwise),
* and reads unix credentials if available. Fills in pid/uid/gid with
@@ -2142,6 +2192,9 @@ _dbus_read_credentials_socket (DBusSocket handle,
{
int bytes_read = 0;
DBusString buf;
+#ifdef HAVE_AFUNIX_H
+ dbus_bool_t uds = FALSE;
+#endif
char *sid = NULL;
dbus_pid_t pid;
@@ -2158,7 +2211,16 @@ _dbus_read_credentials_socket (DBusSocket handle,
_dbus_string_free (&buf);
}
- pid = _dbus_get_peer_pid_from_tcp_handle (handle.sock);
+#ifdef HAVE_AFUNIX_H
+ uds = _dbus_socket_is_af_unix (handle, error);
+ if (dbus_error_is_set (error))
+ return FALSE;
+
+ if (uds)
+ pid = _dbus_get_peer_pid_from_uds_handle (handle.sock);
+ else
+#endif
+ pid = _dbus_get_peer_pid_from_tcp_handle (handle.sock);
if (pid == 0)
return TRUE;
@@ -2374,7 +2436,7 @@ _dbus_sleep_milliseconds (int milliseconds)
* @param tv_usec return location for number of microseconds
*/
void
-_dbus_get_real_time (long *tv_sec,
+_dbus_get_real_time (dbus_int64_t *tv_sec,
long *tv_usec)
{
FILETIME ft;
@@ -2405,7 +2467,7 @@ _dbus_get_real_time (long *tv_sec,
* @param tv_usec return location for number of microseconds
*/
void
-_dbus_get_monotonic_time (long *tv_sec,
+_dbus_get_monotonic_time (dbus_int64_t *tv_sec,
long *tv_usec)
{
/* no implementation yet, fall back to wall-clock time */
@@ -2529,8 +2591,7 @@ _dbus_generate_random_bytes (DBusString *str,
}
/**
- * Gets the temporary files directory by inspecting the environment variables
- * TMPDIR, TMP, and TEMP in that order. If none of those are set "/tmp" is returned
+ * Gets the temporary files directory, using GetTempPath()
*
* @returns location of temp directory, or #NULL if no memory for locking
*/
@@ -2603,209 +2664,6 @@ _dbus_delete_file (const DBusString *filename,
return TRUE;
}
-#if !defined (DBUS_DISABLE_ASSERT) || defined(DBUS_ENABLE_EMBEDDED_TESTS)
-
-#if defined(_MSC_VER) || defined(DBUS_WINCE)
-# ifdef BACKTRACES
-# undef BACKTRACES
-# endif
-#else
-# define BACKTRACES
-#endif
-
-#ifdef BACKTRACES
-/*
- * Backtrace Generator
- *
- * Copyright 2004 Eric Poech
- * Copyright 2004 Robert Shearman
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <winver.h>
-#include <imagehlp.h>
-#include <stdio.h>
-
-#define DPRINTF(fmt, ...) fprintf (stderr, fmt, ##__VA_ARGS__)
-
-#ifdef _MSC_VER
-#define BOOL int
-
-#define __i386__
-#endif
-
-static void dump_backtrace_for_thread (HANDLE hThread)
-{
- ADDRESS old_address;
- STACKFRAME sf;
- CONTEXT context;
- DWORD dwImageType;
- int i = 0;
-
- SymSetOptions (SYMOPT_UNDNAME | SYMOPT_LOAD_LINES);
- SymInitialize (GetCurrentProcess (), NULL, TRUE);
-
-
- /* can't use this function for current thread as GetThreadContext
- * doesn't support getting context from current thread */
- if (hThread == GetCurrentThread())
- return;
-
- DPRINTF ("Backtrace:\n");
-
- _DBUS_ZERO (old_address);
- _DBUS_ZERO (context);
- context.ContextFlags = CONTEXT_FULL;
-
- SuspendThread (hThread);
-
- if (!GetThreadContext (hThread, &context))
- {
- DPRINTF ("Couldn't get thread context (error %ld)\n", GetLastError ());
- ResumeThread (hThread);
- return;
- }
-
- _DBUS_ZERO (sf);
-
-#ifdef __i386__
- dwImageType = IMAGE_FILE_MACHINE_I386;
- sf.AddrFrame.Offset = context.Ebp;
- sf.AddrFrame.Mode = AddrModeFlat;
- sf.AddrPC.Offset = context.Eip;
- sf.AddrPC.Mode = AddrModeFlat;
-#elif defined(_M_X64)
- dwImageType = IMAGE_FILE_MACHINE_AMD64;
- sf.AddrPC.Offset = context.Rip;
- sf.AddrPC.Mode = AddrModeFlat;
- sf.AddrFrame.Offset = context.Rsp;
- sf.AddrFrame.Mode = AddrModeFlat;
- sf.AddrStack.Offset = context.Rsp;
- sf.AddrStack.Mode = AddrModeFlat;
-#elif defined(_M_IA64)
- dwImageType = IMAGE_FILE_MACHINE_IA64;
- sf.AddrPC.Offset = context.StIIP;
- sf.AddrPC.Mode = AddrModeFlat;
- sf.AddrFrame.Offset = context.IntSp;
- sf.AddrFrame.Mode = AddrModeFlat;
- sf.AddrBStore.Offset= context.RsBSP;
- sf.AddrBStore.Mode = AddrModeFlat;
- sf.AddrStack.Offset = context.IntSp;
- sf.AddrStack.Mode = AddrModeFlat;
-#else
-# error You need to fill in the STACKFRAME structure for your architecture
-#endif
-
- /*
- backtrace format
- <level> <address> <symbol>[+offset] [ '[' <file> ':' <line> ']' ] [ 'in' <module> ]
- example:
- 6 0xf75ade6b wine_switch_to_stack+0x2a [/usr/src/debug/wine-snapshot/libs/wine/port.c:59] in libwine.so.1
- */
- while (StackWalk (dwImageType, GetCurrentProcess (),
- hThread, &sf, &context, NULL, SymFunctionTableAccess,
- SymGetModuleBase, NULL))
- {
- char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(char)];
- PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer;
- DWORD64 displacement;
- IMAGEHLP_LINE line;
- DWORD dwDisplacement;
- IMAGEHLP_MODULE moduleInfo;
-
- /*
- on Wine64 version 1.7.54, we get an infinite number of stack entries
- pointing to the same stack frame (_start+0x29 in <wine-loader>)
- see bug https://bugs.winehq.org/show_bug.cgi?id=39606
- */
-#ifndef __i386__
- if (old_address.Offset == sf.AddrPC.Offset)
- {
- break;
- }
-#endif
-
- pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
- pSymbol->MaxNameLen = MAX_SYM_NAME;
-
- if (SymFromAddr (GetCurrentProcess (), sf.AddrPC.Offset, &displacement, pSymbol))
- {
- if (displacement)
- DPRINTF ("%3d %s+0x%I64x", i++, pSymbol->Name, displacement);
- else
- DPRINTF ("%3d %s", i++, pSymbol->Name);
- }
- else
- DPRINTF ("%3d 0x%Ix", i++, sf.AddrPC.Offset);
-
- line.SizeOfStruct = sizeof(IMAGEHLP_LINE);
- if (SymGetLineFromAddr (GetCurrentProcess (), sf.AddrPC.Offset, &dwDisplacement, &line))
- {
- DPRINTF (" [%s:%ld]", line.FileName, line.LineNumber);
- }
-
- moduleInfo.SizeOfStruct = sizeof(moduleInfo);
- if (SymGetModuleInfo (GetCurrentProcess (), sf.AddrPC.Offset, &moduleInfo))
- {
- DPRINTF (" in %s", moduleInfo.ModuleName);
- }
- DPRINTF ("\n");
- old_address = sf.AddrPC;
- }
- ResumeThread (hThread);
-}
-
-static DWORD WINAPI dump_thread_proc (LPVOID lpParameter)
-{
- dump_backtrace_for_thread ((HANDLE) lpParameter);
- return 0;
-}
-
-/* cannot get valid context from current thread, so we have to execute
- * backtrace from another thread */
-static void
-dump_backtrace (void)
-{
- HANDLE hCurrentThread;
- HANDLE hThread;
- DWORD dwThreadId;
- DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
- GetCurrentProcess (), &hCurrentThread,
- 0, FALSE, DUPLICATE_SAME_ACCESS);
- hThread = CreateThread (NULL, 0, dump_thread_proc, (LPVOID)hCurrentThread,
- 0, &dwThreadId);
- WaitForSingleObject (hThread, INFINITE);
- CloseHandle (hThread);
- CloseHandle (hCurrentThread);
-}
-#endif
-#endif /* asserts or tests enabled */
-
-#ifdef BACKTRACES
-void _dbus_print_backtrace (void)
-{
- dump_backtrace ();
-}
-#else
-void _dbus_print_backtrace (void)
-{
- _dbus_verbose (" D-Bus not compiled with backtrace support\n");
-}
-#endif
-
static dbus_uint32_t fromAscii(char ascii)
{
if(ascii >= '0' && ascii <= '9')
@@ -2888,40 +2746,6 @@ dbus_bool_t _dbus_read_local_machine_uuid (DBusGUID *machine_id,
return TRUE;
}
-static
-HANDLE _dbus_global_lock (const char *mutexname)
-{
- HANDLE mutex;
- DWORD gotMutex;
-
- mutex = CreateMutexA( NULL, FALSE, mutexname );
- if( !mutex )
- {
- return FALSE;
- }
-
- gotMutex = WaitForSingleObject( mutex, INFINITE );
- switch( gotMutex )
- {
- case WAIT_ABANDONED:
- ReleaseMutex (mutex);
- CloseHandle (mutex);
- return 0;
- case WAIT_FAILED:
- case WAIT_TIMEOUT:
- return 0;
- default:
- return mutex;
- }
-}
-
-static
-void _dbus_global_unlock (HANDLE mutex)
-{
- ReleaseMutex (mutex);
- CloseHandle (mutex);
-}
-
// for proper cleanup in dbus-daemon
static HANDLE hDBusDaemonMutex = NULL;
static HANDLE hDBusSharedMem = NULL;
@@ -2934,90 +2758,206 @@ static const char *cDBusDaemonMutex = "DBusDaemonMutex";
// named shm for dbus adress info (per user)
static const char *cDBusDaemonAddressInfo = "DBusDaemonAddressInfo";
+/* custom command line parameter for autolaunching daemon */
+static const char *autolaunch_custom_command_line_parameter = "";
+
+/**
+ * Set command line parameters for the dbus daemon to start
+ * for an autolaunch session.
+ *
+ * The specified instance must be valid until the dbus-daemon
+ * is started.
+ *
+ * This function is not thread-safe, and can only be called from a
+ * single-threaded unit test.
+ *
+ * @param path string to use as command line parameter
+ */
+void _dbus_test_win_autolaunch_set_command_line_parameter (const char *path)
+{
+ autolaunch_custom_command_line_parameter = path;
+}
+
+static HANDLE *autolaunch_handle_location;
+
+/**
+ * Set location where to store process handle of an autostarted server
+ *
+ * This function is not thread-safe, and can only be called from a
+ * single-threaded unit test.
+ *
+ * After using the handle it must be closed with @ref CloseHandle().
+ *
+ * @param location Pointer where to store the handle
+ */
+void
+_dbus_test_win_set_autolaunch_handle_location (HANDLE *location)
+{
+ autolaunch_handle_location = location;
+}
+
+/**
+ * Return the hash of the installation root directory, which can be
+ * used to construct a per-installation-root scope for autolaunching
+ *
+ * If the installation root directory could not be
+ * determined, the returned length is set to zero.
+ *
+ * @param out initialized DBusString instance to return hash string
+ * @returns #FALSE on OOM, #TRUE if not OOM
+ */
static dbus_bool_t
-_dbus_get_install_root_as_hash(DBusString *out)
+_dbus_get_install_root_as_hash (DBusString *out)
{
- DBusString install_path;
+ DBusString install_path;
+ dbus_bool_t retval = FALSE;
+ _dbus_assert (out != NULL);
- _dbus_string_init(&install_path);
+ if (!_dbus_string_init (&install_path))
+ return FALSE;
- if (!_dbus_get_install_root (&install_path) ||
- _dbus_string_get_length (&install_path) == 0)
- return FALSE;
+ if (!_dbus_get_install_root (&install_path))
+ goto out;
- _dbus_string_init(out);
- _dbus_string_tolower_ascii(&install_path,0,_dbus_string_get_length(&install_path));
+ /* the install path can't be determined */
+ if (_dbus_string_get_length (&install_path) == 0)
+ {
+ _dbus_string_set_length (out, 0);
+ retval = TRUE;
+ goto out;
+ }
- if (!_dbus_sha_compute (&install_path, out))
- return FALSE;
+ _dbus_string_tolower_ascii (&install_path, 0, _dbus_string_get_length (&install_path));
- return TRUE;
+ if (!_dbus_sha_compute (&install_path, out))
+ goto out;
+
+ retval = TRUE;
+
+out:
+ _dbus_string_free (&install_path);
+ return retval;
}
+/**
+ * Build a name from \p basestring and \p scope, and append it to \p out
+ *
+ * The name will be suitable for naming Windows objects such as mutexes
+ * and shared memory segments that need to be unique for each distinct
+ * \p scope, but shared between clients with the same \p scope.
+ *
+ * If \p scope has one of the special values recognised in autolaunch:
+ * addresses on Windows, substitute a unique string based on the scope
+ * (the username or the hash of the installation path) instead of the
+ * literal scope itself.
+ *
+ * With the '*install-path' \p scope the returned length can be zero,
+ * indicating that the name could not be determined.
+ *
+ * @param out initialized DBusString instance to return bus address
+ * @returns #FALSE on OOM, #TRUE if not OOM
+ */
static dbus_bool_t
_dbus_get_address_string (DBusString *out, const char *basestring, const char *scope)
{
- _dbus_string_init(out);
- _dbus_string_append(out,basestring);
+ _dbus_assert (out != NULL);
- if (!scope)
+ if (!scope || strlen (scope) == 0)
{
- return TRUE;
+ return _dbus_string_append (out, basestring);
}
- else if (strcmp(scope,"*install-path") == 0
+ else if (strcmp (scope, "*install-path") == 0
// for 1.3 compatibility
- || strcmp(scope,"install-path") == 0)
+ || strcmp (scope, "install-path") == 0)
{
DBusString temp;
- if (!_dbus_get_install_root_as_hash(&temp))
+ dbus_bool_t retval = FALSE;
+
+ if (!_dbus_string_init (&temp))
+ return FALSE;
+
+ if (!_dbus_get_install_root_as_hash (&temp))
+ goto out;
+
+ if (_dbus_string_get_length (&temp) == 0)
{
- _dbus_string_free(out);
- return FALSE;
+ _dbus_string_set_length (out, 0);
+ retval = TRUE;
+ goto out;
}
- _dbus_string_append(out,"-");
- _dbus_string_append(out,_dbus_string_get_const_data(&temp));
- _dbus_string_free(&temp);
+
+ if (!_dbus_string_append_printf (out, "%s-%s", basestring, _dbus_string_get_const_data (&temp)))
+ goto out;
+
+ retval = TRUE;
+out:
+ _dbus_string_free (&temp);
+ return retval;
}
- else if (strcmp(scope,"*user") == 0)
+ else if (strcmp (scope, "*user") == 0)
{
- _dbus_string_append(out,"-");
- if (!_dbus_append_user_from_current_process(out))
- {
- _dbus_string_free(out);
- return FALSE;
- }
+ char *sid = NULL;
+ dbus_bool_t retval;
+
+ if (!_dbus_getsid (&sid, _dbus_getpid()))
+ return FALSE;
+
+ retval = _dbus_string_append_printf (out, "%s-%s", basestring, sid);
+
+ LocalFree(sid);
+
+ return retval;
}
- else if (strlen(scope) > 0)
+ else /* strlen(scope) > 0 */
{
- _dbus_string_append(out,"-");
- _dbus_string_append(out,scope);
- return TRUE;
+ return _dbus_string_append_printf (out, "%s-%s", basestring, scope);
}
- return TRUE;
}
+/**
+ * Return name of shared memory segment constructed from the autolaunch scope \p scope
+ *
+ * See @ref _dbus_get_address_string for further usage information.
+ *
+ * @param out initialized DBusString instance to return shared memory segment name
+ * @returns #FALSE on OOM, #TRUE if not OOM
+ */
static dbus_bool_t
_dbus_get_shm_name (DBusString *out,const char *scope)
{
- return _dbus_get_address_string (out,cDBusDaemonAddressInfo,scope);
+ return _dbus_get_address_string (out, cDBusDaemonAddressInfo, scope);
}
+/**
+ * Return mutex name for scope \p scope in \p out
+ *
+ * See @ref _dbus_get_address_string for further usage information.
+ *
+ * @param out initialized DBusString instance to return mutex name
+ * @param scope scope for the requested mutex name
+ * @returns #FALSE on OOM, #TRUE if not OOM
+ */
static dbus_bool_t
-_dbus_get_mutex_name (DBusString *out,const char *scope)
+_dbus_get_mutex_name (DBusString *out, const char *scope)
{
- return _dbus_get_address_string (out,cDBusDaemonMutex,scope);
+ return _dbus_get_address_string (out, cDBusDaemonMutex, scope);
}
dbus_bool_t
_dbus_daemon_is_session_bus_address_published (const char *scope)
{
- HANDLE lock;
+ DBusRMutex *lock = NULL;
DBusString mutex_name;
+ if (!_dbus_string_init (&mutex_name))
+ return FALSE;
+
_dbus_verbose ("scope:%s\n", scope);
- if (!_dbus_get_mutex_name(&mutex_name,scope))
+ if (!_dbus_get_mutex_name (&mutex_name, scope) ||
+ /* not determinable */
+ _dbus_string_get_length (&mutex_name) == 0)
{
- _dbus_string_free( &mutex_name );
+ _dbus_string_free (&mutex_name);
return FALSE;
}
@@ -3026,21 +2966,25 @@ _dbus_daemon_is_session_bus_address_published (const char *scope)
_dbus_verbose ("(scope:%s) -> yes\n", scope);
return TRUE;
}
+ lock = _dbus_win_rmutex_named_new (cUniqueDBusInitMutex);
+ if (!lock)
+ return FALSE;
// sync _dbus_daemon_publish_session_bus_address, _dbus_daemon_unpublish_session_bus_address and _dbus_daemon_already_runs
- lock = _dbus_global_lock( cUniqueDBusInitMutex );
+ _dbus_platform_rmutex_lock (lock);
// we use CreateMutex instead of OpenMutex because of possible race conditions,
// see http://msdn.microsoft.com/en-us/library/ms684315%28VS.85%29.aspx
- hDBusDaemonMutex = CreateMutexA( NULL, FALSE, _dbus_string_get_const_data(&mutex_name) );
+ hDBusDaemonMutex = CreateMutexA (NULL, FALSE, _dbus_string_get_const_data(&mutex_name));
/* The client uses mutex ownership to detect a running server, so the server should do so too.
Fortunally the client deletes the mutex in the lock protected area, so checking presence
will work too. */
- _dbus_global_unlock( lock );
+ _dbus_platform_rmutex_unlock (lock);
+ _dbus_platform_rmutex_free (lock);
- _dbus_string_free( &mutex_name );
+ _dbus_string_free (&mutex_name);
if (hDBusDaemonMutex == NULL)
{
@@ -3064,202 +3008,283 @@ _dbus_daemon_is_session_bus_address_published (const char *scope)
dbus_bool_t
_dbus_daemon_publish_session_bus_address (const char* address, const char *scope)
{
- HANDLE lock;
+ DBusRMutex *lock = NULL;
char *shared_addr = NULL;
- DBusString shm_name;
+ DBusString shm_name = _DBUS_STRING_INIT_INVALID;
DBusString mutex_name;
dbus_uint64_t len;
+ dbus_bool_t retval = FALSE;
_dbus_assert (address);
+ if (!_dbus_string_init (&mutex_name))
+ return FALSE;
+
_dbus_verbose ("address:%s scope:%s\n", address, scope);
- if (!_dbus_get_mutex_name(&mutex_name,scope))
+ if (!_dbus_get_mutex_name (&mutex_name, scope) ||
+ /* not determinable */
+ _dbus_string_get_length (&mutex_name) == 0)
{
- _dbus_string_free( &mutex_name );
+ _dbus_string_free (&mutex_name);
return FALSE;
}
// sync _dbus_daemon_publish_session_bus_address, _dbus_daemon_unpublish_session_bus_address and _dbus_daemon_already_runs
- lock = _dbus_global_lock( cUniqueDBusInitMutex );
+ lock = _dbus_win_rmutex_named_new (cUniqueDBusInitMutex);
+ if (lock == NULL)
+ {
+ _dbus_string_free (&mutex_name);
+ return FALSE;
+ }
+
+ _dbus_platform_rmutex_lock (lock);
if (!hDBusDaemonMutex)
{
- hDBusDaemonMutex = CreateMutexA( NULL, FALSE, _dbus_string_get_const_data(&mutex_name) );
+ hDBusDaemonMutex = CreateMutexA (NULL, FALSE, _dbus_string_get_const_data(&mutex_name));
}
- _dbus_string_free( &mutex_name );
+ _dbus_string_free (&mutex_name);
// acquire the mutex
- if (WaitForSingleObject( hDBusDaemonMutex, 10 ) != WAIT_OBJECT_0)
+ if (WaitForSingleObject (hDBusDaemonMutex, 10) != WAIT_OBJECT_0)
{
- _dbus_global_unlock( lock );
- CloseHandle( hDBusDaemonMutex );
- return FALSE;
+ CloseHandle (hDBusDaemonMutex);
+ goto out;
}
- if (!_dbus_get_shm_name(&shm_name,scope))
+ if (!_dbus_string_init (&shm_name))
{
- _dbus_string_free( &shm_name );
- _dbus_global_unlock( lock );
- return FALSE;
+ goto out;
+ }
+
+ if (!_dbus_get_shm_name (&shm_name, scope) ||
+ /* not determinable */
+ _dbus_string_get_length (&shm_name) == 0)
+ {
+ goto out;
}
// create shm
len = strlen (address) + 1;
- hDBusSharedMem = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
+ hDBusSharedMem = CreateFileMappingA ( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
len >> 32, len & 0xffffffffu,
- _dbus_string_get_const_data(&shm_name) );
- _dbus_assert( hDBusSharedMem );
+ _dbus_string_get_const_data (&shm_name) );
+ _dbus_assert (hDBusSharedMem);
- shared_addr = MapViewOfFile( hDBusSharedMem, FILE_MAP_WRITE, 0, 0, 0 );
+ shared_addr = MapViewOfFile (hDBusSharedMem, FILE_MAP_WRITE, 0, 0, 0);
_dbus_assert (shared_addr);
- strcpy( shared_addr, address);
+ strcpy(shared_addr, address);
// cleanup
- UnmapViewOfFile( shared_addr );
+ UnmapViewOfFile (shared_addr);
- _dbus_global_unlock( lock );
- _dbus_verbose( "published session bus address at %s\n",_dbus_string_get_const_data (&shm_name) );
+ _dbus_verbose ("published session bus address at %s\n",_dbus_string_get_const_data (&shm_name));
+ retval = TRUE;
- _dbus_string_free( &shm_name );
- return TRUE;
+out:
+ _dbus_platform_rmutex_unlock (lock);
+ _dbus_platform_rmutex_free (lock);
+ _dbus_string_free (&shm_name);
+ return retval;
}
-void
+/**
+ * Clear the platform-specific centralized location where the session
+ * bus address is published.
+ *
+ * This must only be called if \ref DBusServer.published_address is #TRUE,
+ * which is be the case if and only if platform-specific code has published
+ * the address centrally.
+ *
+ * On Windows, this is implemented by closing a global shared memory segment.
+ *
+ * On Unix, the session bus address is not published in a centralized
+ * location by libdbus, so this function does nothing. The closest
+ * equivalent on Unix is that the session bus address is published by the
+ * dbus-launch tool, and unpublished automatically when the dbus-launch
+ * tool exits.
+ * @return NULL in case of error
+ */
+dbus_bool_t
_dbus_daemon_unpublish_session_bus_address (void)
{
- HANDLE lock;
+ DBusRMutex *lock = NULL;
_dbus_verbose ("\n");
// sync _dbus_daemon_publish_session_bus_address, _dbus_daemon_unpublish_session_bus_address and _dbus_daemon_already_runs
- lock = _dbus_global_lock( cUniqueDBusInitMutex );
+ lock = _dbus_win_rmutex_named_new (cUniqueDBusInitMutex);
+ if (lock == NULL)
+ return FALSE;
- CloseHandle( hDBusSharedMem );
+ _dbus_platform_rmutex_lock (lock);
+
+ CloseHandle (hDBusSharedMem);
hDBusSharedMem = NULL;
- ReleaseMutex( hDBusDaemonMutex );
+ ReleaseMutex (hDBusDaemonMutex);
- CloseHandle( hDBusDaemonMutex );
+ CloseHandle (hDBusDaemonMutex);
hDBusDaemonMutex = NULL;
- _dbus_global_unlock( lock );
+ _dbus_platform_rmutex_unlock (lock);
+ _dbus_platform_rmutex_free (lock);
+ return TRUE;
}
+/**
+ * Get server bus address from shared memory segment provided by running dbus-daemon
+ *
+ * @param address initialized DBusString instance to store the retrieved address
+ * @param shm_name the name of the shared memory segment
+ * @param wait if TRUE wait maximum 2 seconds for the presence of the shared memory segment
+ * @return #TRUE the bus address was fetched from the shared memory segment
+ * @return #FALSE error during execution
+ */
static dbus_bool_t
-_dbus_get_autolaunch_shm (DBusString *address, DBusString *shm_name)
+_dbus_get_autolaunch_shm (DBusString *address, DBusString *shm_name, dbus_bool_t wait)
{
- HANDLE sharedMem;
+ HANDLE sharedMem = NULL;
char *shared_addr;
int i;
+ int max = 20; /* max 2 seconds */
+ dbus_bool_t retval = FALSE;
+
+ if (!wait)
+ max = 1;
// read shm
- for(i=0;i<20;++i) {
+ for (i = 0; i < max; ++i)
+ {
// we know that dbus-daemon is available, so we wait until shm is available
- sharedMem = OpenFileMappingA( FILE_MAP_READ, FALSE, _dbus_string_get_const_data(shm_name));
- if( sharedMem == 0 )
- Sleep( 100 );
- if ( sharedMem != 0)
- break;
- }
-
- if( sharedMem == 0 )
- return FALSE;
-
- shared_addr = MapViewOfFile( sharedMem, FILE_MAP_READ, 0, 0, 0 );
+ sharedMem = OpenFileMappingA (FILE_MAP_READ, FALSE, _dbus_string_get_const_data (shm_name));
+ if (sharedMem == 0)
+ Sleep (100);
+ if (sharedMem != 0)
+ break;
+ }
- if( !shared_addr )
- return FALSE;
+ if (sharedMem == 0)
+ return FALSE;
- _dbus_string_init( address );
+ shared_addr = MapViewOfFile (sharedMem, FILE_MAP_READ, 0, 0, 0);
- _dbus_string_append( address, shared_addr );
+ if (!shared_addr)
+ goto out;
- // cleanup
- UnmapViewOfFile( shared_addr );
+ retval = _dbus_string_append (address, shared_addr);
- CloseHandle( sharedMem );
+ UnmapViewOfFile (shared_addr);
- return TRUE;
+out:
+ CloseHandle (sharedMem);
+ return retval;
}
static dbus_bool_t
_dbus_daemon_already_runs (DBusString *address, DBusString *shm_name, const char *scope)
{
- HANDLE lock;
+ DBusRMutex *lock = NULL;
HANDLE daemon;
DBusString mutex_name;
- dbus_bool_t bRet = TRUE;
+ dbus_bool_t retval = FALSE;
- if (!_dbus_get_mutex_name(&mutex_name,scope))
+ if (!_dbus_string_init (&mutex_name))
+ return FALSE;
+
+ if (!_dbus_get_mutex_name (&mutex_name, scope) ||
+ /* not determinable */
+ _dbus_string_get_length (&mutex_name) == 0)
{
- _dbus_string_free( &mutex_name );
+ _dbus_string_free (&mutex_name);
return FALSE;
}
// sync _dbus_daemon_publish_session_bus_address, _dbus_daemon_unpublish_session_bus_address and _dbus_daemon_already_runs
- lock = _dbus_global_lock( cUniqueDBusInitMutex );
+ lock = _dbus_win_rmutex_named_new (cUniqueDBusInitMutex);
+ if (lock == NULL)
+ return FALSE;
+
+ _dbus_platform_rmutex_lock (lock);
// do checks
- daemon = CreateMutexA( NULL, FALSE, _dbus_string_get_const_data(&mutex_name) );
- if(WaitForSingleObject( daemon, 10 ) != WAIT_TIMEOUT)
+ daemon = CreateMutexA (NULL, FALSE, _dbus_string_get_const_data (&mutex_name));
+ if (WaitForSingleObject (daemon, 10) != WAIT_TIMEOUT)
{
ReleaseMutex (daemon);
CloseHandle (daemon);
-
- _dbus_global_unlock( lock );
- _dbus_string_free( &mutex_name );
- return FALSE;
+ goto out;
}
- // read shm
- bRet = _dbus_get_autolaunch_shm( address, shm_name );
+ // read shm, wait max 2 seconds
+ retval = _dbus_get_autolaunch_shm (address, shm_name, TRUE);
// cleanup
- CloseHandle ( daemon );
+ CloseHandle (daemon);
- _dbus_global_unlock( lock );
- _dbus_string_free( &mutex_name );
+out:
+ _dbus_platform_rmutex_unlock (lock);
+ _dbus_platform_rmutex_free (lock);
+ _dbus_string_free (&mutex_name);
- return bRet;
+ return retval;
}
dbus_bool_t
-_dbus_get_autolaunch_address (const char *scope, DBusString *address,
+_dbus_get_autolaunch_address (const char *scope,
+ DBusString *address,
DBusError *error)
{
- HANDLE mutex;
+ DBusRMutex *lock = NULL;
STARTUPINFOA si;
PROCESS_INFORMATION pi;
dbus_bool_t retval = FALSE;
LPSTR lpFile;
char dbus_exe_path[MAX_PATH];
- char dbus_args[MAX_PATH * 2];
- const char * daemon_name = DBUS_DAEMON_NAME ".exe";
+ DBusString dbus_args = _DBUS_STRING_INIT_INVALID;
+ const char *daemon_name = DBUS_DAEMON_NAME ".exe";
DBusString shm_name;
+ HANDLE ready_event_handle = NULL;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
- if (!_dbus_get_shm_name(&shm_name,scope))
+ if (!_dbus_string_init (&shm_name))
{
- dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not determine shm name");
- return FALSE;
+ _DBUS_SET_OOM (error);
+ return FALSE;
}
- mutex = _dbus_global_lock ( cDBusAutolaunchMutex );
+ if (!_dbus_get_shm_name (&shm_name, scope) ||
+ /* not determinable */
+ _dbus_string_get_length (&shm_name) == 0)
+ {
+ dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not determine shm name");
+ goto out;
+ }
- if (_dbus_daemon_already_runs(address,&shm_name,scope))
+ lock = _dbus_win_rmutex_named_new (cDBusAutolaunchMutex);
+ if (lock == NULL)
{
- _dbus_verbose( "found running dbus daemon for scope '%s' at %s\n",
- scope ? scope : "", _dbus_string_get_const_data (&shm_name) );
- retval = TRUE;
- goto out;
+ dbus_set_error (error, DBUS_ERROR_FAILED, "Could not lock '%s'", cDBusAutolaunchMutex);
+ _dbus_string_free (&shm_name);
+ return FALSE;
}
- if (!SearchPathA(NULL, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile))
+ _dbus_platform_rmutex_lock (lock);
+
+ if (_dbus_daemon_already_runs (address, &shm_name, scope))
+ {
+ _dbus_verbose ("found running dbus daemon for scope '%s' at %s\n",
+ scope ? scope : "", _dbus_string_get_const_data (&shm_name));
+ retval = TRUE;
+ goto out;
+ }
+
+ if (!SearchPathA (NULL, daemon_name, NULL, sizeof (dbus_exe_path), dbus_exe_path, &lpFile))
{
// Look in directory containing dbus shared library
HMODULE hmod;
@@ -3270,7 +3295,7 @@ _dbus_get_autolaunch_address (const char *scope, DBusString *address,
"trying path where dbus shared library is located");
hmod = _dbus_win_get_dll_hmodule ();
- rc = GetModuleFileNameA (hmod, dbus_module_path, sizeof(dbus_module_path));
+ rc = GetModuleFileNameA (hmod, dbus_module_path, sizeof (dbus_module_path));
if (rc <= 0)
{
dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not retrieve dbus shared library file name");
@@ -3281,8 +3306,8 @@ _dbus_get_autolaunch_address (const char *scope, DBusString *address,
{
char *ext_idx = strrchr (dbus_module_path, '\\');
if (ext_idx)
- *ext_idx = '\0';
- if (!SearchPathA (dbus_module_path, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile))
+ *ext_idx = '\0';
+ if (!SearchPathA (dbus_module_path, daemon_name, NULL, sizeof (dbus_exe_path), dbus_exe_path, &lpFile))
{
dbus_set_error (error, DBUS_ERROR_FAILED,
"Could not find dbus-daemon executable. "
@@ -3296,20 +3321,91 @@ _dbus_get_autolaunch_address (const char *scope, DBusString *address,
}
}
-
// Create process
- ZeroMemory( &si, sizeof(si) );
- si.cb = sizeof(si);
- ZeroMemory( &pi, sizeof(pi) );
+ ZeroMemory (&si, sizeof (si));
+ si.cb = sizeof (si);
+ ZeroMemory (&pi, sizeof (pi));
- _snprintf(dbus_args, sizeof(dbus_args) - 1, "\"%s\" %s", dbus_exe_path, " --session");
+ if (!_dbus_string_init (&dbus_args))
+ {
+ dbus_set_error_const (error, DBUS_ERROR_NO_MEMORY, "Failed to initialize argument buffer");
+ retval = FALSE;
+ goto out;
+ }
-// argv[i] = "--config-file=bus\\session.conf";
- if(CreateProcessA(dbus_exe_path, dbus_args, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
+ if (!_dbus_string_append_printf (&dbus_args, "\"%s\" %s", dbus_exe_path,
+ autolaunch_custom_command_line_parameter ? autolaunch_custom_command_line_parameter : "--session"))
{
+ _DBUS_SET_OOM (error);
+ retval = FALSE;
+ goto out;
+ }
+
+ ready_event_handle = _dbus_win_event_create_inheritable (error);
+ if (ready_event_handle == NULL)
+ goto out;
+
+ _dbus_verbose ("Creating connection readiness event: handle=%p\n", ready_event_handle);
+ if (!_dbus_string_append_printf (&dbus_args, " \"--ready-event-handle=%p\"", ready_event_handle))
+ {
+ _DBUS_SET_OOM (error);
+ goto out;
+ }
+
+ _dbus_verbose ("Starting dbus daemon with args: '%s'\n", _dbus_string_get_const_data (&dbus_args));
+ if (CreateProcessA (dbus_exe_path, _dbus_string_get_data (&dbus_args), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
+ {
+ DWORD status;
+ HANDLE events[2];
+
CloseHandle (pi.hThread);
- CloseHandle (pi.hProcess);
- retval = _dbus_get_autolaunch_shm( address, &shm_name );
+
+ _dbus_verbose ("Wait until dbus-daemon is ready for connections (event handle %p)\n", ready_event_handle);
+
+ events[0] = ready_event_handle;
+ events[1] = pi.hProcess;
+ status = WaitForMultipleObjects (2, events, FALSE, 30000);
+
+ switch (status)
+ {
+ case WAIT_OBJECT_0:
+ /* ready event signalled, everything is okay */
+ retval = TRUE;
+ break;
+
+ case WAIT_OBJECT_0 + 1:
+ /* dbus-daemon process has exited */
+ dbus_set_error (error, DBUS_ERROR_SPAWN_CHILD_EXITED, "dbus-daemon exited before signalling ready");
+ goto out;
+
+ case WAIT_FAILED:
+ _dbus_win_set_error_from_last_error (error, "Unable to wait for server readiness (handle %p)", ready_event_handle);
+ goto out;
+
+ case WAIT_TIMEOUT:
+ /* GetLastError() is not set */
+ dbus_set_error (error, DBUS_ERROR_TIMEOUT, "Timed out waiting for server readiness or exit (handle %p)", ready_event_handle);
+ goto out;
+
+ default:
+ /* GetLastError() is probably not set? */
+ dbus_set_error (error, DBUS_ERROR_FAILED, "Unknown result '%lu' while waiting for server readiness (handle %p)", status, ready_event_handle);
+ goto out;
+ }
+ _dbus_verbose ("Got signal that dbus-daemon with process id '%ld' is ready for connections\n", GetProcessId (pi.hProcess));
+
+ if (autolaunch_handle_location != NULL)
+ {
+ *autolaunch_handle_location = pi.hProcess;
+ _dbus_verbose ("Returning process handle of started server (handle=%p)\n", pi.hProcess);
+ }
+ else
+ {
+ CloseHandle (pi.hProcess);
+ }
+
+ /* do not wait for the appearance of shm, we can assume that it is present */
+ retval = _dbus_get_autolaunch_shm (address, &shm_name, FALSE);
if (retval == FALSE)
dbus_set_error_const (error, DBUS_ERROR_FAILED, "Failed to get autolaunch address from launched dbus-daemon");
}
@@ -3321,12 +3417,16 @@ _dbus_get_autolaunch_address (const char *scope, DBusString *address,
out:
_DBUS_ASSERT_ERROR_XOR_BOOL (error, retval);
- _dbus_global_unlock (mutex);
+ _dbus_platform_rmutex_unlock (lock);
+ _dbus_platform_rmutex_free (lock);
_dbus_string_free (&shm_name);
+ _dbus_string_free (&dbus_args);
+ if (ready_event_handle)
+ _dbus_win_event_free (ready_event_handle, NULL);
+ _DBUS_ASSERT_ERROR_XOR_BOOL (error, retval);
return retval;
- }
-
+}
/** Makes the file readable by every user in the system.
*
@@ -3352,9 +3452,13 @@ _dbus_make_file_world_readable(const DBusString *filename,
dbus_int32_t
_dbus_atomic_inc (DBusAtomic *atomic)
{
- // +/- 1 is needed here!
- // no volatile argument with mingw
+#ifdef HAVE_STDATOMIC_H
+ /* Atomic version of "old = *atomic; *atomic += 1; return old" */
+ return atomic_fetch_add (&atomic->value, 1);
+#else
+ /* Atomic version of "*atomic += 1; return *atomic - 1" */
return InterlockedIncrement (&atomic->value) - 1;
+#endif
}
/**
@@ -3367,9 +3471,13 @@ _dbus_atomic_inc (DBusAtomic *atomic)
dbus_int32_t
_dbus_atomic_dec (DBusAtomic *atomic)
{
- // +/- 1 is needed here!
- // no volatile argument with mingw
+#ifdef HAVE_STDATOMIC_H
+ /* Atomic version of "old = *atomic; *atomic -= 1; return old" */
+ return atomic_fetch_sub (&atomic->value, 1);
+#else
+ /* Atomic version of "*atomic -= 1; return *atomic + 1" */
return InterlockedDecrement (&atomic->value) + 1;
+#endif
}
/**
@@ -3382,6 +3490,10 @@ _dbus_atomic_dec (DBusAtomic *atomic)
dbus_int32_t
_dbus_atomic_get (DBusAtomic *atomic)
{
+#ifdef HAVE_STDATOMIC_H
+ /* Atomic version of "return *atomic" */
+ return atomic_load (&atomic->value);
+#else
/* In this situation, GLib issues a MemoryBarrier() and then returns
* atomic->value. However, mingw from mingw.org (not to be confused with
* mingw-w64 from mingw-w64.sf.net) does not have MemoryBarrier in its
@@ -3395,6 +3507,7 @@ _dbus_atomic_get (DBusAtomic *atomic)
InterlockedExchange (&dummy, 1);
return atomic->value;
+#endif
}
/**
@@ -3405,7 +3518,12 @@ _dbus_atomic_get (DBusAtomic *atomic)
void
_dbus_atomic_set_zero (DBusAtomic *atomic)
{
+#ifdef HAVE_STDATOMIC_H
+ /* Atomic version of "*atomic = 0" */
+ atomic_store (&atomic->value, 0);
+#else
InterlockedExchange (&atomic->value, 0);
+#endif
}
/**
@@ -3416,7 +3534,12 @@ _dbus_atomic_set_zero (DBusAtomic *atomic)
void
_dbus_atomic_set_nonzero (DBusAtomic *atomic)
{
+#ifdef HAVE_STDATOMIC_H
+ /* Atomic version of "*atomic = 1" */
+ atomic_store (&atomic->value, 1);
+#else
InterlockedExchange (&atomic->value, 1);
+#endif
}
/**
@@ -3947,7 +4070,7 @@ _dbus_logv (DBusSystemLogSeverity severity,
{
DBusString out = _DBUS_STRING_INIT_INVALID;
const char *message = NULL;
- DBUS_VA_COPY (tmp, args);
+ va_copy (tmp, args);
if (!_dbus_string_init (&out))
goto out;
@@ -3974,7 +4097,7 @@ out:
if (log_flags & DBUS_LOG_FLAGS_STDERR)
{
- DBUS_VA_COPY (tmp, args);
+ va_copy (tmp, args);
fprintf (stderr, "%s[%lu]: %s: ", log_tag, _dbus_pid_for_log (), s);
vfprintf (stderr, msg, tmp);
fprintf (stderr, "\n");
@@ -3996,5 +4119,403 @@ _dbus_get_low_level_socket_errno (void)
return WSAGetLastError ();
}
+void
+_dbus_win_set_error_from_last_error (DBusError *error,
+ const char *format,
+ ...)
+{
+ const char *name;
+ char *message = NULL;
+
+ if (error == NULL)
+ return;
+
+ /* make sure to do this first, in case subsequent library calls overwrite GetLastError() */
+ name = _dbus_win_error_from_last_error ();
+ message = _dbus_win_error_string (GetLastError ());
+
+ if (format != NULL)
+ {
+ DBusString str;
+ va_list args;
+ dbus_bool_t retval;
+
+ if (!_dbus_string_init (&str))
+ {
+ _DBUS_SET_OOM (error);
+ goto out;
+ }
+
+ va_start (args, format);
+ retval = _dbus_string_append_printf_valist (&str, format, args);
+ va_end (args);
+ if (!retval)
+ {
+ _DBUS_SET_OOM (error);
+ _dbus_string_free (&str);
+ goto out;
+ }
+
+ dbus_set_error (error, name, "%s: %s", _dbus_string_get_const_data (&str), message);
+ _dbus_string_free (&str);
+ }
+ else
+ {
+ dbus_set_error (error, name, "%s", message);
+ }
+
+out:
+ if (message != NULL)
+ _dbus_win_free_error_string (message);
+
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+}
+
+/**
+ * Creates a Windows event object and returns the corresponding handle
+ *
+ * The returned object is unnamed, is a manual-reset event object,
+ * is initially in the non-signalled state, and is inheritable by child
+ * processes.
+ *
+ * @param error the error to set
+ * @return handle for the created event
+ * @return #NULL if an error has occurred, the reason is returned in \p error
+ */
+HANDLE
+_dbus_win_event_create_inheritable (DBusError *error)
+{
+ HANDLE handle;
+
+ handle = CreateEvent (NULL, TRUE, FALSE, NULL);
+ if (handle == NULL)
+ {
+ _dbus_win_set_error_from_last_error (error, "Could not create event");
+ return NULL;
+ }
+ else if (GetLastError () == ERROR_ALREADY_EXISTS)
+ {
+ _dbus_win_set_error_from_last_error (error, "Event already exists");
+ return NULL;
+ }
+
+ if (!SetHandleInformation (handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
+ {
+ _dbus_win_set_error_from_last_error (error, "Could not set inheritance for event %p", handle);
+ CloseHandle (handle);
+ return NULL;
+ }
+ return handle;
+}
+
+/**
+ * Set a Windows event to the signalled state
+ *
+ * @param handle the handle for the event to be set
+ * @return TRUE the event was set successfully
+ * @return FALSE an error has occurred, the reason is returned in \p error
+ */
+dbus_bool_t
+_dbus_win_event_set (HANDLE handle, DBusError *error)
+{
+ _dbus_assert (handle != NULL);
+
+ if (!SetEvent (handle))
+ {
+ _dbus_win_set_error_from_last_error (error, "Could not trigger event (handle %p)", handle);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * Wait for a Windows event to enter the signalled state
+ *
+ * @param handle the handle for the event to wait for
+ * @param timeout the waiting time in milliseconds, or INFINITE to wait forever,
+ * or 0 to check immediately and not wait (polling)
+ * @param error the error to set
+ * @return TRUE the event was set successfully
+ * @return FALSE an error has occurred, the reason is returned in \p error
+ */
+dbus_bool_t
+_dbus_win_event_wait (HANDLE handle, int timeout, DBusError *error)
+{
+ DWORD status;
+
+ _dbus_assert (handle != NULL);
+
+ status = WaitForSingleObject (handle, timeout);
+ switch (status)
+ {
+ case WAIT_OBJECT_0:
+ return TRUE;
+
+ case WAIT_FAILED:
+ {
+ _dbus_win_set_error_from_last_error (error, "Unable to wait for event (handle %p)", handle);
+ return FALSE;
+ }
+
+ case WAIT_TIMEOUT:
+ /* GetLastError() is not set */
+ dbus_set_error (error, DBUS_ERROR_TIMEOUT, "Timed out waiting for event (handle %p)", handle);
+ return FALSE;
+
+ default:
+ /* GetLastError() is probably not set? */
+ dbus_set_error (error, DBUS_ERROR_FAILED, "Unknown result '%lu' while waiting for event (handle %p)", status, handle);
+ return FALSE;
+ }
+}
+
+/**
+ * Delete a Windows event
+ *
+ * @param handle handle for the event to delete
+ * @param error the error to set (optional)
+ * @return TRUE the event has been deleted successfully or the handle is one of the special sentinel values #NULL or #INVALID_HANDLE_VALUE
+ * @return FALSE an error has occurred, the reason is returned in \p error if specified
+ */
+dbus_bool_t
+_dbus_win_event_free (HANDLE handle, DBusError *error)
+{
+ if (handle == NULL || handle == INVALID_HANDLE_VALUE)
+ return TRUE;
+
+ if (CloseHandle (handle))
+ return TRUE;
+
+ /* the handle may already be closed */
+ if (GetLastError () == ERROR_INVALID_HANDLE)
+ return TRUE;
+
+ _dbus_win_set_error_from_last_error (error, "Could not close event (handle %p)", handle);
+ return FALSE;
+}
+
+#ifdef HAVE_AFUNIX_H
+static dbus_bool_t
+_dbus_open_socket (SOCKET *socket_p,
+ int domain,
+ int type,
+ int protocol,
+ DBusError *error)
+{
+ if (!_dbus_win_startup_winsock ())
+ {
+ _DBUS_SET_OOM (error);
+ return FALSE;
+ }
+
+ *socket_p = socket (domain, type, protocol);
+ if (*socket_p == INVALID_SOCKET)
+ {
+ DBUS_SOCKET_SET_ERRNO ();
+ dbus_set_error (error, _dbus_error_from_errno (errno),
+ "Failed to open socket: %s",
+ _dbus_strerror_from_errno ());
+ return FALSE;
+ }
+
+ _dbus_win_handle_set_close_on_exec ((HANDLE) *socket_p);
+ return TRUE;
+}
+
+/**
+ * Opens a UNIX domain socket (as in the socket() call).
+ * Does not bind the socket.
+ *
+ * This will set CLOEXEC for the socket returned
+ *
+ * @param return location for socket descriptor
+ * @param error return location for an error
+ * @returns #FALSE if error is set
+ */
+static dbus_bool_t
+_dbus_open_unix_socket (SOCKET *socket,
+ DBusError *error)
+{
+ return _dbus_open_socket (socket, AF_UNIX, SOCK_STREAM, 0, error);
+}
+#endif /* HAVE_AFUNIX_H */
+
+/**
+ * Creates a socket and connects it to the UNIX domain socket at the
+ * given path. The socket is returned, and is set up as
+ * nonblocking.
+ *
+ * Abstract socket usage always fails.
+ *
+ * This will set FD_CLOEXEC for the socket returned.
+ *
+ * @param path the path to UNIX domain socket
+ * @param abstract #TRUE to use abstract namespace
+ * @param error return location for error code
+ * @returns a valid socket on success or an invalid socket on error
+ */
+DBusSocket
+_dbus_connect_unix_socket (const char *path,
+ dbus_bool_t abstract,
+ DBusError *error)
+{
+ DBusSocket s = DBUS_SOCKET_INIT;
+
+#ifdef HAVE_AFUNIX_H
+ struct sockaddr_un addr;
+ size_t path_len;
+
+ _DBUS_STATIC_ASSERT (sizeof (addr.sun_path) > _DBUS_MAX_SUN_PATH_LENGTH);
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ _dbus_verbose ("connecting to unix socket %s abstract=%d\n",
+ path, abstract);
+
+ if (abstract)
+ {
+ dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
+ "Failed to connect: UNIX abstract socket is not supported on this system");
+ return s;
+ }
+
+ path_len = strlen (path);
+ if (path_len > _DBUS_MAX_SUN_PATH_LENGTH)
+ {
+ dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
+ "Failed to connect: socket name too long");
+ return s;
+ }
+
+ if (!_dbus_open_unix_socket (&s.sock, error))
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ return s;
+ }
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ _DBUS_ZERO (addr);
+ addr.sun_family = AF_UNIX;
+ strncpy (addr.sun_path, path, sizeof (addr.sun_path) - 1);
+
+ if (connect (s.sock, (struct sockaddr *) &addr, _DBUS_STRUCT_OFFSET (struct sockaddr_un, sun_path) + path_len) < 0)
+ {
+ DBUS_SOCKET_SET_ERRNO ();
+ dbus_set_error (error,
+ _dbus_error_from_errno (errno),
+ "Failed to connect to socket %s: %s",
+ path, _dbus_strerror (errno));
+
+ _dbus_close_socket (&s, NULL);
+ return s;
+ }
+
+ if (!_dbus_set_socket_nonblocking (s, error))
+ _dbus_close_socket (&s, NULL);
+
+#else
+ dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
+ "Failed to connect: UNIX socket is not supported with this build");
+#endif
+
+ return s;
+}
+
+/**
+ * Creates a socket and binds it to the given path,
+ * then listens on the socket. The socket is
+ * set to be nonblocking.
+ *
+ * Abstract socket usage always fails.
+ *
+ * This will set CLOEXEC for the socket returned
+ *
+ * @param path the socket name
+ * @param abstract #TRUE to use abstract namespace
+ * @param error return location for errors
+ * @returns a valid socket on success or an invalid socket on error
+ */
+DBusSocket
+_dbus_listen_unix_socket (const char *path,
+ dbus_bool_t abstract,
+ DBusError *error)
+{
+ DBusSocket s = DBUS_SOCKET_INIT;
+
+#ifdef HAVE_AFUNIX_H
+ struct sockaddr_un addr;
+ size_t path_len;
+ _DBUS_STATIC_ASSERT (sizeof (addr.sun_path) > _DBUS_MAX_SUN_PATH_LENGTH);
+
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ _dbus_verbose ("listening on unix socket %s abstract=%d\n",
+ path, abstract);
+
+ if (abstract)
+ {
+ dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
+ "Failed to listen: UNIX abstract socket is not supported on this system");
+ return s;
+ }
+
+ if (!_dbus_open_unix_socket (&s.sock, error))
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ return s;
+ }
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ _DBUS_ZERO (addr);
+ addr.sun_family = AF_UNIX;
+ path_len = strlen (path);
+
+ /* see related comment in dbus-sysdeps-unix.c */
+ /* there is no S_ISSOCK on windows yet, so just unlink the path */
+ unlink (path);
+
+ if (path_len > _DBUS_MAX_SUN_PATH_LENGTH)
+ {
+ dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
+ "Failed to listen: socket name too long");
+ _dbus_close_socket (&s, NULL);
+ return s;
+ }
+
+ strncpy (addr.sun_path, path, sizeof (addr.sun_path) - 1);
+
+ if (bind (s.sock, (struct sockaddr *) &addr, _DBUS_STRUCT_OFFSET (struct sockaddr_un, sun_path) + path_len) < 0)
+ {
+ DBUS_SOCKET_SET_ERRNO ();
+ dbus_set_error (error, _dbus_error_from_errno (errno),
+ "Failed to bind socket \"%s\": %s",
+ path, _dbus_strerror (errno));
+ _dbus_close_socket (&s, NULL);
+ return s;
+ }
+
+ if (listen (s.sock, SOMAXCONN /* backlog */) < 0)
+ {
+ DBUS_SOCKET_SET_ERRNO ();
+ dbus_set_error (error, _dbus_error_from_errno (errno),
+ "Failed to listen on socket \"%s\": %s",
+ path, _dbus_strerror (errno));
+ _dbus_close_socket (&s, NULL);
+ return s;
+ }
+
+ if (!_dbus_set_socket_nonblocking (s, error))
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ _dbus_close_socket (&s, NULL);
+ return s;
+ }
+#else
+ dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
+ "Failed to listen: UNIX socket is not supported with this build");
+#endif
+
+ return s;
+}
+
/** @} end of sysdeps-win */
/* tests in dbus-sysdeps-util.c */
diff --git a/dbus/dbus-sysdeps-win.h b/dbus/dbus-sysdeps-win.h
index edce99a3..f7be2101 100644
--- a/dbus/dbus-sysdeps-win.h
+++ b/dbus/dbus-sysdeps-win.h
@@ -5,6 +5,8 @@
* Copyright (C) 2003 CodeFactory AB
* Copyright (C) 2005 Novell, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -31,6 +33,7 @@ extern void *_dbus_win_get_dll_hmodule (void);
#include "dbus-hash.h"
#include "dbus-string.h"
+#include "dbus-threads-internal.h"
#include <ctype.h>
#include <malloc.h>
#include <windows.h>
@@ -46,9 +49,6 @@ const char* _dbus_win_error_from_last_error (void);
dbus_bool_t _dbus_win_startup_winsock (void);
void _dbus_win_warn_win_error (const char *message,
unsigned long code);
-void _dbus_win_stderr_win_error (const char *app,
- const char *message,
- unsigned long code);
DBUS_PRIVATE_EXPORT
char * _dbus_win_error_string (int error_number);
DBUS_PRIVATE_EXPORT
@@ -87,14 +87,39 @@ _dbus_win_sid_to_name_and_domain (dbus_uid_t uid,
DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_get_install_root (DBusString *str);
-void _dbus_threads_windows_init_global (void);
-void _dbus_threads_windows_ensure_ctor_linked (void);
-
DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_getsid(char **sid, dbus_pid_t process_id);
-HANDLE _dbus_spawn_program (const char *name, char **argv, char **envp);
+HANDLE _dbus_spawn_program (const char *name,
+ char **argv,
+ char **envp,
+ dbus_bool_t inherit_handles,
+ DBusError *error);
+
+DBUS_PRIVATE_EXPORT
+void _dbus_win_set_error_from_last_error (DBusError *error,
+ const char *format,
+ ...) _DBUS_GNUC_PRINTF (2, 3);
+DBUS_PRIVATE_EXPORT
+HANDLE _dbus_win_event_create_inheritable (DBusError *error);
+DBUS_PRIVATE_EXPORT
+dbus_bool_t _dbus_win_event_set (HANDLE handle, DBusError *error);
+DBUS_PRIVATE_EXPORT
+dbus_bool_t _dbus_win_event_wait (HANDLE handle, int timeout, DBusError *error);
+DBUS_PRIVATE_EXPORT
+dbus_bool_t _dbus_win_event_free (HANDLE handle, DBusError *error);
+
+dbus_bool_t _dbus_daemon_is_session_bus_address_published (const char *scope);
+dbus_bool_t _dbus_daemon_publish_session_bus_address (const char *address,
+ const char *shm_name);
+DBUS_PRIVATE_EXPORT
+DBusRMutex *_dbus_win_rmutex_named_new (const char* name);
+
+DBUS_PRIVATE_EXPORT
+void _dbus_test_win_autolaunch_set_command_line_parameter (const char *path);
+DBUS_PRIVATE_EXPORT
+void _dbus_test_win_set_autolaunch_handle_location (HANDLE *location);
#endif
/** @} end of sysdeps-win.h */
diff --git a/dbus/dbus-sysdeps-wince-glue.c b/dbus/dbus-sysdeps-wince-glue.c
index f35e4db2..182262c6 100644
--- a/dbus/dbus-sysdeps-wince-glue.c
+++ b/dbus/dbus-sysdeps-wince-glue.c
@@ -8,6 +8,8 @@
* Copyright (C) 2006 Peter Kümmel <syntheticpp@gmx.net>
* Copyright (C) 2006 Christian Ehrlicher <ch.ehrlicher@gmx.de>
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-sysdeps-wince-glue.h b/dbus/dbus-sysdeps-wince-glue.h
index 4765627a..88b9b104 100644
--- a/dbus/dbus-sysdeps-wince-glue.h
+++ b/dbus/dbus-sysdeps-wince-glue.h
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c
index 4c9b286d..8b82bfd5 100644
--- a/dbus/dbus-sysdeps.c
+++ b/dbus/dbus-sysdeps.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003, 2006 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -506,6 +508,45 @@ _dbus_string_parse_uint (const DBusString *str,
return TRUE;
}
+/**
+ * Parses a dbus_int64_t integer contained in a DBusString. Either return parameter
+ * may be #NULL if you aren't interested in it. The integer is parsed
+ * and stored in value_return. Return parameters are not initialized
+ * if the function returns #FALSE.
+ *
+ * @param str the string
+ * @param start the byte index of the start of the integer
+ * @param value_return return location of the integer value or #NULL
+ * @param end_return return location of the end of the integer, or #NULL
+ * @returns #TRUE on success
+ */
+dbus_bool_t
+_dbus_string_parse_int64 (const DBusString *str,
+ int start,
+ dbus_int64_t *value_return,
+ int *end_return)
+{
+ dbus_int64_t v;
+ const char *p;
+ char *end;
+
+ p = _dbus_string_get_const_data_len (str, start,
+ _dbus_string_get_length (str) - start);
+
+ end = NULL;
+ _dbus_set_errno_to_zero ();
+ v = strtoll (p, &end, 0);
+ if (end == NULL || end == p || errno != 0)
+ return FALSE;
+
+ if (value_return)
+ *value_return = v;
+ if (end_return)
+ *end_return = start + (end - p);
+
+ return TRUE;
+}
+
/** @} */ /* DBusString group */
/**
diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h
index a91c61e3..27053a43 100644
--- a/dbus/dbus-sysdeps.h
+++ b/dbus/dbus-sysdeps.h
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -30,14 +32,16 @@
#include "config.h"
#endif
-#ifdef HAVE_STDINT_H
#include <stdint.h>
-#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
+#ifdef HAVE_STDATOMIC_H
+#include <stdatomic.h>
+#endif
+
#include <dbus/dbus-errors.h>
#include <dbus/dbus-file.h>
#include <dbus/dbus-string.h>
@@ -212,7 +216,7 @@ dbus_bool_t _dbus_set_socket_nonblocking (DBusSocket fd,
DBusError *error);
DBUS_PRIVATE_EXPORT
-dbus_bool_t _dbus_close_socket (DBusSocket fd,
+dbus_bool_t _dbus_close_socket (DBusSocket *fd,
DBusError *error);
DBUS_PRIVATE_EXPORT
int _dbus_read_socket (DBusSocket fd,
@@ -298,7 +302,8 @@ dbus_bool_t _dbus_parse_unix_group_from_config (const DBusString *groupname,
dbus_gid_t *gid_p);
dbus_bool_t _dbus_unix_groups_from_uid (dbus_uid_t uid,
dbus_gid_t **group_ids,
- int *n_group_ids);
+ int *n_group_ids,
+ DBusError *error);
dbus_bool_t _dbus_unix_user_is_at_console (dbus_uid_t uid,
DBusError *error);
dbus_bool_t _dbus_unix_user_is_process_owner (dbus_uid_t uid);
@@ -307,13 +312,21 @@ dbus_bool_t _dbus_windows_user_is_process_owner (const char *windows_sid)
dbus_bool_t _dbus_append_keyring_directory_for_credentials (DBusString *directory,
DBusCredentials *credentials);
-dbus_bool_t _dbus_daemon_is_session_bus_address_published (const char *scope);
+dbus_bool_t _dbus_daemon_unpublish_session_bus_address (void);
-dbus_bool_t _dbus_daemon_publish_session_bus_address (const char* address, const char* shm_name);
+dbus_bool_t _dbus_socket_can_pass_unix_fd(DBusSocket fd);
-void _dbus_daemon_unpublish_session_bus_address (void);
+/* PID FDs are Linux-specific. */
+#ifdef DBUS_WIN
+static inline dbus_pid_t _dbus_resolve_pid_fd (int pid_fd)
+{
+ return DBUS_PID_UNSET;
+}
-dbus_bool_t _dbus_socket_can_pass_unix_fd(DBusSocket fd);
+#else
+DBUS_PRIVATE_EXPORT
+dbus_pid_t _dbus_resolve_pid_fd (int pid_fd);
+#endif
/** Opaque type representing an atomically-modifiable integer
* that can be used from multiple threads.
@@ -325,7 +338,9 @@ typedef struct DBusAtomic DBusAtomic;
*/
struct DBusAtomic
{
-#ifdef DBUS_WIN
+#ifdef HAVE_STDATOMIC_H
+ atomic_int value; /**< Value of the atomic integer. */
+#elif defined(DBUS_WIN)
volatile long value; /**< Value of the atomic integer. */
#else
volatile dbus_int32_t value; /**< Value of the atomic integer. */
@@ -448,11 +463,11 @@ DBUS_PRIVATE_EXPORT
void _dbus_sleep_milliseconds (int milliseconds);
DBUS_PRIVATE_EXPORT
-void _dbus_get_monotonic_time (long *tv_sec,
+void _dbus_get_monotonic_time (dbus_int64_t *tv_sec,
long *tv_usec);
DBUS_PRIVATE_EXPORT
-void _dbus_get_real_time (long *tv_sec,
+void _dbus_get_real_time (dbus_int64_t *tv_sec,
long *tv_usec);
/**
@@ -565,6 +580,18 @@ typedef struct
dbus_bool_t _dbus_stat (const DBusString *filename,
DBusStat *statbuf,
DBusError *error);
+
+DBusSocket _dbus_connect_unix_socket (const char *path,
+ dbus_bool_t abstract,
+ DBusError *error);
+DBusSocket _dbus_listen_unix_socket (const char *path,
+ dbus_bool_t abstract,
+ DBusError *error);
+
+DBusSocket _dbus_connect_exec (const char *path,
+ char *const argv[],
+ DBusError *error);
+
DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_socketpair (DBusSocket *fd1,
DBusSocket *fd2,
@@ -593,9 +620,6 @@ dbus_bool_t _dbus_command_for_pid (unsigned long pid,
int max_len,
DBusError *error);
-dbus_bool_t _dbus_user_at_console (const char *username,
- DBusError *error);
-
typedef enum {
DBUS_LOG_FLAGS_STDERR = (1 << 0),
DBUS_LOG_FLAGS_SYSTEM_LOG = (1 << 1)
@@ -621,31 +645,18 @@ void _dbus_logv (DBusSystemLogSeverity severity,
const char *msg,
va_list args) _DBUS_GNUC_PRINTF (2, 0);
-/**
- * Casts a primitive C type to a byte array and then indexes
- * a particular byte of the array.
- */
-#define _DBUS_BYTE_OF_PRIMITIVE(p, i) \
- (((const char*)&(p))[(i)])
/** On x86 there is an 80-bit FPU, and if you do "a == b" it may have a
* or b in an 80-bit register, thus failing to compare the two 64-bit
* doubles for bitwise equality. So this macro compares the two doubles
* bitwise.
*/
-#define _DBUS_DOUBLES_BITWISE_EQUAL(a, b) \
- (_DBUS_BYTE_OF_PRIMITIVE (a, 0) == _DBUS_BYTE_OF_PRIMITIVE (b, 0) && \
- _DBUS_BYTE_OF_PRIMITIVE (a, 1) == _DBUS_BYTE_OF_PRIMITIVE (b, 1) && \
- _DBUS_BYTE_OF_PRIMITIVE (a, 2) == _DBUS_BYTE_OF_PRIMITIVE (b, 2) && \
- _DBUS_BYTE_OF_PRIMITIVE (a, 3) == _DBUS_BYTE_OF_PRIMITIVE (b, 3) && \
- _DBUS_BYTE_OF_PRIMITIVE (a, 4) == _DBUS_BYTE_OF_PRIMITIVE (b, 4) && \
- _DBUS_BYTE_OF_PRIMITIVE (a, 5) == _DBUS_BYTE_OF_PRIMITIVE (b, 5) && \
- _DBUS_BYTE_OF_PRIMITIVE (a, 6) == _DBUS_BYTE_OF_PRIMITIVE (b, 6) && \
- _DBUS_BYTE_OF_PRIMITIVE (a, 7) == _DBUS_BYTE_OF_PRIMITIVE (b, 7))
+#define _DBUS_DOUBLES_BITWISE_EQUAL(a, b) (memcmp (&(a), &(b), sizeof (double)) == 0)
dbus_bool_t _dbus_get_autolaunch_address (const char *scope,
DBusString *address,
DBusError *error);
+DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_lookup_session_address (dbus_bool_t *supported,
DBusString *address,
DBusError *error);
@@ -738,6 +749,20 @@ void _dbus_combine_tcp_errors (DBusList **sources,
const char *port,
DBusError *dest);
+/**
+ * @def _DBUS_MAX_SUN_PATH_LENGTH
+ *
+ * Maximum length of the path to a UNIX domain socket,
+ * sockaddr_un::sun_path member. POSIX requires that all systems
+ * support at least 100 bytes here, including the nul termination.
+ * We use 99 for the max value to allow for the nul.
+ *
+ * We could probably also do sizeof (addr.sun_path)
+ * but this way we are the same on all platforms
+ * which is probably a good idea.
+ */
+#define _DBUS_MAX_SUN_PATH_LENGTH 99
+
/** @} */
DBUS_END_DECLS
diff --git a/dbus/dbus-test-tap.c b/dbus/dbus-test-tap.c
index 46738de7..e4ae443a 100644
--- a/dbus/dbus-test-tap.c
+++ b/dbus/dbus-test-tap.c
@@ -2,6 +2,7 @@
/* dbus-test-tap — TAP helpers for "embedded tests"
*
* Copyright © 2017 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -39,6 +40,7 @@
#include <stdlib.h>
static unsigned int failures = 0;
+static unsigned int skipped = 0;
static unsigned int tap_test_counter = 0;
/*
@@ -148,6 +150,7 @@ _dbus_test_skip (const char *format,
va_list ap;
printf ("ok %u # SKIP ", ++tap_test_counter);
+ ++skipped;
va_start (ap, format);
vprintf (format, ap);
va_end (ap);
@@ -194,10 +197,14 @@ _dbus_test_check_memleaks (const char *test_name)
int
_dbus_test_done_testing (void)
{
+ _dbus_assert (skipped <= tap_test_counter);
+
if (failures == 0)
- _dbus_test_diag ("%u tests passed", tap_test_counter);
+ _dbus_test_diag ("%u tests passed (%d skipped)",
+ tap_test_counter - skipped, skipped);
else
- _dbus_test_diag ("%u/%u tests failed", failures, tap_test_counter);
+ _dbus_test_diag ("%u/%u tests failed (%d skipped)",
+ failures, tap_test_counter - skipped, skipped);
printf ("1..%u\n", tap_test_counter);
fflush (stdout);
diff --git a/dbus/dbus-test-tap.h b/dbus/dbus-test-tap.h
index fd4c7af7..157942e1 100644
--- a/dbus/dbus-test-tap.h
+++ b/dbus/dbus-test-tap.h
@@ -2,6 +2,7 @@
/* dbus-test-tap — TAP helpers for "embedded tests"
*
* Copyright © 2017 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/dbus/dbus-test.h b/dbus/dbus-test.h
index a8601932..8eac0041 100644
--- a/dbus/dbus-test.h
+++ b/dbus/dbus-test.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-threads-internal.h b/dbus/dbus-threads-internal.h
index c2e786e2..4c7bde63 100644
--- a/dbus/dbus-threads-internal.h
+++ b/dbus/dbus-threads-internal.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2005 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -73,14 +75,83 @@ void _dbus_condvar_free_at_location (DBusCondVar **location_p);
/* Private to threading implementations and dbus-threads.c */
+/**
+ * Creates a new mutex which is recursive if possible
+ *
+ * This mutex is used to avoid deadlocking if we hold them while
+ * calling user code.
+ *
+ * @return mutex instance or #NULL on OOM
+ */
+DBUS_EMBEDDED_TESTS_EXPORT
DBusRMutex *_dbus_platform_rmutex_new (void);
+
+/**
+ * Free a recursive usable mutex
+ *
+ * @param mutex the mutex instance to free
+ */
+DBUS_EMBEDDED_TESTS_EXPORT
void _dbus_platform_rmutex_free (DBusRMutex *mutex);
+
+/**
+ * Locks a recursively usable mutex
+ *
+ * @param mutex the mutex instance to lock
+ *
+ * Unlike _dbus_cmutex_lock(), it is valid for the same thread
+ * to lock a recursive mutex more than once, and it will not
+ * deadlock. Each call to this function must be paired with a
+ * corresponding call to _dbus_rmutex_unlock().
+ */
+DBUS_EMBEDDED_TESTS_EXPORT
void _dbus_platform_rmutex_lock (DBusRMutex *mutex);
+
+/**
+ * Release a recursively usable mutex
+ *
+ * @param mutex the mutex instance to release
+ */
+DBUS_EMBEDDED_TESTS_EXPORT
void _dbus_platform_rmutex_unlock (DBusRMutex *mutex);
+/**
+ * Creates a new mutex suitable for use with condition variables
+ *
+ * @return mutex instance or #NULL on OOM
+ */
+DBUS_EMBEDDED_TESTS_EXPORT
DBusCMutex *_dbus_platform_cmutex_new (void);
+
+/**
+ * Implementation of _dbus_rmutex_new_at_location().
+ * This should only be called internally by the threading implementation.
+ */
+DBUS_EMBEDDED_TESTS_EXPORT
void _dbus_platform_cmutex_free (DBusCMutex *mutex);
+
+/**
+ * Locks a mutex suitable for use with condition variables
+ *
+ * @param mutex the mutex instance to lock
+ *
+ * @note On Windows, after a thread obtains ownership of a mutex,
+ * it can specify the same mutex in repeated calls to the dbus
+ * platform related mutex lock functions without blocking its
+ * execution. This prevents a thread from deadlocking itself
+ * while waiting for a mutex that it already owns. On unix
+ * like os, calling the dbus platform related mutex lock
+ * functions the second time is a programming error.
+ */
+DBUS_EMBEDDED_TESTS_EXPORT
void _dbus_platform_cmutex_lock (DBusCMutex *mutex);
+
+/**
+ * Release a mutex suitable for use with condition variables
+ *
+ * @param mutex the mutex instance to release
+ */
+DBUS_EMBEDDED_TESTS_EXPORT
void _dbus_platform_cmutex_unlock (DBusCMutex *mutex);
DBusCondVar* _dbus_platform_condvar_new (void);
diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c
index 8d7c03cd..b22cc031 100644
--- a/dbus/dbus-threads.c
+++ b/dbus/dbus-threads.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003, 2006 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-threads.h b/dbus/dbus-threads.h
index d30200d8..33e1e327 100644
--- a/dbus/dbus-threads.h
+++ b/dbus/dbus-threads.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-timeout.c b/dbus/dbus-timeout.c
index 131d3f8b..5ee9808a 100644
--- a/dbus/dbus-timeout.c
+++ b/dbus/dbus-timeout.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-timeout.h b/dbus/dbus-timeout.h
index 6b2fb339..73fdb952 100644
--- a/dbus/dbus-timeout.h
+++ b/dbus/dbus-timeout.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 CodeFactory AB
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-transport-protected.h b/dbus/dbus-transport-protected.h
index a42c5a34..136c4031 100644
--- a/dbus/dbus-transport-protected.h
+++ b/dbus/dbus-transport-protected.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2004 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-transport-socket.c b/dbus/dbus-transport-socket.c
index fa1307bd..d3c2b914 100644
--- a/dbus/dbus-transport-socket.c
+++ b/dbus/dbus-transport-socket.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003, 2004, 2006 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -22,6 +24,9 @@
*/
#include <config.h>
+
+#include <stdio.h>
+
#include "dbus-internals.h"
#include "dbus-connection-internal.h"
#include "dbus-nonce.h"
@@ -1042,8 +1047,7 @@ socket_disconnect (DBusTransport *transport)
free_watches (transport);
- _dbus_close_socket (socket_transport->fd, NULL);
- _dbus_socket_invalidate (&socket_transport->fd);
+ _dbus_close_socket (&socket_transport->fd, NULL);
}
static dbus_bool_t
@@ -1430,8 +1434,7 @@ _dbus_transport_new_for_tcp_socket (const char *host,
if (transport == NULL)
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- _dbus_close_socket (fd, NULL);
- _dbus_socket_invalidate (&fd);
+ _dbus_close_socket (&fd, NULL);
}
return transport;
@@ -1502,4 +1505,141 @@ _dbus_transport_open_socket(DBusAddressEntry *entry,
}
}
+/**
+ * Creates a new transport for the given Unix domain socket
+ * path. This creates a client-side of a transport.
+ *
+ * @param path the path to the domain socket.
+ * @param abstract #TRUE to use abstract socket namespace
+ * @param error address where an error can be returned.
+ * @returns a new transport, or #NULL on failure.
+ */
+DBusTransport*
+_dbus_transport_new_for_domain_socket (const char *path,
+ dbus_bool_t abstract,
+ DBusError *error)
+{
+ DBusSocket fd = DBUS_SOCKET_INIT;
+ DBusTransport *transport;
+ DBusString address;
+ DBusString unescaped_path;
+
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ if (!_dbus_string_init (&address))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
+
+ _dbus_string_init_const (&unescaped_path, path);
+
+ if ((abstract &&
+ !_dbus_string_append (&address, "unix:abstract=")) ||
+ (!abstract &&
+ !_dbus_string_append (&address, "unix:path=")) ||
+ !_dbus_address_append_escaped (&address, &unescaped_path))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ goto failed_0;
+ }
+
+ fd = _dbus_connect_unix_socket (path, abstract, error);
+ if (!_dbus_socket_is_valid (fd))
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ goto failed_0;
+ }
+
+ _dbus_verbose ("Successfully connected to unix socket %s\n",
+ path);
+
+ transport = _dbus_transport_new_for_socket (fd, NULL, &address);
+ if (transport == NULL)
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ goto failed_1;
+ }
+
+ _dbus_string_free (&address);
+
+ return transport;
+
+ failed_1:
+ _dbus_close_socket (&fd, NULL);
+ failed_0:
+ _dbus_string_free (&address);
+ return NULL;
+}
+
+/**
+ * Opens a UNIX socket transport.
+ *
+ * @param entry the address entry to try opening as a unix transport.
+ * @param transport_p return location for the opened transport
+ * @param error error to be set
+ * @returns result of the attempt
+ */
+DBusTransportOpenResult
+_dbus_transport_open_unix_socket (DBusAddressEntry *entry,
+ DBusTransport **transport_p,
+ DBusError *error)
+{
+ const char *method;
+
+ method = dbus_address_entry_get_method (entry);
+ _dbus_assert (method != NULL);
+
+ if (strcmp (method, "unix") == 0)
+ {
+ const char *path = dbus_address_entry_get_value (entry, "path");
+ const char *tmpdir = dbus_address_entry_get_value (entry, "tmpdir");
+ const char *abstract = dbus_address_entry_get_value (entry, "abstract");
+
+ if (tmpdir != NULL)
+ {
+ _dbus_set_bad_address (error, NULL, NULL,
+ "cannot use the \"tmpdir\" option for an address to connect to, only in an address to listen on");
+ return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
+ }
+
+ if (path == NULL && abstract == NULL)
+ {
+ _dbus_set_bad_address (error, "unix",
+ "path or abstract",
+ NULL);
+ return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
+ }
+
+ if (path != NULL && abstract != NULL)
+ {
+ _dbus_set_bad_address (error, NULL, NULL,
+ "can't specify both \"path\" and \"abstract\" options in an address");
+ return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
+ }
+
+ if (path)
+ *transport_p = _dbus_transport_new_for_domain_socket (path, FALSE,
+ error);
+ else
+ *transport_p = _dbus_transport_new_for_domain_socket (abstract, TRUE,
+ error);
+ if (*transport_p == NULL)
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
+ }
+ else
+ {
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+ return DBUS_TRANSPORT_OPEN_OK;
+ }
+ }
+ else
+ {
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+ return DBUS_TRANSPORT_OPEN_NOT_HANDLED;
+ }
+}
+
/** @} */
diff --git a/dbus/dbus-transport-socket.h b/dbus/dbus-transport-socket.h
index 24e4b6a2..65de3c15 100644
--- a/dbus/dbus-transport-socket.h
+++ b/dbus/dbus-transport-socket.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2006 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -39,7 +41,13 @@ DBusTransportOpenResult _dbus_transport_open_socket (DBusAddressEntry *e
DBusTransport **transport_p,
DBusError *error);
+DBusTransport* _dbus_transport_new_for_domain_socket (const char *path,
+ dbus_bool_t abstract,
+ DBusError *error);
+DBusTransportOpenResult _dbus_transport_open_unix_socket (DBusAddressEntry *entry,
+ DBusTransport **transport_p,
+ DBusError *error);
DBUS_END_DECLS
diff --git a/dbus/dbus-transport-unix.c b/dbus/dbus-transport-unix.c
index 30c3ba44..a8dfaa52 100644
--- a/dbus/dbus-transport-unix.c
+++ b/dbus/dbus-transport-unix.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003, 2004 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -43,73 +45,6 @@
*/
/**
- * Creates a new transport for the given Unix domain socket
- * path. This creates a client-side of a transport.
- *
- * @todo once we add a way to escape paths in a dbus
- * address, this function needs to do escaping.
- *
- * @param path the path to the domain socket.
- * @param abstract #TRUE to use abstract socket namespace
- * @param error address where an error can be returned.
- * @returns a new transport, or #NULL on failure.
- */
-DBusTransport*
-_dbus_transport_new_for_domain_socket (const char *path,
- dbus_bool_t abstract,
- DBusError *error)
-{
- DBusSocket fd = DBUS_SOCKET_INIT;
- DBusTransport *transport;
- DBusString address;
-
- _DBUS_ASSERT_ERROR_IS_CLEAR (error);
-
- if (!_dbus_string_init (&address))
- {
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- return NULL;
- }
-
- if ((abstract &&
- !_dbus_string_append (&address, "unix:abstract=")) ||
- (!abstract &&
- !_dbus_string_append (&address, "unix:path=")) ||
- !_dbus_string_append (&address, path))
- {
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- goto failed_0;
- }
-
- fd.fd = _dbus_connect_unix_socket (path, abstract, error);
- if (fd.fd < 0)
- {
- _DBUS_ASSERT_ERROR_IS_SET (error);
- goto failed_0;
- }
-
- _dbus_verbose ("Successfully connected to unix socket %s\n",
- path);
-
- transport = _dbus_transport_new_for_socket (fd, NULL, &address);
- if (transport == NULL)
- {
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- goto failed_1;
- }
-
- _dbus_string_free (&address);
-
- return transport;
-
- failed_1:
- _dbus_close_socket (fd, NULL);
- failed_0:
- _dbus_string_free (&address);
- return NULL;
-}
-
-/**
* Creates a new transport for the given binary and arguments. This
* creates a client-side of a transport. The process will be forked
* off and executed with stdin/stdout connected to a local AF_UNIX
@@ -180,8 +115,8 @@ _dbus_transport_new_for_exec (const char *path,
}
}
- fd.fd = _dbus_connect_exec (path, argv, error);
- if (fd.fd < 0)
+ fd = _dbus_connect_exec (path, argv, error);
+ if (!_dbus_socket_is_valid (fd))
{
_DBUS_ASSERT_ERROR_IS_SET (error);
goto failed;
@@ -202,77 +137,25 @@ _dbus_transport_new_for_exec (const char *path,
return transport;
failed:
- if (fd.fd >= 0)
- _dbus_close_socket (fd, NULL);
+ if (_dbus_socket_is_valid (fd))
+ _dbus_close_socket (&fd, NULL);
_dbus_string_free (&address);
return NULL;
}
-/**
- * Opens platform specific transport types.
- *
- * @param entry the address entry to try opening
- * @param transport_p return location for the opened transport
- * @param error error to be set
- * @returns result of the attempt
- */
+
DBusTransportOpenResult
-_dbus_transport_open_platform_specific (DBusAddressEntry *entry,
- DBusTransport **transport_p,
- DBusError *error)
+_dbus_transport_open_unixexec (DBusAddressEntry *entry,
+ DBusTransport **transport_p,
+ DBusError *error)
{
const char *method;
-
+
method = dbus_address_entry_get_method (entry);
_dbus_assert (method != NULL);
- if (strcmp (method, "unix") == 0)
- {
- const char *path = dbus_address_entry_get_value (entry, "path");
- const char *tmpdir = dbus_address_entry_get_value (entry, "tmpdir");
- const char *abstract = dbus_address_entry_get_value (entry, "abstract");
-
- if (tmpdir != NULL)
- {
- _dbus_set_bad_address (error, NULL, NULL,
- "cannot use the \"tmpdir\" option for an address to connect to, only in an address to listen on");
- return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
- }
-
- if (path == NULL && abstract == NULL)
- {
- _dbus_set_bad_address (error, "unix",
- "path or abstract",
- NULL);
- return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
- }
-
- if (path != NULL && abstract != NULL)
- {
- _dbus_set_bad_address (error, NULL, NULL,
- "can't specify both \"path\" and \"abstract\" options in an address");
- return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
- }
-
- if (path)
- *transport_p = _dbus_transport_new_for_domain_socket (path, FALSE,
- error);
- else
- *transport_p = _dbus_transport_new_for_domain_socket (abstract, TRUE,
- error);
- if (*transport_p == NULL)
- {
- _DBUS_ASSERT_ERROR_IS_SET (error);
- return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
- }
- else
- {
- _DBUS_ASSERT_ERROR_IS_CLEAR (error);
- return DBUS_TRANSPORT_OPEN_OK;
- }
- }
- else if (strcmp (method, "unixexec") == 0)
+ if (strcmp (method, "unixexec") == 0)
{
const char *path;
unsigned i;
@@ -346,8 +229,33 @@ _dbus_transport_open_platform_specific (DBusAddressEntry *entry,
return DBUS_TRANSPORT_OPEN_OK;
}
}
+ else
+ {
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+ return DBUS_TRANSPORT_OPEN_NOT_HANDLED;
+ }
+}
+
+/**
+ * Opens platform specific transport types.
+ *
+ * @param entry the address entry to try opening
+ * @param transport_p return location for the opened transport
+ * @param error error to be set
+ * @returns result of the attempt
+ */
+DBusTransportOpenResult
+_dbus_transport_open_platform_specific (DBusAddressEntry *entry,
+ DBusTransport **transport_p,
+ DBusError *error)
+{
#ifdef DBUS_ENABLE_LAUNCHD
- else if (strcmp (method, "launchd") == 0)
+ const char *method;
+
+ method = dbus_address_entry_get_method (entry);
+ _dbus_assert (method != NULL);
+
+ if (strcmp (method, "launchd") == 0)
{
DBusError tmp_error = DBUS_ERROR_INIT;
const char *launchd_env_var = dbus_address_entry_get_value (entry, "env");
@@ -398,8 +306,8 @@ _dbus_transport_open_platform_specific (DBusAddressEntry *entry,
return DBUS_TRANSPORT_OPEN_OK;
}
}
-#endif
else
+#endif /* DBUS_ENABLE_LAUNCHD */
{
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
return DBUS_TRANSPORT_OPEN_NOT_HANDLED;
diff --git a/dbus/dbus-transport-unix.h b/dbus/dbus-transport-unix.h
index 5124e0b6..df30a179 100644
--- a/dbus/dbus-transport-unix.h
+++ b/dbus/dbus-transport-unix.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -23,15 +25,13 @@
#ifndef DBUS_TRANSPORT_UNIX_H
#define DBUS_TRANSPORT_UNIX_H
-#include <dbus/dbus-transport.h>
+#include <dbus/dbus-transport-protected.h>
DBUS_BEGIN_DECLS
-DBusTransport* _dbus_transport_new_for_domain_socket (const char *path,
- dbus_bool_t abstract,
- DBusError *error);
-
-
+DBusTransportOpenResult _dbus_transport_open_unixexec (DBusAddressEntry *entry,
+ DBusTransport **transport_p,
+ DBusError *error);
DBUS_END_DECLS
#endif /* DBUS_TRANSPORT_UNIX_H */
diff --git a/dbus/dbus-transport-win.c b/dbus/dbus-transport-win.c
index 5fbe6fda..6a0dddce 100644
--- a/dbus/dbus-transport-win.c
+++ b/dbus/dbus-transport-win.c
@@ -4,6 +4,8 @@
* Copyright (C) 2002, 2003, 2004 Red Hat Inc.
* Copyright (C) 2007 Ralf Habacker <ralf.habacker@freenet.de>
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-transport-win.h b/dbus/dbus-transport-win.h
index aca99452..28ccfa85 100644
--- a/dbus/dbus-transport-win.h
+++ b/dbus/dbus-transport-win.h
@@ -4,6 +4,8 @@
* Copyright (C) 2002 Red Hat Inc.
* Copyright (C) 2007 Ralf Habacker <ralf.habacker@freenet.de>
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c
index 592abf9f..dd31a82b 100644
--- a/dbus/dbus-transport.c
+++ b/dbus/dbus-transport.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -348,6 +350,10 @@ static const struct {
DBusError *error);
} open_funcs[] = {
{ _dbus_transport_open_socket },
+ { _dbus_transport_open_unix_socket },
+#ifndef _WIN32
+ { _dbus_transport_open_unixexec },
+#endif
{ _dbus_transport_open_platform_specific },
{ _dbus_transport_open_autolaunch }
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
diff --git a/dbus/dbus-transport.h b/dbus/dbus-transport.h
index 4028726f..24fd1ac8 100644
--- a/dbus/dbus-transport.h
+++ b/dbus/dbus-transport.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2004 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-types.h b/dbus/dbus-types.h
index 85f603ae..5ace2733 100644
--- a/dbus/dbus-types.h
+++ b/dbus/dbus-types.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -115,6 +117,27 @@ typedef dbus_uint32_t dbus_bool_t;
*/
/**
+ * @def DBUS_INT64_MODIFIER
+ *
+ * A string literal for a length modifier that is appropriate to print
+ * the #dbus_int64_t and #dbus_uint64_t types.
+ * For example, it might be an empty string, "l", "ll", or "I64".
+ *
+ * This modifier needs to be concatenated with a literal "%" and a
+ * conversion specifier that can print signed or unsigned integers,
+ * for example:
+ *
+ * @code
+ * dbus_int64_t i = -123;
+ * dbus_uint64_t u = 456;
+ *
+ * printf ("signed: %" DBUS_INT64_MODIFIER "d\n", i);
+ * printf ("unsigned decimal: %" DBUS_INT64_MODIFIER "u\n", u);
+ * printf ("unsigned hex: 0x%" DBUS_INT64_MODIFIER "x\n", x);
+ * @endcode
+ */
+
+/**
* An 8-byte struct you could use to access int64 without having
* int64 support. Use #dbus_int64_t or #dbus_uint64_t instead.
*/
diff --git a/dbus/dbus-userdb-util.c b/dbus/dbus-userdb-util.c
index 1ca21eb7..73624495 100644
--- a/dbus/dbus-userdb-util.c
+++ b/dbus/dbus-userdb-util.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003, 2004, 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -65,11 +67,6 @@ dbus_bool_t
_dbus_is_console_user (dbus_uid_t uid,
DBusError *error)
{
-
- DBusUserDatabase *db;
- const DBusUserInfo *info;
- dbus_bool_t result = FALSE;
-
#ifdef HAVE_SYSTEMD
/* check if we have logind */
if (access ("/run/systemd/seats/", F_OK) >= 0)
@@ -120,35 +117,7 @@ _dbus_is_console_user (dbus_uid_t uid,
#endif /* HAVE_CONSOLE_OWNER_FILE */
- if (!_dbus_user_database_lock_system ())
- {
- _DBUS_SET_OOM (error);
- return FALSE;
- }
-
- db = _dbus_user_database_get_system ();
- if (db == NULL)
- {
- dbus_set_error (error, DBUS_ERROR_FAILED, "Could not get system database.");
- _dbus_user_database_unlock_system ();
- return FALSE;
- }
-
- /* TPTD: this should be cache-safe, we've locked the DB and
- _dbus_user_at_console doesn't pass it on. */
- info = _dbus_user_database_lookup (db, uid, NULL, error);
-
- if (info == NULL)
- {
- _dbus_user_database_unlock_system ();
- return FALSE;
- }
-
- result = _dbus_user_at_console (info->username, error);
-
- _dbus_user_database_unlock_system ();
-
- return result;
+ return FALSE;
}
/**
@@ -373,36 +342,38 @@ _dbus_user_database_lookup_group (DBusUserDatabase *db,
* @param uid the UID
* @param group_ids return location for array of group IDs
* @param n_group_ids return location for length of returned array
+ * @param error error to fill in on failure
* @returns #TRUE if the UID existed and we got some credentials
*/
dbus_bool_t
_dbus_groups_from_uid (dbus_uid_t uid,
dbus_gid_t **group_ids,
- int *n_group_ids)
+ int *n_group_ids,
+ DBusError *error)
{
DBusUserDatabase *db;
const DBusUserInfo *info;
+ dbus_bool_t ret = FALSE;
+
*group_ids = NULL;
*n_group_ids = 0;
- /* FIXME: this can't distinguish ENOMEM from other errors */
if (!_dbus_user_database_lock_system ())
- return FALSE;
-
- db = _dbus_user_database_get_system ();
- if (db == NULL)
{
- _dbus_user_database_unlock_system ();
+ _DBUS_SET_OOM (error);
return FALSE;
}
- if (!_dbus_user_database_get_uid (db, uid,
- &info, NULL))
+ db = _dbus_user_database_get_system ();
+ if (db == NULL)
{
- _dbus_user_database_unlock_system ();
- return FALSE;
+ _DBUS_SET_OOM (error);
+ goto out;
}
+ if (!_dbus_user_database_get_uid (db, uid, &info, error))
+ goto out;
+
_dbus_assert (info->uid == uid);
if (info->n_group_ids > 0)
@@ -410,8 +381,8 @@ _dbus_groups_from_uid (dbus_uid_t uid,
*group_ids = dbus_new (dbus_gid_t, info->n_group_ids);
if (*group_ids == NULL)
{
- _dbus_user_database_unlock_system ();
- return FALSE;
+ _DBUS_SET_OOM (error);
+ goto out;
}
*n_group_ids = info->n_group_ids;
@@ -419,7 +390,10 @@ _dbus_groups_from_uid (dbus_uid_t uid,
memcpy (*group_ids, info->group_ids, info->n_group_ids * sizeof (dbus_gid_t));
}
+ ret = TRUE;
+out:
+ _DBUS_ASSERT_ERROR_XOR_BOOL (error, ret);
_dbus_user_database_unlock_system ();
- return TRUE;
+ return ret;
}
/** @} */
diff --git a/dbus/dbus-userdb.c b/dbus/dbus-userdb.c
index ddf41a3c..452ff9d7 100644
--- a/dbus/dbus-userdb.c
+++ b/dbus/dbus-userdb.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003, 2004 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-userdb.h b/dbus/dbus-userdb.h
index fcb515c8..d37d2433 100644
--- a/dbus/dbus-userdb.h
+++ b/dbus/dbus-userdb.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -100,7 +102,8 @@ dbus_bool_t _dbus_get_user_id_and_primary_group (const DBusString *username,
dbus_gid_t *gid_p);
dbus_bool_t _dbus_groups_from_uid (dbus_uid_t uid,
dbus_gid_t **group_ids,
- int *n_group_ids);
+ int *n_group_ids,
+ DBusError *error);
DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_is_console_user (dbus_uid_t uid,
DBusError *error);
diff --git a/dbus/dbus-uuidgen.c b/dbus/dbus-uuidgen.c
index 79159106..4a5aa13f 100644
--- a/dbus/dbus-uuidgen.c
+++ b/dbus/dbus-uuidgen.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2006 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-uuidgen.h b/dbus/dbus-uuidgen.h
index bf07b139..b74d9e0e 100644
--- a/dbus/dbus-uuidgen.h
+++ b/dbus/dbus-uuidgen.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2006 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -27,6 +29,7 @@
#ifndef DBUS_UUIDGEN_H
#define DBUS_UUIDGEN_H
+#include <dbus/dbus-macros-internal.h>
#include <dbus/dbus-types.h>
#include <dbus/dbus-errors.h>
diff --git a/dbus/dbus-valgrind-internal.h b/dbus/dbus-valgrind-internal.h
index 6760b40d..4c3f3ff7 100644
--- a/dbus/dbus-valgrind-internal.h
+++ b/dbus/dbus-valgrind-internal.h
@@ -3,6 +3,8 @@
*
* Copyright © 2011 Nokia Corporation
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-watch.c b/dbus/dbus-watch.c
index 6644bf15..76298ba1 100644
--- a/dbus/dbus-watch.c
+++ b/dbus/dbus-watch.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus-watch.h b/dbus/dbus-watch.h
index b8fe6a84..2b278461 100644
--- a/dbus/dbus-watch.h
+++ b/dbus/dbus-watch.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/dbus.h b/dbus/dbus.h
index dbfe6761..53998c54 100644
--- a/dbus/dbus.h
+++ b/dbus/dbus.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/dbus/meson.build b/dbus/meson.build
new file mode 100644
index 00000000..70b16f5e
--- /dev/null
+++ b/dbus/meson.build
@@ -0,0 +1,251 @@
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+dbus_dependencies = [
+ threads,
+ network_libs,
+ systemd,
+ valgrind.partial_dependency(compile_args: true),
+]
+
+# source code that goes in the installed client library
+# and is specific to library functionality
+dbus_lib_sources = [
+ 'dbus-address.c',
+ 'dbus-auth.c',
+ 'dbus-bus.c',
+ 'dbus-connection.c',
+ 'dbus-credentials.c',
+ 'dbus-errors.c',
+ 'dbus-keyring.c',
+ 'dbus-marshal-byteswap.c',
+ 'dbus-marshal-header.c',
+ 'dbus-marshal-recursive.c',
+ 'dbus-marshal-validate.c',
+ 'dbus-message.c',
+ 'dbus-misc.c',
+ 'dbus-nonce.c',
+ 'dbus-object-tree.c',
+ 'dbus-pending-call.c',
+ 'dbus-resources.c',
+ 'dbus-server-debug-pipe.c',
+ 'dbus-server-socket.c',
+ 'dbus-server.c',
+ 'dbus-sha.c',
+ 'dbus-signature.c',
+ 'dbus-syntax.c',
+ 'dbus-threads.c',
+ 'dbus-timeout.c',
+ 'dbus-transport-socket.c',
+ 'dbus-transport.c',
+ 'dbus-watch.c',
+]
+
+# source code that goes in the installed client library
+# AND is generic utility functionality used by the
+# daemon or test programs (all symbols in here should
+# be underscore-prefixed)
+
+dbus_shared_sources = [
+ 'dbus-dataslot.c',
+ 'dbus-file.c',
+ 'dbus-hash.c',
+ 'dbus-internals.c',
+ 'dbus-list.c',
+ 'dbus-marshal-basic.c',
+ 'dbus-memory.c',
+ 'dbus-mempool.c',
+ 'dbus-pipe.c',
+ 'dbus-string.c',
+ 'dbus-sysdeps.c',
+]
+
+if embedded_tests
+ dbus_shared_sources += 'dbus-test-tap.c'
+endif
+
+
+# source code that is generic utility functionality used
+# by the bus daemon or test apps, but is NOT included
+# in the D-Bus client library (all symbols in here
+# should be underscore-prefixed but don't really need
+# to be unless they move to DBUS_SHARED_SOURCES later)
+
+dbus_util_sources = [
+ 'dbus-asv-util.c',
+ 'dbus-mainloop.c',
+ 'dbus-message-util.c',
+ 'dbus-pollable-set-poll.c',
+ 'dbus-pollable-set.c',
+ 'dbus-shell.c',
+ 'dbus-string-util.c',
+ 'dbus-sysdeps-util.c',
+]
+
+if platform_windows
+ # On Windows, we use C++ constructors to initialize global locks
+ assert(using_cpp)
+
+ dbus_lib_sources += [
+ 'dbus-init-win.cpp',
+ 'dbus-server-win.c',
+ ]
+
+ dbus_lib_sources += windows.compile_resources(configure_file(
+ input: 'versioninfo.rc.in',
+ output: 'versioninfo.rc',
+ configuration: data_config,
+ ))
+
+ dbus_shared_sources += [
+ 'dbus-backtrace-win.c',
+ 'dbus-file-win.c',
+ 'dbus-pipe-win.c',
+ 'dbus-sysdeps-thread-win.c',
+ 'dbus-sysdeps-win.c',
+ 'dbus-transport-win.c',
+ ]
+
+ if platform_win32ce
+ dbus_shared_sources += 'dbus-sysdeps-wince-glue.c'
+ endif
+
+ dbus_util_sources += 'dbus-sysdeps-util-win.c'
+
+ if use_traditional_activation
+ dbus_util_sources += 'dbus-spawn-win.c'
+ endif
+
+else # Unix
+
+ dbus_lib_sources += [
+ 'dbus-uuidgen.c',
+ 'dbus-server-unix.c',
+ ]
+
+ dbus_shared_sources += [
+ 'dbus-file-unix.c',
+ 'dbus-pipe-unix.c',
+ 'dbus-sysdeps-pthread.c',
+ 'dbus-sysdeps-unix.c',
+ 'dbus-transport-unix.c',
+ 'dbus-userdb.c',
+ ]
+
+ if use_launchd
+ dbus_shared_sources += 'dbus-server-launchd.c'
+ endif
+
+ dbus_util_sources += [
+ 'dbus-sysdeps-util-unix.c',
+ 'dbus-userdb-util.c',
+ ]
+
+ if use_traditional_activation
+ dbus_util_sources += 'dbus-spawn-unix.c'
+ endif
+
+endif
+
+
+if use_linux_epoll
+ dbus_util_sources += 'dbus-pollable-set-epoll.c'
+endif
+
+version_script = configure_file(
+ input: 'Version.in',
+ output: 'version_script',
+ configuration: data_config,
+)
+
+# We can't use version_script to check for support, because it hasn't been
+# generated yet, so use a static source file instead.
+if cc.has_link_argument(
+ '-Wl,--version-script,@0@'.format(
+ meson.current_source_dir() / 'test-version-script'
+ )
+)
+ version_flags = ['-Wl,--version-script,@0@'.format(version_script)]
+else
+ version_flags = []
+endif
+
+libdbus = library('dbus-1',
+ dbus_lib_sources,
+ dbus_shared_sources,
+
+ include_directories: root_include,
+ c_args: '-Ddbus_1_EXPORTS',
+
+ link_args: version_flags,
+ soversion: soversion,
+ version: version_info,
+
+ dependencies: dbus_dependencies,
+ install: true,
+)
+
+libdbus_dep = declare_dependency(
+ include_directories: root_include,
+ dependencies: dbus_dependencies,
+ link_with: libdbus,
+)
+
+meson.override_dependency('dbus-1', libdbus_dep)
+
+libdbus_internal = static_library('dbus-internal',
+ dbus_util_sources,
+
+ include_directories: root_include,
+ link_with: libdbus,
+ dependencies: dbus_dependencies,
+)
+
+
+install_headers(
+ 'dbus-address.h',
+ 'dbus-bus.h',
+ 'dbus-connection.h',
+ 'dbus-errors.h',
+ 'dbus-macros.h',
+ 'dbus-memory.h',
+ 'dbus-message.h',
+ 'dbus-misc.h',
+ 'dbus-pending-call.h',
+ 'dbus-protocol.h',
+ 'dbus-server.h',
+ 'dbus-shared.h',
+ 'dbus-signature.h',
+ 'dbus-syntax.h',
+ 'dbus-threads.h',
+ 'dbus-types.h',
+ 'dbus.h',
+ subdir: 'dbus-1.0' / 'dbus',
+)
+
+dbus_arch_deps_h = configure_file(
+ input: 'dbus-arch-deps.h.in',
+ output: 'dbus-arch-deps.h',
+ configuration: arch_config,
+)
+install_data(dbus_arch_deps_h,
+ install_dir: get_option('libdir') / 'dbus-1.0' / 'include' / 'dbus',
+)
diff --git a/dbus/test-version-script b/dbus/test-version-script
new file mode 100644
index 00000000..c0f8462d
--- /dev/null
+++ b/dbus/test-version-script
@@ -0,0 +1,10 @@
+NOT_REALLY_LIBDBUS_1_3 {
+ global:
+ dbus_*;
+ local:
+ *;
+};
+NOT_REALLY_LIBDBUS_PRIVATE_1.2.3 {
+ global:
+ _dbus_*;
+};
diff --git a/dbus/versioninfo.rc.in b/dbus/versioninfo.rc.in
index 6c7301c8..0cee48ac 100644
--- a/dbus/versioninfo.rc.in
+++ b/dbus/versioninfo.rc.in
@@ -1,5 +1,6 @@
/* versioninfo.rc.in - for dbus
* Copyright (C) 2005 g10 Code GmbH
+ * SPDX-License-Identifier: LicenseRef-GAP
*
* This file is free software; as a special exception the author gives
* unlimited permission to copy and/or distribute it, with or without
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index b7d020a8..db93daec 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -12,8 +12,8 @@ if(DOXYGEN_EXECUTABLE)
endif()
if(DBUS_ENABLE_DOXYGEN_DOCS)
- set(top_srcdir ${CMAKE_SOURCE_DIR})
- set(top_builddir ${CMAKE_BINARY_DIR})
+ set(top_srcdir ${PROJECT_SOURCE_DIR})
+ set(top_builddir ${PROJECT_BINARY_DIR})
if(WIN32)
set(DBUS_GENERATE_MAN NO)
else()
@@ -35,15 +35,15 @@ if(DBUS_ENABLE_DOXYGEN_DOCS)
set(DOXYGEN_GENERATE_QHP NO)
set(DBUS_ENABLE_QTHELP_DOCS OFF PARENT_SCOPE)
endif()
- configure_file(../Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile )
- file(GLOB dbus_files "${CMAKE_SOURCE_DIR}/dbus/*.[ch]*")
+ configure_file(../Doxyfile.in ${PROJECT_BINARY_DIR}/Doxyfile )
+ file(GLOB dbus_files "${PROJECT_SOURCE_DIR}/dbus/*.[ch]*")
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/doxygen.stamp
- DEPENDS ${CMAKE_SOURCE_DIR}/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile ${dbus_files}
+ DEPENDS ${PROJECT_SOURCE_DIR}/Doxyfile.in ${PROJECT_BINARY_DIR}/Doxyfile ${dbus_files}
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/api/html
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/api/man
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/api/xml
- COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
+ COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/doxygen.stamp
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
@@ -93,53 +93,53 @@ if(DOCBOOKXSL_DIR AND XSLTPROC_EXECUTABLE)
endif()
if(DBUS_ENABLE_XML_DOCS)
+
#
-# generate docbook file from template
+# generate output file from docbook xml source template or file
#
-macro(generate_docbook_file a b)
- get_filename_component(outname ${b} NAME)
- set(srcfile ${CMAKE_CURRENT_SOURCE_DIR}/${a})
- set(tmpfile ${CMAKE_CURRENT_BINARY_DIR}/${outname}.tmp.cmake)
- file(WRITE ${tmpfile} "
-set(EXPANDED_SYSCONFDIR ${CMAKE_INSTALL_FULL_SYSCONFDIR})
-set(EXPANDED_DATADIR ${CMAKE_INSTALL_FULL_DATADIR})
-set(DBUS_VERSION ${DBUS_VERSION})
-configure_file(${srcfile} ${b})
- ")
- add_custom_command(OUTPUT ${b}
- COMMAND ${CMAKE_COMMAND} -E remove ${b}
- COMMAND ${CMAKE_COMMAND} -P ${tmpfile}
- DEPENDS ${srcfile} ${CMAKE_BINARY_DIR}/CMakeCache.txt
- COMMENT "Generating ${outname}"
- )
- add_custom_target(${outname} DEPENDS ${b})
- add_dependencies(doc ${outname})
-endmacro()
-
-macro(DOCBOOK _sources _format)
- get_filename_component(_infile ${_sources} ABSOLUTE)
- get_filename_component(_name ${_infile} NAME)
- if(${_format} STREQUAL "man")
- string(REPLACE ".xml" "" _outname ${_name})
- set(STYLESHEET "${DOCBOOKXSL_DIR}/manpages/docbook.xsl")
- else()
- string(REPLACE ".xml" ".html" _outname ${_name})
- set(STYLESHEET "${DOCBOOKXSL_DIR}/html/docbook.xsl")
- endif()
- set(_outfile ${CMAKE_CURRENT_BINARY_DIR}/${_outname})
- add_custom_command(
- OUTPUT ${_outfile}
- COMMAND ${XSLTPROC_EXECUTABLE} --output ${_outfile} --nonet --xinclude --param passivetex.extensions '1' --param generate.consistent.ids '1' ${STYLESHEET} ${_infile}
- DEPENDS ${XSLTPROC_EXECUTABLE} ${_infile}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- )
- add_custom_target(${_outname} DEPENDS ${_outfile})
- add_dependencies(xmldoc ${_outname})
- if(${_format} STREQUAL "man")
- install(FILES ${_outfile} DESTINATION ${CMAKE_INSTALL_DATADIR}/man/man1)
- else()
- install(FILES ${_outfile} DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/dbus)
- endif()
+# @param _target base name for the generated file
+# @param TEMPLATE <file> docbook xml template file to generated the output from
+# (with '@var@' variable substitution)
+# @param SOURCE <file> alternative docbook xml file to generated the output from
+# (without variable substitution)
+# @param MAN_CATEGORY <cat> category for creating man pages (also used for html output)
+# @param FORMATS <formats> list with output formats to generate ('html' and/or 'man')
+#
+macro(add_docbook _target)
+ set(options)
+ set(oneValueArgs SOURCE TEMPLATE MAN_CATEGORY)
+ set(multiValueArgs FORMATS)
+ cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ foreach(_format ${ARGS_FORMATS})
+ if(ARGS_TEMPLATE)
+ set(_xmlfile "${CMAKE_CURRENT_BINARY_DIR}/${_target}-${_format}.xml")
+ get_filename_component(_infile ${ARGS_TEMPLATE} ABSOLUTE)
+ configure_file(${_infile} ${_xmlfile})
+ else()
+ get_filename_component(_infile ${ARGS_SOURCE} ABSOLUTE)
+ set(_xmlfile ${_infile})
+ endif()
+ if(${_format} STREQUAL "man")
+ set(_outname "${_target}.${ARGS_MAN_CATEGORY}")
+ set(STYLESHEET "${DOCBOOKXSL_DIR}/manpages/docbook.xsl")
+ set(INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/man/man${ARGS_MAN_CATEGORY})
+ else()
+ set(_outname "${_target}.${ARGS_MAN_CATEGORY}.html")
+ set(STYLESHEET "${DOCBOOKXSL_DIR}/html/docbook.xsl")
+ set(INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/doc/dbus)
+ endif()
+ set(_outfile ${CMAKE_CURRENT_BINARY_DIR}/${_outname})
+ add_custom_command(
+ OUTPUT ${_outfile}
+ COMMAND ${XSLTPROC_EXECUTABLE} --output ${_outfile} --nonet --xinclude --param passivetex.extensions '1' --param generate.consistent.ids '1' ${STYLESHEET} ${_xmlfile}
+ DEPENDS ${XSLTPROC_EXECUTABLE} ${_xmlfile}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ )
+ add_custom_target(xmldoc-${_outname} DEPENDS ${_outfile})
+ add_dependencies(xmldoc xmldoc-${_outname})
+ install(FILES ${_outfile} DESTINATION ${INSTALL_DIR})
+ endforeach()
endmacro()
### copy tests to builddir so that generated tests and static tests
@@ -149,10 +149,10 @@ macro(COPYDIR _src _type)
foreach(FILE_TYPE ${_type})
foreach(DIR ${_src})
file(GLOB FILES "${DIR}/${FILE_TYPE}" )
- file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DIR})
+ file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/${DIR})
foreach(FILE ${FILES})
get_filename_component(FILENAME ${FILE} NAME)
- set(TARGET ${CMAKE_BINARY_DIR}/${DIR}/${FILENAME})
+ set(TARGET ${PROJECT_BINARY_DIR}/${DIR}/${FILENAME})
configure_file(${FILE} ${TARGET} COPYONLY)
if(CONFIG_VERBOSE)
message("FROM: ${FILE}\nTO: ${TARGET}\n")
@@ -162,44 +162,29 @@ macro(COPYDIR _src _type)
endforeach()
endmacro()
+# copy source files from doc directory into associated binary directory
+# which is required to run generated xml docs from build directory
COPYDIR(doc *.png)
COPYDIR(doc *.svg)
-generate_docbook_file(dbus-cleanup-sockets.1.xml.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-cleanup-sockets.1.xml)
-generate_docbook_file(dbus-daemon.1.xml.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-daemon.1.xml)
-generate_docbook_file(dbus-launch.1.xml.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-launch.1.xml)
-generate_docbook_file(dbus-monitor.1.xml.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-monitor.1.xml)
-generate_docbook_file(dbus-run-session.1.xml.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-run-session.1.xml)
-generate_docbook_file(dbus-send.1.xml.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-send.1.xml)
-generate_docbook_file(dbus-test-tool.1.xml.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-test-tool.1.xml)
-generate_docbook_file(dbus-update-activation-environment.1.xml.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-update-activation-environment.1.xml)
-generate_docbook_file(dbus-uuidgen.1.xml.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-uuidgen.1.xml)
-
-docbook(${CMAKE_CURRENT_SOURCE_DIR}/dbus-test-plan.xml html)
-docbook(${CMAKE_CURRENT_SOURCE_DIR}/dbus-tutorial.xml html)
-docbook(${CMAKE_CURRENT_SOURCE_DIR}/dbus-specification.xml html)
-docbook(${CMAKE_CURRENT_SOURCE_DIR}/dbus-faq.xml html)
+# setup variables used in docbook templates
+set(EXPANDED_SYSCONFDIR ${CMAKE_INSTALL_FULL_SYSCONFDIR})
+set(EXPANDED_DATADIR ${CMAKE_INSTALL_FULL_DATADIR})
+set(formats html)
if(UNIX)
- docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-daemon.1.xml man)
- docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-monitor.1.xml man)
- docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-run-session.1.xml man)
- docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-send.1.xml man)
- docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-test-tool.1.xml man)
- docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-launch.1.xml man)
- docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-uuidgen.1.xml man)
- docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-cleanup-sockets.1.xml man)
- docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-update-activation-environment.1.xml man)
+ list(APPEND formats man)
endif()
-docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-daemon.1.xml html)
-docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-monitor.1.xml html)
-docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-run-session.1.xml html)
-docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-send.1.xml html)
-docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-test-tool.1.xml html)
-docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-launch.1.xml html)
-docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-uuidgen.1.xml html)
-docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-cleanup-sockets.1.xml html)
-docbook(${CMAKE_CURRENT_BINARY_DIR}/dbus-update-activation-environment.1.xml html)
+# generate docbook output
+add_docbook(dbus-cleanup-sockets TEMPLATE dbus-cleanup-sockets.1.xml.in MAN_CATEGORY 1 FORMATS ${formats})
+add_docbook(dbus-daemon TEMPLATE dbus-daemon.1.xml.in MAN_CATEGORY 1 FORMATS ${formats})
+add_docbook(dbus-launch TEMPLATE dbus-launch.1.xml.in MAN_CATEGORY 1 FORMATS ${formats})
+add_docbook(dbus-monitor TEMPLATE dbus-monitor.1.xml.in MAN_CATEGORY 1 FORMATS ${formats})
+add_docbook(dbus-run-session TEMPLATE dbus-run-session.1.xml.in MAN_CATEGORY 1 FORMATS ${formats})
+add_docbook(dbus-send TEMPLATE dbus-send.1.xml.in MAN_CATEGORY 1 FORMATS ${formats})
+add_docbook(dbus-test-tool TEMPLATE dbus-test-tool.1.xml.in MAN_CATEGORY 1 FORMATS ${formats})
+add_docbook(dbus-uuidgen TEMPLATE dbus-uuidgen.1.xml.in MAN_CATEGORY 1 FORMATS ${formats})
+add_docbook(dbus-update-activation-environment TEMPLATE dbus-update-activation-environment.1.xml.in MAN_CATEGORY 1 FORMATS ${formats})
#
# handle html index file
@@ -223,12 +208,22 @@ set(DOC_DATA
install(FILES ${DOC_DATA} DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/dbus)
+set(DBUS_DTD_DIR "${CMAKE_INSTALL_DATADIR}/xml/dbus-1" CACHE STRING "Directory for installing DTD files")
+set(DBUS_XML_CATALOG_DIR "${DBUS_DTD_DIR}" CACHE STRING "Directory for installing XML catalog file")
+
set(EXTRA_DIST
busconfig.dtd
introspect.dtd
introspect.xsl
)
-install(FILES ${EXTRA_DIST} DESTINATION ${CMAKE_INSTALL_DATADIR}/xml/dbus-1)
+install(FILES ${EXTRA_DIST} DESTINATION ${DBUS_DTD_DIR})
+
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/catalog.xml.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/catalog.xml"
+ @ONLY)
+
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/catalog.xml" DESTINATION ${DBUS_XML_CATALOG_DIR})
endif()
diff --git a/doc/Makefile.am b/doc/Makefile.am
deleted file mode 100644
index 47bca32e..00000000
--- a/doc/Makefile.am
+++ /dev/null
@@ -1,214 +0,0 @@
-apidir = @htmldir@/api
-
-man_pages = \
- dbus-cleanup-sockets.1 \
- dbus-daemon.1 \
- dbus-launch.1 \
- dbus-monitor.1 \
- dbus-run-session.1 \
- dbus-send.1 \
- dbus-test-tool.1 \
- dbus-update-activation-environment.1 \
- dbus-uuidgen.1 \
- $(NULL)
-
-MAN_XML_FILES = $(patsubst %.1,%.1.xml,$(man_pages))
-
-if DBUS_XML_DOCS_ENABLED
-man1_MANS = $(man_pages)
-endif
-
-MAN_HTML_FILES = $(patsubst %.1,%.1.html,$(man_pages))
-
-dtddir = $(datadir)/xml/dbus-1
-dist_dtd_DATA = \
- busconfig.dtd \
- introspect.dtd
-
-dist_doc_DATA = system-activation.txt
-
-# uploaded and distributed, but not installed
-STATIC_DOCS = \
- dbus-faq.xml \
- dbus-specification.xml \
- dbus-test-plan.xml \
- dbus-tutorial.xml \
- dbus-api-design.duck \
- dcop-howto.txt \
- introspect.xsl
-
-EXTRA_DIST = \
- file-boilerplate.c \
- doxygen_to_devhelp.xsl \
- $(STATIC_DOCS)
-
-html_DATA =
-
-dist_html_DATA =
-
-# diagram.png/diagram.svg aren't really HTML, but must go in the same
-# directory as the HTML to avoid broken links
-STATIC_HTML = \
- diagram.png \
- diagram.svg \
- $(NULL)
-
-# Static HTML helper files generated by yelp-build.
-YELP_STATIC_HTML = \
- yelp.js \
- C.css \
- highlight.pack.js \
- jquery.js \
- jquery.syntax.js \
- jquery.syntax.brush.html.js \
- jquery.syntax.core.js \
- jquery.syntax.layout.yelp.js \
- $(NULL)
-
-dist_html_DATA += $(STATIC_HTML)
-
-# Content HTML files generated by yelp-build.
-YELP_HTML = \
- dbus-api-design.html \
- $(NULL)
-
-XMLTO_HTML = \
- dbus-faq.html \
- dbus-specification.html \
- dbus-test-plan.html \
- dbus-tutorial.html \
- $(MAN_HTML_FILES) \
- $(NULL)
-
-if DBUS_XML_DOCS_ENABLED
-html_DATA += $(XMLTO_HTML)
-
-%.html: %.xml
- $(XMLTO) --stringparam generate.consistent.ids=1 html-nochunks $<
-
-%.1: %.1.xml
- $(XMLTO) man $<
-endif
-
-if DBUS_DOXYGEN_DOCS_ENABLED
-all-local:: doxygen.stamp
-
-doxygen.stamp: $(wildcard $(top_srcdir)/dbus/*.[ch])
- $(AM_V_GEN)cd $(top_builddir) && doxygen Doxyfile
- @touch $@
-
-if DBUS_HAVE_XSLTPROC
-html_DATA += dbus.devhelp2
-
-dbus.devhelp2: $(srcdir)/doxygen_to_devhelp.xsl doxygen.stamp
- $(XSLTPROC) -o $@ $< api/xml/index.xml
-endif
-
-if DBUS_DUCKTYPE_DOCS_ENABLED
-html_DATA += $(YELP_HTML)
-
-%.page: %.duck
- $(DUCKTYPE) -o $@ $<
-%.html: %.page
- $(YELP_BUILD) html $<
-$(YELP_STATIC_HTML): $(YELP_HTML)
-endif
-
-# this assumes CREATE_SUBDIRS isn't set to YES in Doxyfile
-# (which it isn't currently)
-install-data-local:: doxygen.stamp
- $(MKDIR_P) $(DESTDIR)$(apidir)
- $(INSTALL_DATA) api/html/* $(DESTDIR)$(apidir)
-if DBUS_QTHELP_DOCS_ENABLED
- $(MKDIR_P) $(DESTDIR)$(qchdir)
- $(INSTALL_DATA) $(DOXYGEN_QCH_FILE) $(DESTDIR)$(qchdir)
-endif
-if DBUS_DUCKTYPE_DOCS_ENABLED
- $(AM_V_at)for x in $(YELP_STATIC_HTML); do \
- if test -e "$$x"; then \
- $(INSTALL_DATA) "$$x" $(DESTDIR)$(htmldir); \
- fi; \
- done
-endif
-
-uninstall-local::
- rm -f $(DESTDIR)$(apidir)/*.html
- rm -f $(DESTDIR)$(apidir)/*.png
- rm -f $(DESTDIR)$(apidir)/*.css
- rm -f $(DESTDIR)$(apidir)/*.js
- rm -f $(DESTDIR)$(htmldir)/*.css
- rm -f $(DESTDIR)$(htmldir)/*.js
- rm -f $(DESTDIR)$(htmldir)/*.html
- rm -f $(DESTDIR)$(docdir)/*.txt
- rm -f $(DESTDIR)$(htmldir)/*.png
- rm -f $(DESTDIR)$(htmldir)/*.svg
- rm -f $(DESTDIR)$(apidir)/*.qhp
- rm -f $(DESTDIR)$(qchdir)/dbus-*.qch
- rmdir --ignore-fail-on-non-empty $(DESTDIR)$(apidir) || \
- rmdir $(DESTDIR)$(apidir)
-endif
-
-if DBUS_CAN_UPLOAD_DOCS
-BONUS_FILES = \
- $(top_srcdir)/README \
- $(top_srcdir)/CONTRIBUTING.md \
- $(top_srcdir)/AUTHORS \
- $(top_srcdir)/NEWS \
- $(top_srcdir)/COPYING \
- $(NULL)
-
-dbus-docs: $(STATIC_DOCS) $(dist_dtd_DATA) $(MAN_XML_FILES) $(dist_doc_DATA) $(dist_html_DATA) $(MAN_HTML_FILES) $(BONUS_FILES) doxygen.stamp $(XMLTO_HTML) $(YELP_HTML)
- $(AM_V_at)rm -rf $@ $@.tmp
- $(AM_V_GEN)$(MKDIR_P) $@.tmp/api
- $(AM_V_at)cd $(srcdir) && cp $(STATIC_DOCS) @abs_builddir@/$@.tmp
- $(AM_V_at)cd $(srcdir) && cp $(dist_dtd_DATA) @abs_builddir@/$@.tmp
- $(AM_V_at)cd $(srcdir) && cp $(dist_doc_DATA) @abs_builddir@/$@.tmp
- $(AM_V_at)cd $(srcdir) && cp $(STATIC_HTML) @abs_builddir@/$@.tmp
- $(AM_V_at)cp $(XMLTO_HTML) @abs_builddir@/$@.tmp
- $(AM_V_at)cp $(YELP_HTML) @abs_builddir@/$@.tmp
- $(AM_V_at)for x in $(YELP_STATIC_HTML); do \
- if test -e "$$x"; then \
- cp "$$x" @abs_builddir@/$@.tmp; \
- fi; \
- done
- $(AM_V_at)cp $(MAN_HTML_FILES) @abs_builddir@/$@.tmp
- $(AM_V_at)cp $(MAN_XML_FILES) @abs_builddir@/$@.tmp
- $(AM_V_at)cp $(BONUS_FILES) @abs_builddir@/$@.tmp
- $(AM_V_at)cp -r api/html @abs_builddir@/$@.tmp/api
- $(AM_V_at)mv $@.tmp $@
-
-dbus-docs.tar.xz: dbus-docs
- $(AM_V_GEN)tar --xz -c -f $@ $<
-
-DOC_SERVER = dbus.freedesktop.org
-DOC_WWW_DIR = /srv/dbus.freedesktop.org/www
-
-SPECIFICATION_SERVER = specifications.freedesktop.org
-SPECIFICATION_PATH = /srv/specifications.freedesktop.org/www/dbus/1.0
-
-maintainer-upload-docs: dbus-docs.tar.xz dbus-docs
- scp dbus-docs.tar.xz $(DOC_SERVER):$(DOC_WWW_DIR)/
- rsync -rpvzP --chmod=Dg+s,ug+rwX,o=rX \
- dbus-docs/ $(DOC_SERVER):$(DOC_WWW_DIR)/doc/
- cd $(srcdir) && scp -p $(dist_dtd_DATA) $(SPECIFICATION_SERVER):$(SPECIFICATION_PATH)/
-else
-maintainer-upload-docs:
- @echo "Can't upload documentation! Re-run configure with"
- @echo " --enable-doxygen-docs --enable-xml-docs --enable-ducktype-docs"
- @false
-endif
-
-CLEANFILES = \
- $(man1_MANS) \
- $(MAN_XML_FILES) \
- $(XMLTO_HTML) \
- $(YELP_HTML) \
- $(YELP_STATIC_HTML) \
- $(NULL)
-
-clean-local:
- rm -f $(html_DATA)
- rm -rf api
- rm -rf dbus-docs dbus-docs.tmp
- rm -f *.1.html
- rm -f doxygen.stamp
diff --git a/doc/catalog.xml.in b/doc/catalog.xml.in
new file mode 100644
index 00000000..331df361
--- /dev/null
+++ b/doc/catalog.xml.in
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">
+ <public publicId="-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" uri="@DBUS_DTD_DIR@/introspect.dtd"/>
+
+ <system systemId="http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd" uri="@DBUS_DTD_DIR@/introspect.dtd"/>
+
+ <public publicId="-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" uri="@DBUS_DTD_DIR@/busconfig.dtd"/>
+
+ <system systemId="http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd" uri="@DBUS_DTD_DIR@/busconfig.dtd"/>
+</catalog>
diff --git a/doc/dbus-api-design.duck b/doc/dbus-api-design.duck
index 82a36877..c8db6427 100644
--- a/doc/dbus-api-design.duck
+++ b/doc/dbus-api-design.duck
@@ -21,13 +21,13 @@
have been refined over several years of use of D-Bus in many projects.
Pointers will be given for implementing APIs using common D-Bus
libraries like
- $link[>>https://developer.gnome.org/gio/stable/gdbus-convenience.html](GDBus),
+ $link[>>https://developer-old.gnome.org/gio/stable/gdbus-convenience.html](GDBus),
but detailed implementation instructions are left to the libraries’
documentation. Note that you should $em(not) use dbus-glib to implement D-Bus
services as it is deprecated and unmaintained. Most services should also avoid
libdbus (dbus-1), which is a low-level library and is awkward to use
correctly: it is designed to be used via a language binding such as
- $link[>>http://qt-project.org/doc/qt-4.8/qtdbus.html](QtDBus).
+ $link[>>https://doc.qt.io/qt/qtdbus-index.html](QtDBus).
For documentation on D-Bus itself, see the
$link[>>http://dbus.freedesktop.org/doc/dbus-specification.html](D-Bus
@@ -320,7 +320,7 @@ passing nothing.
-->
<signal name="ProgressNotification">
<arg name="progress_message" type="s" />
- </method>
+ </signal>
The progress should be reported as an enumerated value:
[code style="valid" mime="application/xml"]
@@ -335,7 +335,7 @@ passing nothing.
-->
<signal name="ProgressNotification">
<arg name="progress_state" type="u" />
- </method>
+ </signal>
D-Bus has none of the problems of signed versus unsigned integers which C has
(specifically, it does not do implicit sign conversion), so integer types should
@@ -591,14 +591,14 @@ See also: $link[>#api-versioning].
Rather than manually implementing both the server and client sides of a D-Bus
interface, it is often easier to write the interface XML description and use a
tool such as
-$link[>>https://developer.gnome.org/gio/stable/gdbus-codegen.html]($cmd(gdbus-codegen))
+$link[>>https://developer-old.gnome.org/gio/stable/gdbus-codegen.html]($cmd(gdbus-codegen))
to generate type-safe C APIs, then build the implementation using those. This
avoids the tedious and error-prone process of writing code to build and read
D-Bus parameter variants for each method call.
Use of code generators is beyond the scope of this guide; for more information,
see the
-$link[>>https://developer.gnome.org/gio/stable/gdbus-codegen.html]($cmd(gdbus-codegen)
+$link[>>https://developer-old.gnome.org/gio/stable/gdbus-codegen.html]($cmd(gdbus-codegen)
manual).
== Annotations
@@ -644,9 +644,9 @@ choose the method which best matches the tooling and workflow you are using.
=== XML Comments
XML comments containing documentation in the
-$link[>>https://developer.gnome.org/gtk-doc-manual/stable/documenting_syntax.html.en](gtk-doc
+$link[>>https://developer-old.gnome.org/gtk-doc-manual/stable/documenting_syntax.html.en](gtk-doc
format) is the recommended format for use with
-$link[>>https://developer.gnome.org/gio/stable/gdbus-codegen.html]($cmd(gdbus-codegen)).
+$link[>>https://developer-old.gnome.org/gio/stable/gdbus-codegen.html]($cmd(gdbus-codegen)).
Using $cmd(gdbus-codegen), these comments can be extracted, converted to DocBook
format and included in the project’s API manual. For example:
@@ -878,7 +878,7 @@ system bus without modifying its security policy.
=== Bustle
[id="bustle"]
-$link[>>http://willthompson.co.uk/bustle/](Bustle) is a graphical version of
+$link[>>https://gitlab.freedesktop.org/bustle/bustle](Bustle) is a graphical version of
$cmd(dbus-monitor), with a UI focused on profiling D-Bus performance by plotting
messages on a timeline. It is ideal for finding bottlenecks in IPC performance
between a service and client.
diff --git a/doc/dbus-cleanup-sockets.1.xml.in b/doc/dbus-cleanup-sockets.1.xml.in
index 6d98083d..1fa16773 100644
--- a/doc/dbus-cleanup-sockets.1.xml.in
+++ b/doc/dbus-cleanup-sockets.1.xml.in
@@ -28,7 +28,7 @@
<refsect1 id='description'><title>DESCRIPTION</title>
<para>The <command>dbus-cleanup-sockets</command> command cleans up unused D-Bus
-connection sockets. See <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink> for
+connection sockets. See <ulink url='https://www.freedesktop.org/wiki/Software/dbus/'>https://www.freedesktop.org/wiki/Software/dbus/</ulink> for
more information about the big picture.</para>
@@ -60,6 +60,6 @@ linc-cleanup-sockets written by Michael Meeks.</para>
<refsect1 id='bugs'><title>BUGS</title>
<para>Please send bug reports to the D-Bus mailing list or bug tracker,
-see <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink></para>
+see <ulink url='https://www.freedesktop.org/wiki/Software/dbus/'>https://www.freedesktop.org/wiki/Software/dbus/</ulink></para>
</refsect1>
</refentry>
diff --git a/doc/dbus-daemon.1.xml.in b/doc/dbus-daemon.1.xml.in
index a9c0b5d5..ae9b5aa3 100644
--- a/doc/dbus-daemon.1.xml.in
+++ b/doc/dbus-daemon.1.xml.in
@@ -32,6 +32,7 @@
<arg choice='opt'>--nosyslog </arg>
<arg choice='opt'>--syslog </arg>
<arg choice='opt'>--syslog-only </arg>
+ <arg choice='opt'>--ready-event-handle=value</arg>
<sbr/>
</cmdsynopsis>
</refsynopsisdiv>
@@ -39,7 +40,7 @@
<refsect1 id='description'><title>DESCRIPTION</title>
<para><command>dbus-daemon</command> is the D-Bus message bus daemon. See
-<ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink> for more information about
+<ulink url='https://www.freedesktop.org/wiki/Software/dbus/'>https://www.freedesktop.org/wiki/Software/dbus/</ulink> for more information about
the big picture. D-Bus is first a library that provides one-to-one
communication between any two applications; <command>dbus-daemon</command> is an
application that uses this library to implement a message bus
@@ -199,6 +200,29 @@ files.</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--ready-event-handle=value</option></term>
+ <listitem>
+ <para>With this option, the dbus daemon raises an event when it is ready to process
+ connections. The <replaceable>handle</replaceable> must be the Windows handle
+ for an event object, in the format printed by the <function>printf</function>
+ format string <literal>%p</literal>. The parent process must create this event
+ object (for example with the <function>CreateEvent</function> function) in a
+ nonsignaled state, then configure it to be inherited by the dbus-daemon process.
+ The dbus-daemon will signal the event as if via <function>SetEvent</function>
+ when it is ready to receive connections from clients. The parent process can
+ wait for this to occur by using functions such as
+ <function>WaitForSingleObject</function>.
+ This option is only supported under Windows. On Unix platforms,
+ a similar result can be achieved by waiting for the address and/or
+ process ID to be printed to the inherited file descriptors used
+ for <option>--print-address</option> and/or <option>--print-pid</option>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+
+
</variablelist>
</refsect1>
@@ -816,14 +840,6 @@ Available limit names are:</para>
(number of calls-in-progress)
"reply_timeout" : milliseconds (thousandths)
until a method call times out
- "max_containers" : max number of restricted servers for use
- in app-containers, in total
- "max_containers_per_user" : max number of app-containers per Unix uid
- "max_container_metadata_bytes": max number of bytes of metadata to store
- for each app-container
- "max_connections_per_container": max number of (authenticated or
- unauthenticated) connections to each
- app-container
</literallayout> <!-- .fi -->
@@ -1529,12 +1545,12 @@ for example.</para>
</refsect1>
<refsect1 id='author'><title>AUTHOR</title>
-<para>See <ulink url='http://www.freedesktop.org/software/dbus/doc/AUTHORS'>http://www.freedesktop.org/software/dbus/doc/AUTHORS</ulink></para>
+<para>See <ulink url='https://dbus.freedesktop.org/doc/AUTHORS'>https://dbus.freedesktop.org/doc/AUTHORS</ulink></para>
</refsect1>
<refsect1 id='bugs'><title>BUGS</title>
<para>Please send bug reports to the D-Bus mailing list or bug tracker,
-see <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink></para>
+see <ulink url='https://www.freedesktop.org/wiki/Software/dbus/'>https://www.freedesktop.org/wiki/Software/dbus/</ulink></para>
</refsect1>
</refentry>
diff --git a/doc/dbus-launch.1.xml.in b/doc/dbus-launch.1.xml.in
index 2fcea03f..1b4b4db2 100644
--- a/doc/dbus-launch.1.xml.in
+++ b/doc/dbus-launch.1.xml.in
@@ -77,7 +77,7 @@ In scripts, it's more robust to avoid --auto-syntax and you hopefully
know which shell your script is written in.</para>
-<para>See <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink> for more information
+<para>See <ulink url='https://www.freedesktop.org/wiki/Software/dbus/'>https://www.freedesktop.org/wiki/Software/dbus/</ulink> for more information
about D-Bus. See also the man page for <emphasis remap='I'>dbus-daemon</emphasis>.</para>
</refsect1>
@@ -297,12 +297,12 @@ own right.</para>
</refsect1>
<refsect1 id='author'><title>AUTHOR</title>
-<para>See <ulink url='http://www.freedesktop.org/software/dbus/doc/AUTHORS'>http://www.freedesktop.org/software/dbus/doc/AUTHORS</ulink></para>
+<para>See <ulink url='https://dbus.freedesktop.org/doc/AUTHORS'>https://dbus.freedesktop.org/doc/AUTHORS</ulink></para>
</refsect1>
<refsect1 id='bugs'><title>BUGS</title>
<para>Please send bug reports to the D-Bus mailing list or bug tracker,
-see <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink></para>
+see <ulink url='https://www.freedesktop.org/wiki/Software/dbus/'>https://www.freedesktop.org/wiki/Software/dbus/</ulink></para>
</refsect1>
</refentry>
diff --git a/doc/dbus-monitor.1.xml.in b/doc/dbus-monitor.1.xml.in
index 2f807d2f..7a15b945 100644
--- a/doc/dbus-monitor.1.xml.in
+++ b/doc/dbus-monitor.1.xml.in
@@ -32,7 +32,7 @@
<refsect1 id='description'><title>DESCRIPTION</title>
<para>The <command>dbus-monitor</command> command is used to monitor messages going
through a D-Bus message bus. See
-<ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink> for more information about
+<ulink url='https://www.freedesktop.org/wiki/Software/dbus/'>https://www.freedesktop.org/wiki/Software/dbus/</ulink> for more information about
the big picture.</para>
@@ -128,6 +128,6 @@ The profiling output mode was added by Olli Salli.</para>
<refsect1 id='bugs'><title>BUGS</title>
<para>Please send bug reports to the D-Bus mailing list or bug tracker,
-see <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink></para>
+see <ulink url='https://www.freedesktop.org/wiki/Software/dbus/'>https://www.freedesktop.org/wiki/Software/dbus/</ulink></para>
</refsect1>
</refentry>
diff --git a/doc/dbus-run-session.1.xml.in b/doc/dbus-run-session.1.xml.in
index a7ec28a4..01989d59 100644
--- a/doc/dbus-run-session.1.xml.in
+++ b/doc/dbus-run-session.1.xml.in
@@ -142,7 +142,12 @@ in the environment variable
<refsect1 id='bugs'><title>BUGS</title>
<para>Please send bug reports to the D-Bus mailing list or bug tracker,
-see <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink></para>
+see <ulink url='https://www.freedesktop.org/wiki/Software/dbus/'>https://www.freedesktop.org/wiki/Software/dbus/</ulink></para>
+</refsect1>
+
+<refsect1 id='author'>
+ <title>AUTHOR</title>
+ <para>See <ulink url='https://dbus.freedesktop.org/doc/AUTHORS'>https://dbus.freedesktop.org/doc/AUTHORS</ulink></para>
</refsect1>
<refsect1 id='see_also'><title>SEE ALSO</title>
diff --git a/doc/dbus-send.1.xml.in b/doc/dbus-send.1.xml.in
index 981c786d..65194b44 100644
--- a/doc/dbus-send.1.xml.in
+++ b/doc/dbus-send.1.xml.in
@@ -37,7 +37,7 @@
<refsect1 id='description'><title>DESCRIPTION</title>
<para>The <command>dbus-send</command> command is used to send a message to a D-Bus message
-bus. See <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink> for more
+bus. See <ulink url='https://www.freedesktop.org/wiki/Software/dbus/'>https://www.freedesktop.org/wiki/Software/dbus/</ulink> for more
information about the big picture.</para>
@@ -172,6 +172,6 @@ The default is implementation&hyphen;defined, typically 25 seconds.</para>
<refsect1 id='bugs'><title>BUGS</title>
<para>Please send bug reports to the D-Bus mailing list or bug tracker,
-see <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink></para>
+see <ulink url='https://www.freedesktop.org/wiki/Software/dbus/'>https://www.freedesktop.org/wiki/Software/dbus/</ulink></para>
</refsect1>
</refentry>
diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml
index 31a351dd..8ebe7a8d 100644
--- a/doc/dbus-specification.xml
+++ b/doc/dbus-specification.xml
@@ -6,8 +6,8 @@
<article id="index">
<articleinfo>
<title>D-Bus Specification</title>
- <releaseinfo>Version 0.36</releaseinfo>
- <date>2020-04-21</date>
+ <releaseinfo>Version 0.42</releaseinfo>
+ <date>2023-08-21</date>
<authorgroup>
<author>
<firstname>Havoc</firstname>
@@ -79,6 +79,72 @@
</revremark>
</revision>
<revision>
+ <revnumber>0.42</revnumber>
+ <date>2023-08-21</date>
+ <authorinitials></authorinitials>
+ <revdescription>
+ <itemizedlist>
+ <listitem><simpara>GetConnectionCredentials can return ProcessFD</simpara></listitem>
+ </itemizedlist>
+ </revdescription>
+ </revision>
+ <revision>
+ <revnumber>0.41</revnumber>
+ <date>2023-02-08</date>
+ <authorinitials></authorinitials>
+ <revdescription>
+ <itemizedlist>
+ <listitem><simpara>Clarify intended handling of /run vs. /var/run</simpara></listitem>
+ </itemizedlist>
+ </revdescription>
+ </revision>
+ <revision>
+ <revnumber>0.40</revnumber>
+ <date>2022-10-05</date>
+ <authorinitials></authorinitials>
+ <revdescription>
+ <itemizedlist>
+ <listitem><simpara>Clarify that unix:tmpdir is not required to use an abstract socket on Linux</simpara></listitem>
+ <listitem><simpara>Mention implications of abstract sockets for Linux namespacing</simpara></listitem>
+ </itemizedlist>
+ </revdescription>
+ </revision>
+ <revision>
+ <revnumber>0.39</revnumber>
+ <date>2022-09-22</date>
+ <authorinitials></authorinitials>
+ <revdescription>
+ <itemizedlist>
+ <listitem><simpara>Document a recommendation for IDNs in reversed domain names</simpara></listitem>
+ <listitem><simpara>Clarify documentation regarding AF_UNIX sockets</simpara></listitem>
+ </itemizedlist>
+ </revdescription>
+ </revision>
+ <revision>
+ <revnumber>0.38</revnumber>
+ <date>2022-02-23</date>
+ <authorinitials></authorinitials>
+ <revdescription>
+ <itemizedlist>
+ <listitem><simpara>Add ActivatableServicesChanged signal and feature flag</simpara></listitem>
+ <listitem><simpara><literal>*</literal> is optionally-escaped in addresses</simpara></listitem>
+ </itemizedlist>
+ </revdescription>
+ </revision>
+ <revision>
+ <revnumber>0.37</revnumber>
+ <date>2021-12-17</date>
+ <authorinitials></authorinitials>
+ <revdescription>
+ <itemizedlist>
+ <listitem><simpara>Update recommendations for interoperable DBUS_COOKIE_SHA1 timeouts</simpara></listitem>
+ <listitem><simpara>Clarify padding requirements for arrays and variants</simpara></listitem>
+ <listitem><simpara>Describe where the interoperable machine ID comes from</simpara></listitem>
+ <listitem><simpara>Clarify use of dictionary (array of dict-entry) types</simpara></listitem>
+ </itemizedlist>
+ </revdescription>
+ </revision>
+ <revision>
<revnumber>0.36</revnumber>
<date>2020-04-21</date>
<authorinitials></authorinitials>
@@ -1952,6 +2018,21 @@
</para>
<para>
+ If the author's DNS domain name is an internationalized domain
+ name (IDN) such as <literal>δοκιμή.example</literal>,
+ the ASCII encoding (known as ACE-encoding or Punycode) such as
+ <literal>xn--jxalpdlp.example</literal>
+ should be used as a basis for the reversed-domain-name form.
+ As with any other name, hyphen/minus characters should be
+ replaced by underscores in the reversed-domain-name form, for
+ example <literal>example.xn__jxalpdlp.ExampleService1</literal>.
+ For more information about internationalized domain names, see
+ <ulink url="https://datatracker.ietf.org/doc/html/rfc5890">RFC
+ 5890 "Internationalized Domain Names for Applications (IDNA):
+ Definitions and Document Framework"</ulink>.
+ </para>
+
+ <para>
D-Bus does not distinguish between the concepts that would be
called classes and interfaces in Java: either can be identified on
D-Bus by an interface name.
@@ -2025,12 +2106,18 @@
</para>
<para>
- As with interface names, if the author's DNS domain name
+ As with <link linkend="message-protocol-names-interface">interface
+ names</link>, if the author's DNS domain name
contains hyphen/minus characters they should be replaced by
- underscores, and if it contains leading digits they should be
- escaped by prepending an underscore. For example, if the owner
+ underscores, if it contains leading digits they should be
+ escaped by prepending an underscore, and internationalized
+ domain names (IDN) need to be encoded in their ASCII form
+ (ACE-encoding, Punycode) before replacing dashes with underscores.
+ For example, if the owner
of 7-zip.org used a D-Bus name for an archiving application,
- it might be named <literal>org._7_zip.Archiver</literal>.
+ it might be named <literal>org._7_zip.Archiver</literal>,
+ while the owner of <literal>δοκιμή.example</literal> might
+ use the name <literal>example.xn__jxalpdlp.ExampleService1</literal>.
</para>
<para>
@@ -3497,7 +3584,7 @@
<listitem>
<para>
The set of optionally-escaped bytes is:
- <literal>[-0-9A-Za-z_/.\]</literal>. To escape, each
+ <literal>[-0-9A-Za-z_/.\*]</literal>. To escape, each
<emphasis>byte</emphasis> (note, not character) which is not in the
set of optionally-escaped bytes must be replaced with an ASCII
percent (<literal>%</literal>) and the value of the byte in hex.
@@ -3610,18 +3697,14 @@
</para>
<para>
- When a socket is opened by the D-Bus library it truncates the path
- name right before the first trailing Nul byte. This is true for both
- normal paths and abstract paths. Note that this is a departure from
- previous versions of D-Bus that would create sockets with a fixed
- length path name. Names which were shorter than the fixed length
- would be padded by Nul bytes.
+ When a Unix socket is opened by the D-Bus library, the socket address
+ length does not include the whole <literal>struct sockaddr_un</literal>,
+ but only the length of the pathname or abstract string (beside other
+ fields).
</para>
<para>
- Unix domain sockets are not available on Windows.
- On all other platforms, they are the recommended transport for
- D-Bus, either used alone or in conjunction with
- <link linkend="transports-systemd">systemd</link> or
+ They are the recommended transport for D-Bus, either used alone or in
+ conjunction with <link linkend="transports-systemd">systemd</link> or
<link linkend="transports-launchd">launchd</link> addresses.
</para>
<para>
@@ -3676,7 +3759,14 @@
The same as "dir", except that on platforms with
abstract sockets, the server may attempt to create an
abstract socket whose name starts with this directory instead
- of a path-based socket. This key can only be used in server
+ of a path-based socket.
+ The server is not required to create an abstract socket, even
+ on platforms that support it: treating "tmpdir" as being
+ equivalent to "dir" is a valid implementation, and recent
+ versions of the reference implementation of D-Bus do this.
+ See "abstract", below, for more details of the consequences
+ of using abstract sockets.
+ Like "dir", this key can only be used in server
addresses, not in client addresses; the resulting client address
will have the "abstract" or "path" key instead.
</entry>
@@ -3689,6 +3779,21 @@
resembling a path but unconnected to the filesystem namespace.
This key is only supported on platforms with abstract Unix
sockets, of which Linux is the only known example.
+ Implementors should note that on Linux, abstract sockets are
+ namespaced according to
+ <ulink url="https://man7.org/linux/man-pages/man7/network_namespaces.7.html"
+ >network namespaces</ulink>
+ rather than being part of the filesystem.
+ This means that abstract sockets are unaffected by mechanisms
+ like
+ <ulink url="https://man7.org/linux/man-pages/man2/chroot.2.html"
+ >chroot(2)</ulink>
+ and
+ <ulink url="https://man7.org/linux/man-pages/man7/mount_namespaces.7.html"
+ >mount namespaces</ulink>,
+ which can lead to a sandbox escape if a sandboxing
+ implementation alters the sandboxed process's view of the
+ filesystem but shares the network namespace with the host.
</entry>
</row>
<row>
@@ -3922,14 +4027,6 @@
information on situations where these transports have been used,
and alternatives to these transports.
</para>
- <para>
- Implementations of D-Bus on Windows operating systems normally
- use a nonce-tcp transport via the local loopback interface.
- This is because the
- <link linkend="transports-unix-domain-sockets">unix</link>
- transport, which would otherwise be recommended, is not
- available on these operating systems.
- </para>
<para>
On start, the server generates a random 16 byte nonce and writes it
@@ -4246,6 +4343,24 @@
reference implementation handles this method automatically.
</para>
<para>
+ On Unix, implementations should try to read the machine ID from
+ <literal>/var/lib/dbus/machine-id</literal> and
+ <literal>/etc/machine-id</literal>. The latter is
+ <ulink url='https://www.freedesktop.org/software/systemd/man/machine-id.html'>
+ defined by systemd</ulink>, but systems not using systemd may provide
+ an equivalent file.
+ If both exist, they are expected to have the same contents, and if they
+ differ, the spec does not define which takes precedence (the reference
+ implementation prefers <literal>/var/lib/dbus/machine-id</literal>,
+ but sd-bus does not).
+ </para>
+ <para>
+ On Windows, the hardware profile GUID is used as the machine ID,
+ with the punctuation removed. This can be obtained with the
+ <ulink url='https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcurrenthwprofilea'>
+ <function>GetCurrentHwProfile</function></ulink> function.
+ </para>
+ <para>
The UUID is intended to be per-instance-of-the-operating-system, so may represent
a virtual machine running on a hypervisor, rather than a physical machine.
Basically if two processes see the same UUID, they should also see the same
@@ -4296,7 +4411,7 @@
in STRING property_name,
in VARIANT value);
org.freedesktop.DBus.Properties.GetAll (in STRING interface_name,
- out DICT&lt;STRING,VARIANT&gt; props);
+ out ARRAY of DICT_ENTRY&lt;STRING,VARIANT&gt; props);
</programlisting>
</para>
<para>
@@ -4346,7 +4461,7 @@
<para>
<programlisting>
org.freedesktop.DBus.Properties.PropertiesChanged (STRING interface_name,
- DICT&lt;STRING,VARIANT&gt; changed_properties,
+ ARRAY of DICT_ENTRY&lt;STRING,VARIANT&gt; changed_properties,
ARRAY&lt;STRING&gt; invalidated_properties);
</programlisting>
</para>
@@ -4393,7 +4508,7 @@
</para>
<para>
<programlisting>
- org.freedesktop.DBus.ObjectManager.GetManagedObjects (out DICT&lt;OBJPATH,DICT&lt;STRING,DICT&lt;STRING,VARIANT&gt;&gt;&gt; objpath_interfaces_and_properties);
+ org.freedesktop.DBus.ObjectManager.GetManagedObjects (out ARRAY of DICT_ENTRY&lt;OBJPATH,ARRAY of DICT_ENTRY&lt;STRING,ARRAY of DICT_ENTRY&lt;STRING,VARIANT&gt;&gt;&gt; objpath_interfaces_and_properties);
</programlisting>
</para>
<para>
@@ -4416,7 +4531,7 @@
<para>
<programlisting>
org.freedesktop.DBus.ObjectManager.InterfacesAdded (OBJPATH object_path,
- DICT&lt;STRING,DICT&lt;STRING,VARIANT&gt;&gt; interfaces_and_properties);
+ ARRAY of DICT_ENTRY&lt;STRING,ARRAY of DICT_ENTRY&lt;STRING,VARIANT&gt;&gt; interfaces_and_properties);
org.freedesktop.DBus.ObjectManager.InterfacesRemoved (OBJPATH object_path,
ARRAY&lt;STRING&gt; interfaces);
</programlisting>
@@ -5688,13 +5803,27 @@
variable. If that variable is not set, applications should try
to connect to the well-known address
<literal>unix:path=/var/run/dbus/system_bus_socket</literal>.
- <footnote>
- <para>
- The D-Bus reference implementation actually honors the
- <literal>$(localstatedir)</literal> configure option
- for this address, on both client and server side.
- </para>
- </footnote>
+ Implementations of the well-known system bus should listen on
+ an address that will result in that connection being successful.
+ </para>
+ <para>
+ On systems where <filename>/var/run/</filename> is known to be
+ synonymous with <filename>/run/</filename> (such as most Linux
+ operating system distributions), implementations might prefer
+ to make use of that knowledge to connect to or listen on
+ <literal>unix:path=/run/dbus/system_bus_socket</literal> instead,
+ which has some minor technical advantages, particularly during
+ early startup and late shutdown.
+ </para>
+ <para>
+ In practice, implementations of D-Bus often have build-time
+ configuration options for the system bus address, whose defaults
+ often depend on other build-time options such as the installation
+ prefix (in particular, this is the case for dbus, the reference
+ implementation of D-Bus).
+ Distributors intending to provide access to the well-known
+ system bus should verify that they are using an interoperable
+ address.
</para>
<para>
On Unix systems, the system bus should default to searching
@@ -6410,6 +6539,32 @@
</para>
</sect3>
+ <sect3 id="bus-messages-activatable-services-changed">
+ <title><literal>org.freedesktop.DBus.ActivatableServicesChanged</literal></title>
+ <para>
+ This is a signal:
+ <programlisting>
+ ActivatableServicesChanged ()
+ </programlisting>
+ </para>
+ <para>
+ This signal is sent when the list of activatable services,
+ as returned by ListActivatableNames(), might have changed
+ (see <xref linkend="bus-messages-list-activatable-names"/>).
+ Clients that have cached information about the activatable
+ services should call ListActivatableNames() again to update
+ their cache.
+ </para>
+ <para>
+ The presence of this signal is indicated by a
+ bus feature property (for details see
+ <xref linkend="message-bus-properties-features"/>).
+ In older implementations that do not have this feature,
+ there is no way to be informed when the list of activatable
+ names has changed.
+ </para>
+ </sect3>
+
<sect3 id="bus-messages-start-service-by-name">
<title><literal>org.freedesktop.DBus.StartServiceByName</literal></title>
<para>
@@ -6516,7 +6671,7 @@
<para>
As a method:
<programlisting>
- UpdateActivationEnvironment (in ARRAY of DICT&lt;STRING,STRING&gt; environment)
+ UpdateActivationEnvironment (in ARRAY of DICT_ENTRY&lt;STRING,STRING&gt; environment)
</programlisting>
Message arguments:
<informaltable>
@@ -6531,7 +6686,7 @@
<tbody>
<row>
<entry>0</entry>
- <entry>ARRAY of DICT&lt;STRING,STRING&gt;</entry>
+ <entry>ARRAY of DICT_ENTRY&lt;STRING,STRING&gt;</entry>
<entry>Environment to add or update</entry>
</row>
</tbody>
@@ -6710,7 +6865,7 @@
<para>
As a method:
<programlisting>
- DICT&lt;STRING,VARIANT&gt; GetConnectionCredentials (in STRING bus_name)
+ ARRAY of DICT_ENTRY&lt;STRING,VARIANT&gt; GetConnectionCredentials (in STRING bus_name)
</programlisting>
Message arguments:
<informaltable>
@@ -6746,7 +6901,7 @@
<tbody>
<row>
<entry>0</entry>
- <entry>DICT&lt;STRING,VARIANT&gt;</entry>
+ <entry>ARRAY of DICT_ENTRY&lt;STRING,VARIANT&gt;</entry>
<entry>Credentials</entry>
</row>
</tbody>
@@ -6798,6 +6953,17 @@
</entry>
</row>
<row>
+ <entry>ProcessFD</entry>
+ <entry>UNIX_FD</entry>
+ <entry>A file descriptor pinning the process, on platforms
+ that have this concept. On Linux, the SO_PEERPIDFD socket
+ option is a suitable implementation. This is safer to use
+ to identify a process than the <literal>ProcessID</literal>,
+ as the latter is subject to re-use attacks, while the FD
+ cannot be recycled. If the original process no longer exists
+ the FD will no longer be resolvable.</entry>
+ </row>
+ <row>
<entry>ProcessID</entry>
<entry>UINT32</entry>
<entry>The numeric process ID, on platforms that have
@@ -7223,6 +7389,17 @@
<variablelist>
<varlistentry>
+ <term><literal>ActivatableServicesChanged</literal></term>
+ <listitem>
+ <para>
+ This message bus emits the <literal>ActivatableServicesChanged</literal>
+ signal whenever its list of activatable services might have changed
+ (for details see <xref linkend="bus-messages-activatable-services-changed"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><literal>AppArmor</literal></term>
<listitem>
<para>
diff --git a/doc/dbus-test-tool.1.xml.in b/doc/dbus-test-tool.1.xml.in
index 5b7c43ed..1d0d8a82 100644
--- a/doc/dbus-test-tool.1.xml.in
+++ b/doc/dbus-test-tool.1.xml.in
@@ -7,6 +7,10 @@
<holder>Collabora Ltd.</holder>
</copyright>
<legalnotice>
+ <!--
+ Copyright 2015 Collabora Ltd.
+ SPDX-License-Identifier: GPL-2.0-or-later
+ -->
<para>This man page is distributed under the same terms as
dbus-test-tool (GPL-2+). There is NO WARRANTY, to the extent
permitted by law.</para>
@@ -315,7 +319,12 @@
<refsect1 id="bugs">
<title>BUGS</title>
<para>Please send bug reports to the D-Bus bug tracker or mailing list.
- See <ulink url="http://www.freedesktop.org/software/dbus/">http://www.freedesktop.org/software/dbus/</ulink>.</para>
+ See <ulink url="https://www.freedesktop.org/wiki/Software/dbus/">https://www.freedesktop.org/wiki/Software/dbus/</ulink>.</para>
+ </refsect1>
+
+ <refsect1 id='author'>
+ <title>AUTHOR</title>
+ <para>See <ulink url='https://dbus.freedesktop.org/doc/AUTHORS'>https://dbus.freedesktop.org/doc/AUTHORS</ulink></para>
</refsect1>
<refsect1 id="see_also">
diff --git a/doc/dbus-update-activation-environment.1.xml.in b/doc/dbus-update-activation-environment.1.xml.in
index 8a495df6..3d207a49 100644
--- a/doc/dbus-update-activation-environment.1.xml.in
+++ b/doc/dbus-update-activation-environment.1.xml.in
@@ -200,7 +200,12 @@
<refsect1 id="bugs">
<title>BUGS</title>
<para>Please send bug reports to the D-Bus bug tracker or mailing list.
- See <ulink url="http://www.freedesktop.org/software/dbus/">http://www.freedesktop.org/software/dbus/</ulink>.</para>
+ See <ulink url="https://www.freedesktop.org/wiki/Software/dbus/">https://www.freedesktop.org/wiki/Software/dbus/</ulink>.</para>
+ </refsect1>
+
+ <refsect1 id='author'>
+ <title>AUTHOR</title>
+ <para>See <ulink url='https://dbus.freedesktop.org/doc/AUTHORS'>https://dbus.freedesktop.org/doc/AUTHORS</ulink></para>
</refsect1>
<refsect1 id="see_also">
diff --git a/doc/dbus-uuidgen.1.xml.in b/doc/dbus-uuidgen.1.xml.in
index fbd26812..60cfc8c9 100644
--- a/doc/dbus-uuidgen.1.xml.in
+++ b/doc/dbus-uuidgen.1.xml.in
@@ -37,7 +37,7 @@ UUIDs compatible with that spec. Many systems have a separate command
for that (often called "uuidgen").</para>
-<para>See <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink> for more information
+<para>See <ulink url='https://www.freedesktop.org/wiki/Software/dbus/'>https://www.freedesktop.org/wiki/Software/dbus/</ulink> for more information
about D-Bus.</para>
@@ -115,12 +115,12 @@ On success, prints no output.</para>
</refsect1>
<refsect1 id='author'><title>AUTHOR</title>
-<para>See <ulink url='http://www.freedesktop.org/software/dbus/doc/AUTHORS'>http://www.freedesktop.org/software/dbus/doc/AUTHORS</ulink></para>
+<para>See <ulink url='https://dbus.freedesktop.org/doc/AUTHORS'>https://dbus.freedesktop.org/doc/AUTHORS</ulink></para>
</refsect1>
<refsect1 id='bugs'><title>BUGS</title>
<para>Please send bug reports to the D-Bus mailing list or bug tracker,
-see <ulink url='http://www.freedesktop.org/software/dbus/'>http://www.freedesktop.org/software/dbus/</ulink></para>
+see <ulink url='https://www.freedesktop.org/wiki/Software/dbus/'>https://www.freedesktop.org/wiki/Software/dbus/</ulink></para>
</refsect1>
</refentry>
diff --git a/doc/file-boilerplate.c b/doc/file-boilerplate.c
index bc365f80..1baaf96b 100644
--- a/doc/file-boilerplate.c
+++ b/doc/file-boilerplate.c
@@ -3,6 +3,8 @@
*
* Copyright (C) YEAR COPYRIGHT HOLDER
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/doc/introspect.xsl b/doc/introspect.xsl
index 89b68441..edc9d795 100644
--- a/doc/introspect.xsl
+++ b/doc/introspect.xsl
@@ -4,6 +4,8 @@
<!--
Copyright (C) 2005 Lennart Poettering.
+ SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+
Licensed under the Academic Free License version 2.1
This program is free software; you can redistribute it and/or modify
diff --git a/doc/list-doc-source.py b/doc/list-doc-source.py
new file mode 100644
index 00000000..2ed442ca
--- /dev/null
+++ b/doc/list-doc-source.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python3
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+
+import glob
+import sys
+
+print('\n'.join(glob.glob(sys.argv[1] + '/*.[ch]')))
diff --git a/doc/maintainer-upload-docs.sh b/doc/maintainer-upload-docs.sh
new file mode 100755
index 00000000..f090cf46
--- /dev/null
+++ b/doc/maintainer-upload-docs.sh
@@ -0,0 +1,53 @@
+#!/usr/bin/env bash
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+set -eux
+
+: "${DOC_SERVER:=dbus.freedesktop.org}"
+: "${DOC_WWW_DIR:=/srv/dbus.freedesktop.org/www}"
+
+: "${SPECIFICATION_SERVER:=specifications.freedesktop.org}"
+: "${SPECIFICATION_PATH:=/srv/specifications.freedesktop.org/www/dbus/1.0}"
+
+if [ -n "${MESON_BUILD_ROOT-}" ]; then
+ cd "${MESON_BUILD_ROOT}"
+fi
+
+if [ -n "${MESON_SOURCE_ROOT-}" ]; then
+ top_srcdir="${MESON_SOURCE_ROOT}"
+else
+ # assume build directory is inside source directory
+ top_srcdir=".."
+fi
+
+TMPDIR=$(mktemp -d)
+
+mkdir -p "$TMPDIR/api"
+cp -r doc/api/html "$TMPDIR/api"
+cp -r "$@" "$TMPDIR"
+mv "$TMPDIR" dbus-docs
+tar --xz -c -f dbus-docs.tar.xz dbus-docs
+
+scp dbus-docs.tar.xz "$DOC_SERVER:$DOC_WWW_DIR/"
+rsync -rpvzP --chmod=Dg+s,ug+rwX,o=rX dbus-docs/ "$DOC_SERVER:$DOC_WWW_DIR/doc/"
+
+scp -p "$top_srcdir"/doc/*.dtd "$SPECIFICATION_SERVER:$SPECIFICATION_PATH/"
diff --git a/doc/meson.build b/doc/meson.build
new file mode 100644
index 00000000..adc6f17d
--- /dev/null
+++ b/doc/meson.build
@@ -0,0 +1,252 @@
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+# XML files used for Man and html doc
+xmls_mans_htmls_names = [
+ 'dbus-cleanup-sockets.1',
+ 'dbus-daemon.1',
+ 'dbus-launch.1',
+ 'dbus-monitor.1',
+ 'dbus-run-session.1',
+ 'dbus-send.1',
+ 'dbus-test-tool.1',
+ 'dbus-update-activation-environment.1',
+ 'dbus-uuidgen.1',
+]
+xml_files = []
+man_html_list = []
+foreach xml_in : xmls_mans_htmls_names
+ xml_file = configure_file(
+ input : xml_in + '.xml.in',
+ output: xml_in + '.xml',
+ configuration: data_config,
+ )
+ man_html_list += {
+ 'xml' : xml_file,
+ 'man' : xml_in,
+ 'html' : xml_in + '.html',
+ }
+ xml_files += xml_file
+endforeach
+
+# XML files used for html doc
+xmls_names = [
+ 'dbus-faq',
+ 'dbus-specification',
+ 'dbus-test-plan',
+ 'dbus-tutorial',
+]
+html_list = []
+foreach xml_in : xmls_names
+ html_list += {
+ 'xml' : xml_in + '.xml',
+ 'html' : xml_in + '.html',
+ }
+endforeach
+
+# uploaded and distributed, but not installed
+static_docs = files(
+ 'dbus-api-design.duck',
+ 'dbus-faq.xml',
+ 'dbus-specification.xml',
+ 'dbus-test-plan.xml',
+ 'dbus-tutorial.xml',
+ 'dcop-howto.txt',
+ 'introspect.xsl',
+)
+
+###############################################################################
+# Install man files
+
+if build_xml_docs
+ foreach man: man_html_list
+ custom_target(man.get('man'),
+ input: man.get('xml'),
+ output: man.get('man'),
+ command: [
+ xsltproc,
+ '--nonet',
+ '--xinclude',
+ '--stringparam', 'man.output.quietly', '1',
+ '-o', '@OUTPUT@',
+ 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl',
+ '@INPUT@',
+ ],
+ install: true,
+ install_dir: get_option('mandir') / 'man1',
+ )
+ endforeach
+endif
+
+###############################################################################
+# Install html doc files
+
+html_files = []
+if build_xml_docs
+ foreach man: man_html_list + html_list
+ html_files += custom_target(man.get('html'),
+ input: man.get('xml'),
+ output: man.get('html'),
+ command: [
+ xsltproc,
+ '--nonet',
+ '--xinclude',
+ '--stringparam', 'generate.consistent.ids', '1',
+ '-o', '@OUTPUT@',
+ 'http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl',
+ '@INPUT@',
+ ],
+ install: true,
+ install_dir: docs_dir,
+ )
+ endforeach
+endif
+
+docs_files = [
+ 'system-activation.txt',
+ 'diagram.png',
+ 'diagram.svg',
+]
+
+install_data(
+ sources: docs_files,
+ install_dir: docs_dir,
+)
+
+configure_file(
+ input: 'index.html.in',
+ output: 'index.html',
+ configuration: data_config,
+ install_dir: docs_dir,
+)
+
+###############################################################################
+# Install dtd files
+
+
+xml_dir = get_option('datadir') / 'xml' / 'dbus-1'
+dtd_files = [
+ 'busconfig.dtd',
+ 'introspect.dtd',
+]
+
+install_data(
+ sources: dtd_files,
+ install_dir: xml_dir,
+)
+
+configure_file(
+ input: 'catalog.xml.in',
+ output: 'catalog.xml',
+ install_dir: xml_dir,
+ configuration: {'DBUS_DTD_DIR': get_option('prefix') / xml_dir},
+)
+
+###############################################################################
+# Doxygen
+if doxygen.found()
+ qch_dir = get_option('qch_dir')
+ if qch_dir == ''
+ qch_dir = docs_dir
+ endif
+
+ doxyfile = configure_file(
+ input: '../Doxyfile.in',
+ output: 'Doxyfile',
+ configuration: data_config,
+ )
+
+ dbus_srcs = run_command(
+ python,
+ files('list-doc-source.py'),
+ meson.project_source_root() / 'dbus',
+ check: true
+ ).stdout().strip().split('\n')
+ dbus_srcs += dbus_arch_deps_h
+
+ doxygen_tgt = custom_target('doxygen',
+ input: doxyfile,
+ output: 'api',
+ depend_files: dbus_srcs,
+ command: [doxygen, doxyfile],
+ )
+ alias_target('doxygen', doxygen_tgt)
+
+ meson.add_install_script(
+ 'meson_post_install.py',
+ meson.current_build_dir(),
+ docs_dir,
+ meson.current_build_dir() / 'api/qch/dbus-@0@.qch'.format(version),
+ qch_dir,
+ # ignored further arguments, but for dependency
+ doxygen_tgt,
+ )
+
+ if xsltproc.found()
+ custom_target('dbus.devhelp2',
+ input: 'doxygen_to_devhelp.xsl',
+ output: 'dbus.devhelp2',
+ depends: [doxygen_tgt],
+ command: [ xsltproc, '-o', '@OUTPUT@', '@INPUT@', meson.current_build_dir() / 'api/xml/index.xml' ],
+ install: true,
+ install_dir: docs_dir,
+ )
+ endif
+endif
+
+if ducktype.found() and yelpbuild.found()
+ design_page = custom_target('dbus-api-design.page',
+ input: 'dbus-api-design.duck',
+ output: 'dbus-api-design.page',
+ command: [ ducktype, '-o', '@OUTPUT@', '@INPUT@' ],
+ )
+ html_files += custom_target('dbus-api-design.html',
+ input: design_page,
+ output: [
+ 'dbus-api-design.html',
+ 'yelp.js',
+ 'C.css',
+ 'highlight.pack.js',
+ ],
+ command: [
+ yelpbuild, 'html',
+ '-o', meson.current_build_dir(),
+ '@INPUT@',
+ ],
+ install: true,
+ install_dir: docs_dir,
+ )
+endif
+
+if can_upload_docs
+ run_target('maintainer-upload-docs',
+ command: [
+ find_program('maintainer-upload-docs.sh'),
+ files(docs_files),
+ files(dtd_files),
+ static_docs,
+ html_files,
+ xml_files,
+ bonus_files,
+ ],
+ depends: doxygen_tgt,
+ )
+endif
diff --git a/doc/meson_post_install.py b/doc/meson_post_install.py
new file mode 100644
index 00000000..106725cc
--- /dev/null
+++ b/doc/meson_post_install.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+import os
+import sys
+import shutil
+from pathlib import Path
+
+
+if __name__ == "__main__":
+ arg_builddir = sys.argv[1]
+ arg_docdir = sys.argv[2]
+ arg_qch = sys.argv[3]
+ arg_qchdir = sys.argv[4]
+ env_destdir = os.getenv('MESON_INSTALL_DESTDIR_PREFIX')
+
+ builddir = Path(arg_builddir)
+ docdir = Path(arg_docdir)
+ qch = Path(arg_qch)
+ qchdir = Path(arg_qchdir)
+ destdir = Path(env_destdir)
+ apidir = Path(destdir /docdir / 'api')
+ shutil.rmtree(apidir, ignore_errors=True)
+ shutil.copytree(builddir / 'api/html', apidir)
+ if qch.is_file():
+ shutil.copy(qch, destdir / qchdir)
diff --git a/m4/as-ac-expand.m4 b/m4/as-ac-expand.m4
deleted file mode 100644
index deebd2bf..00000000
--- a/m4/as-ac-expand.m4
+++ /dev/null
@@ -1,49 +0,0 @@
-dnl as-ac-expand.m4 0.2.0 -*- autoconf -*-
-dnl autostars m4 macro for expanding directories using configure's prefix
-
-dnl (C) 2003, 2004, 2005 Thomas Vander Stichele <thomas at apestaart dot org>
-
-dnl Copying and distribution of this file, with or without modification,
-dnl are permitted in any medium without royalty provided the copyright
-dnl notice and this notice are preserved.
-
-dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
-
-dnl example:
-dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
-dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
-
-AC_DEFUN([AS_AC_EXPAND],
-[
- EXP_VAR=[$1]
- FROM_VAR=[$2]
-
- dnl first expand prefix and exec_prefix if necessary
- prefix_save=$prefix
- exec_prefix_save=$exec_prefix
-
- dnl if no prefix given, then use /usr/local, the default prefix
- if test "x$prefix" = "xNONE"; then
- prefix="$ac_default_prefix"
- fi
- dnl if no exec_prefix given, then use prefix
- if test "x$exec_prefix" = "xNONE"; then
- exec_prefix=$prefix
- fi
-
- full_var="$FROM_VAR"
- dnl loop until it doesn't change anymore
- while true; do
- new_full_var="`eval echo $full_var`"
- if test "x$new_full_var" = "x$full_var"; then break; fi
- full_var=$new_full_var
- done
-
- dnl clean up
- full_var=$new_full_var
- AC_SUBST([$1], "$full_var")
-
- dnl restore prefix and exec_prefix
- prefix=$prefix_save
- exec_prefix=$exec_prefix_save
-])
diff --git a/m4/ax_ac_append_to_file.m4 b/m4/ax_ac_append_to_file.m4
deleted file mode 100644
index 242b3d52..00000000
--- a/m4/ax_ac_append_to_file.m4
+++ /dev/null
@@ -1,32 +0,0 @@
-# ===========================================================================
-# https://www.gnu.org/software/autoconf-archive/ax_ac_append_to_file.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AX_AC_APPEND_TO_FILE([FILE],[DATA])
-#
-# DESCRIPTION
-#
-# Appends the specified data to the specified Autoconf is run. If you want
-# to append to a file when configure is run use AX_APPEND_TO_FILE instead.
-#
-# LICENSE
-#
-# Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved. This file is offered as-is, without any
-# warranty.
-
-#serial 10
-
-AC_DEFUN([AX_AC_APPEND_TO_FILE],[
-AC_REQUIRE([AX_FILE_ESCAPES])
-m4_esyscmd(
-AX_FILE_ESCAPES
-[
-printf "%s" "$2" >> "$1"
-])
-])
diff --git a/m4/ax_ac_print_to_file.m4 b/m4/ax_ac_print_to_file.m4
deleted file mode 100644
index 642dfc15..00000000
--- a/m4/ax_ac_print_to_file.m4
+++ /dev/null
@@ -1,32 +0,0 @@
-# ===========================================================================
-# https://www.gnu.org/software/autoconf-archive/ax_ac_print_to_file.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AX_AC_PRINT_TO_FILE([FILE],[DATA])
-#
-# DESCRIPTION
-#
-# Writes the specified data to the specified file when Autoconf is run. If
-# you want to print to a file when configure is run use AX_PRINT_TO_FILE
-# instead.
-#
-# LICENSE
-#
-# Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved. This file is offered as-is, without any
-# warranty.
-
-#serial 10
-
-AC_DEFUN([AX_AC_PRINT_TO_FILE],[
-m4_esyscmd(
-AC_REQUIRE([AX_FILE_ESCAPES])
-[
-printf "%s" "$2" > "$1"
-])
-])
diff --git a/m4/ax_add_am_macro_static.m4 b/m4/ax_add_am_macro_static.m4
deleted file mode 100644
index 6442d24b..00000000
--- a/m4/ax_add_am_macro_static.m4
+++ /dev/null
@@ -1,28 +0,0 @@
-# ===========================================================================
-# https://www.gnu.org/software/autoconf-archive/ax_add_am_macro_static.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AX_ADD_AM_MACRO_STATIC([RULE])
-#
-# DESCRIPTION
-#
-# Adds the specified rule to $AMINCLUDE.
-#
-# LICENSE
-#
-# Copyright (c) 2009 Tom Howard <tomhoward@users.sf.net>
-# Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved. This file is offered as-is, without any
-# warranty.
-
-#serial 8
-
-AC_DEFUN([AX_ADD_AM_MACRO_STATIC],[
- AC_REQUIRE([AX_AM_MACROS_STATIC])
- AX_AC_APPEND_TO_FILE(AMINCLUDE_STATIC,[$1])
-])
diff --git a/m4/ax_am_macros_static.m4 b/m4/ax_am_macros_static.m4
deleted file mode 100644
index f4cee8c8..00000000
--- a/m4/ax_am_macros_static.m4
+++ /dev/null
@@ -1,38 +0,0 @@
-# ===========================================================================
-# https://www.gnu.org/software/autoconf-archive/ax_am_macros_static.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AX_AM_MACROS_STATIC
-#
-# DESCRIPTION
-#
-# Adds support for macros that create Automake rules. You must manually
-# add the following line
-#
-# include $(top_srcdir)/aminclude_static.am
-#
-# to your Makefile.am files.
-#
-# LICENSE
-#
-# Copyright (c) 2009 Tom Howard <tomhoward@users.sf.net>
-# Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved. This file is offered as-is, without any
-# warranty.
-
-#serial 11
-
-AC_DEFUN([AMINCLUDE_STATIC],[aminclude_static.am])
-
-AC_DEFUN([AX_AM_MACROS_STATIC],
-[
-AX_AC_PRINT_TO_FILE(AMINCLUDE_STATIC,[
-# ]AMINCLUDE_STATIC[ generated automatically by Autoconf
-# from AX_AM_MACROS_STATIC on ]m4_esyscmd([LC_ALL=C date])[
-])
-])
diff --git a/m4/ax_code_coverage.m4 b/m4/ax_code_coverage.m4
deleted file mode 100644
index 3d36924b..00000000
--- a/m4/ax_code_coverage.m4
+++ /dev/null
@@ -1,272 +0,0 @@
-# ===========================================================================
-# https://www.gnu.org/software/autoconf-archive/ax_code_coverage.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AX_CODE_COVERAGE()
-#
-# DESCRIPTION
-#
-# Defines CODE_COVERAGE_CPPFLAGS, CODE_COVERAGE_CFLAGS,
-# CODE_COVERAGE_CXXFLAGS and CODE_COVERAGE_LIBS which should be included
-# in the CPPFLAGS, CFLAGS CXXFLAGS and LIBS/LIBADD variables of every
-# build target (program or library) which should be built with code
-# coverage support. Also add rules using AX_ADD_AM_MACRO_STATIC; and
-# $enable_code_coverage which can be used in subsequent configure output.
-# CODE_COVERAGE_ENABLED is defined and substituted, and corresponds to the
-# value of the --enable-code-coverage option, which defaults to being
-# disabled.
-#
-# Test also for gcov program and create GCOV variable that could be
-# substituted.
-#
-# Note that all optimization flags in CFLAGS must be disabled when code
-# coverage is enabled.
-#
-# Usage example:
-#
-# configure.ac:
-#
-# AX_CODE_COVERAGE
-#
-# Makefile.am:
-#
-# include $(top_srcdir)/aminclude_static.am
-#
-# my_program_LIBS = ... $(CODE_COVERAGE_LIBS) ...
-# my_program_CPPFLAGS = ... $(CODE_COVERAGE_CPPFLAGS) ...
-# my_program_CFLAGS = ... $(CODE_COVERAGE_CFLAGS) ...
-# my_program_CXXFLAGS = ... $(CODE_COVERAGE_CXXFLAGS) ...
-#
-# clean-local: code-coverage-clean
-# distclean-local: code-coverage-dist-clean
-#
-# This results in a "check-code-coverage" rule being added to any
-# Makefile.am which do "include $(top_srcdir)/aminclude_static.am"
-# (assuming the module has been configured with --enable-code-coverage).
-# Running `make check-code-coverage` in that directory will run the
-# module's test suite (`make check`) and build a code coverage report
-# detailing the code which was touched, then print the URI for the report.
-#
-# This code was derived from Makefile.decl in GLib, originally licensed
-# under LGPLv2.1+.
-#
-# LICENSE
-#
-# Copyright (c) 2012, 2016 Philip Withnall
-# Copyright (c) 2012 Xan Lopez
-# Copyright (c) 2012 Christian Persch
-# Copyright (c) 2012 Paolo Borelli
-# Copyright (c) 2012 Dan Winship
-# Copyright (c) 2015,2018 Bastien ROUCARIES
-#
-# This library is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation; either version 2.1 of the License, or (at
-# your option) any later version.
-#
-# This library is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
-# General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see <https://www.gnu.org/licenses/>.
-
-#serial 32
-
-m4_define(_AX_CODE_COVERAGE_RULES,[
-AX_ADD_AM_MACRO_STATIC([
-# Code coverage
-#
-# Optional:
-# - CODE_COVERAGE_DIRECTORY: Top-level directory for code coverage reporting.
-# Multiple directories may be specified, separated by whitespace.
-# (Default: \$(top_builddir))
-# - CODE_COVERAGE_OUTPUT_FILE: Filename and path for the .info file generated
-# by lcov for code coverage. (Default:
-# \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage.info)
-# - CODE_COVERAGE_OUTPUT_DIRECTORY: Directory for generated code coverage
-# reports to be created. (Default:
-# \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage)
-# - CODE_COVERAGE_BRANCH_COVERAGE: Set to 1 to enforce branch coverage,
-# set to 0 to disable it and leave empty to stay with the default.
-# (Default: empty)
-# - CODE_COVERAGE_LCOV_SHOPTS_DEFAULT: Extra options shared between both lcov
-# instances. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE)
-# - CODE_COVERAGE_LCOV_SHOPTS: Extra options to shared between both lcov
-# instances. (Default: $CODE_COVERAGE_LCOV_SHOPTS_DEFAULT)
-# - CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH: --gcov-tool pathtogcov
-# - CODE_COVERAGE_LCOV_OPTIONS_DEFAULT: Extra options to pass to the
-# collecting lcov instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH)
-# - CODE_COVERAGE_LCOV_OPTIONS: Extra options to pass to the collecting lcov
-# instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_DEFAULT)
-# - CODE_COVERAGE_LCOV_RMOPTS_DEFAULT: Extra options to pass to the filtering
-# lcov instance. (Default: empty)
-# - CODE_COVERAGE_LCOV_RMOPTS: Extra options to pass to the filtering lcov
-# instance. (Default: $CODE_COVERAGE_LCOV_RMOPTS_DEFAULT)
-# - CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT: Extra options to pass to the
-# genhtml instance. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE)
-# - CODE_COVERAGE_GENHTML_OPTIONS: Extra options to pass to the genhtml
-# instance. (Default: $CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT)
-# - CODE_COVERAGE_IGNORE_PATTERN: Extra glob pattern of files to ignore
-#
-# The generated report will be titled using the \$(PACKAGE_NAME) and
-# \$(PACKAGE_VERSION). In order to add the current git hash to the title,
-# use the git-version-gen script, available online.
-# Optional variables
-# run only on top dir
-if CODE_COVERAGE_ENABLED
- ifeq (\$(abs_builddir), \$(abs_top_builddir))
-CODE_COVERAGE_DIRECTORY ?= \$(top_builddir)
-CODE_COVERAGE_OUTPUT_FILE ?= \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage.info
-CODE_COVERAGE_OUTPUT_DIRECTORY ?= \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage
-
-CODE_COVERAGE_BRANCH_COVERAGE ?=
-CODE_COVERAGE_LCOV_SHOPTS_DEFAULT ?= \$(if \$(CODE_COVERAGE_BRANCH_COVERAGE),\
---rc lcov_branch_coverage=\$(CODE_COVERAGE_BRANCH_COVERAGE))
-CODE_COVERAGE_LCOV_SHOPTS ?= \$(CODE_COVERAGE_LCOV_SHOPTS_DEFAULT)
-CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH ?= --gcov-tool \"\$(GCOV)\"
-CODE_COVERAGE_LCOV_OPTIONS_DEFAULT ?= \$(CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH)
-CODE_COVERAGE_LCOV_OPTIONS ?= \$(CODE_COVERAGE_LCOV_OPTIONS_DEFAULT)
-CODE_COVERAGE_LCOV_RMOPTS_DEFAULT ?=
-CODE_COVERAGE_LCOV_RMOPTS ?= \$(CODE_COVERAGE_LCOV_RMOPTS_DEFAULT)
-CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT ?=\
-\$(if \$(CODE_COVERAGE_BRANCH_COVERAGE),\
---rc genhtml_branch_coverage=\$(CODE_COVERAGE_BRANCH_COVERAGE))
-CODE_COVERAGE_GENHTML_OPTIONS ?= \$(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT)
-CODE_COVERAGE_IGNORE_PATTERN ?=
-
-GITIGNOREFILES = \$(GITIGNOREFILES) \$(CODE_COVERAGE_OUTPUT_FILE) \$(CODE_COVERAGE_OUTPUT_DIRECTORY)
-code_coverage_v_lcov_cap = \$(code_coverage_v_lcov_cap_\$(V))
-code_coverage_v_lcov_cap_ = \$(code_coverage_v_lcov_cap_\$(AM_DEFAULT_VERBOSITY))
-code_coverage_v_lcov_cap_0 = @echo \" LCOV --capture\" \$(CODE_COVERAGE_OUTPUT_FILE);
-code_coverage_v_lcov_ign = \$(code_coverage_v_lcov_ign_\$(V))
-code_coverage_v_lcov_ign_ = \$(code_coverage_v_lcov_ign_\$(AM_DEFAULT_VERBOSITY))
-code_coverage_v_lcov_ign_0 = @echo \" LCOV --remove /tmp/*\" \$(CODE_COVERAGE_IGNORE_PATTERN);
-code_coverage_v_genhtml = \$(code_coverage_v_genhtml_\$(V))
-code_coverage_v_genhtml_ = \$(code_coverage_v_genhtml_\$(AM_DEFAULT_VERBOSITY))
-code_coverage_v_genhtml_0 = @echo \" GEN \" \"\$(CODE_COVERAGE_OUTPUT_DIRECTORY)\";
-code_coverage_quiet = \$(code_coverage_quiet_\$(V))
-code_coverage_quiet_ = \$(code_coverage_quiet_\$(AM_DEFAULT_VERBOSITY))
-code_coverage_quiet_0 = --quiet
-
-# sanitizes the test-name: replaces with underscores: dashes and dots
-code_coverage_sanitize = \$(subst -,_,\$(subst .,_,\$(1)))
-
-# Use recursive makes in order to ignore errors during check
-check-code-coverage:
- -\$(AM_V_at)\$(MAKE) \$(AM_MAKEFLAGS) -k check
- \$(AM_V_at)\$(MAKE) \$(AM_MAKEFLAGS) code-coverage-capture
-
-# Capture code coverage data
-code-coverage-capture: code-coverage-capture-hook
- \$(code_coverage_v_lcov_cap)\$(LCOV) \$(code_coverage_quiet) \$(addprefix --directory ,\$(CODE_COVERAGE_DIRECTORY)) --capture --output-file \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" --test-name \"\$(call code_coverage_sanitize,\$(PACKAGE_NAME)-\$(PACKAGE_VERSION))\" --no-checksum --compat-libtool \$(CODE_COVERAGE_LCOV_SHOPTS) \$(CODE_COVERAGE_LCOV_OPTIONS)
- \$(code_coverage_v_lcov_ign)\$(LCOV) \$(code_coverage_quiet) \$(addprefix --directory ,\$(CODE_COVERAGE_DIRECTORY)) --remove \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" \"/tmp/*\" \$(CODE_COVERAGE_IGNORE_PATTERN) --output-file \"\$(CODE_COVERAGE_OUTPUT_FILE)\" \$(CODE_COVERAGE_LCOV_SHOPTS) \$(CODE_COVERAGE_LCOV_RMOPTS)
- -@rm -f \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\"
- \$(code_coverage_v_genhtml)LANG=C \$(GENHTML) \$(code_coverage_quiet) \$(addprefix --prefix ,\$(CODE_COVERAGE_DIRECTORY)) --output-directory \"\$(CODE_COVERAGE_OUTPUT_DIRECTORY)\" --title \"\$(PACKAGE_NAME)-\$(PACKAGE_VERSION) Code Coverage\" --legend --show-details \"\$(CODE_COVERAGE_OUTPUT_FILE)\" \$(CODE_COVERAGE_GENHTML_OPTIONS)
- @echo \"file://\$(abs_builddir)/\$(CODE_COVERAGE_OUTPUT_DIRECTORY)/index.html\"
-
-code-coverage-clean:
- -\$(LCOV) --directory \$(top_builddir) -z
- -rm -rf \"\$(CODE_COVERAGE_OUTPUT_FILE)\" \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" \"\$(CODE_COVERAGE_OUTPUT_DIRECTORY)\"
- -find . \\( -name \"*.gcda\" -o -name \"*.gcno\" -o -name \"*.gcov\" \\) -delete
-
-code-coverage-dist-clean:
-
-A][M_DISTCHECK_CONFIGURE_FLAGS = \$(A][M_DISTCHECK_CONFIGURE_FLAGS) --disable-code-coverage
- else # ifneq (\$(abs_builddir), \$(abs_top_builddir))
-check-code-coverage:
-
-code-coverage-capture: code-coverage-capture-hook
-
-code-coverage-clean:
-
-code-coverage-dist-clean:
- endif # ifeq (\$(abs_builddir), \$(abs_top_builddir))
-else #! CODE_COVERAGE_ENABLED
-# Use recursive makes in order to ignore errors during check
-check-code-coverage:
- @echo \"Need to reconfigure with --enable-code-coverage\"
-# Capture code coverage data
-code-coverage-capture: code-coverage-capture-hook
- @echo \"Need to reconfigure with --enable-code-coverage\"
-
-code-coverage-clean:
-
-code-coverage-dist-clean:
-
-endif #CODE_COVERAGE_ENABLED
-# Hook rule executed before code-coverage-capture, overridable by the user
-code-coverage-capture-hook:
-
-.PHONY: check-code-coverage code-coverage-capture code-coverage-dist-clean code-coverage-clean code-coverage-capture-hook
-])
-])
-
-AC_DEFUN([_AX_CODE_COVERAGE_ENABLED],[
- AX_CHECK_GNU_MAKE([],[AC_MSG_ERROR([not using GNU make that is needed for coverage])])
- AC_REQUIRE([AX_ADD_AM_MACRO_STATIC])
- # check for gcov
- AC_CHECK_TOOL([GCOV],
- [$_AX_CODE_COVERAGE_GCOV_PROG_WITH],
- [:])
- AS_IF([test "X$GCOV" = "X:"],
- [AC_MSG_ERROR([gcov is needed to do coverage])])
- AC_SUBST([GCOV])
-
- dnl Check if gcc is being used
- AS_IF([ test "$GCC" = "no" ], [
- AC_MSG_ERROR([not compiling with gcc, which is required for gcov code coverage])
- ])
-
- AC_CHECK_PROG([LCOV], [lcov], [lcov])
- AC_CHECK_PROG([GENHTML], [genhtml], [genhtml])
-
- AS_IF([ test x"$LCOV" = x ], [
- AC_MSG_ERROR([To enable code coverage reporting you must have lcov installed])
- ])
-
- AS_IF([ test x"$GENHTML" = x ], [
- AC_MSG_ERROR([Could not find genhtml from the lcov package])
- ])
-
- dnl Build the code coverage flags
- dnl Define CODE_COVERAGE_LDFLAGS for backwards compatibility
- CODE_COVERAGE_CPPFLAGS="-DNDEBUG"
- CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
- CODE_COVERAGE_CXXFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
- CODE_COVERAGE_LIBS="-lgcov"
-
- AC_SUBST([CODE_COVERAGE_CPPFLAGS])
- AC_SUBST([CODE_COVERAGE_CFLAGS])
- AC_SUBST([CODE_COVERAGE_CXXFLAGS])
- AC_SUBST([CODE_COVERAGE_LIBS])
-])
-
-AC_DEFUN([AX_CODE_COVERAGE],[
- dnl Check for --enable-code-coverage
-
- # allow to override gcov location
- AC_ARG_WITH([gcov],
- [AS_HELP_STRING([--with-gcov[=GCOV]], [use given GCOV for coverage (GCOV=gcov).])],
- [_AX_CODE_COVERAGE_GCOV_PROG_WITH=$with_gcov],
- [_AX_CODE_COVERAGE_GCOV_PROG_WITH=gcov])
-
- AC_MSG_CHECKING([whether to build with code coverage support])
- AC_ARG_ENABLE([code-coverage],
- AS_HELP_STRING([--enable-code-coverage],
- [Whether to enable code coverage support]),,
- enable_code_coverage=no)
-
- AM_CONDITIONAL([CODE_COVERAGE_ENABLED], [test "x$enable_code_coverage" = xyes])
- AC_SUBST([CODE_COVERAGE_ENABLED], [$enable_code_coverage])
- AC_MSG_RESULT($enable_code_coverage)
-
- AS_IF([ test "x$enable_code_coverage" = xyes ], [
- _AX_CODE_COVERAGE_ENABLED
- ])
-
- _AX_CODE_COVERAGE_RULES
-])
diff --git a/m4/ax_file_escapes.m4 b/m4/ax_file_escapes.m4
deleted file mode 100644
index a86fdc32..00000000
--- a/m4/ax_file_escapes.m4
+++ /dev/null
@@ -1,30 +0,0 @@
-# ===========================================================================
-# https://www.gnu.org/software/autoconf-archive/ax_file_escapes.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AX_FILE_ESCAPES
-#
-# DESCRIPTION
-#
-# Writes the specified data to the specified file.
-#
-# LICENSE
-#
-# Copyright (c) 2008 Tom Howard <tomhoward@users.sf.net>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved. This file is offered as-is, without any
-# warranty.
-
-#serial 8
-
-AC_DEFUN([AX_FILE_ESCAPES],[
-AX_DOLLAR="\$"
-AX_SRB="\\135"
-AX_SLB="\\133"
-AX_BS="\\\\"
-AX_DQ="\""
-])
diff --git a/m4/ld-version-script.m4 b/m4/ld-version-script.m4
deleted file mode 100644
index 228f52f5..00000000
--- a/m4/ld-version-script.m4
+++ /dev/null
@@ -1,43 +0,0 @@
-# ld-version-script.m4 serial 1
-dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Simon Josefsson
-
-# FIXME: The test below returns a false positive for mingw
-# cross-compiles, 'local:' statements does not reduce number of
-# exported symbols in a DLL. Use --disable-ld-version-script to work
-# around the problem.
-
-# gl_LD_VERSION_SCRIPT
-# --------------------
-# Check if LD supports linker scripts, and define automake conditional
-# HAVE_LD_VERSION_SCRIPT if so.
-AC_DEFUN([gl_LD_VERSION_SCRIPT],
-[
- AC_ARG_ENABLE([ld-version-script],
- AS_HELP_STRING([--enable-ld-version-script],
- [enable linker version script (default is enabled when possible)]),
- [have_ld_version_script=$enableval], [])
- if test -z "$have_ld_version_script"; then
- AC_MSG_CHECKING([if LD -Wl,--version-script works])
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
- cat > conftest.map <<EOF
-VERS_1 {
- global: sym;
-};
-
-VERS_2 {
- global: sym;
-} VERS_1;
-EOF
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
- [have_ld_version_script=yes], [have_ld_version_script=no])
- rm -f conftest.map
- LDFLAGS="$save_LDFLAGS"
- AC_MSG_RESULT($have_ld_version_script)
- fi
-])
diff --git a/m4/pkg.m4 b/m4/pkg.m4
deleted file mode 100644
index 64be7479..00000000
--- a/m4/pkg.m4
+++ /dev/null
@@ -1,155 +0,0 @@
-# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
-#
-# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# PKG_PROG_PKG_CONFIG([MIN-VERSION])
-# ----------------------------------
-AC_DEFUN([PKG_PROG_PKG_CONFIG],
-[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
-m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
-AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
-if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
- AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
-fi
-if test -n "$PKG_CONFIG"; then
- _pkg_min_version=m4_default([$1], [0.9.0])
- AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
- if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- PKG_CONFIG=""
- fi
-
-fi[]dnl
-])# PKG_PROG_PKG_CONFIG
-
-# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-#
-# Check to see whether a particular set of modules exists. Similar
-# to PKG_CHECK_MODULES(), but does not set variables or print errors.
-#
-#
-# Similar to PKG_CHECK_MODULES, make sure that the first instance of
-# this or PKG_CHECK_MODULES is called, or make sure to call
-# PKG_CHECK_EXISTS manually
-# --------------------------------------------------------------
-AC_DEFUN([PKG_CHECK_EXISTS],
-[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
-if test -n "$PKG_CONFIG" && \
- AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
- m4_ifval([$2], [$2], [:])
-m4_ifvaln([$3], [else
- $3])dnl
-fi])
-
-
-# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
-# ---------------------------------------------
-m4_define([_PKG_CONFIG],
-[if test -n "$$1"; then
- pkg_cv_[]$1="$$1"
- elif test -n "$PKG_CONFIG"; then
- PKG_CHECK_EXISTS([$3],
- [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
- [pkg_failed=yes])
- else
- pkg_failed=untried
-fi[]dnl
-])# _PKG_CONFIG
-
-# _PKG_SHORT_ERRORS_SUPPORTED
-# -----------------------------
-AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
-[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
- _pkg_short_errors_supported=yes
-else
- _pkg_short_errors_supported=no
-fi[]dnl
-])# _PKG_SHORT_ERRORS_SUPPORTED
-
-
-# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
-# [ACTION-IF-NOT-FOUND])
-#
-#
-# Note that if there is a possibility the first call to
-# PKG_CHECK_MODULES might not happen, you should be sure to include an
-# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
-#
-#
-# --------------------------------------------------------------
-AC_DEFUN([PKG_CHECK_MODULES],
-[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
-AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
-AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
-
-pkg_failed=no
-AC_MSG_CHECKING([for $1])
-
-_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
-_PKG_CONFIG([$1][_LIBS], [libs], [$2])
-
-m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
-and $1[]_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details.])
-
-if test $pkg_failed = yes; then
- _PKG_SHORT_ERRORS_SUPPORTED
- if test $_pkg_short_errors_supported = yes; then
- $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
- else
- $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
- fi
- # Put the nasty error message in config.log where it belongs
- echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
-
- ifelse([$4], , [AC_MSG_ERROR(dnl
-[Package requirements ($2) were not met:
-
-$$1_PKG_ERRORS
-
-Consider adjusting the PKG_CONFIG_PATH environment variable if you
-installed software in a non-standard prefix.
-
-_PKG_TEXT
-])],
- [AC_MSG_RESULT([no])
- $4])
-elif test $pkg_failed = untried; then
- ifelse([$4], , [AC_MSG_FAILURE(dnl
-[The pkg-config script could not be found or is too old. Make sure it
-is in your PATH or set the PKG_CONFIG environment variable to the full
-path to pkg-config.
-
-_PKG_TEXT
-
-To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
- [$4])
-else
- $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
- $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
- AC_MSG_RESULT([yes])
- ifelse([$3], , :, [$3])
-fi[]dnl
-])# PKG_CHECK_MODULES
diff --git a/m4/visibility.m4 b/m4/visibility.m4
deleted file mode 100644
index 552e3977..00000000
--- a/m4/visibility.m4
+++ /dev/null
@@ -1,77 +0,0 @@
-# visibility.m4 serial 5 (gettext-0.18.2)
-dnl Copyright (C) 2005, 2008, 2010-2014 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Bruno Haible.
-
-dnl Tests whether the compiler supports the command-line option
-dnl -fvisibility=hidden and the function and variable attributes
-dnl __attribute__((__visibility__("hidden"))) and
-dnl __attribute__((__visibility__("default"))).
-dnl Does *not* test for __visibility__("protected") - which has tricky
-dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
-dnl Mac OS X.
-dnl Does *not* test for __visibility__("internal") - which has processor
-dnl dependent semantics.
-dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
-dnl "really only recommended for legacy code".
-dnl Set the variable CFLAG_VISIBILITY.
-dnl Defines and sets the variable HAVE_VISIBILITY.
-
-AC_DEFUN([gl_VISIBILITY],
-[
- AC_REQUIRE([AC_PROG_CC])
- CFLAG_VISIBILITY=
- HAVE_VISIBILITY=0
- if test -n "$GCC"; then
- dnl First, check whether -Werror can be added to the command line, or
- dnl whether it leads to an error because of some other option that the
- dnl user has put into $CC $CFLAGS $CPPFLAGS.
- AC_MSG_CHECKING([whether the -Werror option is usable])
- AC_CACHE_VAL([gl_cv_cc_vis_werror], [
- gl_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror"
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([[]], [[]])],
- [gl_cv_cc_vis_werror=yes],
- [gl_cv_cc_vis_werror=no])
- CFLAGS="$gl_save_CFLAGS"])
- AC_MSG_RESULT([$gl_cv_cc_vis_werror])
- dnl Now check whether visibility declarations are supported.
- AC_MSG_CHECKING([for simple visibility declarations])
- AC_CACHE_VAL([gl_cv_cc_visibility], [
- gl_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -fvisibility=hidden"
- dnl We use the option -Werror and a function dummyfunc, because on some
- dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
- dnl "visibility attribute not supported in this configuration; ignored"
- dnl at the first function definition in every compilation unit, and we
- dnl don't want to use the option in this case.
- if test $gl_cv_cc_vis_werror = yes; then
- CFLAGS="$CFLAGS -Werror"
- fi
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
- extern __attribute__((__visibility__("default"))) int exportedvar;
- extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
- extern __attribute__((__visibility__("default"))) int exportedfunc (void);
- void dummyfunc (void) {}
- ]],
- [[]])],
- [gl_cv_cc_visibility=yes],
- [gl_cv_cc_visibility=no])
- CFLAGS="$gl_save_CFLAGS"])
- AC_MSG_RESULT([$gl_cv_cc_visibility])
- if test $gl_cv_cc_visibility = yes; then
- CFLAG_VISIBILITY="-fvisibility=hidden"
- HAVE_VISIBILITY=1
- fi
- fi
- AC_SUBST([CFLAG_VISIBILITY])
- AC_SUBST([HAVE_VISIBILITY])
- AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY],
- [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.])
-])
diff --git a/maint/i686-w64-mingw32.txt b/maint/i686-w64-mingw32.txt
new file mode 100644
index 00000000..dd92c458
--- /dev/null
+++ b/maint/i686-w64-mingw32.txt
@@ -0,0 +1,33 @@
+# Copyright 2018-2020 Meson contributors
+# SPDX-License-Identifier: Apache-2.0
+
+[binaries]
+c = '/usr/bin/i686-w64-mingw32-gcc'
+cpp = '/usr/bin/i686-w64-mingw32-g++'
+objc = '/usr/bin/i686-w64-mingw32-gcc'
+ar = '/usr/bin/i686-w64-mingw32-ar'
+strip = '/usr/bin/i686-w64-mingw32-strip'
+pkgconfig = '/usr/bin/i686-w64-mingw32-pkg-config'
+windres = '/usr/bin/i686-w64-mingw32-windres'
+exe_wrapper = ['xvfb-run', '-a', 'wine']
+ld = '/usr/bin/i686-w64-mingw32-ld'
+cmake = '/usr/bin/cmake'
+
+[properties]
+# Directory that contains 'bin', 'lib', etc
+root = '/usr/i686-w64-mingw32'
+# Directory that contains 'bin', 'lib', etc for the toolchain and system libraries
+sys_root = '/usr/i686-w64-mingw32/sys-root/mingw'
+
+[host_machine]
+system = 'windows'
+cpu_family = 'x86'
+cpu = 'i686'
+endian = 'little'
+
+[cmake]
+CMAKE_BUILD_WITH_INSTALL_RPATH = 'ON'
+CMAKE_FIND_ROOT_PATH_MODE_PROGRAM = 'NEVER'
+CMAKE_FIND_ROOT_PATH_MODE_LIBRARY = 'ONLY'
+CMAKE_FIND_ROOT_PATH_MODE_INCLUDE = 'ONLY'
+CMAKE_FIND_ROOT_PATH_MODE_PACKAGE = 'ONLY'
diff --git a/maint/release-checklist.md b/maint/release-checklist.md
new file mode 100644
index 00000000..ce2159b4
--- /dev/null
+++ b/maint/release-checklist.md
@@ -0,0 +1,89 @@
+# dbus release checklist
+
+To make a release of D-Bus, do the following:
+
+ - check out a fresh copy from Git
+
+ - verify that the libtool versioning/library soname is
+ changed if it needs to be, or not changed if not
+ - remember to update **both** `configure.ac` **and** `meson.build`
+ - CMake takes the version number from `meson.build` and so should not
+ need updating
+
+ - update the file NEWS based on the git history
+
+ - verify that the version number of dbus-specification.xml is
+ changed if it needs to be; if changes have been made, update the
+ release date in that file
+
+ - update the AUTHORS file with
+ `ninja -C ${builddir} maintainer-update-authors`
+ if necessary
+
+ - the version number should have major.minor.micro, even
+ if micro is 0, i.e. "1.0.0" and "1.2.0" not "1.0"/"1.2"; the micro
+ version should be even for releases, and odd for intermediate snapshots
+ - remember to update **both** `configure.ac` **and** `meson.build`
+ - CMake takes the version number from `meson.build` and so should not
+ need updating
+
+ - `meson dist -C ${builddir)`
+ (this is the equivalent of Autotools `make distcheck`)
+
+ - if `meson dist` failed, fix it.
+
+ - once dist succeeds, `git commit -a`. This is the version
+ of the tree that corresponds exactly to the released tarball.
+
+ - tag the tree with `git tag -s -m 'Released X.Y.Z' dbus-X.Y.Z`
+ where X.Y.Z is the version of the release. If you can't sign
+ then simply created an unsigned annotated tag:
+ `git tag -a -m 'Released X.Y.Z' dbus-X.Y.Z`.
+
+ - bump the version number up in `configure.ac` and `meson.build`
+ again (so the micro version is odd),
+ and commit it. Make sure you do this *after* tagging the previous
+ release! The idea is that git has a newer version number
+ than anything released. Similarly, bump the version number of
+ dbus-specification.xml and set the release date to "(not finalized)".
+
+ - push your changes and the tag to the central repository with
+ `git push origin master dbus-X.Y dbus-X.Y.Z`
+
+ - scp your tarball to freedesktop.org server and copy it to
+ `dbus.freedesktop.org:/srv/dbus.freedesktop.org/www/releases/dbus/dbus-X.Y.Z.tar.xz`.
+ This should be possible if you're in group "dbus"
+
+ - Update the online documentation with
+ `ninja -C ${builddir} maintainer-upload-docs`.
+
+ - update the wiki page http://www.freedesktop.org/Software/dbus by
+ adding the new release under the Download heading. Then, cut the
+ link and changelog for the previous that was there.
+
+ - post to dbus@lists.freedesktop.org announcing the release.
+
+## Making a ".0" stable release
+
+We create a branch for each stable release. The branch name should be
+dbus-X.Y which is a branch that has releases versioned X.Y.Z;
+changes on a stable branch should be limited to significant bug fixes.
+
+Because we won't make minor changes like keeping up with the latest
+deprecations on a stable branch, stable branches should turn off the
+gcc warning for deprecated declarations (e.g. see commit 4ebb275ab7).
+
+Be extra-careful not to merge master (or any branch based on master) into a
+stable branch.
+
+To branch:
+
+ git branch dbus-X.Y
+
+and upload the branch tag to the server:
+
+ git push origin dbus-X.Y
+
+To develop in this branch:
+
+ git checkout dbus-X.Y
diff --git a/maint/update-authors.sh b/maint/update-authors.sh
new file mode 100755
index 00000000..c8d5c3f4
--- /dev/null
+++ b/maint/update-authors.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Copyright 2010 Lennart Poettering
+# Copyright 2022 Simon McVittie
+# SPDX-License-Identifier: MIT
+
+set -eux
+
+if [ -n "${MESON_SOURCE_ROOT-}" ]; then
+ cd "${MESON_SOURCE_ROOT}"
+fi
+
+git shortlog -s -e | cut -c 8- | sort > AUTHORS
diff --git a/maint/x86_64-w64-mingw32.txt b/maint/x86_64-w64-mingw32.txt
new file mode 100644
index 00000000..80c3607a
--- /dev/null
+++ b/maint/x86_64-w64-mingw32.txt
@@ -0,0 +1,33 @@
+# Copyright 2018-2020 Meson contributors
+# SPDX-License-Identifier: Apache-2.0
+
+[binaries]
+c = '/usr/bin/x86_64-w64-mingw32-gcc'
+cpp = '/usr/bin/x86_64-w64-mingw32-g++'
+objc = '/usr/bin/x86_64-w64-mingw32-gcc'
+ar = '/usr/bin/x86_64-w64-mingw32-ar'
+strip = '/usr/bin/x86_64-w64-mingw32-strip'
+pkgconfig = '/usr/bin/x86_64-w64-mingw32-pkg-config'
+windres = '/usr/bin/x86_64-w64-mingw32-windres'
+exe_wrapper = ['xvfb-run', '-a', 'wine']
+ld = '/usr/bin/x86_64-w64-mingw32-ld'
+cmake = '/usr/bin/cmake'
+
+[properties]
+# Directory that contains 'bin', 'lib', etc
+root = '/usr/x86_64-w64-mingw32'
+# Directory that contains 'bin', 'lib', etc for the toolchain and system libraries
+sys_root = '/usr/x86_64-w64-mingw32/sys-root/mingw'
+
+[host_machine]
+system = 'windows'
+cpu_family = 'x86_64'
+cpu = 'x86_64'
+endian = 'little'
+
+[cmake]
+CMAKE_BUILD_WITH_INSTALL_RPATH = 'ON'
+CMAKE_FIND_ROOT_PATH_MODE_PROGRAM = 'NEVER'
+CMAKE_FIND_ROOT_PATH_MODE_LIBRARY = 'ONLY'
+CMAKE_FIND_ROOT_PATH_MODE_INCLUDE = 'ONLY'
+CMAKE_FIND_ROOT_PATH_MODE_PACKAGE = 'ONLY'
diff --git a/meson.build b/meson.build
new file mode 100644
index 00000000..19b41cd9
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,1381 @@
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+project('dbus',
+ 'c',
+ version: '1.15.9',
+ meson_version: '>=0.56',
+)
+
+project_url = 'https://gitlab.freedesktop.org/dbus/dbus'
+
+cc = meson.get_compiler('c')
+
+windows = import('windows')
+pkgconfig = import('pkgconfig')
+
+config = configuration_data()
+# Used for dbus-arch-deps.h, separated from config.h
+arch_config = configuration_data()
+# Non-quoted variables
+data_config = configuration_data()
+
+install_emptydirs = []
+install_symlinks = []
+
+###############################################################################
+# Project configuration
+
+not_found = dependency('', required: false)
+
+version = meson.project_version()
+config.set_quoted('VERSION', version)
+data_config.set('VERSION', version)
+data_config.set('DBUS_VERSION', version)
+
+ver_array = version.split('.')
+arch_config.set('DBUS_VERSION', version)
+arch_config.set('DBUS_MAJOR_VERSION', ver_array[0])
+arch_config.set('DBUS_MINOR_VERSION', ver_array[1])
+arch_config.set('DBUS_MICRO_VERSION', ver_array[2])
+
+config.set_quoted('DBUS_DAEMON_NAME', 'dbus-daemon')
+
+###############################################################################
+# libtool versioning - this applies to libdbus
+# http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91
+#
+# These variables are parsed automatically by cmake/modules/MacrosMeson.cmake,
+# be careful if changing the formatting
+
+## increment if the interface has additions, changes, removals.
+lt_current = 41
+## increment any time the source changes;
+## set to 0 if you increment CURRENT
+lt_revision = 0
+## increment if any interfaces have been added;
+## set to 0 if any interfaces have been changed or removed.
+## removal has precedence over adding, so set to 0 if both happened.
+lt_age = 38
+
+soversion = (lt_current - lt_age)
+version_info = '@0@.@1@.@2@'.format(soversion, lt_age, lt_revision)
+
+data_config.set('SOVERSION', soversion)
+
+###############################################################################
+# System detection
+
+python = find_program('python3')
+
+host_os = host_machine.system()
+
+platform_windows = host_os.contains('windows')
+
+if platform_windows
+ # On Windows, we use C++ constructors to initialize global locks
+ using_cpp = true
+ add_languages('cpp', required: true, native: false)
+ cpp = meson.get_compiler('cpp')
+else
+ using_cpp = false
+endif
+
+platform_cygwin = host_os.contains('cygwin')
+
+# TODO: meson doesn't actually have WinCE support
+platform_win32ce = host_os.contains('mingw32ce')
+
+platform_unix = not platform_windows
+
+config.set('DBUS_UNIX', platform_unix)
+config.set('DBUS_CYGWIN', platform_cygwin)
+config.set('DBUS_WIN', platform_windows)
+config.set('DBUS_WINCE', platform_win32ce)
+
+if platform_unix
+ platform = 'Unix'
+elif platform_cygwin
+ platform = 'cygwin'
+elif platform_win32ce
+ platform = 'win32ce'
+elif platform_windows
+ platform = 'windows'
+else
+ platform = 'unknown'
+endif
+message('Detected platform : @0@ (@1@)'.format(platform, host_os))
+
+if platform_windows
+ config.set('FD_SETSIZE', 8192,
+ description: 'The maximum number of connections that can be handled at once'
+ )
+ if platform_win32ce
+ config.set('_WIN32_WCE', '0x0502', description: 'Get newer W32 CE APIs')
+ else
+ config.set('_WIN32_WINNT', '0x0600',
+ description: 'Define to the minimum supported Windows version (Vista)'
+ )
+ endif
+
+ build_timestamp = run_command(
+ find_program('tools/build-timestamp.py'),
+ check: true,
+ ).stdout().strip()
+
+ data_config.set('BUILD_TIMESTAMP', build_timestamp)
+ data_config.set('BUILD_FILEVERSION', ','.join(version.split('.')))
+
+ data_config.set('DBUS_VER_FILE_TYPE', 'VFT_DLL')
+ data_config.set('DBUS_VER_INTERNAL_NAME', 'libdbus-1-@0@' .format(soversion))
+ data_config.set('DBUS_VER_ORIGINAL_NAME', 'libdbus-1-@0@.dll' .format(soversion))
+endif
+
+if platform_windows
+ conf_maybe_external = '<!--<auth>EXTERNAL</auth>-->'
+else
+ conf_maybe_external = '<auth>EXTERNAL</auth>'
+endif
+data_config.set('DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL', conf_maybe_external)
+
+###############################################################################
+# Functionally necessary compiler arguments
+# Note that these must be set up before we do any checks like
+# cc.has_header_symbol, otherwise we'll fail to find symbols that only exist
+# when a particular feature-test macro like _GNU_SOURCE is defined.
+
+compile_args = [
+ '-D_GNU_SOURCE',
+]
+
+# dbus makes assumptions about aliasing that Standard C does not guarantee,
+# particularly in DBusString.
+# See https://gitlab.freedesktop.org/dbus/dbus/-/issues/4
+compile_args += ['-fno-strict-aliasing']
+
+if host_os.contains('solaris')
+ compile_args += [
+ # Solaris' C library apparently needs these runes to be threadsafe...
+ '-D_POSIX_PTHREAD_SEMANTICS',
+ # ... this opt-in to get sockaddr_in6 and sockaddr_storage...
+ '-D__EXTENSIONS__',
+ # ... and this opt-in to get file descriptor passing support
+ ' -D_XOPEN_SOURCE=500',
+ ]
+endif
+
+dbus_static_flags = ( get_option('default_library') == 'static'
+ ? [ '-DDBUS_STATIC_BUILD' ]
+ : []
+)
+compile_args += dbus_static_flags
+
+if cc.get_id() != 'msvc'
+ compile_args += [
+ # On Windows, we expect to be using msvcrt.dll-compatible printf
+ # (%I64u instead of %llu)
+ '-D__USE_MINGW_ANSI_STDIO=0',
+ ]
+endif
+
+compile_args_c = cc.get_supported_arguments(compile_args)
+add_project_arguments(compile_args_c, language: 'c')
+
+if using_cpp
+ compile_args_cpp = cpp.get_supported_arguments(compile_args)
+ add_project_arguments(compile_args_cpp, language: 'cpp')
+endif
+
+# Try to use hidden visibility on Unix. We don't do this on Windows to avoid
+# interfering with use of __declspec(dllexport) and __declspec(dllimport),
+# which have a similar effect.
+if cc.has_argument('-fvisibility=hidden') and not platform_windows
+ default_visibility = '__attribute__ ((__visibility__ ("default")))'
+ test_visibility = '''
+@0@ void public_func (void);
+@0@ int public_var;
+int main (void) { return 0; }
+'''.format(default_visibility)
+
+ if cc.compiles(test_visibility, args: compile_args_c + ['-fvisibility=hidden'])
+ add_project_arguments(['-fvisibility=hidden'], language: 'c')
+ config.set('DBUS_PRIVATE_EXPORT', default_visibility)
+ config.set('DBUS_EXPORT', default_visibility)
+ # If we were using C++ then we'd need to add -fvisibility=hidden
+ # to the C++ arguments too, but that's not currently applicable here.
+ assert(not using_cpp, 'C++ only used on Windows')
+ endif
+endif
+
+if host_machine.endian() == 'big'
+ config.set('WORDS_BIGENDIAN', 1)
+endif
+
+# Integer sizes
+int_types = [
+ {
+ 'type': 'short',
+ 'size': cc.sizeof('short'),
+ }, {
+ 'type': 'int',
+ 'size': cc.sizeof('int'),
+ 'type_c': '(val)',
+ 'type_u_c': '(val)',
+ 'type_m': '',
+ }, {
+ 'type': 'long',
+ 'size': cc.sizeof('long'),
+ 'type_c': '(val##L)',
+ 'type_u_c': '(val##UL)',
+ 'type_m': 'l',
+ }, {
+ 'type': 'long long',
+ 'size': cc.sizeof('long long'),
+ 'type_c': '(val##LL)',
+ 'type_u_c': '(val##ULL)',
+ 'type_m': 'll',
+ }, {
+ 'type': '__int64',
+ 'size': cc.sizeof('__int64'),
+ 'type_c': '(val##i64)',
+ 'type_u_c': '(val##ui64)',
+ 'type_m': 'I64',
+ }, {
+ 'type': 'err'
+ },
+]
+
+foreach type : int_types
+ if type.get('type') == 'err'
+ error('Could not find a 64-bit integer type.')
+ endif
+ if type.get('size') == 8
+ arch_config.set('DBUS_INT64_TYPE', type.get('type'))
+ arch_config.set('DBUS_INT64_CONSTANT', type.get('type_c'))
+ arch_config.set('DBUS_UINT64_CONSTANT', type.get('type_u_c'))
+ if platform_windows
+ # MSVCRT.dll printf() doesn't support %lld
+ arch_config.set('DBUS_INT64_MODIFIER', 'I64')
+ else
+ arch_config.set('DBUS_INT64_MODIFIER', type.get('type_m'))
+ endif
+ break
+ endif
+endforeach
+
+foreach type : int_types
+ if type.get('type') == 'err'
+ error('Could not find a 32-bit integer type.')
+ endif
+ if type.get('size') == 4
+ arch_config.set('DBUS_INT32_TYPE', type.get('type'))
+ break
+ endif
+endforeach
+
+foreach type : int_types
+ if type.get('type') == 'err'
+ error('Could not find a 16-bit integer type.')
+ endif
+ if type.get('size') == 2
+ arch_config.set('DBUS_INT16_TYPE', type.get('type'))
+ break
+ endif
+endforeach
+
+arch_config.set('DBUS_SIZEOF_VOID_P', cc.sizeof('void *'))
+
+###############################################################################
+# Dependencies
+
+xsltproc = find_program('xsltproc', required: get_option('xml_docs'))
+build_xml_docs = false
+
+if xsltproc.found()
+ build_xml_docs = true
+ foreach fmt: [ 'html', 'manpages' ]
+ xsl = 'http://docbook.sourceforge.net/release/xsl/current/@0@/docbook.xsl'.format(fmt)
+ if run_command([xsltproc, '--nonet', xsl], check : false).returncode() == 0
+ continue
+ endif
+
+ build_xml_docs = false
+ if get_option('xml_docs').enabled()
+ error('Docbook XSL "@0@" not found'.format(fmt))
+ else
+ message('Docbook XSL "@0@" not found, disabled automatically'.format(fmt))
+ endif
+ endforeach
+endif
+
+# For doxygen
+doxygen = find_program('doxygen', required: get_option('doxygen_docs'))
+ducktype = find_program('ducktype', required: get_option('ducktype_docs'))
+yelpbuild = find_program('yelp-build', required: get_option('ducktype_docs'))
+
+can_upload_docs = doxygen.found() and xsltproc.found() and ducktype.found()
+
+qhelpgen = find_program('qhelpgenerator', 'qhelpgenerator-qt5', required: get_option('qt_help'))
+qt_help_generate = doxygen.found() and qhelpgen.found()
+
+data_config.set('DBUS_GENERATE_MAN', platform_windows ? 'NO' : 'YES')
+data_config.set('DOXYGEN_QCH_FILE', meson.current_build_dir()
+ / 'doc' / 'api' / 'qch' / 'dbus-@0@.qch'.format(version))
+if qhelpgen.found()
+ data_config.set('DOXYGEN_QHG_LOCATION', qhelpgen.full_path())
+ data_config.set('DOXYGEN_GENERATE_QHP', 'YES')
+else
+ data_config.set('DOXYGEN_QHG_LOCATION', '')
+ data_config.set('DOXYGEN_GENERATE_QHP', 'NO')
+endif
+data_config.set('top_srcdir', meson.project_source_root())
+data_config.set('top_builddir', meson.project_build_root())
+
+
+threads = dependency('threads')
+config.set(
+ 'HAVE_MONOTONIC_CLOCK',
+ cc.has_header_symbol('pthread.h', 'CLOCK_MONOTONIC', args: compile_args_c)
+ and cc.has_header_symbol('pthread.h', 'pthread_condattr_setclock', args: compile_args_c)
+ and cc.has_header_symbol('time.h', 'clock_getres', args: compile_args_c),
+)
+
+# Controls whether message bus daemon is built. Tests which depend on
+# a running dbus-daemon will be disabled if message_bus is not set.
+message_bus = get_option('message_bus')
+
+if get_option('modular_tests').disabled()
+ glib = dependency('', required: false)
+else
+ glib = dependency(
+ 'glib-2.0', version: '>=2.40',
+ required: get_option('modular_tests'),
+ fallback: ['glib', 'libglib_dep'],
+ default_options: [
+ 'tests=false',
+ ],
+ )
+endif
+
+if glib.found()
+ if platform_windows
+ gio = dependency('gio-windows-2.0', required: glib.found())
+ have_gio_unix = false
+ else
+ gio = dependency('gio-unix-2.0', required: glib.found())
+ have_gio_unix = gio.found()
+ endif
+else
+ gio = dependency('', required: false)
+ have_gio_unix = false
+endif
+use_glib = glib.found() and gio.found()
+config.set('DBUS_WITH_GLIB', use_glib)
+
+if message_bus
+ expat = dependency('expat')
+else
+ expat = dependency('', required: false)
+endif
+
+if expat.type_name() == 'internal'
+ # Configure-time checks can't act on subprojects that haven't been
+ # built yet, but we know that subprojects/expat.wrap is a new enough
+ # version to have this
+ config.set('HAVE_XML_SETHASHSALT', true)
+else
+ config.set('HAVE_XML_SETHASHSALT', cc.has_function('XML_SetHashSalt', dependencies: expat))
+endif
+
+selinux = dependency('libselinux', version: '>=2.0.86', required: get_option('selinux'))
+
+# the selinux code creates threads which requires libpthread even on linux
+# TODO: smcv: actually we've stopped doing that. We still include <pthread.h> in
+# selinux.c (but probably shouldn't), and we don't actually create the thread;
+# so this can probably be simplified.
+config.set('HAVE_SELINUX', selinux.found() and threads.found())
+
+apparmor = dependency('libapparmor', version: '>=2.8.95', required: get_option('apparmor'))
+config.set('HAVE_APPARMOR', apparmor.found())
+config.set('HAVE_APPARMOR_2_10', apparmor.version().version_compare('>=2.10'))
+
+if get_option('inotify').disabled()
+ use_inotify = false
+else
+ use_inotify = cc.has_header('sys/inotify.h', args: compile_args_c)
+ if get_option('inotify').enabled() and not use_inotify
+ error('inotify support requested but not found')
+ endif
+endif
+
+if get_option('epoll').disabled()
+ use_linux_epoll = false
+else
+ use_linux_epoll = (
+ cc.has_header('sys/epoll.h', args: compile_args_c) and
+ cc.has_function(
+ 'epoll_create1',
+ prefix: '#include <sys/epoll.h>',
+ args: compile_args_c,
+ )
+ )
+ if get_option('epoll').enabled() and not use_linux_epoll
+ error('epoll support requested but not found')
+ endif
+endif
+config.set('DBUS_HAVE_LINUX_EPOLL', use_linux_epoll)
+
+if get_option('kqueue').disabled()
+ use_kqueue = false
+else
+ use_kqueue = (
+ cc.has_header('sys/event.h', args: compile_args_c) and
+ cc.has_function(
+ 'kqueue',
+ prefix: '#include <sys/event.h>',
+ args: compile_args_c,
+ )
+ )
+ if get_option('kqueue').enabled() and not use_kqueue
+ error('kqueue support requested but not found')
+ endif
+endif
+config.set('DBUS_BUS_ENABLE_KQUEUE', use_kqueue)
+
+if get_option('launchd').disabled()
+ use_launchd = false
+else
+ launchctl = find_program('launchctl', required: get_option('launchd'))
+ use_launchd = cc.has_header('launch.h', args: compile_args_c) and launchctl.found()
+ if get_option('launchd').enabled() and not use_launchd
+ error('launchd support requested but not found')
+ endif
+endif
+config.set('DBUS_BUS_ENABLE_LAUNCHD', use_launchd)
+
+if use_launchd
+ launchd_agent_dir = get_option('launchd_agent_dir')
+ if launchd_agent_dir == ''
+ launchd_agent_dir = '/Library/LaunchAgents'
+ endif
+endif
+
+systemd = dependency('libsystemd', version: '>=209', required: get_option('systemd'))
+use_systemd = systemd.found()
+config.set('HAVE_SYSTEMD', use_systemd)
+
+if use_systemd
+ # If not found in $PATH, we might still have systemd and systemctl at runtime
+ # (perhaps dbus is being compiled in a minimal chroot with no systemd).
+ # Assume the upstream-recommended location. Distributors with split /usr
+ # can override this with --native-file (see https://mesonbuild.com/Machine-files.html)
+ systemctl = find_program('systemctl', required: false)
+ if systemctl.found()
+ systemctl = systemctl.full_path()
+ else
+ systemctl = '/usr/bin/systemctl'
+ endif
+
+ systemd_system_unitdir = get_option('systemd_system_unitdir')
+ systemd_user_unitdir = get_option('systemd_user_unitdir')
+
+ systemd_dirs = dependency('systemd', required: false)
+ if systemd_system_unitdir == ''
+ systemd_system_unitdir = (systemd_dirs.found()
+ ? systemd_dirs.get_variable(pkgconfig: 'systemdsystemunitdir')
+ : '/lib/systemd/system'
+ )
+ endif
+ if systemd_user_unitdir == ''
+ systemd_user_unitdir = (systemd_dirs.found()
+ ? systemd_dirs.get_variable(pkgconfig: 'systemduserunitdir')
+ : '/usr/lib/systemd/user'
+ )
+ endif
+else
+ systemctl = ''
+endif
+data_config.set('SYSTEMCTL', systemctl)
+
+
+
+use_traditional_activation = message_bus and get_option('traditional_activation')
+config.set('ENABLE_TRADITIONAL_ACTIVATION', use_traditional_activation)
+
+if not (use_systemd or use_traditional_activation)
+ warning('Traditional activation and systemd activation are both disabled, '
+ + 'so service activation (automatically starting services that '
+ + 'receive messages) will not work')
+endif
+
+
+have_console_owner_file = false
+console_owner_file = get_option('solaris_console_owner_file')
+if console_owner_file != ''
+ if not host_os.contains('solaris')
+ error('solaris_console_owner_file is only supported on Solaris)')
+ endif
+ have_console_owner_file = true
+ if console_owner_file == 'auto'
+ console_owner_file = '/dev/console'
+ else
+ endif
+endif
+config.set('HAVE_CONSOLE_OWNER_FILE', have_console_owner_file)
+config.set_quoted('DBUS_CONSOLE_OWNER_FILE', console_owner_file)
+
+if get_option('libaudit').disabled()
+ have_libaudit = false
+else
+ libaudit = cc.find_library('audit', required: false)
+ libaudit_ok = cc.has_function('audit_log_user_avc_message', dependencies: libaudit)
+ cap_ng = cc.find_library('cap-ng', required: false)
+ cap_ng_ok = cc.has_function('capng_clear', dependencies: cap_ng)
+ have_libaudit = libaudit_ok and cap_ng_ok
+ if get_option('libaudit').enabled() and not have_libaudit
+ error('libaudit support requested but not found')
+ endif
+ # For the systemd system unit
+ data_config.set('AMBIENT_CAPS', 'AmbientCapabilities=CAP_AUDIT_WRITE')
+endif
+config.set('HAVE_LIBAUDIT', have_libaudit)
+
+if have_libaudit
+ selinux = [ selinux, libaudit, cap_ng ]
+endif
+
+# Check for ADT API (Solaris Basic Security Mode auditing)
+adt_api_check = cc.compiles('''
+#include <bsm/adt.h>
+int main() {
+ adt_user_context = ADT_USER;
+ return 0;
+}
+''', args: compile_args_c)
+config.set('HAVE_ADT', adt_api_check)
+if adt_api_check
+ adt_libs = cc.find_library('bsm')
+else
+ adt_libs = dependency('', required: false)
+endif
+
+# Check for SCM_RIGHTS
+has_scm_rights = cc.compiles('''
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+int main() {
+ static int x = SCM_RIGHTS;
+ return 0;
+}
+''', args: compile_args_c)
+config.set('HAVE_UNIX_FD_PASSING', has_scm_rights)
+
+valgrind = dependency(
+ 'valgrind',
+ version: '>=3.6',
+ required: get_option('valgrind'),
+)
+config.set('WITH_VALGRIND', valgrind.found())
+
+if platform_win32ce
+ network_libs = [
+ cc.find_library('ws2'),
+ ]
+elif platform_windows
+ network_libs = [
+ cc.find_library('ws2_32'),
+ cc.find_library('iphlpapi'),
+ cc.find_library('dbghelp'),
+ ]
+else
+ network_libs = []
+endif
+
+if get_option('x11_autolaunch').disabled()
+ use_x11_autolaunch = false
+ x11 = not_found
+else
+ if get_option('x11_autolaunch').enabled() and platform_windows
+ error('X11 autolaunch is not supported on Windows')
+ endif
+
+ x11 = dependency('x11', required: false)
+ use_x11_autolaunch = x11.found()
+
+ if get_option('x11_autolaunch').enabled() and not use_x11_autolaunch
+ error('X11 autolaunch support requested but not found')
+ endif
+endif
+config.set('DBUS_BUILD_X11', use_x11_autolaunch)
+config.set('DBUS_ENABLE_X11_AUTOLAUNCH', use_x11_autolaunch)
+
+# Opt-in to large timestamp support, which we know doesn't break libdbus ABI:
+# https://gitlab.freedesktop.org/dbus/dbus/-/issues/465
+# Meson does the equivalent for large offsets and inode numbers automatically.
+if (
+ cc.has_header_symbol('time.h', '__GLIBC__', args: compile_args_c)
+ and not cc.has_header_symbol('time.h', '_TIME_BITS', args: compile_args_c)
+ and cc.sizeof('void *') == 4
+)
+ config.set('_TIME_BITS', '64')
+endif
+
+# keep CMakeLists.txt in sync
+check_functions = [
+ 'accept4',
+ 'clearenv',
+ 'closefrom',
+ 'close_range',
+ 'fpathconf',
+ 'getgrouplist',
+ 'getpeereid',
+ 'getpeerucred',
+ 'getpwnam_r',
+ 'getrandom',
+ 'getresuid',
+ 'getrlimit',
+ 'inotify_init1',
+ 'issetugid',
+ 'localeconv',
+ 'nanosleep',
+ 'pipe2',
+ 'poll',
+ 'prctl',
+ 'prlimit',
+ 'raise',
+ 'setenv',
+ 'setlocale',
+ 'setresuid',
+ 'setrlimit',
+ 'socketpair',
+ 'unsetenv',
+ 'usleep',
+]
+
+foreach function : check_functions
+ macro = 'HAVE_' + function.underscorify().to_upper()
+ config.set(macro, cc.has_function(function, args: compile_args_c) ? 1 : false)
+endforeach
+
+# keep CMakeLists.txt in sync
+check_headers = [
+ 'afunix.h',
+ 'alloca.h',
+ 'byteswap.h',
+ 'crt_externs.h',
+ 'dirent.h',
+ 'errno.h',
+ 'inttypes.h',
+ 'io.h',
+ 'locale.h',
+ 'linux/close_range.h',
+ 'linux/magic.h',
+ 'locale.h',
+ 'signal.h',
+ 'stdatomic.h',
+ 'syslog.h',
+ 'sys/prctl.h',
+ 'sys/random.h',
+ 'sys/resource.h',
+ 'sys/syscall.h',
+ 'sys/time.h',
+ 'sys/vfs.h',
+ 'unistd.h',
+ 'ws2tcpip.h',
+]
+
+foreach header : check_headers
+ macro = 'HAVE_' + header.underscorify().to_upper()
+ config.set(macro, cc.check_header(header, args: compile_args_c) ? 1 : false)
+endforeach
+
+execinfo = cc.find_library('execinfo', required: false)
+have_backtrace = (cc.has_header('execinfo.h', args: compile_args_c)
+ and cc.has_function('backtrace', dependencies: execinfo, args: compile_args_c)
+)
+config.set('HAVE_BACKTRACE', have_backtrace)
+
+# Can't use cc.has_function here because atomic operations are not
+# exactly functions
+config.set10(
+ 'DBUS_USE_SYNC',
+ cc.links('''
+ int main(void)
+ {
+ int a = 4;
+ int b = __sync_sub_and_fetch (&a, 4);
+ return b;
+ }
+ ''', args: compile_args_c)
+)
+
+config.set10(
+ 'HAVE_DECL_ENVIRON',
+ cc.has_header_symbol('unistd.h', 'environ', args: compile_args_c),
+)
+config.set10('HAVE_DECL_LOG_PERROR',
+ cc.has_header_symbol('syslog.h', 'LOG_PERROR', args: compile_args_c),
+)
+config.set10('HAVE_DECL_MSG_NOSIGNAL',
+ cc.has_header_symbol(
+ 'sys/socket.h',
+ 'MSG_NOSIGNAL',
+ args: compile_args_c,
+ ),
+)
+config.set('HAVE_SOCKLEN_T',
+ cc.has_type(
+ 'socklen_t',
+ prefix: '#include <sys/socket.h>',
+ args: compile_args_c,
+ )
+)
+config.set('HAVE_CMSGCRED',
+ cc.has_type(
+ 'struct cmsgcred',
+ prefix: '#include <sys/socket.h>',
+ args: compile_args_c,
+ )
+)
+
+config.set('HAVE_WRITEV',
+ cc.has_header_symbol(
+ 'sys/uio.h',
+ 'writev',
+ args: compile_args_c,
+ )
+)
+
+config.set('HAVE_UNPCBID',
+ cc.has_member(
+ 'struct unpcbid',
+ 'unp_pid',
+ prefix: '#include <sys/un.h>',
+ args: compile_args_c,
+ )
+)
+
+config.set('HAVE_FSTATFS',
+ cc.has_function(
+ 'fstatfs',
+ prefix : '#include <sys/vfs.h>',
+ args: compile_args_c,
+ )
+)
+
+config.set10('HAVE_DECL_SYS_PIDFD_OPEN',
+ cc.has_header_symbol(
+ 'sys/syscall.h',
+ 'SYS_pidfd_open',
+ args: compile_args_c,
+ )
+)
+
+###############################################################################
+# Project options
+
+warning_args = []
+link_args = []
+
+# Verbose mode
+verbose_mode = get_option('verbose_mode')
+config.set('DBUS_ENABLE_VERBOSE_MODE', verbose_mode)
+
+# Asserts defaults to developer mode
+asserts = get_option('asserts')
+config.set('DBUS_ENABLE_ASSERT', asserts ? 1 : false)
+config.set('DBUS_DISABLE_ASSERT', not asserts ? 1 : false)
+
+# -rdynamic is needed for glibc's backtrace_symbols to work.
+# No clue how much overhead this adds, but it's useful
+# to do this on any assertion failure,
+# so for now it's enabled anytime asserts are (currently not
+# in production builds).
+# To get -rdynamic you pass -export-dynamic to libtool.
+config.set('DBUS_BUILT_R_DYNAMIC', asserts ? 1 : false)
+if asserts
+ link_args += '-export-dynamic'
+endif
+
+if not asserts
+ warning_args += [
+ '-Wno-unused-function',
+ ]
+endif
+
+checks = get_option('checks')
+config.set('DBUS_ENABLE_CHECKS', checks ? 1 : false)
+config.set('DBUS_DISABLE_CHECKS', not checks ? 1 : false)
+config.set('G_DISABLE_CHECKS', not checks ? 1 : false)
+config.set('HAVE_GIO_UNIX', have_gio_unix ? 1 : false)
+# Ignore post-2.38 deprecations, prevent use of post-2.44 APIs.
+# keep in sync with CMakeLists.txt
+config.set('GLIB_VERSION_MIN_REQUIRED', 'GLIB_VERSION_2_38')
+config.set('GLIB_VERSION_MAX_ALLOWED', 'G_ENCODE_VERSION(2,44)')
+
+if not checks
+ warning_args += [
+ '-Wno-unused-label',
+ ]
+endif
+
+if not (asserts and checks)
+ warning_args += [
+ '-Wno-unused-but-set-variable',
+ '-Wno-unused-variable',
+ ]
+endif
+
+windows_output_debug = get_option('windows_output_debug_string')
+config.set('DBUS_USE_OUTPUT_DEBUG_STRING', windows_output_debug)
+
+# Controls whether the tools are built.
+tools = get_option('tools')
+
+# DBUS_ENABLE_EMBEDDED_TESTS controls unit tests built in to .c files
+# and some stuff in the test/ subdir.
+embedded_tests = get_option('embedded_tests')
+config.set('DBUS_ENABLE_EMBEDDED_TESTS', embedded_tests)
+
+
+# DBUS_ENABLE_MODULAR_TESTS controls tests that work based on public API.
+# These use GTest, from GLib, because life's too short. They're enabled by
+# default (unless you don't have GLib), because they don't bloat the library
+# or binaries.
+dbus_enable_modular_tests = (
+ not get_option('modular_tests').disabled()
+ and glib.version().version_compare('>=2.40')
+ and gio.found()
+)
+
+###############################################################################
+# Paths and directories
+
+docs_dir = get_option('datadir') / 'doc' / 'dbus'
+
+# TODO: If a future Meson version gets a runstatedir option, try both.
+# https://github.com/mesonbuild/meson/issues/4141
+runstatedir = get_option('runtime_dir')
+
+if runstatedir == ''
+ if get_option('prefix') == '/usr'
+ runstatedir = '/run'
+ else
+ runstatedir = get_option('localstatedir') / 'run'
+ endif
+endif
+
+data_config.set('EXPANDED_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
+data_config.set('EXPANDED_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
+data_config.set('EXPANDED_RUNSTATEDIR', get_option('prefix') / runstatedir)
+data_config.set('EXPANDED_BINDIR', get_option('prefix') / get_option('bindir'))
+data_config.set('EXPANDED_DATADIR', get_option('prefix') / get_option('datadir'))
+
+data_config.set('DBUS_PREFIX', get_option('prefix'))
+config.set_quoted('DBUS_PREFIX', get_option('prefix'))
+config.set_quoted('DBUS_BINDIR', get_option('prefix') / get_option('bindir'))
+config.set_quoted('DBUS_DATADIR',get_option('prefix') / get_option('datadir'))
+data_config.set('DBUS_LIBEXECDIR', get_option('prefix') / get_option('libexecdir'))
+
+config.set_quoted('DBUS_RUNSTATEDIR',
+ get_option('prefix') / runstatedir
+)
+config.set_quoted('DBUS_MACHINE_UUID_FILE',
+ get_option('prefix') / get_option('localstatedir') / 'lib'/'dbus'/'machine-id'
+)
+config.set_quoted('DBUS_SYSTEM_CONFIG_FILE',
+ get_option('prefix') / get_option('datadir') / 'dbus-1' / 'system.conf'
+)
+config.set_quoted('DBUS_SESSION_CONFIG_FILE',
+ get_option('prefix') / get_option('datadir') / 'dbus-1' / 'session.conf'
+)
+
+
+system_socket = get_option('system_socket')
+if system_socket == ''
+ system_socket = (
+ get_option('prefix') / runstatedir / 'dbus' / 'system_bus_socket'
+ )
+endif
+
+# This check assumes that the disposition of /run and /var/run on the
+# system where we're building is the same as on the system we're building
+# for, so we can't usefully do this check if we're building for Windows,
+# or if we're cross-building for Unix on a Windows machine.
+#
+# The check is shared between Autotools, CMake and Meson.
+# Because we only run it on Unix, it's fine to make it a shell script.
+if platform_unix and build_machine.system() != 'windows'
+ msg = run_command(
+ find_program('tools/check-runstatedir.sh'),
+ system_socket,
+ check: false,
+ ).stdout()
+ if msg != ''
+ warning(msg)
+ endif
+endif
+
+data_config.set('DBUS_SYSTEM_SOCKET', system_socket)
+
+## System bus only listens on local domain sockets, and never
+## on an abstract socket (so only root can create the socket).
+##
+## This won't work on Windows. It's not meant to - the system bus is
+## meaningless on Windows anyway.
+##
+## This has to be suitable for hard-coding in client libraries as well as
+## in the dbus-daemon's configuration, so it has to be valid to listen on
+## and also to connect to. If this ever changes, it'll need to be split into
+## two variables, one for the listening address and one for the connecting
+## address.
+system_bus_default_address = 'unix:path=@0@'.format(system_socket)
+data_config.set('DBUS_SYSTEM_BUS_DEFAULT_ADDRESS', system_bus_default_address)
+config.set_quoted('DBUS_SYSTEM_BUS_DEFAULT_ADDRESS', system_bus_default_address)
+
+
+system_pid_file = get_option('system_pid_file')
+if system_pid_file == ''
+ system_pid_file = get_option('prefix') / runstatedir / 'dbus'/'pid'
+endif
+data_config.set('DBUS_SYSTEM_PID_FILE', system_pid_file)
+
+
+dbus_user = get_option('dbus_user')
+data_config.set('DBUS_USER', dbus_user)
+config.set_quoted('DBUS_USER', dbus_user)
+
+test_user = get_option('test_user')
+config.set_quoted('DBUS_TEST_USER', test_user)
+
+daemon_dir = get_option('dbus_daemondir')
+if daemon_dir == ''
+ daemon_dir = get_option('prefix') / get_option('bindir')
+endif
+data_config.set('DBUS_DAEMONDIR', daemon_dir)
+config.set_quoted('DBUS_DAEMONDIR', daemon_dir)
+
+
+
+# Relocation is disabled by default, let's check if we need to enable it
+relocation = false
+if get_option('relocation').enabled()
+ # Manually forced at true
+ relocation = true
+endif
+if get_option('relocation').auto() and platform_windows
+ # By default, on Windows we are relocatable if possible
+ relocation = true
+endif
+
+# Now check if it's not possible
+# Meson does not separate exec_prefix and prefix (hopefully)
+if relocation and not (get_option('libdir') in [ 'lib', 'lib64', ])
+ message = (
+ 'Relocatable pkg-config metadata requires default libdir, '
+ + 'not @0@'.format(get_option('libdir'))
+ )
+ if get_option('relocation').enabled()
+ error(message)
+ else
+ warning(message)
+ endif
+endif
+
+#### Directory to source sysconfdir configuration from
+
+# On Windows this is relative to where we put the bus setup, in
+# ${datadir}/dbus-1. For simplicity, we only do this if
+# ${sysconfdir} = ${prefix}/etc and ${datadir} = ${prefix}/share.
+#
+# On Unix, or on Windows with weird install layouts, it's the absolute path.
+if (platform_windows
+ and data_config.get('EXPANDED_SYSCONFDIR') == get_option('prefix') / 'etc'
+ and data_config.get('EXPANDED_DATADIR') == get_option('prefix') / 'share'
+)
+ sysconfdir_from_pkgdatadir = '../../etc'
+ datadir_from_pkgsysconfdir = '../../share'
+else
+ sysconfdir_from_pkgdatadir = data_config.get('EXPANDED_SYSCONFDIR')
+ datadir_from_pkgsysconfdir = data_config.get('EXPANDED_DATADIR')
+endif
+data_config.set('SYSCONFDIR_FROM_PKGDATADIR', sysconfdir_from_pkgdatadir)
+data_config.set('DATADIR_FROM_PKGSYSCONFDIR', datadir_from_pkgsysconfdir)
+
+#### Find socket directories
+values = run_command(python, '-c',
+ 'import os; [print(os.getenv(e, "")) for e in ["TMPDIR", "TEMP", "TMP"]]',
+ check: true,
+).stdout()
+values += '/tmp'
+default_socket_dir = values.strip().split('\n')[0]
+
+test_socket_dir = get_option('test_socket_dir')
+if test_socket_dir == ''
+ test_socket_dir = default_socket_dir
+endif
+test_listen = platform_unix ? 'unix:tmpdir=' + test_socket_dir : 'tcp:host=localhost'
+config.set_quoted('TEST_LISTEN', test_listen)
+config.set_quoted('DBUS_TEST_SOCKET_DIR', test_socket_dir)
+data_config.set('TEST_LISTEN', test_listen)
+
+session_socket_dir = get_option('session_socket_dir')
+if session_socket_dir == ''
+ session_socket_dir = default_socket_dir
+endif
+config.set_quoted('DBUS_SESSION_SOCKET_DIR', session_socket_dir)
+
+# This must be a listening address. It doesn't necessarily need to be an
+# address you can connect to - it can be something vague like
+# "nonce-tcp:".
+session_bus_listen_address = get_option('dbus_session_bus_listen_address')
+if session_bus_listen_address == ''
+ if platform_windows
+ # On Windows, you can (and should) listen on autolaunch addresses,
+ # because autolaunching is not the same as X11 autolaunching.
+ session_bus_listen_address = 'autolaunch:'
+ elif use_launchd
+ # macOS default is to use launchd
+ session_bus_listen_address = 'launchd:env=DBUS_LAUNCHD_SESSION_BUS_SOCKET'
+ else
+ # The default on all other Unix platforms (notably Linux)
+ # is to create a randomly named socket in /tmp or similar
+ session_bus_listen_address = 'unix:tmpdir=@0@'.format(session_socket_dir)
+ endif
+endif
+data_config.set('DBUS_SESSION_BUS_LISTEN_ADDRESS', session_bus_listen_address)
+
+
+# This must be an address you can connect to. It doesn't necessarily
+# need to be an address you can listen on - it can be "autolaunch:",
+# even on Unix.
+session_bus_connect_address = get_option('dbus_session_bus_connect_address')
+if session_bus_connect_address == ''
+ session_bus_connect_address = 'autolaunch:'
+endif
+config.set_quoted('DBUS_SESSION_BUS_CONNECT_ADDRESS', session_bus_connect_address)
+
+
+config.set('DBUS_ENABLE_STATS', get_option('stats'))
+config.set('DBUS_ENABLE_CONTAINERS', get_option('containers'))
+enable_user_session = get_option('user_session')
+
+
+config.set('DBUS_COMPILATION', true)
+
+exe_ext = platform_windows ? '.exe' : ''
+config.set_quoted('DBUS_EXEEXT', exe_ext)
+
+compile_warnings = []
+compile_warnings_c = []
+
+# -fno-common makes the linker more strict: on some systems the linker
+# is *always* this strict, so we want to behave like that everywhere.
+# We treat this like a warning, since that's basically how we're using it.
+compile_warnings += ['-fno-common']
+
+if cc.get_id() == 'msvc'
+ compile_warnings += [
+ # once
+ '/wo4018', # 'expression' : signed/unsigned mismatch
+ # disabled
+ '/wd4090', # 'operation' : different 'modifier' qualifiers
+ '/wd4101', # 'identifier' : unreferenced local variable
+ '/wd4127', # conditional expression is constant
+ '/wd4244', # 'argument' : conversion from 'type1' to 'type2', possible loss of data
+ # error
+ '/we4002', # too many actual parameters for macro 'identifier'
+ '/we4003', # not enough actual parameters for macro 'identifier'
+ '/we4013', # 'function' undefined; assuming extern returning int
+ '/we4028', # formal parameter 'number' different from declaration
+ '/we4031', # second formal parameter list longer than the first list
+ '/we4047', # operator' : 'identifier1' differs in levels of indirection from 'identifier2'
+ '/we4114', # same type qualifier used more than once
+ '/we4133', # 'type' : incompatible types - from 'type1' to 'type2'
+ ]
+else
+ compile_warnings += [
+ # These warnings are intentionally disabled:
+ # - missing field initializers being implicitly 0 is a feature,
+ # not a bug
+ # - -Wunused-parameter is annoying when writing callbacks that follow
+ # a fixed signature but do not necessarily need all of its parameters
+ '-Wno-missing-field-initializers',
+ '-Wno-unused-parameter',
+
+ # General warnings for both C and C++
+ # TODO: Some of these are probably redundant with Meson's warning_level
+ '-Warray-bounds',
+ '-Wcast-align',
+ '-Wchar-subscripts',
+ '-Wdouble-promotion',
+ '-Wduplicated-branches',
+ '-Wduplicated-cond',
+ '-Wfloat-equal',
+ '-Wformat-nonliteral',
+ '-Wformat-security',
+ '-Wformat=2',
+ '-Winit-self',
+ '-Winline',
+ '-Wlogical-op',
+ '-Wmissing-declarations',
+ '-Wmissing-format-attribute',
+ '-Wmissing-include-dirs',
+ '-Wmissing-noreturn',
+ '-Wnull-dereference',
+ '-Wpacked',
+ '-Wpointer-arith',
+ '-Wredundant-decls',
+ '-Wrestrict',
+ '-Wreturn-type',
+ '-Wshadow',
+ '-Wsign-compare',
+ '-Wstrict-aliasing',
+ '-Wswitch-default',
+ '-Wswitch-enum',
+ '-Wundef',
+ '-Wunused-but-set-variable',
+ '-Wwrite-strings',
+ ]
+
+ compile_warnings_c += [
+ # Extra warnings just for C
+ '-Wdeclaration-after-statement',
+ '-Wimplicit-function-declaration',
+ '-Wjump-misses-init',
+ '-Wmissing-prototypes',
+ '-Wnested-externs',
+ '-Wold-style-definition',
+ '-Wpointer-sign',
+ '-Wstrict-prototypes',
+ ]
+endif
+
+compile_warnings_c = cc.get_supported_arguments(compile_warnings + compile_warnings_c)
+add_project_arguments(compile_warnings_c, language: 'c')
+
+link_args = cc.get_supported_link_arguments(link_args)
+add_project_link_arguments(link_args, language: ['c'])
+
+if using_cpp
+ compile_warnings_cpp = cpp.get_supported_arguments(compile_warnings)
+ add_project_arguments(compile_warnings_cpp, language: 'cpp')
+ add_project_link_arguments(link_args, language: ['cpp'])
+endif
+
+root_include = include_directories('.')
+
+configure_file(
+ output: 'config.h',
+ configuration: config,
+)
+
+bonus_files = files(
+ 'AUTHORS',
+ 'CONTRIBUTING.md',
+ 'COPYING',
+ 'NEWS',
+ 'README',
+)
+
+if platform_unix
+ run_target(
+ 'maintainer-update-authors',
+ command: 'maint/update-authors.sh',
+ )
+endif
+
+subdir('dbus')
+if message_bus
+ subdir('bus')
+endif
+if tools
+ subdir('tools')
+endif
+subdir('test')
+subdir('doc')
+subdir('cmake')
+
+meson.add_install_script('meson_post_install.py',
+ '@0@'.format(relocation),
+)
+
+pkgconfig.generate(
+ libdbus,
+ name: 'dbus',
+ filebase: 'dbus-1',
+ description: 'Free desktop message bus',
+ subdirs: [ 'dbus-1.0' ],
+ extra_cflags: [
+ '-I${libdir}/dbus-1.0/include',
+ ] + dbus_static_flags,
+ variables: {
+ 'original_prefix': get_option('prefix'),
+
+ 'exec_prefix': '${prefix}',
+ 'bindir': '${prefix}' / get_option('bindir'),
+ 'datadir': '${prefix}' / get_option('datadir'),
+ 'datarootdir': '${prefix}' / get_option('datadir'),
+ 'sysconfdir': '${prefix}' / get_option('sysconfdir'),
+
+ 'daemondir': '${bindir}',
+ 'system_bus_default_address': system_bus_default_address,
+ 'session_bus_services_dir': '${datadir}/dbus-1/services',
+ 'system_bus_services_dir': '${datadir}/dbus-1/system-services',
+ 'interfaces_dir': '${datadir}/dbus-1/interfaces',
+ }
+)
+
+if meson.version().version_compare('>=0.60.0')
+ foreach dir : install_emptydirs
+ install_emptydir(dir)
+ endforeach
+else
+ meson.add_install_script(
+ 'tools/meson-compat-install-emptydirs.py',
+ ':'.join(install_emptydirs),
+ )
+endif
+
+foreach symlink : install_symlinks
+ if not platform_unix
+ warning(
+ 'Not creating symbolic link @0@/@1@ -> @2@'.format(
+ symlink['install_dir'],
+ symlink['link_name'],
+ symlink['pointing_to'],
+ )
+ )
+ elif meson.version().version_compare('>=0.61.0')
+ install_symlink(
+ symlink['link_name'],
+ install_dir : symlink['install_dir'],
+ pointing_to : symlink['pointing_to'],
+ )
+ else
+ meson.add_install_script(
+ 'tools/meson-compat-install-symlink.py',
+ symlink['link_name'],
+ symlink['install_dir'],
+ symlink['pointing_to'],
+ )
+ endif
+endforeach
+
+summary_dict = {
+ 'prefix': get_option('prefix'),
+ 'exec_prefix': get_option('prefix'),
+ 'libdir': get_option('prefix') / get_option('libdir'),
+ 'libexecdir': get_option('prefix') / get_option('libexecdir'),
+ 'bindir': get_option('prefix') / get_option('bindir'),
+ 'sysconfdir': data_config.get('EXPANDED_SYSCONFDIR'),
+ 'localstatedir': data_config.get('EXPANDED_LOCALSTATEDIR'),
+ 'runstatedir': data_config.get('EXPANDED_RUNSTATEDIR'),
+ 'datadir': data_config.get('EXPANDED_DATADIR'),
+ 'source code location': meson.project_source_root(),
+ 'compiler': cc.get_id(),
+ 'cflags': compile_args_c + compile_warnings_c,
+}
+
+if using_cpp
+ summary_dict += {
+ 'cxxflags': compile_args_cpp + compile_warnings_cpp,
+ }
+endif
+
+summary_dict += {
+ 'ldflags': (link_args.length() == 0) ? '[]' : link_args,
+ '64-bit int': arch_config.get('DBUS_INT64_TYPE'),
+ '32-bit int': arch_config.get('DBUS_INT32_TYPE'),
+ '16-bit int': arch_config.get('DBUS_INT16_TYPE'),
+ 'pointer size': arch_config.get('DBUS_SIZEOF_VOID_P'),
+ 'xsltproc': xsltproc.found() ? xsltproc.full_path() : '',
+ 'Doxygen': doxygen.found() ? doxygen.full_path() : '',
+ 'ducktype': ducktype.found() ? ducktype.full_path() : '',
+ 'yelp-build': yelpbuild.found() ? yelpbuild.full_path() : '',
+
+ 'gcc coverage': get_option('b_coverage'),
+ 'gcc profiling': get_option('b_pgo'),
+ 'Building embedded tests': embedded_tests,
+ 'Building modular tests': dbus_enable_modular_tests,
+ '- with GLib': use_glib,
+ 'Installing tests': get_option('installed_tests'),
+ 'Building verbose mode': verbose_mode,
+ 'Building assertions': asserts,
+ 'Building checks': checks,
+ 'Building bus stats API': get_option('stats'),
+ 'Building container API': get_option('containers'),
+ 'Building SELinux support': config.get('HAVE_SELINUX'),
+ 'Building AppArmor support': apparmor.found(),
+ 'Building inotify support': use_inotify,
+ 'Building kqueue support': use_kqueue,
+ 'Building systemd support': use_systemd,
+ 'Traditional activation': use_traditional_activation,
+ 'Building X11 code': config.get('DBUS_BUILD_X11'),
+ 'Building Doxygen docs': doxygen.found(),
+ 'Building Qt help file': qt_help_generate,
+ 'Building Ducktype docs': ducktype.found(),
+ 'Building XML docs': build_xml_docs,
+ 'Building launchd support': use_launchd,
+ 'Building dbus-daemon': message_bus,
+ 'Building tools': tools,
+ 'System bus socket': data_config.get('DBUS_SYSTEM_SOCKET'),
+ 'System bus address': config.get('DBUS_SYSTEM_BUS_DEFAULT_ADDRESS'),
+ 'System bus PID file': data_config.get('DBUS_SYSTEM_PID_FILE'),
+ 'Session bus listens on': data_config.get('DBUS_SESSION_BUS_LISTEN_ADDRESS'),
+ 'Session clients connect to': config.get('DBUS_SESSION_BUS_CONNECT_ADDRESS'),
+ 'System bus user': dbus_user,
+ 'Session bus services dir':
+ get_option('prefix') / get_option('datadir') / 'dbus-1' / 'services',
+ 'Tests socket dir': test_socket_dir,
+}
+
+if host_os.contains('solaris')
+ summary_dict += {
+ 'Console owner file': console_owner_file,
+ }
+endif
+
+summary(summary_dict, bool_yn: true)
+
+if embedded_tests
+ warning('building with unit tests increases the size of the installed library and renders it insecure.')
+ if not asserts
+ warning('building with embedded tests but without assertions means tests may not properly report failures (this configuration is only useful when doing something like profiling the tests)')
+ endif
+endif
+
+if get_option('b_coverage')
+ warning('Building with coverage profiling is definitely for developers only.')
+endif
+
+if verbose_mode
+ warning('building with verbose mode increases library size, may slightly increase security risk, and decreases performance.')
+endif
+
+if asserts
+ warning('building with assertions increases library size and decreases performance.')
+endif
+
+if not checks
+ warning('building without checks for arguments passed to public API makes it harder to debug apps using D-Bus, but will slightly decrease D-Bus library size and _very_ slightly improve performance.')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 00000000..83c1c921
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,314 @@
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+option(
+ 'apparmor',
+ type: 'feature',
+ value: 'auto',
+ description: 'AppArmor support'
+)
+
+option(
+ 'asserts',
+ type: 'boolean',
+ value: false,
+ description: 'Include assertion checks'
+)
+
+option(
+ 'checks',
+ type: 'boolean',
+ value: true,
+ description: 'Check for usage errors at public API'
+)
+
+option(
+ 'containers',
+ type: 'boolean',
+ value: false,
+ description: 'Enable restricted servers for app containers'
+)
+
+option(
+ 'dbus_daemondir',
+ type: 'string',
+ description: 'Directory for installing the dbus-daemon'
+)
+
+option(
+ 'dbus_user',
+ type: 'string',
+ description: 'User for running the system dbus-daemon',
+ value: 'messagebus'
+)
+
+option(
+ 'dbus_session_bus_connect_address',
+ type: 'string',
+ value: '',
+ description: 'Fallback address for a session bus client to connect to',
+)
+
+option(
+ 'dbus_session_bus_listen_address',
+ type: 'string',
+ value: '',
+ description: 'Default address for a session bus to listen on',
+)
+
+option(
+ 'doxygen_docs',
+ type: 'feature',
+ value: 'auto',
+ description: 'Build Doxygen documentation'
+)
+
+option(
+ 'ducktype_docs',
+ type: 'feature',
+ value: 'auto',
+ description: 'Build Ducktype documentation'
+)
+
+option(
+ 'embedded_tests',
+ type: 'boolean',
+ value: false,
+ description: 'Enable unit test code in the library and binaries'
+)
+
+option(
+ 'epoll',
+ type: 'feature',
+ value: 'auto',
+ description: 'Use epoll(4) on Linux'
+)
+
+option(
+ 'inotify',
+ type: 'feature',
+ value: 'auto',
+ description: 'Inotify support on Linux'
+)
+
+option(
+ 'installed_tests',
+ type: 'boolean',
+ value: false,
+ description: 'Install automated tests for "as-installed" testing'
+)
+
+option(
+ 'kqueue',
+ type: 'feature',
+ value: 'auto',
+ description: 'Kqueue support'
+)
+
+option(
+ 'launchd',
+ type: 'feature',
+ value: 'auto',
+ description: 'Launchd auto-launch support'
+)
+
+option(
+ 'launchd_agent_dir',
+ type: 'string',
+ description: 'Directory to put the launchd agent'
+)
+
+option(
+ 'libaudit',
+ type: 'feature',
+ value: 'auto',
+ description: 'Audit logging support for SELinux and AppArmor'
+)
+
+option(
+ 'message_bus',
+ type: 'boolean',
+ value: 'true',
+ description: 'Enable dbus-daemon'
+)
+
+option(
+ 'modular_tests',
+ type: 'feature',
+ value: 'auto',
+ description: 'Enable modular regression tests (requires GLib)'
+)
+
+option(
+ 'qch_dir',
+ type: 'string',
+ description: 'Directory to put the Qt help file'
+)
+
+option(
+ 'qt_help',
+ type: 'feature',
+ value: 'auto',
+ description: 'Build Qt help documentation'
+)
+
+option(
+ 'relocation',
+ type: 'feature',
+ value: 'auto',
+ description: 'Make pkg-config metadata relocatable'
+)
+
+# Deliberately not named runstatedir to avoid colliding with
+# https://github.com/mesonbuild/meson/issues/4141
+option(
+ 'runtime_dir',
+ type: 'string',
+ value: '',
+ description: 'Directory for transient runtime state [default: LOCALSTATEDIR/run or /run]'
+)
+
+option(
+ 'selinux',
+ type: 'feature',
+ value: 'auto',
+ description: 'SELinux support'
+)
+
+option(
+ 'session_socket_dir',
+ type: 'string',
+ description: 'Where to put sockets for the per-login-session message bus'
+)
+
+option(
+ 'solaris_console_owner_file',
+ type: 'string',
+ value: '',
+ description: 'File to determine current console owner on Solaris (or "auto")'
+)
+
+option(
+ 'stats',
+ type: 'boolean',
+ value: true,
+ description: 'Enable bus daemon usage statistics'
+)
+
+option(
+ 'system_pid_file',
+ type: 'string',
+ description: 'PID file for systemwide daemon'
+)
+
+option(
+ 'system_socket',
+ type: 'string',
+ description: 'UNIX domain socket for systemwide daemon'
+)
+
+option(
+ 'systemd_system_unitdir',
+ type: 'string',
+ description: 'Directory for systemd system service files'
+)
+
+option(
+ 'systemd_user_unitdir',
+ type: 'string',
+ description: 'Directory for systemd user service files'
+)
+
+option(
+ 'systemd',
+ type: 'feature',
+ value: 'auto',
+ description: 'Systemd at_console support'
+)
+
+option(
+ 'test_socket_dir',
+ type: 'string',
+ description: 'Where to put sockets for make check'
+)
+
+option(
+ 'test_user',
+ type: 'string',
+ description: 'Unprivileged user for regression tests, other than root and the dbus_user',
+ value: 'nobody'
+)
+
+option(
+ 'tools',
+ type: 'boolean',
+ value: 'true',
+ description: 'Enable CLI tools such as dbus-send and dbus-monitor'
+)
+
+option(
+ 'traditional_activation',
+ type: 'boolean',
+ value: true,
+ description: 'Build support for service activation without using SystemdService'
+)
+
+option(
+ 'user_session',
+ type: 'boolean',
+ value: true,
+ description: 'Enable user-session semantics for session bus under systemd'
+)
+
+option(
+ 'valgrind',
+ type: 'feature',
+ value: 'disabled',
+ description: 'Build with Valgrind instrumentation (note that this currently adds a hard dependency on valgrind)'
+)
+
+option(
+ 'verbose_mode',
+ type: 'boolean',
+ value: false,
+ description: 'Support verbose debug mode'
+)
+
+option(
+ 'x11_autolaunch',
+ type: 'feature',
+ value: 'auto',
+ description: 'Build with X11 auto-launch support'
+)
+
+option(
+ 'xml_docs',
+ type: 'feature',
+ value: 'auto',
+ description: 'Build XML documentation'
+)
+
+option(
+ 'windows_output_debug_string',
+ type: 'boolean',
+ value: false,
+ description: 'use OutputDebugString() to log messages to Windows debug port'
+)
diff --git a/meson_post_install.py b/meson_post_install.py
new file mode 100755
index 00000000..cfc03b22
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,106 @@
+#!/usr/bin/env python3
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+import os, sys, stat
+from pathlib import Path
+import shlex, subprocess, json
+
+meson = shlex.split(os.environ.get('MESONINTROSPECT', ''))
+introspection = json.loads(subprocess.check_output(meson + ['-a']).decode())
+build_options = introspection['buildoptions']
+targets = introspection['targets']
+
+def get_option(name):
+ for i in build_options:
+ if i['name'] == name:
+ return i['value']
+ return None
+
+def get_target(name):
+ for i in targets:
+ if i['name'] == name:
+ return i
+ return None
+
+destdir = Path(os.getenv('DESTDIR')) if 'DESTDIR' in os.environ else None
+prefix = Path(get_option('prefix'))
+destdir_prefix = Path(os.getenv('MESON_INSTALL_DESTDIR_PREFIX'))
+
+def to_destdir(path):
+ path_abs = prefix / path
+ if destdir:
+ path_rel_root = path_abs.relative_to(path_abs.anchor)
+ path_final = destdir / path_rel_root
+ return path_final
+ else:
+ return path_abs
+
+###############################################################################
+
+# Define paths here
+abs_libexecdir = destdir_prefix / get_option('libexecdir')
+
+relocation = sys.argv[1].lower() == 'true'
+
+def post_install_relocation():
+ # Edit pkg-config file to replace the prefix
+ #
+ # TODO: Meson >=0.63 has a new feature, -Dpkgconfig.relocatable=true.
+
+ if not relocation:
+ return
+
+ pc_filepath = next(
+ v for (k,v) in introspection['installed'].items() if k.endswith('.pc')
+ )
+ # Find the really installed path
+ pc_filepath = to_destdir(pc_filepath)
+
+ with open(pc_filepath, 'r') as pcfile:
+ lines = pcfile.readlines()
+ with open(pc_filepath, 'w') as pcfile:
+ for line in lines:
+ if line.startswith('prefix='):
+ line = 'prefix=${pcfiledir}/../..\n'
+ pcfile.write(line)
+
+def post_install_exe():
+ # Setuid, chmod and chown for dbus-daemon-launch-helper
+ daemon_launch_helper = get_target('dbus-daemon-launch-helper')
+ if daemon_launch_helper:
+ import grp
+ exe_name = os.path.basename(daemon_launch_helper['install_filename'][0])
+ exe_path = abs_libexecdir / exe_name
+ dbus_user = get_option('dbus_user')
+ if os.getuid() == 0:
+ os.chown(exe_path, 0, grp.getgrnam(dbus_user).gr_gid)
+ os.chmod(exe_path, stat.S_ISUID | stat.S_IXUSR | stat.S_IXGRP)
+ else:
+ print('Not installing {0} binary setuid!'.format(exe_path))
+ print('You\'ll need to manually set permissions to root:{0} and permissions 4750'
+ .format(dbus_user)
+ )
+
+
+if __name__ == "__main__":
+ post_install_relocation()
+ post_install_exe()
diff --git a/subprojects/expat.wrap b/subprojects/expat.wrap
new file mode 100644
index 00000000..87dab046
--- /dev/null
+++ b/subprojects/expat.wrap
@@ -0,0 +1,11 @@
+[wrap-file]
+directory = expat-2.4.8
+source_url = https://github.com/libexpat/libexpat/releases/download/R_2_4_8/expat-2.4.8.tar.xz
+source_filename = expat-2.4.8.tar.bz2
+source_hash = f79b8f904b749e3e0d20afeadecf8249c55b2e32d4ebb089ae378df479dcaf25
+patch_filename = expat_2.4.8-1_patch.zip
+patch_url = https://wrapdb.mesonbuild.com/v2/expat_2.4.8-1/get_patch
+patch_hash = 9aec253a2c6d1c0feb852c5c6920298d14701eeec7acc6832bb402438b52112a
+
+[provide]
+expat = expat_dep
diff --git a/subprojects/glib.wrap b/subprojects/glib.wrap
new file mode 100644
index 00000000..3b1faf10
--- /dev/null
+++ b/subprojects/glib.wrap
@@ -0,0 +1,10 @@
+[wrap-file]
+directory = glib-2.72.2
+source_url = https://download.gnome.org/sources/glib/2.72/glib-2.72.2.tar.xz
+source_filename = glib-2.72.2.tar.xz
+source_hash = 78d599a133dba7fe2036dfa8db8fb6131ab9642783fc9578b07a20995252d2de
+wrapdb_version = 2.72.2-1
+
+[provide]
+dependency_names = gthread-2.0, gobject-2.0, gmodule-no-export-2.0, gmodule-export-2.0, gmodule-2.0, glib-2.0, gio-2.0, gio-windows-2.0, gio-unix-2.0
+program_names = glib-genmarshal, glib-mkenums, glib-compile-schemas, glib-compile-resources, gio-querymodules, gdbus-codegen
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 20e75d85..b3c593e5 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -78,6 +78,7 @@ add_helper_executable(manual-dir-iter ${manual-dir-iter_SOURCES} ${DBUS_INTERNAL
add_helper_executable(test-service ${test-service_SOURCES} dbus-testutils)
add_helper_executable(test-names ${test-names_SOURCES} dbus-testutils)
add_test_executable(test-shell ${test-shell_SOURCES} ${DBUS_INTERNAL_LIBRARIES})
+add_test_executable(test-string internals/strings.c dbus-testutils)
add_test_executable(test-printf internals/printf.c dbus-testutils)
add_helper_executable(test-privserver test-privserver.c dbus-testutils)
add_helper_executable(test-shell-service ${test-shell-service_SOURCES} dbus-testutils)
@@ -144,23 +145,37 @@ if(DBUS_ENABLE_EMBEDDED_TESTS)
add_test_executable(test-misc-internals "${SOURCES}" dbus-testutils)
set_target_properties(test-misc-internals PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
- set(SOURCES bus/main.c)
+ add_test_executable(test-platform-mutex test-platform-mutex.c ${DBUS_INTERNAL_LIBRARIES} dbus-testutils)
+
+ set(SOURCES bus/main.c bus/common.c bus/common.h)
add_test_executable(test-bus "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
set_target_properties(test-bus PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
- set(SOURCES bus/dispatch.c)
- add_test_executable(test-bus-dispatch "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
- set_target_properties(test-bus-dispatch PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
+ if(ENABLE_TRADITIONAL_ACTIVATION)
+ set(SOURCES bus/normal-activation.c bus/common.c bus/common.h)
+ add_test_executable(test-bus-normal-activation "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
+ set_target_properties(test-bus-normal-activation PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
+ endif()
+
- set(SOURCES bus/dispatch-sha1.c)
+ set(SOURCES bus/dispatch-sha1.c bus/common.c bus/common.h)
add_test_executable(test-bus-dispatch-sha1 "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
set_target_properties(test-bus-dispatch-sha1 PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
if(NOT WIN32)
add_test_executable(test-bus-system bus/system.c launch-helper-internal dbus-testutils)
+ add_test_executable(test-counter internals/counter.c dbus-testutils)
if(ENABLE_TRADITIONAL_ACTIVATION)
add_test_executable(test-bus-launch-helper-oom bus/launch-helper-oom.c launch-helper-internal dbus-testutils)
add_helper_executable(dbus-daemon-launch-helper-for-tests bus/launch-helper-for-tests.c launch-helper-internal)
+
+ set(SOURCES bus/failed-helper-activation.c bus/common.c bus/common.h)
+ add_test_executable(test-bus-failed-helper-activation "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
+ set_target_properties(test-bus-failed-helper-activation PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
+
+ set(SOURCES bus/helper-activation.c bus/common.c bus/common.h)
+ add_test_executable(test-bus-helper-activation "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
+ set_target_properties(test-bus-helper-activation PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
endif()
endif()
endif()
@@ -189,6 +204,7 @@ if(DBUS_WITH_GLIB)
add_test_executable(test-dbus-daemon-eavesdrop dbus-daemon-eavesdrop.c ${TEST_LIBRARIES})
add_test_executable(test-desktop-file internals/desktop-file.c ${TEST_LIBRARIES})
add_test_executable(test-fdpass fdpass.c ${TEST_LIBRARIES})
+ add_test_executable(test-header-fields header-fields.c ${TEST_LIBRARIES})
add_test_executable(test-loopback loopback.c ${TEST_LIBRARIES})
add_test_executable(test-marshal marshal.c ${TEST_LIBRARIES})
add_test_executable(test-monitor monitor.c ${TEST_LIBRARIES})
@@ -199,6 +215,7 @@ if(DBUS_WITH_GLIB)
add_test_executable(test-sysdeps internals/sysdeps.c ${TEST_LIBRARIES})
add_test_executable(test-syslog internals/syslog.c ${TEST_LIBRARIES})
add_test_executable(test-uid-permissions uid-permissions.c ${TEST_LIBRARIES})
+ add_test_executable(test-userdb internals/userdb.c ${TEST_LIBRARIES})
add_helper_executable(manual-authz manual-authz.c ${TEST_LIBRARIES})
add_helper_executable(manual-test-thread-blocking thread-blocking.c ${TEST_LIBRARIES})
endif()
@@ -215,6 +232,7 @@ set(TESTDIRS
data/valid-config-files/session.d
data/valid-config-files-system
data/valid-config-files-system/system.d
+ data/valid-messages
data/valid-service-files
data/valid-service-files-system
data/invalid-config-files
@@ -227,31 +245,39 @@ set(TESTDIRS
data/equiv-config-files/entities
data/equiv-config-files/entities/basic.d
)
-set(CONFIG_VERBOSE 1)
foreach(DIR ${TESTDIRS})
- file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DIR})
+ file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/${DIR})
endforeach()
### copy tests to builddir so that generated tests and static tests
### are all in one place.
-message(STATUS "Copying test files to test directory")
+if(NOT ENABLE_VERBOSE_CONFIG)
+ set(HINT " (use -DENABLE_VERBOSE_CONFIG=ON to see the list of files)")
+endif()
+
+message(STATUS "Copying test files to test directory${HINT}")
+
+macro(dbus_configure_file _src _dest)
+ configure_file(${_src} ${_dest} ${ARGN})
+ if(ENABLE_VERBOSE_CONFIG)
+ message(" generating ${_dest}")
+ endif()
+endmacro()
+
foreach(FILE_TYPE *.message-raw *.auth-script *.sha1 *.txt *.conf *.service)
foreach(DIR ${TESTDIRS})
file(GLOB FILES "${DIR}/${FILE_TYPE}" )
foreach(FILE ${FILES})
get_filename_component(FILENAME ${FILE} NAME)
set(TARGET ${CMAKE_CURRENT_BINARY_DIR}/${DIR}/${FILENAME})
- configure_file(${FILE} ${TARGET} COPYONLY)
- if(CONFIG_VERBOSE)
- message("${FILE}")
- endif()
+ dbus_configure_file(${FILE} ${TARGET} COPYONLY)
endforeach()
endforeach()
endforeach()
### generate test files
-message(STATUS "Generating test files from templates into test directory")
+message(STATUS "Generating test files from templates into test directory${HINT}")
foreach(FILE_TYPE *.conf.in *.service.in)
foreach(DIR ${TESTDIRS})
@@ -260,14 +286,11 @@ foreach(FILE_TYPE *.conf.in *.service.in)
get_filename_component(FILENAME ${FILE} NAME)
string(REGEX REPLACE "\\.in$" "" FILENAME ${FILENAME})
set(TARGET ${CMAKE_CURRENT_BINARY_DIR}/${DIR}/${FILENAME})
- configure_file(${FILE} ${TARGET} @ONLY IMMEDIATE)
- if(CONFIG_VERBOSE)
- message("${FILE}")
- endif()
+ dbus_configure_file(${FILE} ${TARGET} @ONLY IMMEDIATE)
endforeach()
endforeach()
endforeach()
-message(STATUS "Copying generated bus config files to test directory")
-configure_file(../bus/session.conf.in ${CMAKE_BINARY_DIR}/test/data/valid-config-files/session.conf @ONLY)
-configure_file(../bus/system.conf.in ${CMAKE_BINARY_DIR}/test/data/valid-config-files-system/system.conf @ONLY)
+message(STATUS "Copying generated bus config files to test directory${HINT}")
+dbus_configure_file(../bus/session.conf.in ${PROJECT_BINARY_DIR}/test/data/valid-config-files/session.conf @ONLY)
+dbus_configure_file(../bus/system.conf.in ${PROJECT_BINARY_DIR}/test/data/valid-config-files-system/system.conf @ONLY)
diff --git a/test/Makefile.am b/test/Makefile.am
deleted file mode 100644
index b539524c..00000000
--- a/test/Makefile.am
+++ /dev/null
@@ -1,847 +0,0 @@
-## the "name-test" subdir in fact contains a bunch of tests now that need a temporary bus
-## to be running to do stuff with. The directory should be renamed.
-## We want to build the current directory first to pick up the testutils lib
-SUBDIRS= . name-test
-DIST_SUBDIRS=name-test
-
-CLEANFILES =
-EXTRA_DIST =
-
-AM_CPPFLAGS = \
- $(CODE_COVERAGE_CPPFLAGS) \
- -I$(top_srcdir) \
- $(DBUS_STATIC_BUILD_CPPFLAGS) \
- -DDBUS_COMPILATION \
- $(APPARMOR_CFLAGS) \
- $(GLIB_CFLAGS) \
- $(GIO_UNIX_CFLAGS) \
- $(VALGRIND_CFLAGS) \
- $(NULL)
-
-# improve backtraces from test stuff
-AM_LDFLAGS = @R_DYNAMIC_LDFLAG@
-
-AM_CFLAGS = \
- $(CODE_COVERAGE_CFLAGS) \
- $(SANITIZE_CFLAGS) \
- $(NULL)
-
-noinst_LTLIBRARIES = libdbus-testutils.la
-
-libdbus_testutils_la_SOURCES = \
- disable-crash-handling.c \
- disable-crash-handling.h \
- test-utils.c \
- test-utils.h \
- $(NULL)
-
-if DBUS_WITH_GLIB
-libdbus_testutils_la_SOURCES += \
- test-utils-glib.c \
- test-utils-glib.h \
- $(NULL)
-endif
-
-libdbus_testutils_la_LIBADD = \
- $(CODE_COVERAGE_LIBS) \
- $(top_builddir)/dbus/libdbus-1.la \
- $(top_builddir)/dbus/libdbus-internal.la \
- $(NULL)
-
-TEST_EXTENSIONS = .sh
-
-LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/build-aux/tap-driver.sh
-LOG_COMPILER = $(srcdir)/glib-tap-test.sh
-SH_LOG_DRIVER = $(LOG_DRIVER)
-SH_LOG_COMPILER = $(SHELL)
-EXTRA_DIST += glib-tap-test.sh
-EXTRA_DIST += tap-test.sh.in
-
-TESTS =
-noinst_PROGRAMS =
-
-if DBUS_ENABLE_EMBEDDED_TESTS
-
-uninstallable_test_programs =
-
-## break-loader removed for now
-## these binaries are used in tests but are not themselves tests
-TEST_BINARIES = \
- test-exit \
- test-names \
- test-privserver \
- test-segfault \
- test-shell-service \
- $(NULL)
-
-if !DBUS_WINCE
-if ENABLE_TRADITIONAL_ACTIVATION
-uninstallable_test_programs += test-spawn-oom
-endif ENABLE_TRADITIONAL_ACTIVATION
-endif !DBUS_WINCE
-
-if ENABLE_TRADITIONAL_ACTIVATION
-TEST_BINARIES += test-spawn
-endif
-
-uninstallable_test_programs += \
- test-bus \
- test-bus-dispatch \
- test-bus-dispatch-sha1 \
- test-marshal-recursive \
- test-message-internals \
- $(NULL)
-
-if DBUS_UNIX
-if ENABLE_TRADITIONAL_ACTIVATION
-uninstallable_test_programs += test-bus-launch-helper-oom
-uninstallable_test_programs += test-bus-system
-# this is used by the tests but is not, itself, a test
-TEST_BINARIES += dbus-daemon-launch-helper-for-tests
-endif ENABLE_TRADITIONAL_ACTIVATION
-endif DBUS_UNIX
-
-noinst_PROGRAMS += $(uninstallable_test_programs)
-TESTS += $(uninstallable_test_programs)
-
-else !DBUS_ENABLE_EMBEDDED_TESTS
-
-TEST_BINARIES=
-
-endif !DBUS_ENABLE_EMBEDDED_TESTS
-
-test_atomic_SOURCES = internals/atomic.c
-test_atomic_LDADD = libdbus-testutils.la
-
-noinst_PROGRAMS += $(TEST_BINARIES)
-
-# This helper is meant to crash, so if we're compiling the rest with
-# AddressSanitizer, we need to stop it from catching the SIGSEGV and
-# turning it into _exit(1); so don't give it SANITIZE_CFLAGS.
-# CODE_COVERAGE_CFLAGS are fairly pointless here, too.
-test_segfault_CFLAGS =
-
-test_service_LDADD = libdbus-testutils.la
-test_names_LDADD = libdbus-testutils.la
-test_privserver_LDADD = libdbus-testutils.la
-## break_loader_LDADD = $(top_builddir)/dbus/libdbus-internal.la
-test_shell_service_LDADD = libdbus-testutils.la
-test_shell_SOURCES = shell-test.c
-test_shell_LDADD = libdbus-testutils.la
-
-if ENABLE_TRADITIONAL_ACTIVATION
-test_spawn_SOURCES = spawn-test.c
-test_spawn_LDADD = $(top_builddir)/dbus/libdbus-internal.la
-test_spawn_oom_SOURCES = internals/spawn-oom.c
-test_spawn_oom_LDADD = libdbus-testutils.la
-endif
-
-test_assertions_SOURCES = internals/assertions.c
-test_assertions_LDADD = libdbus-testutils.la $(GLIB_LIBS)
-
-test_printf_SOURCES = internals/printf.c
-test_printf_LDADD = $(top_builddir)/dbus/libdbus-internal.la
-
-test_refs_SOURCES = internals/refs.c
-test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS)
-
-# We have to compile a separate copy of disable-crash-handling.c for
-# test-segfault rather than using libdbus-testutils.la, because
-# otherwise it would fail to link when using the AddressSanitizer.
-test_segfault_SOURCES = \
- disable-crash-handling.c \
- disable-crash-handling.h \
- test-segfault.c \
- $(NULL)
-# Deliberately not adding CODE_COVERAGE_LIBS here because we really
-# don't care about coverage for the test program that segfaults!
-
-test_server_oom_SOURCES = internals/server-oom.c
-test_server_oom_LDADD = libdbus-testutils.la $(GLIB_LIBS)
-
-test_sysdeps_SOURCES = internals/sysdeps.c
-test_sysdeps_LDADD = libdbus-testutils.la $(GLIB_LIBS)
-
-test_syslog_SOURCES = internals/syslog.c
-test_syslog_LDADD = libdbus-testutils.la $(GLIB_LIBS)
-
-test_variant_SOURCES = internals/variant.c
-test_variant_LDADD = libdbus-testutils.la $(GLIB_LIBS)
-
-manual_backtrace_SOURCES = manual-backtrace.c
-manual_backtrace_LDADD = $(top_builddir)/dbus/libdbus-1.la
-
-manual_dir_iter_SOURCES = manual-dir-iter.c
-manual_dir_iter_LDADD = $(top_builddir)/dbus/libdbus-internal.la
-
-manual_paths_SOURCES = manual-paths.c
-manual_paths_LDADD = libdbus-testutils.la
-
-manual_tcp_SOURCES = manual-tcp.c
-manual_tcp_LDADD = $(top_builddir)/dbus/libdbus-internal.la
-
-test_bus_launch_helper_oom_SOURCES = bus/launch-helper-oom.c
-test_bus_launch_helper_oom_LDADD = \
- $(top_builddir)/bus/liblaunch-helper-internal.la \
- libdbus-testutils.la \
- $(NULL)
-
-dbus_daemon_launch_helper_for_tests_SOURCES = bus/launch-helper-for-tests.c
-dbus_daemon_launch_helper_for_tests_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- $(top_builddir)/bus/liblaunch-helper-internal.la \
- $(NULL)
-
-test_bus_system_SOURCES = bus/system.c
-test_bus_system_LDADD = \
- $(top_builddir)/bus/liblaunch-helper-internal.la \
- libdbus-testutils.la \
- $(NULL)
-
-test_bus_SOURCES = bus/main.c
-test_bus_LDADD = \
- $(top_builddir)/bus/libdbus-daemon-internal.la \
- libdbus-testutils.la \
- $(NULL)
-
-test_bus_dispatch_SOURCES = bus/dispatch.c
-test_bus_dispatch_LDADD = \
- $(top_builddir)/bus/libdbus-daemon-internal.la \
- libdbus-testutils.la \
- $(NULL)
-
-test_bus_dispatch_sha1_SOURCES = bus/dispatch-sha1.c
-test_bus_dispatch_sha1_LDADD = \
- $(top_builddir)/bus/libdbus-daemon-internal.la \
- libdbus-testutils.la \
- $(NULL)
-
-test_hash_SOURCES = internals/hash.c
-test_hash_LDADD = libdbus-testutils.la
-
-test_marshal_recursive_SOURCES = \
- internals/dbus-marshal-recursive-util.c \
- internals/dbus-marshal-recursive-util.h \
- internals/marshal-recursive.c \
- $(NULL)
-test_marshal_recursive_LDADD = libdbus-testutils.la
-
-test_message_internals_SOURCES = \
- internals/dbus-marshal-recursive-util.c \
- internals/dbus-marshal-recursive-util.h \
- internals/dbus-message-factory.c \
- internals/dbus-message-factory.h \
- internals/dbus-message-util.c \
- internals/dbus-message-util.h \
- internals/message-internals.c \
- $(NULL)
-test_message_internals_LDADD = libdbus-testutils.la
-
-test_misc_internals_SOURCES = \
- internals/address.c \
- internals/dbus-auth-script.c \
- internals/dbus-auth-script.h \
- internals/dbus-auth-util.c \
- internals/dbus-credentials-util.c \
- internals/dbus-marshal-byteswap-util.c \
- internals/dbus-marshal-recursive-util.c \
- internals/dbus-marshal-recursive-util.h \
- internals/dbus-marshal-validate-util.c \
- internals/dbus-string-util.c \
- internals/dbus-sysdeps-util.c \
- internals/mempool.c \
- internals/misc-internals.c \
- internals/misc-internals.h \
- internals/sha.c \
- $(NULL)
-test_misc_internals_LDADD = libdbus-testutils.la
-
-EXTRA_DIST += dbus-test-runner
-
-testexecdir = $(libexecdir)/installed-tests/dbus
-testmetadir = $(datadir)/installed-tests/dbus
-
-nobase_dist_testexec_SCRIPTS =
-nobase_testexec_PROGRAMS =
-nobase_testmeta_DATA =
-
-installable_helpers = \
- test-service \
- test-sleep-forever \
- $(NULL)
-installable_tests = \
- test-atomic \
- test-hash \
- test-shell \
- test-misc-internals \
- test-printf \
- $(NULL)
-installable_manual_tests = \
- manual-backtrace \
- manual-dir-iter \
- manual-tcp \
- $(NULL)
-dist_installable_test_scripts = \
- $(NULL)
-dist_installed_test_scripts = \
- $(NULL)
-
-if DBUS_WIN
-installable_manual_tests += manual-paths
-endif
-
-if DBUS_WITH_GLIB
-installable_tests += \
- test-assertions \
- test-corrupt \
- test-dbus-daemon \
- test-dbus-daemon-eavesdrop \
- test-desktop-file \
- test-fdpass \
- test-header-fields \
- test-message \
- test-monitor \
- test-loopback \
- test-marshal \
- test-refs \
- test-relay \
- test-server-oom \
- test-syntax \
- test-sysdeps \
- test-syslog \
- test-uid-permissions \
- test-variant \
- $(NULL)
-
-if DBUS_UNIX
-# These binaries are used in tests but are not themselves tests
-installable_helpers += \
- test-apparmor-activation \
- $(NULL)
-
-installable_tests += \
- test-containers \
- test-sd-activation \
- $(NULL)
-
-dist_installable_test_scripts += \
- test-dbus-daemon-fork.sh \
- $(NULL)
-
-# Only runnable when installed, not from the source tree
-dist_installed_test_scripts += \
- integration/transient-services.sh \
- test-apparmor-activation.sh \
- $(NULL)
-
-# Testing dbus-launch relies on special code in that binary.
-if DBUS_ENABLE_EMBEDDED_TESTS
-dist_installable_test_scripts += \
- test-dbus-launch-eval.sh \
- $(NULL)
-
-if DBUS_ENABLE_X11_AUTOLAUNCH
-dist_installable_test_scripts += \
- test-dbus-launch-x11.sh \
- $(NULL)
-endif DBUS_ENABLE_X11_AUTOLAUNCH
-endif DBUS_ENABLE_EMBEDDED_TESTS
-
-endif DBUS_UNIX
-
-installable_manual_tests += \
- manual-authz \
- manual-test-thread-blocking \
- $(NULL)
-endif DBUS_WITH_GLIB
-
-installable_test_meta = \
- $(dist_installable_test_scripts:=.test) \
- $(dist_installed_test_scripts:=.test) \
- $(installable_tests:=.test) \
- $(NULL)
-installable_test_meta_with_config = \
- $(dist_installable_test_scripts:=_with_config.test) \
- $(dist_installed_test_scripts:=_with_config.test) \
- $(installable_tests:=_with_config.test) \
- $(NULL)
-
-installcheck_tests =
-installcheck_environment = \
- export XDG_DATA_HOME=@abs_top_builddir@/test/XDG_DATA_HOME; \
- export XDG_DATA_DIRS=@abs_top_builddir@/test/XDG_DATA_DIRS:$(DESTDIR)$(datadir); \
- export XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR; \
- export DBUS_SESSION_BUS_ADDRESS=do-not-use-real-session:; \
- export DBUS_TEST_DAEMON=$(DESTDIR)$(DBUS_DAEMONDIR)/dbus-daemon$(EXEEXT); \
- export DBUS_TEST_DBUS_LAUNCH=$(DESTDIR)$(bindir)/dbus-launch$(EXEEXT); \
- export DBUS_TEST_DBUS_MONITOR=$(DESTDIR)$(bindir)/dbus-monitor$(EXEEXT); \
- export DBUS_TEST_DBUS_SEND=$(DESTDIR)$(bindir)/dbus-send$(EXEEXT); \
- export DBUS_TEST_DBUS_UUIDGEN=$(DESTDIR)$(bindir)/dbus-uuidgen$(EXEEXT); \
- export DBUS_TEST_EXEC=@abs_top_builddir@/test; \
- export DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus; \
- export DBUS_TEST_DATADIR=$(DESTDIR)$(datadir); \
- export DBUS_TEST_UNINSTALLED=1; \
- export HOME=@abs_top_builddir@/dbus; \
- ${NULL}
-
-# Tests in bus/config-parser.c rely on these specific values for XDG_* and
-# DBUS_TEST_BUILDDIR.
-AM_TESTS_ENVIRONMENT = \
- export XDG_DATA_HOME=@abs_top_builddir@/test/XDG_DATA_HOME; \
- export XDG_DATA_DIRS=@abs_top_builddir@/test/XDG_DATA_DIRS:@abs_top_builddir@/test/XDG_DATA_DIRS2; \
- export XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR; \
- export DBUS_FATAL_WARNINGS=1; \
- export DBUS_SESSION_BUS_ADDRESS=do-not-use-real-session:; \
- export DBUS_TEST_BUILDDIR=@abs_builddir@; \
- export DBUS_TEST_SRCDIR=@abs_srcdir@; \
- export DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT); \
- export DBUS_TEST_DBUS_LAUNCH=@abs_top_builddir@/tools/dbus-launch$(EXEEXT); \
- export DBUS_TEST_DBUS_MONITOR=@abs_top_builddir@/tools/dbus-monitor$(EXEEXT); \
- export DBUS_TEST_DBUS_SEND=@abs_top_builddir@/tools/dbus-send$(EXEEXT); \
- export DBUS_TEST_DBUS_UUIDGEN=@abs_top_builddir@/tools/dbus-uuidgen$(EXEEXT); \
- export DBUS_TEST_DATA=@abs_top_builddir@/test/data; \
- export DBUS_TEST_EXEC=@abs_top_builddir@/test; \
- export DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus; \
- export DBUS_TEST_UNINSTALLED=1; \
- export HOME=@abs_top_builddir@/dbus; \
- $(NULL)
-
-manual_authz_SOURCES = manual-authz.c
-manual_authz_LDADD = \
- libdbus-testutils.la \
- $(GLIB_LIBS) \
- $(NULL)
-
-if DBUS_UNIX
-test_apparmor_activation_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -DDBUS_TEST_APPARMOR_ACTIVATION \
- $(NULL)
-test_apparmor_activation_SOURCES = \
- sd-activation.c \
- $(NULL)
-test_apparmor_activation_LDADD = \
- libdbus-testutils.la \
- $(APPARMOR_LIBS) \
- $(GLIB_LIBS) \
- $(NULL)
-endif
-
-test_containers_SOURCES = containers.c
-test_containers_LDADD = \
- libdbus-testutils.la \
- $(GLIB_LIBS) \
- $(NULL)
-
-test_corrupt_SOURCES = corrupt.c
-test_corrupt_LDADD = \
- libdbus-testutils.la \
- $(GLIB_LIBS) \
- $(NULL)
-
-test_loopback_SOURCES = loopback.c
-test_loopback_LDADD = \
- libdbus-testutils.la \
- $(GLIB_LIBS) \
- $(NULL)
-
-test_relay_SOURCES = relay.c
-test_relay_LDADD = \
- libdbus-testutils.la \
- $(GLIB_LIBS) \
- $(NULL)
-
-test_dbus_daemon_SOURCES = dbus-daemon.c
-test_dbus_daemon_LDADD = \
- libdbus-testutils.la \
- $(GLIB_LIBS) \
- $(GIO_UNIX_LIBS) \
- $(NULL)
-
-test_dbus_daemon_eavesdrop_SOURCES = dbus-daemon-eavesdrop.c
-test_dbus_daemon_eavesdrop_LDADD = \
- libdbus-testutils.la \
- $(GLIB_LIBS) \
- $(NULL)
-
-test_desktop_file_SOURCES = \
- internals/desktop-file.c \
- $(NULL)
-test_desktop_file_LDADD = \
- libdbus-testutils.la \
- $(top_builddir)/dbus/libdbus-internal.la \
- $(GLIB_LIBS) \
- $(NULL)
-
-test_header_fields_SOURCES = \
- header-fields.c \
- $(NULL)
-test_header_fields_LDADD = \
- libdbus-testutils.la \
- $(top_builddir)/dbus/libdbus-internal.la \
- $(GLIB_LIBS) \
- $(NULL)
-
-if DBUS_UNIX
-test_sd_activation_SOURCES = \
- sd-activation.c \
- $(NULL)
-test_sd_activation_LDADD = \
- libdbus-testutils.la \
- $(GLIB_LIBS) \
- $(NULL)
-endif
-
-test_marshal_SOURCES = marshal.c
-test_marshal_LDADD = \
- libdbus-testutils.la \
- $(GLIB_LIBS) \
- $(NULL)
-
-test_message_SOURCES = \
- message.c \
- $(NULL)
-test_message_LDADD = \
- libdbus-testutils.la \
- $(top_builddir)/dbus/libdbus-internal.la \
- $(GLIB_LIBS) \
- $(NULL)
-
-test_monitor_SOURCES = \
- monitor.c \
- $(NULL)
-test_monitor_LDADD = \
- libdbus-testutils.la \
- $(GLIB_LIBS) \
- $(NULL)
-
-test_syntax_SOURCES = syntax.c
-test_syntax_LDADD = \
- libdbus-testutils.la \
- $(GLIB_LIBS) \
- $(NULL)
-
-manual_test_thread_blocking_SOURCES = thread-blocking.c
-manual_test_thread_blocking_LDADD = \
- libdbus-testutils.la \
- $(GLIB_LIBS) \
- $(NULL)
-
-test_uid_permissions_SOURCES = \
- uid-permissions.c \
- $(NULL)
-test_uid_permissions_LDADD = \
- libdbus-testutils.la \
- $(GLIB_LIBS) \
- $(NULL)
-
-test_fdpass_SOURCES = \
- fdpass.c \
- $(NULL)
-test_fdpass_LDADD = \
- libdbus-testutils.la \
- $(GLIB_LIBS) \
- $(NULL)
-
-TESTS += $(dist_installable_test_scripts)
-installcheck_tests += $(dist_installable_test_scripts)
-
-if DBUS_ENABLE_MODULAR_TESTS
-TESTS += $(installable_tests)
-installcheck_tests += $(installable_tests)
-
-if DBUS_ENABLE_INSTALLED_TESTS
- nobase_testexec_PROGRAMS += $(installable_helpers)
- nobase_testexec_PROGRAMS += $(installable_manual_tests)
- nobase_testexec_PROGRAMS += $(installable_tests)
- nobase_dist_testexec_SCRIPTS += $(dist_installed_test_scripts)
- nobase_dist_testexec_SCRIPTS += $(dist_installable_test_scripts)
-
- nobase_testmeta_DATA += $(installable_test_meta)
- nobase_testmeta_DATA += $(installable_test_meta_with_config)
-else !DBUS_ENABLE_INSTALLED_TESTS
- noinst_PROGRAMS += $(installable_helpers)
- noinst_PROGRAMS += $(installable_manual_tests)
- noinst_PROGRAMS += $(installable_tests)
-endif !DBUS_ENABLE_INSTALLED_TESTS
-
-else !DBUS_ENABLE_MODULAR_TESTS
-
-if DBUS_ENABLE_EMBEDDED_TESTS
- noinst_PROGRAMS += $(installable_helpers)
-endif DBUS_ENABLE_EMBEDDED_TESTS
-
-endif !DBUS_ENABLE_MODULAR_TESTS
-
-# If we're installing the tests into a DESTDIR we can't run them
-# again using the installed copy, because we don't know how to
-# do a portable equivalent of setting LD_LIBRARY_PATH.
-installcheck-local:
- $(MAKE) check-TESTS TESTS='$$(installcheck_tests)' \
- AM_TESTS_ENVIRONMENT='$$(installcheck_environment)'
-if DBUS_ENABLE_INSTALLED_TESTS
- test -n "$(DESTDIR)" || { \
- $(installcheck_environment) \
- $(srcdir)/dbus-test-runner \
- $(testexecdir) \
- $(installable_tests); }
-endif DBUS_ENABLE_INSTALLED_TESTS
-
-in_data = \
- data/dbus-installed-tests.aaprofile.in \
- data/systemd-activation/com.example.ReceiveDeniedByAppArmorLabel.service.in \
- data/systemd-activation/com.example.SendDeniedByAppArmorLabel.service.in \
- data/systemd-activation/com.example.SendDeniedByNonexistentAppArmorLabel.service.in \
- data/systemd-activation/com.example.SystemdActivatable3.service.in \
- data/valid-config-files-system/debug-allow-all-fail.conf.in \
- data/valid-config-files-system/debug-allow-all-pass.conf.in \
- data/valid-config-files/as-another-user.conf.in \
- data/valid-config-files/count-fds.conf.in \
- data/valid-config-files/debug-allow-all-sha1.conf.in \
- data/valid-config-files/debug-allow-all.conf.in \
- data/valid-config-files/finite-timeout.conf.in \
- data/valid-config-files/forbidding.conf.in \
- data/valid-config-files/incoming-limit.conf.in \
- data/valid-config-files/limit-containers.conf.in \
- data/valid-config-files/max-completed-connections.conf.in \
- data/valid-config-files/max-connections-per-user.conf.in \
- data/valid-config-files/max-containers.conf.in \
- data/valid-config-files/max-match-rules-per-connection.conf.in \
- data/valid-config-files/max-names-per-connection.conf.in \
- data/valid-config-files/max-replies-per-connection.conf.in \
- data/valid-config-files/multi-user.conf.in \
- data/valid-config-files/pending-fd-timeout.conf.in \
- data/valid-config-files/send-destination-prefix-rules.conf.in \
- data/valid-config-files/systemd-activation.conf.in \
- data/valid-config-files/tmp-session.conf.in \
- data/valid-config-files-system/tmp-session-like-system.conf.in \
- data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoExec.service.in \
- data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoService.service.in \
- data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoUser.service.in \
- data/valid-service-files-system/org.freedesktop.DBus.TestSuiteEchoService.service.in \
- data/valid-service-files-system/org.freedesktop.DBus.TestSuiteSegfaultService.service.in \
- data/valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service.in \
- data/valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service.in \
- data/valid-service-files/org.freedesktop.DBus.TestSuite.PrivServer.service.in \
- data/valid-service-files/org.freedesktop.DBus.TestSuiteEchoService.service.in \
- data/valid-service-files/org.freedesktop.DBus.TestSuiteForkingEchoService.service.in \
- data/valid-service-files/org.freedesktop.DBus.TestSuiteSegfaultService.service.in \
- data/valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service.in \
- data/valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service.in \
- $(NULL)
-
-EXTRA_DIST += $(in_data)
-
-static_data = \
- data/auth/anonymous-client-successful.auth-script \
- data/auth/anonymous-server-successful.auth-script \
- data/auth/cancel.auth-script \
- data/auth/client-out-of-mechanisms.auth-script \
- data/auth/cookie-sha1-username.auth-script \
- data/auth/cookie-sha1.auth-script \
- data/auth/external-auto.auth-script \
- data/auth/external-failed.auth-script \
- data/auth/external-root.auth-script \
- data/auth/external-silly.auth-script \
- data/auth/external-successful.auth-script \
- data/auth/external-username.auth-script \
- data/auth/extra-bytes.auth-script \
- data/auth/fail-after-n-attempts.auth-script \
- data/auth/fallback.auth-script \
- data/auth/invalid-command-client.auth-script \
- data/auth/invalid-command.auth-script \
- data/auth/invalid-hex-encoding.auth-script \
- data/auth/mechanisms.auth-script \
- data/equiv-config-files/basic/basic-1.conf \
- data/equiv-config-files/basic/basic-2.conf \
- data/equiv-config-files/basic/basic.d/basic.conf \
- data/equiv-config-files/entities/basic.d/basic.conf \
- data/equiv-config-files/entities/entities-1.conf \
- data/equiv-config-files/entities/entities-2.conf \
- data/invalid-config-files/apparmor-bad-attribute.conf \
- data/invalid-config-files/apparmor-bad-mode.conf \
- data/invalid-config-files/bad-attribute.conf \
- data/invalid-config-files/bad-attribute-2.conf \
- data/invalid-config-files/bad-element.conf \
- data/invalid-config-files/bad-limit.conf \
- data/invalid-config-files/badselinux-1.conf \
- data/invalid-config-files/badselinux-2.conf \
- data/invalid-config-files/circular-1.conf \
- data/invalid-config-files/circular-2.conf \
- data/invalid-config-files/circular-3.conf \
- data/invalid-config-files/double-attribute.conf \
- data/invalid-config-files/impossible-send.conf \
- data/invalid-config-files/limit-no-name.conf \
- data/invalid-config-files/ludicrous-limit.conf \
- data/invalid-config-files/negative-limit.conf \
- data/invalid-config-files/non-numeric-limit.conf \
- data/invalid-config-files/not-well-formed.conf \
- data/invalid-config-files/policy-bad-at-console.conf \
- data/invalid-config-files/policy-bad-attribute.conf \
- data/invalid-config-files/policy-bad-context.conf \
- data/invalid-config-files/policy-bad-rule-attribute.conf \
- data/invalid-config-files/policy-contradiction.conf \
- data/invalid-config-files/policy-member-no-path.conf \
- data/invalid-config-files/policy-mixed.conf \
- data/invalid-config-files/policy-no-attributes.conf \
- data/invalid-config-files/policy-no-rule-attribute.conf \
- data/invalid-config-files/truncated-file.conf \
- data/invalid-config-files/send-and-receive.conf \
- data/invalid-config-files/unknown-limit.conf \
- data/invalid-messages/boolean-has-no-value.message-raw \
- data/sha-1/Readme.txt \
- data/sha-1/bit-hashes.sha1 \
- data/sha-1/bit-messages.sha1 \
- data/sha-1/byte-hashes.sha1 \
- data/sha-1/byte-messages.sha1 \
- data/systemd-activation/com.example.ReceiveDenied.service \
- data/systemd-activation/com.example.SendDenied.service \
- data/systemd-activation/com.example.SendDeniedByAppArmorName.service \
- data/systemd-activation/com.example.SendPrefixDenied.service \
- data/systemd-activation/com.example.SendPrefixDenied.internal.service \
- data/systemd-activation/com.example.SendPrefixDenied.SendPrefixAllowed.internal.service \
- data/systemd-activation/com.example.SystemdActivatable1.service \
- data/systemd-activation/com.example.SystemdActivatable2.service \
- data/systemd-activation/org.freedesktop.systemd1.service \
- data/valid-config-files/basic.conf \
- data/valid-config-files/basic.d/basic.conf \
- data/valid-config-files/check-own-rules.conf \
- data/valid-config-files/entities.conf \
- data/valid-config-files/listen-unix-runtime.conf \
- data/valid-config-files/many-rules.conf \
- data/valid-config-files/minimal.conf \
- data/valid-config-files/standard-session-dirs.conf \
- data/valid-config-files-system/many-rules.conf \
- data/valid-config-files-system/system.d/test.conf \
- $(NULL)
-
-EXTRA_DIST += $(static_data)
-
-## copy tests to builddir so that generated tests and static tests
-## are all in one place.
-## Note that we can't create the XDG_RUNTIME_DIR with permissions 0700
-## on MSYS2, which rejects attempts to change permissions, hence "|| true".
-all-local: copy-config-local uninstalled-config-local
- $(AM_V_at)$(MKDIR_P) XDG_RUNTIME_DIR
- $(AM_V_at)chmod 0700 XDG_RUNTIME_DIR || true
-
-copy-config-local:
- $(AM_V_at)$(MKDIR_P) data/valid-config-files/session.d
- $(AM_V_GEN)set -e; \
- if test $(srcdir) = . || test $(srcdir) -ef .; then \
- echo '-- No need to copy test data as srcdir = builddir'; \
- else \
- for F in $(static_data); do \
- $(MKDIR_P) "$${F%/*}"; \
- rm -f "$$F"; \
- cp $(srcdir)/"$$F" "$$F"; \
- done; \
- fi
-
-uninstalled-config-local:
- $(AM_V_GEN)set -e; \
- for F in $(in_data); do \
- $(MKDIR_P) "$${F%/*}"; \
- sed \
- -e 's,[@]DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL[@],$(DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL),' \
- -e 's,[@]DBUS_SESSION_BUS_LISTEN_ADDRESS[@],$(DBUS_SESSION_BUS_LISTEN_ADDRESS),' \
- -e 's,[@]DBUS_TEST_DATA[@],@abs_builddir@/data,' \
- -e 's,[@]DBUS_TEST_EXEC[@],@abs_builddir@,' \
- -e 's,[@]DBUS_USER[@],$(DBUS_USER),' \
- -e 's,[@]EXEEXT[@],$(EXEEXT),' \
- -e 's,[@]TEST_LAUNCH_HELPER_BINARY[@],@abs_top_builddir@/test/dbus-daemon-launch-helper-for-tests$(EXEEXT),' \
- -e 's,[@]TEST_LISTEN[@],$(TEST_LISTEN),' \
- < $(srcdir)/"$$F" > "$${F%.in}"; \
- done
-
-installable-config-local:
-if DBUS_ENABLE_INSTALLED_TESTS
- $(AM_V_GEN)set -e; \
- for F in $(in_data); do \
- $(MKDIR_P) "installable/$${F%/*}"; \
- sed \
- -e 's,[@]DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL[@],$(DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL),' \
- -e 's,[@]DBUS_SESSION_BUS_LISTEN_ADDRESS[@],$(DBUS_SESSION_BUS_LISTEN_ADDRESS),' \
- -e 's,[@]DBUS_TEST_DATA[@],$(testexecdir)/data,' \
- -e 's,[@]DBUS_TEST_EXEC[@],$(testexecdir),' \
- -e 's,[@]DBUS_USER[@],$(DBUS_USER),' \
- -e 's,[@]EXEEXT[@],$(EXEEXT),' \
- -e 's,[@]TEST_LAUNCH_HELPER_BINARY[@],/bin/false,' \
- -e 's,[@]TEST_LISTEN[@],$(TEST_LISTEN),' \
- < $(srcdir)/"$$F" > "installable/$${F%.in}"; \
- done
-else
- @:
-endif
-
-
-install-data-local: install-config-local
- @:
-
-install-config-local: installable-config-local
-if DBUS_ENABLE_INSTALLED_TESTS
- $(AM_V_GEN)set -e; \
- for F in $(static_data); do \
- install -d "$(DESTDIR)$(testexecdir)/$${F%/*}"; \
- install -m644 "$(srcdir)/$$F" "$(DESTDIR)$(testexecdir)/$$F"; \
- done; \
- for F in $(in_data); do \
- install -d "$(DESTDIR)$(testexecdir)/$${F%/*}"; \
- install -m644 "installable/$${F%.in}" "$(DESTDIR)$(testexecdir)/$${F%.in}"; \
- done
- ln -nfs $(datadir)/dbus-1/session.conf $(DESTDIR)$(testexecdir)/data/valid-config-files/session.conf
- ln -nfs $(datadir)/dbus-1/system.conf $(DESTDIR)$(testexecdir)/data/valid-config-files-system/system.conf
-else
- @:
-endif
-
-## this doesn't clean most copied test data files when srcdir=builddir
-clean-local:
- $(AM_V_at)if test $(srcdir) = . || test $(srcdir) -ef .; then \
- echo '-- No need to clean test data as srcdir = builddir'; \
- else \
- rm -f $(static_data); \
- for F in $(in_data); do \
- rm -f "$${F%.in}"; \
- done; \
- fi
- rm -fr ./XDG_RUNTIME_DIR ./installable
-
-imported_data = \
- data/valid-config-files/session.conf \
- data/valid-config-files-system/system.conf \
- $(NULL)
-
-noinst_DATA = $(imported_data)
-CLEANFILES += \
- $(noinst_DATA) \
- $(NULL)
-
-data/valid-config-files/session.conf: $(top_builddir)/bus/session.conf
- $(AM_V_at)$(MKDIR_P) data/valid-config-files
- $(AM_V_GEN)cp $< $@
-
-data/valid-config-files-system/system.conf: $(top_builddir)/bus/system.conf
- $(AM_V_at)$(MKDIR_P) data/valid-config-files-system
- $(AM_V_GEN)cp $< $@
-
-$(installable_test_meta): %.test: %$(EXEEXT) Makefile
- $(AM_V_at)$(MKDIR_P) $(dir $@)
- $(AM_V_GEN) ( \
- echo '[Test]'; \
- echo 'Type=session'; \
- echo 'Output=TAP'; \
- echo 'Exec=env $(testexecdir)/$* --tap'; \
- ) > $@.tmp && mv $@.tmp $@
-
-$(installable_test_meta_with_config): %_with_config.test: %$(EXEEXT) Makefile
- $(AM_V_at)$(MKDIR_P) $(dir $@)
- $(AM_V_GEN) ( \
- echo '[Test]'; \
- echo 'Type=session'; \
- echo 'Output=TAP'; \
- echo 'Exec=env DBUS_TEST_EXEC=$(testexecdir) DBUS_TEST_DATA=$(testexecdir)/data $(testexecdir)/$* --tap'; \
- ) > $@.tmp && mv $@.tmp $@
-
-# Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE
-include $(top_srcdir)/aminclude_static.am
diff --git a/test/bus/dispatch.c b/test/bus/common.c
index ad6718fe..e8b38dc9 100644
--- a/test/bus/dispatch.c
+++ b/test/bus/common.c
@@ -1,7 +1,8 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright 2003-2009 Red Hat, Inc.
- * Copyright 2011-2018 Collabora Ltd.
+ * Copyright 2011-2022 Collabora Ltd.
+ * SPDX-License-Identifier: AFL-2.1 or GPL-2.0-or-later
*
* Licensed under the Academic Free License version 2.1
*
@@ -18,17 +19,14 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
*/
#include <config.h>
-#include "bus/test.h"
-
-#include <dbus/dbus-test-tap.h>
-
#include "bus/audit.h"
#include "bus/selinux.h"
+
+#include "test/bus/common.h"
#include "test/test-utils.h"
#ifndef DBUS_ENABLE_EMBEDDED_TESTS
@@ -49,12 +47,13 @@ test_post_hook (void)
bus_audit_shutdown ();
}
-static DBusTestCase test = { "dispatch", bus_dispatch_test };
-
int
-main (int argc, char **argv)
+bus_test_main (int argc,
+ char **argv,
+ size_t n_tests,
+ const DBusTestCase *tests)
{
- return _dbus_test_main (argc, argv, 1, &test,
+ return _dbus_test_main (argc, argv, n_tests, tests,
(DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS |
DBUS_TEST_FLAGS_CHECK_FD_LEAKS |
DBUS_TEST_FLAGS_REQUIRE_DATA),
diff --git a/test/bus/common.h b/test/bus/common.h
new file mode 100644
index 00000000..0f3c87d0
--- /dev/null
+++ b/test/bus/common.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2022 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef TEST_BUS_COMMON_H
+#define TEST_BUS_COMMON_H
+
+#ifndef DBUS_ENABLE_EMBEDDED_TESTS
+#error This file is only relevant for the embedded tests
+#endif
+
+#include "bus/test.h"
+#include "test/test-utils.h"
+
+int bus_test_main (int argc,
+ char **argv,
+ size_t n_tests,
+ const DBusTestCase *tests);
+
+#endif
diff --git a/test/bus/dispatch-sha1.c b/test/bus/dispatch-sha1.c
index a32508bc..d36cb70c 100644
--- a/test/bus/dispatch-sha1.c
+++ b/test/bus/dispatch-sha1.c
@@ -3,6 +3,8 @@
* Copyright 2003-2009 Red Hat, Inc.
* Copyright 2011-2018 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -22,41 +24,12 @@
*/
#include <config.h>
-
-#include "bus/test.h"
-
-#include <dbus/dbus-test-tap.h>
-
-#include "bus/audit.h"
-#include "bus/selinux.h"
-#include "test/test-utils.h"
-
-#ifndef DBUS_ENABLE_EMBEDDED_TESTS
-#error This file is only relevant for the embedded tests
-#endif
-
-static void
-test_pre_hook (void)
-{
-}
-
-static void
-test_post_hook (void)
-{
- if (_dbus_getenv ("DBUS_TEST_SELINUX"))
- bus_selinux_shutdown ();
-
- bus_audit_shutdown ();
-}
+#include "test/bus/common.h"
static DBusTestCase test = { "dispatch-sha1", bus_dispatch_sha1_test };
int
main (int argc, char **argv)
{
- return _dbus_test_main (argc, argv, 1, &test,
- (DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS |
- DBUS_TEST_FLAGS_CHECK_FD_LEAKS |
- DBUS_TEST_FLAGS_REQUIRE_DATA),
- test_pre_hook, test_post_hook);
+ return bus_test_main (argc, argv, 1, &test);
}
diff --git a/dbus/dbus-server-unix.h b/test/bus/failed-helper-activation.c
index be33fa70..ee740054 100644
--- a/dbus/dbus-server-unix.h
+++ b/test/bus/failed-helper-activation.c
@@ -1,7 +1,9 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
-/* dbus-server-unix.h Server implementation for Unix network protocols.
+/*
+ * Copyright 2003-2009 Red Hat, Inc.
+ * Copyright 2011-2018 Collabora Ltd.
*
- * Copyright (C) 2002 Red Hat Inc.
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
*
* Licensed under the Academic Free License version 2.1
*
@@ -20,18 +22,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-#ifndef DBUS_SERVER_UNIX_H
-#define DBUS_SERVER_UNIX_H
-#include <dbus/dbus-internals.h>
-#include <dbus/dbus-server-protected.h>
+#include <config.h>
+#include "test/bus/common.h"
-DBUS_BEGIN_DECLS
+static DBusTestCase test =
+{
+ "failed-helper-activation",
+ bus_test_failed_helper_activation
+};
-DBusServer* _dbus_server_new_for_domain_socket (const char *path,
- dbus_bool_t abstract,
- DBusError *error);
-
-DBUS_END_DECLS
-
-#endif /* DBUS_SERVER_UNIX_H */
+int
+main (int argc, char **argv)
+{
+ return bus_test_main (argc, argv, 1, &test);
+}
diff --git a/test/bus/helper-activation.c b/test/bus/helper-activation.c
new file mode 100644
index 00000000..9cb3907a
--- /dev/null
+++ b/test/bus/helper-activation.c
@@ -0,0 +1,35 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright 2003-2009 Red Hat, Inc.
+ * Copyright 2011-2018 Collabora Ltd.
+ *
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include <config.h>
+#include "test/bus/common.h"
+
+static DBusTestCase test = { "helper-activation", bus_test_helper_activation };
+
+int
+main (int argc, char **argv)
+{
+ return bus_test_main (argc, argv, 1, &test);
+}
diff --git a/test/bus/launch-helper-for-tests.c b/test/bus/launch-helper-for-tests.c
index 6ad003d0..e8f29d37 100644
--- a/test/bus/launch-helper-for-tests.c
+++ b/test/bus/launch-helper-for-tests.c
@@ -1,4 +1,8 @@
-/* Embed a version of the real activation helper that has been altered
+/*
+ * Copyright 2018 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ *
+ * Embed a version of the real activation helper that has been altered
* to be testable. We monkey-patch it like this because we don't want to
* compile test-only code into the real setuid executable, and Automake
* versions older than 1.16 can't cope with expanding directory variables
diff --git a/test/bus/launch-helper-oom.c b/test/bus/launch-helper-oom.c
index 8a9879e1..415eb8ce 100644
--- a/test/bus/launch-helper-oom.c
+++ b/test/bus/launch-helper-oom.c
@@ -4,6 +4,8 @@
* Copyright 2007 Red Hat, Inc.
* Copyright 2013-2018 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/bus/main.c b/test/bus/main.c
index 445e9269..013be480 100644
--- a/test/bus/main.c
+++ b/test/bus/main.c
@@ -4,6 +4,8 @@
* Copyright 2003-2009 Red Hat, Inc.
* Copyright 2011-2018 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -23,32 +25,7 @@
*/
#include <config.h>
-
-#include "bus/test.h"
-
-#include <dbus/dbus-test-tap.h>
-
-#include "bus/audit.h"
-#include "bus/selinux.h"
-#include "test/test-utils.h"
-
-#ifndef DBUS_ENABLE_EMBEDDED_TESTS
-#error This file is only relevant for the embedded tests
-#endif
-
-static void
-test_pre_hook (void)
-{
-}
-
-static void
-test_post_hook (void)
-{
- if (_dbus_getenv ("DBUS_TEST_SELINUX"))
- bus_selinux_shutdown ();
-
- bus_audit_shutdown ();
-}
+#include "test/bus/common.h"
static DBusTestCase tests[] =
{
@@ -63,9 +40,5 @@ static DBusTestCase tests[] =
int
main (int argc, char **argv)
{
- return _dbus_test_main (argc, argv, _DBUS_N_ELEMENTS (tests), tests,
- (DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS |
- DBUS_TEST_FLAGS_CHECK_FD_LEAKS |
- DBUS_TEST_FLAGS_REQUIRE_DATA),
- test_pre_hook, test_post_hook);
+ return bus_test_main (argc, argv, _DBUS_N_ELEMENTS (tests), tests);
}
diff --git a/test/bus/normal-activation.c b/test/bus/normal-activation.c
new file mode 100644
index 00000000..326f777e
--- /dev/null
+++ b/test/bus/normal-activation.c
@@ -0,0 +1,35 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright 2003-2009 Red Hat, Inc.
+ * Copyright 2011-2018 Collabora Ltd.
+ *
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include <config.h>
+#include "test/bus/common.h"
+
+static DBusTestCase test = { "normal-activation", bus_test_normal_activation };
+
+int
+main (int argc, char **argv)
+{
+ return bus_test_main (argc, argv, 1, &test);
+}
diff --git a/test/bus/system.c b/test/bus/system.c
index 38307e1f..d6cf33f6 100644
--- a/test/bus/system.c
+++ b/test/bus/system.c
@@ -4,6 +4,8 @@
* Copyright 2003-2007 Red Hat, Inc.
* Copyright 2013-2018 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/containers.c b/test/containers.c
index dcc81c5c..79636460 100644
--- a/test/containers.c
+++ b/test/containers.c
@@ -1,6 +1,7 @@
/* Integration tests for restricted sockets for containers
*
* Copyright © 2017-2018 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -46,6 +47,8 @@
#include "test-utils-glib.h"
+#define DBUS_INTERFACE_CONTAINERS1 "org.freedesktop.DBus.Containers1"
+
typedef struct {
TestMainContext *ctx;
gboolean skip;
diff --git a/test/corrupt.c b/test/corrupt.c
index 758084a4..5eb3ff3f 100644
--- a/test/corrupt.c
+++ b/test/corrupt.c
@@ -2,6 +2,7 @@
*
* Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Copyright © 2010-2011 Nokia Corporation
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -86,9 +87,10 @@ setup (Fixture *f,
dbus_error_init (&f->e);
g_queue_init (&f->client_messages);
- if ((g_str_has_prefix (addr, "tcp:") ||
- g_str_has_prefix (addr, "nonce-tcp:")) &&
- !test_check_tcp_works ())
+ if ((g_str_has_prefix (addr, "unix:") && !test_check_af_unix_works ()) ||
+ ((g_str_has_prefix (addr, "tcp:") ||
+ g_str_has_prefix (addr, "nonce-tcp:")) &&
+ !test_check_tcp_works ()))
{
f->skip = TRUE;
return;
@@ -406,26 +408,31 @@ main (int argc,
char **argv)
{
int ret;
+#ifdef DBUS_UNIX
+ char *tmp = _dbus_strdup ("/tmp");
+#else
+ char *tmp = dbus_address_escape_value (g_get_tmp_dir ());
+#endif
+ gchar *unix_tmpdir = g_strdup_printf ("unix:tmpdir=%s", tmp);
test_init (&argc, &argv);
g_test_add ("/corrupt/tcp", Fixture, "tcp:host=127.0.0.1", setup,
test_corrupt, teardown);
-#ifdef DBUS_UNIX
- g_test_add ("/corrupt/unix", Fixture, "unix:tmpdir=/tmp", setup,
+ g_test_add ("/corrupt/unix", Fixture, unix_tmpdir, setup,
test_corrupt, teardown);
-#endif
g_test_add ("/corrupt/byte-order/tcp", Fixture, "tcp:host=127.0.0.1", setup,
test_byte_order, teardown);
-#ifdef DBUS_UNIX
- g_test_add ("/corrupt/byte-order/unix", Fixture, "unix:tmpdir=/tmp", setup,
+ g_test_add ("/corrupt/byte-order/unix", Fixture, unix_tmpdir, setup,
test_byte_order, teardown);
-#endif
ret = g_test_run ();
dbus_shutdown ();
+
+ g_free (unix_tmpdir);
+ dbus_free (tmp);
return ret;
}
diff --git a/test/data/copy_data_for_tests.py b/test/data/copy_data_for_tests.py
new file mode 100755
index 00000000..7a49c4c0
--- /dev/null
+++ b/test/data/copy_data_for_tests.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+import sys, os, shutil
+
+def pairs(args):
+ while args:
+ yield (args[0], args[1])
+ args = args[2:]
+
+for src, dst in pairs(sys.argv[1:]):
+ os.makedirs(os.path.dirname(dst), exist_ok=True)
+ try:
+ shutil.copy(src, dst)
+ except (IOError, OSError) as e:
+ print(e.filename)
diff --git a/test/data/dbus-installed-tests.aaprofile.in b/test/data/dbus-installed-tests.aaprofile.in
index 7a65282a..823d24c2 100644
--- a/test/data/dbus-installed-tests.aaprofile.in
+++ b/test/data/dbus-installed-tests.aaprofile.in
@@ -1,4 +1,5 @@
# Copyright © 2016 Collabora Ltd.
+# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
@@ -32,6 +33,7 @@
# We aren't really confining this process seriously; allow most things.
/** mrix,
/tmp/dbus-daemon-test.*/{,**} w,
+ /tmp/dbus-* w,
@{sys}/kernel/security/apparmor/** w,
dbus (send, receive, bind),
network,
@@ -44,6 +46,7 @@
#include <abstractions/base>
/** mrix,
+ /tmp/dbus-* w,
@{sys}/kernel/security/apparmor/** w,
dbus (send, receive, bind),
network,
@@ -62,6 +65,7 @@
#include <abstractions/base>
/** mrix,
+ /tmp/dbus-* w,
@{sys}/kernel/security/apparmor/** w,
dbus,
network,
@@ -88,6 +92,7 @@
#include <abstractions/base>
/** mrix,
+ /tmp/dbus-* w,
@{sys}/kernel/security/apparmor/** w,
dbus (send, receive, bind),
network,
diff --git a/test/data/installable/meson.build b/test/data/installable/meson.build
new file mode 100644
index 00000000..68bc8705
--- /dev/null
+++ b/test/data/installable/meson.build
@@ -0,0 +1,45 @@
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+# Some configuration parameters used in installed-tests are not the same
+# as the configuration parameters used during build-time testing.
+installed_tests_config = configuration_data()
+installed_tests_config.merge_from(data_config)
+installed_tests_config.set('DBUS_TEST_DATA', get_option('prefix') / test_exec_dir / 'data')
+installed_tests_config.set('DBUS_TEST_EXEC', get_option('prefix') / test_exec_dir)
+installed_tests_config.set('EXEEXT', exe_ext)
+installed_tests_config.set('TEST_LAUNCH_HELPER_BINARY', '/bin/false')
+
+foreach file : data_in_to_install
+ # Underscorify the output name because Meson doesn't allow subdir output files
+ configured_file = configure_file(
+ input : files('../' + file + '.in'),
+ output: file.underscorify(),
+ configuration: installed_tests_config,
+ )
+ if install_tests
+ install_data(configured_file,
+ rename: file,
+ install_dir: test_exec_dir / 'data',
+ )
+ endif
+endforeach
diff --git a/test/data/invalid-messages/boolean-has-no-value.message-raw.license b/test/data/invalid-messages/boolean-has-no-value.message-raw.license
new file mode 100644
index 00000000..31bb323c
--- /dev/null
+++ b/test/data/invalid-messages/boolean-has-no-value.message-raw.license
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: 2003 Red Hat, Inc.
+SPDX-License-Identifier: MIT
diff --git a/test/data/invalid-messages/fixed-array-not-divisible.message-raw b/test/data/invalid-messages/fixed-array-not-divisible.message-raw
new file mode 100644
index 00000000..d7de929d
--- /dev/null
+++ b/test/data/invalid-messages/fixed-array-not-divisible.message-raw
Binary files differ
diff --git a/test/data/invalid-messages/fixed-array-not-divisible.message-raw.hex b/test/data/invalid-messages/fixed-array-not-divisible.message-raw.hex
new file mode 100644
index 00000000..0527abd5
--- /dev/null
+++ b/test/data/invalid-messages/fixed-array-not-divisible.message-raw.hex
@@ -0,0 +1,55 @@
+# Copyright 2022 Evgeny Vereshchagin
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+#
+# This is an annotated hex-dump of a message originally generated by a
+# fuzzer.
+#
+# To output as binary:
+# sed -e 's/#.*//' test/data/invalid-messages/fixed-array-not-divisible.message-raw.hex |
+# xxd -p -r - test/data/invalid-messages/fixed-array-not-divisible.message-raw
+#
+# This message is invalid because the array of int64 has a length that is
+# not a multiple of the length of an item.
+
+# Offset % 0x10:
+# 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f
+
+ 6c # little-endian
+ 40 # an undefined message type
+ ff # flags = all set
+ 01 # major protocol version = 1
+ 0000 0000 # message body is 0 bytes
+ f600 59df # serial number 0xdf5900f6
+ 1801 0000 # header is an array of 0x0118 bytes of struct (yv)
+ 52 # header field code 0x52 (an undefined header)
+ 11 # signature is 0x11 = 17 bytes, + \0
+ 6128 6128 7979 7979 7979 7979 2979 # "a(a(yyyyyyyy)y"...
+ 6174 2900 # ..."at)" + trailing \0
+ 0001 0000 # outer array is 0x0100 = 256 bytes in total
+ # enter first a(yyyyyyyy)yat
+ d800 0000 # inner array is 0xd8 = 216 bytes in total
+ 0000 0000 # padding to 8-byte boundary (not included in the 216)
+ # enter array of (yyyyyyyy), 8-byte structures
+ 016f 5d00 0000 0000 # first struct (yyyyyyyy), 8 arbitrary bytes
+ 0001 5602 4472 6565 # second struct (yyyyyyyy), etc.
+ 6465 736b 0000 17f6 0059 df20 dfff 09a9 # {
+ 1161 2061 2879 7179 00d8 42e9 2f6f 7267 # {
+ 6565 6420 2020 2020 2020 2000 2020 2020 # {
+ 2020 2020 2020 2020 2020 2020 2020 20b0 # {
+ 0024 0000 0000 0000 e6df dfdf 2020 2020 # {
+ 6500 0000 0000 0000 0000 0000 0000 0000 # { arbitrary, fuzzer-generated
+ 0000 0000 0000 0000 0000 0000 0000 0000 # {
+ 0000 0000 0000 0000 0000 0000 0000 0000 # {
+ 2875 7987 ff27 b5e9 d901 0000 5e30 4b79 # {
+ 0001 6f2d 5d67 446f 7244 4472 6565 6400 # {
+ 1765 6b73 00f6 0059 ffa9 1161 2061 2879 # {
+ 71fd 7eee ff01 0000 0000 0000 1067 c8c8 # {
+ c8c8 c8c8 c801 0000 # 27th struct (yyyyyyyy)
+ 00 # byte (y) = 0
+ 00 0000 # padding to 4-byte boundary
+ 0500 0000 # array of int64 (at) is 5 bytes long, which makes no sense
+ 0000 faff 0000 0000 0000 0000 0000 0000
+ 1200 0000 0000 0000
+
+#sha1 30fafa4da12cdedc1361ad2e8ecf2ced5ae7d6eb
diff --git a/test/data/invalid-messages/fixed-array-not-divisible.message-raw.license b/test/data/invalid-messages/fixed-array-not-divisible.message-raw.license
new file mode 100644
index 00000000..252ebde8
--- /dev/null
+++ b/test/data/invalid-messages/fixed-array-not-divisible.message-raw.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2022 Evgeny Vereshchagin
+SPDX-FileCopyrightText: 2022 Collabora Ltd.
+SPDX-License-Identifier: MIT
diff --git a/test/data/invalid-messages/issue418.message-raw b/test/data/invalid-messages/issue418.message-raw
new file mode 100644
index 00000000..c0aec6fe
--- /dev/null
+++ b/test/data/invalid-messages/issue418.message-raw
Binary files differ
diff --git a/test/data/invalid-messages/issue418.message-raw.hex b/test/data/invalid-messages/issue418.message-raw.hex
new file mode 100644
index 00000000..05a42e6a
--- /dev/null
+++ b/test/data/invalid-messages/issue418.message-raw.hex
@@ -0,0 +1,47 @@
+# Copyright 2022 Evgeny Vereshchagin
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+#
+# This is an annotated hex-dump of a message originally generated by a
+# fuzzer.
+#
+# To output as binary:
+# sed -e 's/#.*//' test/data/invalid-messages/issue418.message-raw.hex |
+# xxd -p -r - test/data/invalid-messages/issue418.message-raw
+#
+# The rather non-specific name is because this message is invalid in at
+# least three separate ways:
+#
+# - parentheses and curly brackets in the signature are not nested correctly
+# - the signature of one header field is of zero length
+# - the signature of another header field is longer than the message
+#
+# mis-nested-sig.message-raw.hex,
+# truncated-variant-sig.message-raw.hex,
+# zero-length-variant-sig.message-raw.hex are simplified versions of this
+# message with only one of those reasons to be invalid.
+
+# Offset % 0x10:
+# 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f
+
+ 6c # little-endian
+ 8f # an undefined message type
+ 28 # flags
+ 01 # major protocol version 1
+ 0000 0000 # message body is 0 bytes
+ 7b22 0008 # serial number 0x0800227b
+ 1800 0000 # header is an array of 0x18 bytes of struct (yv)
+ fd # header field code 0xfd (an undefined header)
+ 15 # signature is 0x15 = 21 bytes
+ 2874 617b 7961 7b64 617b 7961 7b79 # "(ta{ya{da{ya{y"...
+ 6171 7d7d 7d29 7d00 # "aq}}})}" \0
+ 0000 0000 0000 0000 # padding to 8-byte boundary
+ 0c # header field code 0x0c
+ 00 # signature is zero-length (invalid!)
+ 00 # "" \0
+ 00 0000 0000 0000 0000 0000 0000 # padding
+ fe # header field code 0xfe
+ ff # signature is 0xff = 255 bytes
+ 0000 # truncated (invalid!)
+
+#sha1 e5d2bc02229d93ffdd7f589b7123adb3902ee981
diff --git a/test/data/invalid-messages/issue418.message-raw.license b/test/data/invalid-messages/issue418.message-raw.license
new file mode 100644
index 00000000..252ebde8
--- /dev/null
+++ b/test/data/invalid-messages/issue418.message-raw.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2022 Evgeny Vereshchagin
+SPDX-FileCopyrightText: 2022 Collabora Ltd.
+SPDX-License-Identifier: MIT
diff --git a/test/data/invalid-messages/mis-nested-sig.message-raw b/test/data/invalid-messages/mis-nested-sig.message-raw
new file mode 100644
index 00000000..54ab7a2f
--- /dev/null
+++ b/test/data/invalid-messages/mis-nested-sig.message-raw
Binary files differ
diff --git a/test/data/invalid-messages/mis-nested-sig.message-raw.hex b/test/data/invalid-messages/mis-nested-sig.message-raw.hex
new file mode 100644
index 00000000..fdc39b6f
--- /dev/null
+++ b/test/data/invalid-messages/mis-nested-sig.message-raw.hex
@@ -0,0 +1,26 @@
+# Copyright 2022 Evgeny Vereshchagin
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+#
+# Simplified from fuzzer output (see issue418.message-raw.hex).
+#
+# To output as binary:
+# sed -e 's/#.*//' test/data/invalid-messages/mis-nested-sig.message-raw.hex |
+# xxd -p -r - test/data/invalid-messages/mis-nested-sig.message-raw
+
+# Offset % 0x10:
+# 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f
+
+ 6c # little-endian
+ ff # an undefined message type
+ 00 # flags
+ 01 # major protocol version 1
+ 0000 0000 # message body is 0 bytes
+ 0100 0000 # serial number 1
+ 1800 0000 # header is an array of 0x18 bytes of struct (yv)
+ ff # header field code 0xff (an undefined header)
+ 15 # signature is 0x15 = 21 bytes
+ 2874 617b 7961 7b64 617b 7961 7b79 # "(ta{ya{da{ya{y"...
+ 6171 7d7d 7d29 7d00 # "aq}}})}" \0
+
+#sha1 90533a4ddb9aa5e82c67789a5624762367620b24
diff --git a/test/data/invalid-messages/mis-nested-sig.message-raw.license b/test/data/invalid-messages/mis-nested-sig.message-raw.license
new file mode 100644
index 00000000..252ebde8
--- /dev/null
+++ b/test/data/invalid-messages/mis-nested-sig.message-raw.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2022 Evgeny Vereshchagin
+SPDX-FileCopyrightText: 2022 Collabora Ltd.
+SPDX-License-Identifier: MIT
diff --git a/test/data/invalid-messages/truncated-variant-sig.message-raw b/test/data/invalid-messages/truncated-variant-sig.message-raw
new file mode 100644
index 00000000..c2342268
--- /dev/null
+++ b/test/data/invalid-messages/truncated-variant-sig.message-raw
Binary files differ
diff --git a/test/data/invalid-messages/truncated-variant-sig.message-raw.hex b/test/data/invalid-messages/truncated-variant-sig.message-raw.hex
new file mode 100644
index 00000000..28d66b8b
--- /dev/null
+++ b/test/data/invalid-messages/truncated-variant-sig.message-raw.hex
@@ -0,0 +1,23 @@
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+#
+# To output as binary:
+# sed -e 's/#.*//' test/data/invalid-messages/truncated-variant-sig.message-raw.hex |
+# xxd -p -r - test/data/invalid-messages/truncated-variant-sig.message-raw
+
+# Offset % 0x10:
+# 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f
+
+ 6c # little-endian
+ ff # an undefined message type
+ 00 # flags
+ 01 # major protocol version 1
+ 0000 0000 # message body is 0 bytes
+ 0100 0000 # serial number 1
+ 0400 0000 # header is an array of 4 bytes of struct (yv)
+ ff # header field code 0xff
+ ff # signature is 0xff = 255 bytes
+ 0000 # truncated (invalid!)
+ 0000 0000 # padding to 8-byte boundary
+
+#sha1 be4640e0bc1534ddf1667ced6a5e2a59c447dbdd
diff --git a/test/data/invalid-messages/truncated-variant-sig.message-raw.license b/test/data/invalid-messages/truncated-variant-sig.message-raw.license
new file mode 100644
index 00000000..3833a492
--- /dev/null
+++ b/test/data/invalid-messages/truncated-variant-sig.message-raw.license
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: 2022 Collabora Ltd.
+SPDX-License-Identifier: MIT
diff --git a/test/data/invalid-messages/zero-length-variant-sig.message-raw b/test/data/invalid-messages/zero-length-variant-sig.message-raw
new file mode 100644
index 00000000..85167a7d
--- /dev/null
+++ b/test/data/invalid-messages/zero-length-variant-sig.message-raw
Binary files differ
diff --git a/test/data/invalid-messages/zero-length-variant-sig.message-raw.hex b/test/data/invalid-messages/zero-length-variant-sig.message-raw.hex
new file mode 100644
index 00000000..6acdc2ca
--- /dev/null
+++ b/test/data/invalid-messages/zero-length-variant-sig.message-raw.hex
@@ -0,0 +1,23 @@
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+#
+# To output as binary:
+# sed -e 's/#.*//' test/data/invalid-messages/zero-length-variant-sig.message-raw.hex |
+# xxd -p -r - test/data/invalid-messages/zero-length-variant-sig.message-raw
+
+# Offset % 0x10:
+# 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f
+
+ 6c # little-endian
+ ff # an undefined message type
+ 00 # flags
+ 01 # major protocol version 1
+ 0000 0000 # message body is 0 bytes
+ 0100 0000 # serial number 1
+ 0300 0000 # header is an array of 0x03 bytes of struct (yv)
+ ff # header field code 0xff (undefined)
+ 00 # signature is zero-length (invalid!)
+ 00 # "" \0
+ 00 0000 0000 # padding to 8-byte boundary
+
+#sha1 5b85e1e6586b9737bde18c3e99a201ed6314ecb6
diff --git a/test/data/invalid-messages/zero-length-variant-sig.message-raw.license b/test/data/invalid-messages/zero-length-variant-sig.message-raw.license
new file mode 100644
index 00000000..3833a492
--- /dev/null
+++ b/test/data/invalid-messages/zero-length-variant-sig.message-raw.license
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: 2022 Collabora Ltd.
+SPDX-License-Identifier: MIT
diff --git a/test/data/meson.build b/test/data/meson.build
new file mode 100644
index 00000000..ef570492
--- /dev/null
+++ b/test/data/meson.build
@@ -0,0 +1,239 @@
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+data_to_install = [
+ 'auth/anonymous-client-successful.auth-script',
+ 'auth/anonymous-server-successful.auth-script',
+ 'auth/cancel.auth-script',
+ 'auth/client-out-of-mechanisms.auth-script',
+ 'auth/cookie-sha1-username.auth-script',
+ 'auth/cookie-sha1.auth-script',
+ 'auth/external-auto.auth-script',
+ 'auth/external-failed.auth-script',
+ 'auth/external-root.auth-script',
+ 'auth/external-silly.auth-script',
+ 'auth/external-successful.auth-script',
+ 'auth/external-username.auth-script',
+ 'auth/extra-bytes.auth-script',
+ 'auth/fail-after-n-attempts.auth-script',
+ 'auth/fallback.auth-script',
+ 'auth/invalid-command-client.auth-script',
+ 'auth/invalid-command.auth-script',
+ 'auth/invalid-hex-encoding.auth-script',
+ 'auth/mechanisms.auth-script',
+ 'equiv-config-files/basic/basic-1.conf',
+ 'equiv-config-files/basic/basic-2.conf',
+ 'equiv-config-files/basic/basic.d/basic.conf',
+ 'equiv-config-files/entities/basic.d/basic.conf',
+ 'equiv-config-files/entities/entities-1.conf',
+ 'equiv-config-files/entities/entities-2.conf',
+ 'invalid-config-files/apparmor-bad-attribute.conf',
+ 'invalid-config-files/apparmor-bad-mode.conf',
+ 'invalid-config-files/bad-attribute-2.conf',
+ 'invalid-config-files/bad-attribute.conf',
+ 'invalid-config-files/bad-element.conf',
+ 'invalid-config-files/bad-limit.conf',
+ 'invalid-config-files/badselinux-1.conf',
+ 'invalid-config-files/badselinux-2.conf',
+ 'invalid-config-files/circular-1.conf',
+ 'invalid-config-files/circular-2.conf',
+ 'invalid-config-files/circular-3.conf',
+ 'invalid-config-files/double-attribute.conf',
+ 'invalid-config-files/impossible-send.conf',
+ 'invalid-config-files/limit-no-name.conf',
+ 'invalid-config-files/ludicrous-limit.conf',
+ 'invalid-config-files/negative-limit.conf',
+ 'invalid-config-files/non-numeric-limit.conf',
+ 'invalid-config-files/not-well-formed.conf',
+ 'invalid-config-files/policy-bad-at-console.conf',
+ 'invalid-config-files/policy-bad-attribute.conf',
+ 'invalid-config-files/policy-bad-context.conf',
+ 'invalid-config-files/policy-bad-rule-attribute.conf',
+ 'invalid-config-files/policy-contradiction.conf',
+ 'invalid-config-files/policy-member-no-path.conf',
+ 'invalid-config-files/policy-mixed.conf',
+ 'invalid-config-files/policy-no-attributes.conf',
+ 'invalid-config-files/policy-no-rule-attribute.conf',
+ 'invalid-config-files/send-and-receive.conf',
+ 'invalid-config-files/truncated-file.conf',
+ 'invalid-config-files/unknown-limit.conf',
+ 'invalid-messages/boolean-has-no-value.message-raw',
+ 'invalid-messages/fixed-array-not-divisible.message-raw',
+ 'invalid-messages/fixed-array-not-divisible.message-raw.hex',
+ 'invalid-messages/issue418.message-raw',
+ 'invalid-messages/issue418.message-raw.hex',
+ 'invalid-messages/mis-nested-sig.message-raw',
+ 'invalid-messages/mis-nested-sig.message-raw.hex',
+ 'invalid-messages/truncated-variant-sig.message-raw',
+ 'invalid-messages/truncated-variant-sig.message-raw.hex',
+ 'invalid-messages/zero-length-variant-sig.message-raw',
+ 'invalid-messages/zero-length-variant-sig.message-raw.hex',
+ 'sha-1/bit-hashes.sha1',
+ 'sha-1/bit-messages.sha1',
+ 'sha-1/byte-hashes.sha1',
+ 'sha-1/byte-messages.sha1',
+ 'sha-1/Readme.txt',
+ 'systemd-activation/com.example.ReceiveDenied.service',
+ 'systemd-activation/com.example.SendDenied.service',
+ 'systemd-activation/com.example.SendDeniedByAppArmorName.service',
+ 'systemd-activation/com.example.SendPrefixDenied.internal.service',
+ 'systemd-activation/com.example.SendPrefixDenied.SendPrefixAllowed.internal.service',
+ 'systemd-activation/com.example.SendPrefixDenied.service',
+ 'systemd-activation/com.example.SystemdActivatable1.service',
+ 'systemd-activation/com.example.SystemdActivatable2.service',
+ 'systemd-activation/org.freedesktop.systemd1.service',
+ 'valid-config-files-system/many-rules.conf',
+ 'valid-config-files-system/system.d/test.conf',
+ 'valid-config-files/basic.conf',
+ 'valid-config-files/basic.d/basic.conf',
+ 'valid-config-files/check-own-rules.conf',
+ 'valid-config-files/entities.conf',
+ 'valid-config-files/listen-unix-runtime.conf',
+ 'valid-config-files/many-rules.conf',
+ 'valid-config-files/minimal.conf',
+ 'valid-config-files/standard-session-dirs.conf',
+ 'valid-messages/byteswap-fd-index.message-raw',
+ 'valid-messages/byteswap-fd-index.message-raw.hex',
+ 'valid-messages/minimal.message-raw',
+ 'valid-messages/minimal.message-raw.hex',
+]
+
+data_in_to_install = [
+ 'dbus-installed-tests.aaprofile',
+ 'invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoExec.service',
+ 'invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoService.service',
+ 'invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoUser.service',
+ 'systemd-activation/com.example.ReceiveDeniedByAppArmorLabel.service',
+ 'systemd-activation/com.example.SendDeniedByAppArmorLabel.service',
+ 'systemd-activation/com.example.SendDeniedByNonexistentAppArmorLabel.service',
+ 'systemd-activation/com.example.SystemdActivatable3.service',
+ 'valid-config-files-system/debug-allow-all-fail.conf',
+ 'valid-config-files-system/debug-allow-all-pass.conf',
+ 'valid-config-files-system/tmp-session-like-system.conf',
+ 'valid-config-files/as-another-user.conf',
+ 'valid-config-files/count-fds.conf',
+ 'valid-config-files/debug-allow-all-sha1.conf',
+ 'valid-config-files/debug-allow-all.conf',
+ 'valid-config-files/finite-timeout.conf',
+ 'valid-config-files/forbidding.conf',
+ 'valid-config-files/incoming-limit.conf',
+ 'valid-config-files/limit-containers.conf',
+ 'valid-config-files/listen-autolaunch-win.conf',
+ 'valid-config-files/max-completed-connections.conf',
+ 'valid-config-files/max-connections-per-user.conf',
+ 'valid-config-files/max-containers.conf',
+ 'valid-config-files/max-match-rules-per-connection.conf',
+ 'valid-config-files/max-names-per-connection.conf',
+ 'valid-config-files/max-replies-per-connection.conf',
+ 'valid-config-files/multi-user.conf',
+ 'valid-config-files/pending-fd-timeout.conf',
+ 'valid-config-files/send-destination-prefix-rules.conf',
+ 'valid-config-files/systemd-activation.conf',
+ 'valid-config-files/tmp-session.conf',
+ 'valid-service-files-system/org.freedesktop.DBus.TestSuiteEchoService.service',
+ 'valid-service-files-system/org.freedesktop.DBus.TestSuiteSegfaultService.service',
+ 'valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service',
+ 'valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service',
+ 'valid-service-files/org.freedesktop.DBus.TestSuite.PrivServer.service',
+ 'valid-service-files/org.freedesktop.DBus.TestSuiteEchoService.service',
+ 'valid-service-files/org.freedesktop.DBus.TestSuiteForkingEchoService.service',
+ 'valid-service-files/org.freedesktop.DBus.TestSuiteSegfaultService.service',
+ 'valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service',
+ 'valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service',
+]
+
+foreach file : data_to_install
+ if install_tests
+ install_data(file,
+ rename: file,
+ install_dir: test_exec_dir / 'data',
+ )
+ endif
+endforeach
+
+foreach file : data_in_to_install
+ # Underscorify the output name because Meson doesn't allow subdir output files
+ configured_file = configure_file(
+ input : file + '.in',
+ output: file.underscorify(),
+ configuration: test_data_config,
+ )
+ # We don't install this version: see test/data/installable/ for the
+ # version that we *do* install.
+endforeach
+
+###############################################################################
+# Copy files into correct places in build directory for tests
+
+files = []
+foreach file : data_to_install
+ src = meson.current_source_dir() / file
+ dst = meson.current_build_dir() / file
+ files += src
+ files += dst
+endforeach
+
+foreach file : data_in_to_install
+ src = meson.current_build_dir() / file.underscorify()
+ dst = meson.current_build_dir() / file
+ files += src
+ files += dst
+endforeach
+
+if message_bus
+ files += meson.project_build_root() / 'bus' / 'session.conf'
+ files += meson.current_build_dir() / 'valid-config-files/session.conf'
+
+ if platform_unix
+ files += meson.project_build_root() / 'bus' / 'system.conf'
+ files += meson.current_build_dir() / 'valid-config-files-system/system.conf'
+ endif
+endif
+
+run_result = run_command(find_program('copy_data_for_tests.py'), files, check: true)
+
+files_not_found = run_result.stdout().split()
+if files_not_found.length() > 0
+ error('Those files could not be copied for test : @0@'.format(files_not_found))
+endif
+
+if install_tests
+ subdir('installable')
+
+ if platform_unix
+ install_symlinks += [
+ {
+ 'link_name': 'session.conf',
+ 'install_dir': test_exec_dir / 'data' / 'valid-config-files',
+ 'pointing_to':
+ get_option('prefix') / get_option('datadir') /
+ 'dbus-1' / 'session.conf',
+ },
+ {
+ 'link_name': 'system.conf',
+ 'install_dir': test_exec_dir / 'data' / 'valid-config-files-system',
+ 'pointing_to':
+ get_option('prefix') / get_option('datadir') /
+ 'dbus-1' / 'system.conf',
+ },
+ ]
+ endif
+endif
diff --git a/test/data/valid-config-files/forbidding.conf.in b/test/data/valid-config-files/forbidding.conf.in
index d145613c..58b3cc6a 100644
--- a/test/data/valid-config-files/forbidding.conf.in
+++ b/test/data/valid-config-files/forbidding.conf.in
@@ -24,5 +24,8 @@
<allow send_interface="com.example.CannotUnicast2" send_broadcast="true"/>
<deny receive_interface="com.example.CannotReceive"/>
+
+ <!-- Used to reproduce dbus#457 -->
+ <deny receive_interface="org.freedesktop.DBus" receive_member="NameAcquired"/>
</policy>
</busconfig>
diff --git a/test/data/valid-config-files/limit-containers.conf.in b/test/data/valid-config-files/limit-containers.conf.in
index 3cc3bb05..44dd3979 100644
--- a/test/data/valid-config-files/limit-containers.conf.in
+++ b/test/data/valid-config-files/limit-containers.conf.in
@@ -13,9 +13,4 @@
<!-- Allow anyone to own anything -->
<allow own="*"/>
</policy>
-
- <limit name="max_containers">5</limit>
- <limit name="max_containers_per_user">3</limit>
- <limit name="max_container_metadata_bytes">4096</limit>
- <limit name="max_connections_per_container">3</limit>
</busconfig>
diff --git a/test/data/valid-config-files/listen-autolaunch-win.conf.in b/test/data/valid-config-files/listen-autolaunch-win.conf.in
new file mode 100644
index 00000000..7557e526
--- /dev/null
+++ b/test/data/valid-config-files/listen-autolaunch-win.conf.in
@@ -0,0 +1,11 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <type>session</type>
+ <listen>@TEST_LISTEN@</listen>
+ <policy context="default">
+ <allow send_destination="*" eavesdrop="true"/>
+ <allow eavesdrop="true"/>
+ <allow own="*"/>
+ </policy>
+</busconfig>
diff --git a/test/data/valid-config-files/tmp-session.conf.in b/test/data/valid-config-files/tmp-session.conf.in
index 502619dd..d1effae1 100644
--- a/test/data/valid-config-files/tmp-session.conf.in
+++ b/test/data/valid-config-files/tmp-session.conf.in
@@ -57,11 +57,4 @@
<limit name="max_names_per_connection">50000</limit>
<limit name="max_match_rules_per_connection">50000</limit>
<limit name="max_replies_per_connection">50000</limit>
- <limit name="max_containers">10000</limit>
- <limit name="max_containers_per_user">10000</limit>
- <limit name="max_container_metadata_bytes">1000000000</limit>
- <!-- This is relatively low so that app-containers (which we do not fully
- trust) do not cause DoS. -->
- <limit name="max_connections_per_container">16</limit>
-
</busconfig>
diff --git a/test/data/valid-messages/byteswap-fd-index.message-raw b/test/data/valid-messages/byteswap-fd-index.message-raw
new file mode 100644
index 00000000..a1724ff8
--- /dev/null
+++ b/test/data/valid-messages/byteswap-fd-index.message-raw
Binary files differ
diff --git a/test/data/valid-messages/byteswap-fd-index.message-raw.hex b/test/data/valid-messages/byteswap-fd-index.message-raw.hex
new file mode 100644
index 00000000..f3d0f912
--- /dev/null
+++ b/test/data/valid-messages/byteswap-fd-index.message-raw.hex
@@ -0,0 +1,43 @@
+# Copyright 2022 Evgeny Vereshchagin
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+#
+# This is an annotated hex-dump of a message originally generated by a
+# fuzzer.
+#
+# To output as binary:
+# sed -e 's/#.*//' test/data/invalid-messages/endian.message-raw.hex |
+# xxd -p -r - test/data/invalid-messages/endian.message-raw
+#
+# This message is technically valid, but not practically useful: it
+# contains a "handle" for the 4163371528th out-of-band file descriptor,
+# which is not a practically useful thing to send, because it exceeds any
+# reasonable number of file descriptors to attach to a message.
+#
+# The message is also in big-endian encoding (the opposite of the encoding
+# used by all commonly-used CPU architectures in 2022), which until
+# recently would trigger a denial-of-service vulnerability in the dbus
+# message marshalling code.
+
+# Offset % 0x10:
+# 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f
+
+ 42 # big-endian
+ 2d # an undefined message type
+ 31 # flags
+ 01 # major protocol version 1
+ 0000 000c # message body is 0x0c = 12 bytes
+ 97bc 9023 # serial number 0x97bc9023
+ 0000 0008 # header is an array of 8 bytes of struct (yv)
+ 08 # header field code 0x08 (signature)
+ 01 # variant signature is 1 byte
+ 6700 # "g" \0
+ 02 # signature is 2 bytes
+ 68 7600 # "hv" \0
+ # begin message body, 12 bytes
+ f828 0208 # out-of-band fd, index = 0xf8280208
+ 02 # variant signature is 2 bytes
+ 61 7600 # "av" \0
+ 0000 0000 # array length is 0
+
+#sha1 f99a286aaaf84d9b97549f35f71042f4a2f37e78
diff --git a/test/data/valid-messages/byteswap-fd-index.message-raw.license b/test/data/valid-messages/byteswap-fd-index.message-raw.license
new file mode 100644
index 00000000..252ebde8
--- /dev/null
+++ b/test/data/valid-messages/byteswap-fd-index.message-raw.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2022 Evgeny Vereshchagin
+SPDX-FileCopyrightText: 2022 Collabora Ltd.
+SPDX-License-Identifier: MIT
diff --git a/test/data/valid-messages/minimal.message-raw b/test/data/valid-messages/minimal.message-raw
new file mode 100644
index 00000000..3b5ee188
--- /dev/null
+++ b/test/data/valid-messages/minimal.message-raw
Binary files differ
diff --git a/test/data/valid-messages/minimal.message-raw.hex b/test/data/valid-messages/minimal.message-raw.hex
new file mode 100644
index 00000000..ab0534da
--- /dev/null
+++ b/test/data/valid-messages/minimal.message-raw.hex
@@ -0,0 +1,25 @@
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+#
+# To output as binary:
+# sed -e 's/#.*//' test/data/valid-messages/minimal.message-raw.hex |
+# xxd -p -r - test/data/valid-messages/minimal.message-raw
+#
+# This is a minimal valid message.
+
+# Offset % 0x10:
+# 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f
+
+ 6c # little-endian
+ 02 # method call reply
+ 00 # no flags
+ 01 # major protocol version 1
+ 0000 0000 # message body is 0 bytes
+ 0200 0000 # serial number 2
+ 0800 0000 # header is an array of 8 bytes of struct (yv)
+ 05 # in reply to
+ 01 # signature is 1 byte
+ 7500 # "u" \0
+ 0100 0000 # in reply to serial number 1
+
+#sha1 06942854add9c4346a8b1c76a2b02e2e73abe72a
diff --git a/test/data/valid-messages/minimal.message-raw.license b/test/data/valid-messages/minimal.message-raw.license
new file mode 100644
index 00000000..3833a492
--- /dev/null
+++ b/test/data/valid-messages/minimal.message-raw.license
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: 2022 Collabora Ltd.
+SPDX-License-Identifier: MIT
diff --git a/test/dbus-daemon-eavesdrop.c b/test/dbus-daemon-eavesdrop.c
index 6f4d9bb5..1f8054f2 100644
--- a/test/dbus-daemon-eavesdrop.c
+++ b/test/dbus-daemon-eavesdrop.c
@@ -3,6 +3,7 @@
* Author: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
* Based on: tests/dbus-daemon.c by Simon McVittie
* Copyright © 2010-2011 Nokia Corporation
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c
index e8bdace3..1288fe0c 100644
--- a/test/dbus-daemon.c
+++ b/test/dbus-daemon.c
@@ -4,6 +4,7 @@
* Copyright © 2008 Red Hat, Inc.
* Copyright © 2010-2011 Nokia Corporation
* Copyright © 2015-2018 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -100,6 +101,7 @@ typedef struct {
gchar *address;
DBusConnection *left_conn;
+ gboolean left_conn_shouted_signal_filter;
DBusConnection *right_conn;
GQueue held_messages;
@@ -107,6 +109,7 @@ typedef struct {
gboolean right_conn_hold;
gboolean wait_forever_called;
guint activation_forking_counter;
+ guint signal_counter;
gchar *tmp_runtime_dir;
gchar *saved_runtime_dir;
@@ -158,6 +161,19 @@ hold_filter (DBusConnection *connection,
return DBUS_HANDLER_RESULT_HANDLED;
}
+static DBusHandlerResult
+shouted_signal_filter (DBusConnection *connection,
+ DBusMessage *message,
+ void *user_data)
+{
+ Fixture *f = user_data;
+
+ if (dbus_message_is_signal (message, "com.example", "Shouted"))
+ f->signal_counter++;
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
typedef struct {
const char *bug_ref;
guint min_messages;
@@ -237,6 +253,31 @@ add_hold_filter (Fixture *f)
}
static void
+add_shouted_signal_filter (Fixture *f)
+{
+ if (!dbus_connection_add_filter (f->left_conn, shouted_signal_filter, f, NULL))
+ g_error ("OOM");
+
+ f->left_conn_shouted_signal_filter = TRUE;
+}
+
+static void
+right_conn_emit_shouted (Fixture *f)
+{
+ DBusMessage *m;
+
+ m = dbus_message_new_signal ("/", "com.example", "Shouted");
+
+ if (m == NULL)
+ g_error ("OOM");
+
+ if (!dbus_connection_send (f->right_conn, m, NULL))
+ g_error ("OOM");
+
+ dbus_clear_message (&m);
+}
+
+static void
pc_count (DBusPendingCall *pc,
void *data)
{
@@ -257,30 +298,11 @@ pc_enqueue (DBusPendingCall *pc,
}
static void
-test_echo (Fixture *f,
- gconstpointer context)
+echo_left_to_right (Fixture *f,
+ guint count)
{
- const Config *config = context;
- guint count = 2000;
guint sent;
guint received = 0;
- double elapsed;
-
- if (f->skip)
- return;
-
- if (config != NULL && config->bug_ref != NULL)
- g_test_bug (config->bug_ref);
-
- if (g_test_perf ())
- count = 100000;
-
- if (config != NULL)
- count = MAX (config->min_messages, count);
-
- add_echo_filter (f);
-
- g_test_timer_start ();
for (sent = 0; sent < count; sent++)
{
@@ -309,6 +331,33 @@ test_echo (Fixture *f,
while (received < count)
test_main_context_iterate (f->ctx, TRUE);
+}
+
+static void
+test_echo (Fixture *f,
+ gconstpointer context)
+{
+ const Config *config = context;
+ guint count = 2000;
+ double elapsed;
+
+ if (f->skip)
+ return;
+
+ if (config != NULL && config->bug_ref != NULL)
+ g_test_bug (config->bug_ref);
+
+ if (g_test_perf ())
+ count = 100000;
+
+ if (config != NULL)
+ count = MAX (config->min_messages, count);
+
+ add_echo_filter (f);
+
+ g_test_timer_start ();
+
+ echo_left_to_right (f, count);
elapsed = g_test_timer_elapsed ();
@@ -588,10 +637,6 @@ test_creds (Fixture *f,
g_assert_not_reached ();
#endif
}
- else if (g_str_has_prefix (name, DBUS_INTERFACE_CONTAINERS1 "."))
- {
- g_assert_not_reached ();
- }
dbus_message_iter_next (&arr_iter);
}
@@ -2535,6 +2580,12 @@ teardown (Fixture *f,
if (f->left_conn != NULL)
{
+ if (f->left_conn_shouted_signal_filter)
+ {
+ dbus_connection_remove_filter (f->left_conn, shouted_signal_filter, f);
+ f->left_conn_shouted_signal_filter = FALSE;
+ }
+
test_connection_shutdown (f->ctx, f->left_conn);
dbus_connection_close (f->left_conn);
}
@@ -2674,6 +2725,71 @@ static Config send_destination_prefix_config = {
TEST_USER_ME, SPECIFY_ADDRESS
};
+static void
+test_match_remove_fails (Fixture *f,
+ gconstpointer context G_GNUC_UNUSED)
+{
+ const char *match_rule = "type='signal'";
+
+ if (f->skip)
+ return;
+
+ /* Unlike in test_match_remove_succeeds(), we never added this */
+ dbus_bus_remove_match (f->left_conn, match_rule, &f->e);
+ g_assert_cmpstr (f->e.name, ==, DBUS_ERROR_MATCH_RULE_NOT_FOUND);
+}
+
+static void
+test_match_remove_succeeds (Fixture *f,
+ gconstpointer context G_GNUC_UNUSED)
+{
+ const char *match_rule = "type='signal'";
+
+ if (f->skip)
+ return;
+
+ add_shouted_signal_filter (f);
+
+ /* We use this to make sure that a method call from the "left" connection
+ * will get a reply from the "right", to sync up */
+ add_echo_filter (f);
+
+ /* Emit a signal from the "right" connection, and assert that the "left"
+ * does not receive it yet */
+ f->signal_counter = 0;
+ right_conn_emit_shouted (f);
+ /* Because messages are totally-ordered, if the "left" connection was
+ * going to receive the signal, it would receive it before it got
+ * the reply from this async call to the "right" connection */
+ echo_left_to_right (f, 1);
+ g_assert_cmpuint (f->signal_counter, ==, 0);
+
+ dbus_bus_add_match (f->left_conn, match_rule, &f->e);
+ test_assert_no_error (&f->e);
+
+ f->signal_counter = 0;
+
+ /* Emit a signal from the "right" connection, and assert that the "left"
+ * receives it */
+ right_conn_emit_shouted (f);
+
+ while (f->signal_counter < 1)
+ test_main_context_iterate (f->ctx, TRUE);
+
+ dbus_bus_remove_match (f->left_conn, match_rule, &f->e);
+ test_assert_no_error (&f->e);
+
+ /* Emit a signal from the "right" connection, and assert that the "left"
+ * does not receive it this time */
+ f->signal_counter = 0;
+ right_conn_emit_shouted (f);
+ /* Because messages are totally-ordered, if the "left" connection was
+ * going to receive the signal, it would receive it before it got
+ * the reply from this async call to the "right" connection */
+ echo_left_to_right (f, 1);
+ g_assert_cmpuint (f->signal_counter, ==, 0);
+}
+
int
main (int argc,
char **argv)
@@ -2708,6 +2824,10 @@ main (int argc,
g_test_add ("/limits/max-names-per-connection", Fixture,
&max_names_per_connection_config,
setup, test_max_names_per_connection, teardown);
+ g_test_add ("/match/remove/fails", Fixture, NULL,
+ setup, test_match_remove_fails, teardown);
+ g_test_add ("/match/remove/succeeds", Fixture, NULL,
+ setup, test_match_remove_succeeds, teardown);
g_test_add ("/peer/ping", Fixture, NULL, setup, test_peer_ping, teardown);
g_test_add ("/peer/get-machine-id", Fixture, NULL,
setup, test_peer_get_machine_id, teardown);
diff --git a/test/disable-crash-handling.c b/test/disable-crash-handling.c
index 14295071..8ac5b5d5 100644
--- a/test/disable-crash-handling.c
+++ b/test/disable-crash-handling.c
@@ -4,6 +4,8 @@
* Copyright 2014-2018 Collabora Ltd.
* Copyright 2016 Yiyang Fei
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/disable-crash-handling.h b/test/disable-crash-handling.h
index 28ca33cf..f300b018 100644
--- a/test/disable-crash-handling.h
+++ b/test/disable-crash-handling.h
@@ -4,6 +4,8 @@
* Copyright 2014-2018 Collabora Ltd.
* Copyright 2016 Yiyang Fei
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/fdpass.c b/test/fdpass.c
index abd41504..cf344dae 100644
--- a/test/fdpass.c
+++ b/test/fdpass.c
@@ -1,6 +1,7 @@
/*
* Copyright © 2010-2012 Nokia Corporation
* Copyright © 2014 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -752,6 +753,15 @@ test_odd_limit (Fixture *f,
if (f->skip)
return;
+#ifdef __FreeBSD__
+ g_test_message ("Running test on FreeBSD %d...", getosreldate ());
+ if (GPOINTER_TO_INT (data) == 0 && getosreldate () < 1400000)
+ {
+ g_test_skip ("This test fails on FreeBSD < 14.0");
+ return;
+ }
+#endif
+
test_connect (f, TRUE);
dbus_connection_set_max_message_unix_fds (f->left_server_conn, 7);
dbus_connection_set_max_message_unix_fds (f->right_server_conn, 7);
diff --git a/test/header-fields.c b/test/header-fields.c
index b0d89d61..c4dcd97f 100644
--- a/test/header-fields.c
+++ b/test/header-fields.c
@@ -1,6 +1,7 @@
/* Unit tests for detailed header field manipulation
*
* Copyright © 2017 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/test/integration/transient-services.sh b/test/integration/transient-services.sh
index 2d946d9e..27a930a0 100644
--- a/test/integration/transient-services.sh
+++ b/test/integration/transient-services.sh
@@ -1,6 +1,7 @@
#!/bin/sh
# Copyright © 2017 Collabora Ltd.
+# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
@@ -74,8 +75,19 @@ trap cleanup EXIT
echo "1..2"
-# This is an integration test, so we expect the dbus-daemon to already be
-# running
+# If the dbus-daemon is launched on-demand by a systemd socket unit, it
+# might not be there yet, even if the socket is
+(
+dbus-send --session --dest="org.freedesktop.DBus" \
+ --type=method_call --print-reply /org/freedesktop/DBus \
+ org.freedesktop.DBus.Peer.Ping || touch "$workdir/failed" \
+) 2>&1 | sed -e 's/^/# /'
+
+if [ -e "$workdir/failed" ]; then
+ echo "Bail out! Unable to ensure dbus-daemon has started"
+ exit 1
+fi
+
if ! test -d "$XDG_RUNTIME_DIR/dbus-1/services"; then
echo "Bail out! $XDG_RUNTIME_DIR/dbus-1/services is not a directory"
exit 1
diff --git a/test/internals/address.c b/test/internals/address.c
index dbc8bca2..9923fe28 100644
--- a/test/internals/address.c
+++ b/test/internals/address.c
@@ -6,6 +6,8 @@
* Copyright (C) 2007 Ralf Habacker
* Copyright (C) 2013 Chengwei Yang / Intel
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/internals/assertions.c b/test/internals/assertions.c
index d1360e0f..12b6735d 100644
--- a/test/internals/assertions.c
+++ b/test/internals/assertions.c
@@ -1,5 +1,6 @@
/*
* Copyright © 2018 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -78,10 +79,10 @@ static void
test_assert_error_is_set (Fixture *f,
gconstpointer context G_GNUC_UNUSED)
{
+#if defined(DBUS_ENABLE_ASSERT) && defined(DBUS_ENABLE_CHECKS)
DBusError e = DBUS_ERROR_INIT;
DBusError *ep = NULL;
-#if defined(DBUS_ENABLE_ASSERT) && defined(DBUS_ENABLE_CHECKS)
if (!g_test_undefined ())
{
g_test_skip ("Not testing programming errors");
diff --git a/test/internals/atomic.c b/test/internals/atomic.c
index d595dc17..136265ea 100644
--- a/test/internals/atomic.c
+++ b/test/internals/atomic.c
@@ -2,6 +2,7 @@
*
* Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Copyright © 2013 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/test/internals/counter.c b/test/internals/counter.c
new file mode 100644
index 00000000..f46ce5e5
--- /dev/null
+++ b/test/internals/counter.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2023 Ralf Habacker
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <config.h>
+
+#include "dbus/dbus-resources.h"
+#include "dbus/dbus-test.h"
+#include "dbus/dbus-test-tap.h"
+#include "test/test-utils.h"
+
+#include <pthread.h>
+
+static dbus_bool_t verbose = FALSE;
+static DBusCounter *counter = NULL;
+
+static void* unix_fd_thread1 (void *arg _DBUS_GNUC_UNUSED)
+{
+ long i;
+ for (i=0; i < 10000; i++)
+ {
+ long j;
+ _dbus_counter_adjust_unix_fd (counter, 1);
+ j = _dbus_counter_get_unix_fd_value (counter);
+ if (verbose)
+ _dbus_test_diag ("write %ld\n", j);
+ }
+ return NULL;
+}
+
+static void* unix_fd_thread2 (void *arg _DBUS_GNUC_UNUSED)
+{
+ long j = 0;
+ do
+ {
+ j = _dbus_counter_get_unix_fd_value (counter);
+ if (verbose)
+ _dbus_test_diag ("read %ld\n", j);
+ } while (j < 10000);
+ return NULL;
+}
+
+static void* size_value_thread1 (void *arg _DBUS_GNUC_UNUSED)
+{
+ long i;
+ for (i=0; i < 10000; i++)
+ {
+ long j;
+ _dbus_counter_adjust_size (counter, 1);
+ j = _dbus_counter_get_size_value (counter);
+ if (verbose)
+ _dbus_test_diag ("write %ld\n", j);
+ }
+ return NULL;
+}
+
+static void* size_value_thread2 (void *arg _DBUS_GNUC_UNUSED)
+{
+ long j = 0;
+ do
+ {
+ j = _dbus_counter_get_size_value (counter);
+ if (verbose)
+ _dbus_test_diag("read %ld\n", j);
+ } while (j < 10000);
+ return NULL;
+}
+
+static dbus_bool_t
+_dbus_counter_unix_fd_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ pthread_t tid[2];
+ dbus_bool_t ret = TRUE;
+ counter = _dbus_counter_new ();
+
+ pthread_create (&(tid[0]), NULL, &unix_fd_thread1, NULL);
+ pthread_create (&(tid[1]), NULL, &unix_fd_thread2, NULL);
+
+ pthread_join (tid[0], NULL);
+ pthread_join (tid[1], NULL);
+
+ _dbus_counter_unref (counter);
+
+ return ret;
+}
+
+static dbus_bool_t
+_dbus_counter_size_value_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ pthread_t tid[2];
+ dbus_bool_t ret = TRUE;
+ counter = _dbus_counter_new ();
+
+ pthread_create (&(tid[0]), NULL, &size_value_thread1, NULL);
+ pthread_create (&(tid[1]), NULL, &size_value_thread2, NULL);
+
+ pthread_join (tid[0], NULL);
+ pthread_join (tid[1], NULL);
+
+ _dbus_counter_unref (counter);
+
+ return ret;
+}
+
+static const DBusTestCase test[] =
+{
+ { "unix_fd", _dbus_counter_unix_fd_test },
+ { "size", _dbus_counter_size_value_test },
+};
+
+
+int
+main (int argc,
+ char **argv)
+{
+ return _dbus_test_main (argc, argv, sizeof(test) / sizeof (DBusTestCase), test,
+ DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS,
+ NULL, NULL);
+}
diff --git a/test/internals/dbus-auth-script.c b/test/internals/dbus-auth-script.c
index 61b8f674..41b03998 100644
--- a/test/internals/dbus-auth-script.c
+++ b/test/internals/dbus-auth-script.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -307,7 +309,6 @@ _dbus_auth_script_run (const DBusString *filename)
state = DBUS_AUTH_STATE_NEED_DISCONNECT;
line_no = 0;
- next_iteration:
while (_dbus_string_pop_line (&file, &line))
{
line_no += 1;
@@ -336,20 +337,20 @@ _dbus_auth_script_run (const DBusString *filename)
if (_dbus_string_get_length (&line) == 0)
{
/* empty line */
- goto next_iteration;
+ continue;
}
else if (_dbus_string_starts_with_c_str (&line,
"#"))
{
/* Ignore this comment */
- goto next_iteration;
+ continue;
}
#ifdef DBUS_WIN
else if (_dbus_string_starts_with_c_str (&line,
"WIN_ONLY"))
{
/* Ignore this line */
- goto next_iteration;
+ continue;
}
else if (_dbus_string_starts_with_c_str (&line,
"UNIX_ONLY"))
@@ -365,7 +366,7 @@ _dbus_auth_script_run (const DBusString *filename)
"UNIX_ONLY"))
{
/* Ignore this line */
- goto next_iteration;
+ continue;
}
else if (_dbus_string_starts_with_c_str (&line,
"WIN_ONLY"))
@@ -837,7 +838,7 @@ _dbus_auth_script_run (const DBusString *filename)
else
goto parse_failed;
- goto next_iteration; /* skip parse_failed */
+ continue; /* skip parse_failed */
parse_failed:
{
diff --git a/test/internals/dbus-auth-script.h b/test/internals/dbus-auth-script.h
index fd5d9cc3..5fce78ac 100644
--- a/test/internals/dbus-auth-script.h
+++ b/test/internals/dbus-auth-script.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2003 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/internals/dbus-auth-util.c b/test/internals/dbus-auth-util.c
index bd862b0e..980fe801 100644
--- a/test/internals/dbus-auth-util.c
+++ b/test/internals/dbus-auth-util.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2002, 2003, 2004 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -82,7 +84,6 @@ process_test_subdir (const DBusString *test_base_dir,
_dbus_test_diag ("Testing %s:", subdir);
- next:
while (_dbus_directory_get_next_file (dir, &filename, &error))
{
DBusString full_path;
@@ -101,7 +102,7 @@ process_test_subdir (const DBusString *test_base_dir,
_dbus_verbose ("Skipping non-.auth-script file %s\n",
_dbus_string_get_const_data (&filename));
_dbus_string_free (&full_path);
- goto next;
+ continue;
}
_dbus_test_diag (" %s", _dbus_string_get_const_data (&filename));
diff --git a/test/internals/dbus-credentials-util.c b/test/internals/dbus-credentials-util.c
index 8c497b22..6fada302 100644
--- a/test/internals/dbus-credentials-util.c
+++ b/test/internals/dbus-credentials-util.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2007 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -127,13 +129,15 @@ _dbus_credentials_test (const char *test_data_dir)
DBusCredentials *creds;
DBusCredentials *creds2;
DBusString str;
+ DBusString str2;
const dbus_gid_t *gids;
size_t n;
+ dbus_pid_t pid = _dbus_getpid();
if (test_data_dir == NULL)
return TRUE;
- creds = make_credentials (12, 511, 1, SAMPLE_SID);
+ creds = make_credentials (12, pid, 1, SAMPLE_SID);
if (creds == NULL)
_dbus_test_fatal ("oom");
@@ -147,7 +151,7 @@ _dbus_credentials_test (const char *test_data_dir)
_dbus_assert (_dbus_credentials_include (creds, DBUS_CREDENTIAL_WINDOWS_SID));
_dbus_assert (_dbus_credentials_get_unix_uid (creds) == 12);
- _dbus_assert (_dbus_credentials_get_pid (creds) == 511);
+ _dbus_assert (_dbus_credentials_get_pid (creds) == pid);
_dbus_assert (strcmp (_dbus_credentials_get_windows_sid (creds), SAMPLE_SID) == 0);
_dbus_assert (_dbus_credentials_get_unix_gids (creds, &gids, &n));
_dbus_assert (n == 4);
@@ -170,7 +174,7 @@ _dbus_credentials_test (const char *test_data_dir)
_dbus_assert (_dbus_credentials_include (creds2, DBUS_CREDENTIAL_WINDOWS_SID));
_dbus_assert (_dbus_credentials_get_unix_uid (creds2) == 12);
- _dbus_assert (_dbus_credentials_get_pid (creds2) == 511);
+ _dbus_assert (_dbus_credentials_get_pid (creds2) == pid);
_dbus_assert (strcmp (_dbus_credentials_get_windows_sid (creds2), SAMPLE_SID) == 0);
_dbus_assert (_dbus_credentials_get_unix_gids (creds2, &gids, &n));
_dbus_assert (n == 4);
@@ -243,7 +247,7 @@ _dbus_credentials_test (const char *test_data_dir)
_dbus_credentials_unref (creds2);
/* Same user, but not a superset, if groups are different */
- creds2 = make_credentials (12, 511, 2, SAMPLE_SID);
+ creds2 = make_credentials (12, pid, 2, SAMPLE_SID);
if (creds2 == NULL)
_dbus_test_fatal ("oom");
@@ -253,7 +257,7 @@ _dbus_credentials_test (const char *test_data_dir)
_dbus_credentials_unref (creds2);
/* Groups being in the same order make no difference */
- creds2 = make_credentials (12, 511, 3, SAMPLE_SID);
+ creds2 = make_credentials (12, pid, 3, SAMPLE_SID);
if (creds2 == NULL)
_dbus_test_fatal ("oom");
@@ -280,7 +284,7 @@ _dbus_credentials_test (const char *test_data_dir)
_dbus_credentials_unref (creds);
/* Make some more realistic credentials blobs to test stringification */
- if (!_dbus_string_init (&str))
+ if (!_dbus_string_init (&str) || !_dbus_string_init (&str2))
_dbus_test_fatal ("oom");
creds = make_credentials (12, DBUS_PID_UNSET, 0, NULL);
@@ -296,7 +300,7 @@ _dbus_credentials_test (const char *test_data_dir)
_dbus_credentials_unref (creds);
- creds = make_credentials (12, 511, 1, NULL);
+ creds = make_credentials (12, pid, 1, NULL);
if (creds == NULL)
_dbus_test_fatal ("oom");
@@ -306,9 +310,11 @@ _dbus_credentials_test (const char *test_data_dir)
if (!_dbus_credentials_to_string_append (creds, &str))
_dbus_test_fatal ("oom");
+ if (!_dbus_string_append_printf(&str2, "uid=12 pid=" DBUS_PID_FORMAT " gid=42 gid=123 gid=1000 gid=5678", pid))
+ _dbus_test_fatal ("oom");
+
_dbus_test_diag ("Unix complete set: %s", _dbus_string_get_const_data (&str));
- _dbus_assert (strcmp (_dbus_string_get_const_data (&str),
- "uid=12 pid=511 gid=42 gid=123 gid=1000 gid=5678") == 0);
+ _dbus_assert (strcmp (_dbus_string_get_const_data (&str), _dbus_string_get_const_data (&str2)) == 0);
_dbus_credentials_unref (creds);
@@ -328,23 +334,26 @@ _dbus_credentials_test (const char *test_data_dir)
_dbus_credentials_unref (creds);
- creds = make_credentials (DBUS_UID_UNSET, 511, 0, SAMPLE_SID);
+ creds = make_credentials (DBUS_UID_UNSET, pid, 0, SAMPLE_SID);
if (creds == NULL)
_dbus_test_fatal ("oom");
- if (!_dbus_string_set_length (&str, 0))
+ if (!_dbus_string_set_length (&str, 0) || !_dbus_string_set_length (&str2, 0))
_dbus_test_fatal ("oom");
if (!_dbus_credentials_to_string_append (creds, &str))
_dbus_test_fatal ("oom");
+ if (!_dbus_string_append_printf(&str2, "pid=" DBUS_PID_FORMAT " sid=" SAMPLE_SID, pid))
+ _dbus_test_fatal ("oom");
+
_dbus_test_diag ("Windows complete set: %s", _dbus_string_get_const_data (&str));
- _dbus_assert (strcmp (_dbus_string_get_const_data (&str),
- "pid=511 sid=" SAMPLE_SID) == 0);
+ _dbus_assert (strcmp (_dbus_string_get_const_data (&str), _dbus_string_get_const_data (&str2)) == 0);
_dbus_credentials_unref (creds);
_dbus_string_free (&str);
+ _dbus_string_free (&str2);
return TRUE;
}
diff --git a/test/internals/dbus-marshal-byteswap-util.c b/test/internals/dbus-marshal-byteswap-util.c
index 40b1780a..72abfc4c 100644
--- a/test/internals/dbus-marshal-byteswap-util.c
+++ b/test/internals/dbus-marshal-byteswap-util.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/internals/dbus-marshal-recursive-util.c b/test/internals/dbus-marshal-recursive-util.c
index f81efffa..a7113304 100644
--- a/test/internals/dbus-marshal-recursive-util.c
+++ b/test/internals/dbus-marshal-recursive-util.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2004, 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -34,10 +36,6 @@
#include <dbus/dbus-test-tap.h>
#include <string.h>
-#if !defined(PRIx64) && defined(DBUS_WIN)
-#define PRIx64 "I64x"
-#endif
-
/** turn this on to get deluged in TypeWriter verbose spam */
#define RECURSIVE_MARSHAL_WRITE_TRACE 0
@@ -2629,11 +2627,28 @@ double_read_value (TestTypeNode *node,
expected = double_from_seed (seed);
if (!_DBUS_DOUBLES_BITWISE_EQUAL (v, expected))
- _dbus_test_fatal ("Expected double %g got %g\n bits = 0x%" PRIx64 " vs.\n bits = 0x%" PRIx64,
- expected, v,
- *(dbus_uint64_t*)(char*)&expected,
- *(dbus_uint64_t*)(char*)&v);
-
+ {
+ DBusString es = _DBUS_STRING_INIT_INVALID;
+ DBusString vs = _DBUS_STRING_INIT_INVALID;
+ if (!_dbus_string_init (&es))
+ goto out;
+ if (!_dbus_string_init (&vs))
+ goto out;
+ if (!_dbus_string_append_buffer_as_hex (&es, &expected, sizeof(double)))
+ goto out;
+ if (!_dbus_string_append_buffer_as_hex (&vs, &v, sizeof(double)))
+ goto out;
+ _dbus_test_fatal ("Expected double %g got %g\n"
+ " bits = 0x%s vs.\n"
+ " bits = 0x%s",
+ expected, v,
+ _dbus_string_get_const_data (&es),
+ _dbus_string_get_const_data (&vs));
+out:
+ _dbus_string_free (&es);
+ _dbus_string_free (&vs);
+ return FALSE;
+ }
return TRUE;
}
diff --git a/test/internals/dbus-marshal-recursive-util.h b/test/internals/dbus-marshal-recursive-util.h
index ab069e4c..20cee97e 100644
--- a/test/internals/dbus-marshal-recursive-util.h
+++ b/test/internals/dbus-marshal-recursive-util.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2004, 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/internals/dbus-marshal-validate-util.c b/test/internals/dbus-marshal-validate-util.c
index 4179928b..41012f46 100644
--- a/test/internals/dbus-marshal-validate-util.c
+++ b/test/internals/dbus-marshal-validate-util.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2005 Red Hat, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/internals/dbus-message-factory.c b/test/internals/dbus-message-factory.c
index db02737a..b6f97d76 100644
--- a/test/internals/dbus-message-factory.c
+++ b/test/internals/dbus-message-factory.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2005 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/internals/dbus-message-factory.h b/test/internals/dbus-message-factory.h
index 636e4709..f57b2972 100644
--- a/test/internals/dbus-message-factory.h
+++ b/test/internals/dbus-message-factory.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2005 Red Hat Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/internals/dbus-message-util.c b/test/internals/dbus-message-util.c
index df2ab8cf..310822d6 100644
--- a/test/internals/dbus-message-util.c
+++ b/test/internals/dbus-message-util.c
@@ -12,6 +12,8 @@
* Copyright 2014 Ralf Habacker
* Copyright 2017 Endless Mobile, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -510,7 +512,6 @@ process_test_subdir (const DBusString *test_base_dir,
_dbus_test_diag ("Testing %s:", subdir);
- next:
while (_dbus_directory_get_next_file (dir, &filename, &error))
{
DBusString full_path;
@@ -531,7 +532,7 @@ process_test_subdir (const DBusString *test_base_dir,
_dbus_verbose ("Skipping non-.message-raw file %s\n",
_dbus_string_get_const_data (&filename));
_dbus_string_free (&full_path);
- goto next;
+ continue;
}
_dbus_test_diag (" %s",
@@ -589,6 +590,10 @@ foreach_message_file (const char *test_data_dir,
_dbus_string_init_const (&test_directory, test_data_dir);
+ if (!process_test_subdir (&test_directory, "valid-messages",
+ DBUS_VALID, func, user_data))
+ goto failed;
+
if (!process_test_subdir (&test_directory, "invalid-messages",
DBUS_INVALID_FOR_UNKNOWN_REASON, func, user_data))
goto failed;
diff --git a/test/internals/dbus-message-util.h b/test/internals/dbus-message-util.h
index d65be2d9..f9c4a537 100644
--- a/test/internals/dbus-message-util.h
+++ b/test/internals/dbus-message-util.h
@@ -11,6 +11,8 @@
* Copyright 2014 Ralf Habacker
* Copyright 2017 Endless Mobile, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/internals/dbus-string-util.c b/test/internals/dbus-string-util.c
index b2af6ca3..d5a740c4 100644
--- a/test/internals/dbus-string-util.c
+++ b/test/internals/dbus-string-util.c
@@ -10,6 +10,8 @@
* Copyright 2011 Roberto Guido
* Copyright 2016-2018 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -746,7 +748,7 @@ _dbus_string_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
_dbus_test_fatal ("failed to compact after set_length");
/* peek inside to make sure it worked */
- if (((DBusRealString *)&str)->allocated > 30)
+ if (_dbus_string_get_allocated_size (&str) > 30)
_dbus_test_fatal ("compacting string didn't do anything");
if (!_dbus_string_equal_c_str (&str, "abcdefghij"))
diff --git a/test/internals/dbus-sysdeps-util.c b/test/internals/dbus-sysdeps-util.c
index 7e2dc064..3c8c5cc1 100644
--- a/test/internals/dbus-sysdeps-util.c
+++ b/test/internals/dbus-sysdeps-util.c
@@ -7,6 +7,8 @@
* Copyright 2006 Sjoerd Simons
* Copyright 2016-2018 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/internals/desktop-file.c b/test/internals/desktop-file.c
index 4db4076f..c28e0dff 100644
--- a/test/internals/desktop-file.c
+++ b/test/internals/desktop-file.c
@@ -1,5 +1,6 @@
/*
* Copyright 2018 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/test/internals/hash.c b/test/internals/hash.c
index 192d82e3..ae4d829c 100644
--- a/test/internals/hash.c
+++ b/test/internals/hash.c
@@ -5,6 +5,7 @@
* Copyright 2002-2009 Red Hat, Inc.
* Copyright 2003 Joe Shaw
* Copyright 2011-2018 Collabora Ltd.
+ * SPDX-License-Identifier: (AFL-2.1 OR GPL-2.0-or-later) AND TCL
*
* Licensed under the Academic Free License version 2.1
*
diff --git a/test/internals/marshal-recursive.c b/test/internals/marshal-recursive.c
index 5866657a..137d52a6 100644
--- a/test/internals/marshal-recursive.c
+++ b/test/internals/marshal-recursive.c
@@ -3,6 +3,8 @@
* Copyright 2002-2009 Red Hat, Inc.
* Copyright 2011-2018 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/internals/mempool.c b/test/internals/mempool.c
index 53a606fd..dd65889f 100644
--- a/test/internals/mempool.c
+++ b/test/internals/mempool.c
@@ -5,6 +5,8 @@
* Copyright (C) 2003 CodeFactory AB
* Copyright (C) 2013 Chengwei Yang / Intel
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/internals/message-internals.c b/test/internals/message-internals.c
index 547947ae..6698d509 100644
--- a/test/internals/message-internals.c
+++ b/test/internals/message-internals.c
@@ -3,6 +3,8 @@
* Copyright 2002-2009 Red Hat, Inc.
* Copyright 2011-2018 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/internals/misc-internals.c b/test/internals/misc-internals.c
index a1777bb2..3fc9d504 100644
--- a/test/internals/misc-internals.c
+++ b/test/internals/misc-internals.c
@@ -6,6 +6,8 @@
* Copyright 2011-2019 Collabora Ltd.
* Copyright 2012 Lennart Poettering
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -35,6 +37,7 @@
#ifdef DBUS_UNIX
#include "dbus/dbus-userdb.h"
+#include <unistd.h>
#endif
#include "misc-internals.h"
@@ -671,55 +674,96 @@ _dbus_misc_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
return TRUE;
}
-static dbus_bool_t
-_dbus_server_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
+_DBUS_GNUC_PRINTF (1, 2) static void
+start_test_dbus_server (const char *fmt, ...)
{
- const char *valid_addresses[] = {
- "tcp:port=1234",
- "tcp:host=localhost,port=1234",
- "tcp:host=localhost,port=1234;tcp:port=5678",
-#ifdef DBUS_UNIX
- "unix:path=./boogie",
- "tcp:port=1234;unix:path=./boogie",
-#endif
- };
-
DBusServer *server;
- int i;
- for (i = 0; i < _DBUS_N_ELEMENTS (valid_addresses); i++)
+ DBusError error = DBUS_ERROR_INIT;
+ DBusString listen_address = _DBUS_STRING_INIT_INVALID;
+ char *address;
+ char *id;
+ va_list ap;
+
+ if (!_dbus_string_init (&listen_address))
+ _dbus_test_fatal ("Out of memory");
+
+ va_start (ap, fmt);
+ if (!_dbus_string_append_printf_valist (&listen_address, fmt, ap))
+ _dbus_test_fatal ("Out of memory");
+ va_end (ap);
+
+ _dbus_test_diag ("checking server address '%s'",
+ _dbus_string_get_const_data (&listen_address));
+ server = dbus_server_listen (_dbus_string_get_const_data (&listen_address),
+ &error);
+ if (server == NULL)
{
- DBusError error = DBUS_ERROR_INIT;
- char *address;
- char *id;
+ _dbus_warn ("server listen error: %s: %s", error.name, error.message);
+ dbus_error_free (&error);
+ _dbus_test_fatal ("Failed to listen for valid address '%s'.",
+ _dbus_string_get_const_data (&listen_address));
+ }
- server = dbus_server_listen (valid_addresses[i], &error);
- if (server == NULL)
- {
- _dbus_warn ("server listen error: %s: %s", error.name, error.message);
- dbus_error_free (&error);
- _dbus_test_fatal ("Failed to listen for valid address.");
- }
+ id = dbus_server_get_id (server);
+ _dbus_test_check (id != NULL);
+ address = dbus_server_get_address (server);
+ _dbus_test_check (address != NULL);
- id = dbus_server_get_id (server);
- _dbus_test_check (id != NULL);
- address = dbus_server_get_address (server);
- _dbus_test_check (address != NULL);
+ if (strstr (address, id) == NULL)
+ {
+ _dbus_warn ("server id '%s' is not in the server address '%s'", id,
+ address);
+ _dbus_test_fatal ("bad server id or address");
+ }
- if (strstr (address, id) == NULL)
- {
- _dbus_warn ("server id '%s' is not in the server address '%s'",
- id, address);
- _dbus_test_fatal ("bad server id or address");
- }
+ dbus_free (id);
+ dbus_free (address);
- dbus_free (id);
- dbus_free (address);
+ dbus_server_disconnect (server);
+ dbus_server_unref (server);
+ _dbus_string_free (&listen_address);
+}
- dbus_server_disconnect (server);
- dbus_server_unref (server);
- }
+#ifdef DBUS_UNIX
+static char test_socket_dir[] = DBUS_TEST_SOCKET_DIR "/dbus-test-XXXXXX";
+static void
+cleanup_test_socket_tempdir (void)
+{
+ if (rmdir (test_socket_dir) != 0)
+ _dbus_test_not_ok ("failed to remove test socket directory %s",
+ test_socket_dir);
+ else
+ _dbus_test_diag ("removed test socket directory %s", test_socket_dir);
+}
+#endif
+static dbus_bool_t
+_dbus_server_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ start_test_dbus_server ("tcp:port=1234");
+ start_test_dbus_server ("tcp:host=localhost,port=1234");
+ start_test_dbus_server ("tcp:host=localhost,port=1234;tcp:port=5678");
+ start_test_dbus_server ("tcp:port=1234");
+#ifdef DBUS_UNIX
+ /* Create a unique temporary directory for socket paths. */
+ if (mkdtemp (test_socket_dir) == NULL)
+ _dbus_test_fatal ("Failed to create temporary dir from template '%s'.",
+ test_socket_dir);
+ /* Clean up the test socket directory using atexit() since the test function
+ * can call _dbus_test_fatal() which terminates the test program. */
+ atexit (cleanup_test_socket_tempdir);
+
+ /* Check that both absolute and relative paths work. */
+ start_test_dbus_server ("unix:path=%s/boogie", test_socket_dir);
+ start_test_dbus_server ("tcp:port=1234;unix:path=%s/boogie",
+ test_socket_dir);
+
+ if (chdir (test_socket_dir) != 0)
+ _dbus_test_fatal ("Failed to chdir() to %s.", test_socket_dir);
+ start_test_dbus_server ("unix:path=./boogie");
+ start_test_dbus_server ("tcp:port=1234;unix:path=./boogie");
+#endif
return TRUE;
}
@@ -935,7 +979,7 @@ _dbus_userdb_test (const char *test_data_dir)
dbus_uid_t uid;
unsigned long *group_ids;
int n_group_ids, i;
- DBusError error;
+ DBusError error = DBUS_ERROR_INIT;
if (!_dbus_username_from_current_process (&username))
_dbus_test_fatal ("didn't get username");
@@ -946,8 +990,8 @@ _dbus_userdb_test (const char *test_data_dir)
if (!_dbus_get_user_id (username, &uid))
_dbus_test_fatal ("didn't get uid");
- if (!_dbus_groups_from_uid (uid, &group_ids, &n_group_ids))
- _dbus_test_fatal ("didn't get groups");
+ if (!_dbus_groups_from_uid (uid, &group_ids, &n_group_ids, &error))
+ _dbus_test_fatal ("didn't get groups: %s: %s", error.name, error.message);
_dbus_test_diag (" Current user: %s homedir: %s gids:",
_dbus_string_get_const_data (username),
diff --git a/test/internals/misc-internals.h b/test/internals/misc-internals.h
index 7f4d2cdf..999590fc 100644
--- a/test/internals/misc-internals.h
+++ b/test/internals/misc-internals.h
@@ -3,6 +3,8 @@
* Copyright 2002-2009 Red Hat, Inc.
* Copyright 2011-2018 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/internals/printf.c b/test/internals/printf.c
index 1160b2ae..d9a16257 100644
--- a/test/internals/printf.c
+++ b/test/internals/printf.c
@@ -2,6 +2,7 @@
*
* Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Copyright © 2013 Intel Corporation
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -66,6 +67,34 @@ do_test (int minimum,
#define X_TIMES_512 X_TIMES_256 X_TIMES_256
#define X_TIMES_1024 X_TIMES_512 X_TIMES_512
+static void
+print64 (void)
+{
+ dbus_int64_t i = -123;
+ dbus_uint64_t u = 456;
+ DBusString buf = _DBUS_STRING_INIT_INVALID;
+ const char expected[] = "i=-123;u=456;x=1c8";
+
+ if (!_dbus_string_init (&buf))
+ _dbus_test_fatal ("out of memory");
+
+ if (!_dbus_string_append_printf (&buf,
+ "i=%" DBUS_INT64_MODIFIER "d;"
+ "u=%" DBUS_INT64_MODIFIER "u;"
+ "x=%" DBUS_INT64_MODIFIER "x",
+ i, u, u))
+ _dbus_test_fatal ("out of memory");
+
+ if (_dbus_string_get_length (&buf) != (int) strlen (expected) ||
+ strcmp (_dbus_string_get_const_data (&buf), expected) != 0)
+ _dbus_test_fatal ("expected: \"%s\", got: %d chars \"%s\"",
+ expected,
+ _dbus_string_get_length (&buf),
+ _dbus_string_get_const_data (&buf));
+
+ _dbus_string_free (&buf);
+}
+
/* This test outputs TAP syntax: http://testanything.org/ */
int
main (int argc,
@@ -101,6 +130,9 @@ main (int argc,
}
printf ("ok %d\n", ++test_num);
+ print64 ();
+ printf ("ok %d\n", ++test_num);
+
/* Tell the TAP driver that we have done all the tests we plan to do.
* This is how it can distinguish between an unexpected exit and
* successful completion. */
diff --git a/test/internals/refs.c b/test/internals/refs.c
index f75ba1b6..37d9c40e 100644
--- a/test/internals/refs.c
+++ b/test/internals/refs.c
@@ -2,6 +2,7 @@
*
* Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Copyright © 2011 Nokia Corporation
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/test/internals/server-oom.c b/test/internals/server-oom.c
index dc3127fa..459994b9 100644
--- a/test/internals/server-oom.c
+++ b/test/internals/server-oom.c
@@ -1,6 +1,7 @@
/* Targeted unit tests for OOM paths in DBusServer
*
* Copyright © 2017 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -94,6 +95,10 @@ test_oom_wrapper (gconstpointer data)
{
const OOMTestCase *test = data;
+ if (g_str_has_prefix (test->data, "unix:") &&
+ !test_check_af_unix_works ())
+ return;
+
if ((g_str_has_prefix (test->data, "tcp:") ||
g_str_has_prefix (test->data, "nonce-tcp:")) &&
!test_check_tcp_works ())
@@ -131,6 +136,12 @@ main (int argc,
char **argv)
{
int ret;
+#ifdef DBUS_UNIX
+ char *tmp = _dbus_strdup ("/tmp");
+#else
+ char *tmp = dbus_address_escape_value (g_get_tmp_dir ());
+#endif
+ gchar *unix_tmpdir = g_strdup_printf ("unix:tmpdir=%s", tmp);
test_init (&argc, &argv);
@@ -139,13 +150,13 @@ main (int argc,
add_oom_test ("/server/new-nonce-tcp", test_new_server, "nonce-tcp:host=127.0.0.1,bind=127.0.0.1");
add_oom_test ("/server/new-tcp-star", test_new_server, "tcp:host=127.0.0.1,bind=*");
add_oom_test ("/server/new-tcp-v4", test_new_server, "tcp:host=127.0.0.1,bind=127.0.0.1,family=ipv4");
-#ifdef DBUS_UNIX
- add_oom_test ("/server/unix", test_new_server, "unix:tmpdir=/tmp");
-#endif
+ add_oom_test ("/server/unix", test_new_server, unix_tmpdir);
ret = g_test_run ();
g_queue_free_full (test_cases_to_free, g_free);
dbus_shutdown ();
+ g_free (unix_tmpdir);
+ dbus_free (tmp);
return ret;
}
diff --git a/test/internals/sha.c b/test/internals/sha.c
index 8de77efb..47a7ccc6 100644
--- a/test/internals/sha.c
+++ b/test/internals/sha.c
@@ -5,6 +5,8 @@
* Copyright (C) 1995 A. M. Kuchling
* Copyright (C) 2017 Thomas Zimmermann
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -188,22 +190,27 @@ get_next_expected_result (DBusString *results,
if (!_dbus_string_init (&line))
_dbus_test_fatal ("no memory");
- next_iteration:
while (_dbus_string_pop_line (results, &line))
{
_dbus_string_delete_leading_blanks (&line);
if (_dbus_string_get_length (&line) == 0)
- goto next_iteration;
+ {
+ continue;
+ }
else if (_dbus_string_starts_with_c_str (&line, "#"))
- goto next_iteration;
+ {
+ continue;
+ }
else if (_dbus_string_starts_with_c_str (&line, "H>"))
{
/* don't print */
}
else if (_dbus_string_starts_with_c_str (&line, "D>") ||
_dbus_string_starts_with_c_str (&line, "<D"))
- goto next_iteration;
+ {
+ continue;
+ }
else
{
int i;
@@ -324,7 +331,6 @@ process_test_data (const char *test_data_dir)
success_count = 0;
line_no = 0;
- next_iteration:
while (_dbus_string_pop_line (&tests, &line))
{
line_no += 1;
@@ -332,9 +338,13 @@ process_test_data (const char *test_data_dir)
_dbus_string_delete_leading_blanks (&line);
if (_dbus_string_get_length (&line) == 0)
- goto next_iteration;
+ {
+ continue;
+ }
else if (_dbus_string_starts_with_c_str (&line, "#"))
- goto next_iteration;
+ {
+ continue;
+ }
else if (_dbus_string_starts_with_c_str (&line, "H>"))
{
_dbus_test_diag ("SHA-1: %s", _dbus_string_get_const_data (&line));
@@ -353,7 +363,9 @@ process_test_data (const char *test_data_dir)
}
else if (_dbus_string_starts_with_c_str (&line, "D>") ||
_dbus_string_starts_with_c_str (&line, "<D"))
- goto next_iteration;
+ {
+ continue;
+ }
else
{
DBusString test;
diff --git a/test/internals/spawn-oom.c b/test/internals/spawn-oom.c
index b24df7fd..7884f607 100644
--- a/test/internals/spawn-oom.c
+++ b/test/internals/spawn-oom.c
@@ -5,6 +5,8 @@
* Copyright (C) 2003 CodeFactory AB
* Copyright (C) 2005 Novell, Inc.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/internals/strings.c b/test/internals/strings.c
new file mode 100644
index 00000000..6027e6a2
--- /dev/null
+++ b/test/internals/strings.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2023 Ralf Habacker
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <config.h>
+
+#include "dbus/dbus-string.h"
+#include "dbus/dbus-test.h"
+#include "dbus/dbus-test-tap.h"
+#include "test/test-utils.h"
+
+static dbus_bool_t
+_dbus_string_skip_blank_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ int end;
+ DBusString s = _DBUS_STRING_INIT_INVALID;
+ const char *p = " \rT\r\n";
+
+ _dbus_string_init (&s);
+ if (!_dbus_string_append (&s, p))
+ {
+ _dbus_string_free (&s);
+ return FALSE;
+ }
+
+ _dbus_string_skip_blank (&s, 0, &end);
+ _dbus_string_free (&s);
+ return TRUE;
+}
+
+static const DBusTestCase test[] =
+{
+ { "skip_blank", _dbus_string_skip_blank_test },
+};
+
+
+int
+main (int argc,
+ char **argv)
+{
+ return _dbus_test_main (argc, argv, sizeof(test) / sizeof (DBusTestCase), test,
+ DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS,
+ NULL, NULL);
+}
diff --git a/test/internals/sysdeps.c b/test/internals/sysdeps.c
index 33d04f91..3f920c73 100644
--- a/test/internals/sysdeps.c
+++ b/test/internals/sysdeps.c
@@ -1,5 +1,6 @@
/*
* Copyright © 2018 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -28,9 +29,19 @@
#include "dbus/dbus-sysdeps.h"
#include "test-utils-glib.h"
+#ifdef G_OS_UNIX
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include "dbus/dbus-sysdeps-unix.h"
+#endif
+
typedef struct
{
- int dummy;
+ size_t n_fds;
+ int *fds;
} Fixture;
static void
@@ -43,10 +54,6 @@ setup (Fixture *f G_GNUC_UNUSED,
* handle (a HANDLE, vaguely analogous to a file descriptor) on Windows.
* For _dbus_command_for_pid() we need an actual process ID. */
#ifdef G_OS_UNIX
-# include <errno.h>
-# include <sys/wait.h>
-# include <sys/types.h>
-
# define NO_PROCESS 0
# ifndef G_PID_FORMAT
# define G_PID_FORMAT "i"
@@ -184,10 +191,129 @@ test_command_for_pid (Fixture *f,
g_free (argv[0]);
}
+#ifdef G_OS_UNIX
+static gboolean
+check_valid_fd (int fd,
+ gboolean *close_on_exec)
+{
+ int flags = fcntl (fd, F_GETFD);
+
+ if (flags < 0)
+ {
+ int saved_errno = errno;
+
+ g_assert_cmpint (saved_errno, ==, EBADF);
+ return FALSE;
+ }
+
+ if (close_on_exec != NULL)
+ *close_on_exec = ((flags & FD_CLOEXEC) != 0);
+
+ return TRUE;
+}
+
+static void
+fixture_open_some_fds (Fixture *f)
+{
+ const size_t n = 50; /* must be divisible by 2, otherwise arbitrary */
+ size_t i;
+ const char *error_str = NULL;
+
+ /* Ensure that fds[] will not contain 0, 1 or 2 */
+ if (!_dbus_ensure_standard_fds (0, &error_str))
+ g_error ("_dbus_ensure_standard_fds: %s (%s)",
+ error_str, g_strerror (errno));
+
+ g_assert_cmpuint (f->n_fds, ==, 0);
+ g_assert_null (f->fds);
+ f->n_fds = n;
+ f->fds = g_new0 (int, n);
+
+ for (i = 0; i < n; i++)
+ f->fds[i] = -1;
+
+ for (i = 0; i < n; i += 2)
+ {
+ gboolean cloexec;
+
+ if (pipe (&f->fds[i]) < 0)
+ g_error ("pipe: %s", g_strerror (errno));
+
+ g_assert_cmpint (f->fds[i], >=, 3);
+ g_assert_cmpint (f->fds[i + 1], >=, 3);
+ _dbus_fd_clear_close_on_exec (f->fds[i]);
+ _dbus_fd_clear_close_on_exec (f->fds[i + 1]);
+ g_assert_true (check_valid_fd (f->fds[i], &cloexec));
+ g_assert_false (cloexec);
+ g_assert_true (check_valid_fd (f->fds[i + 1], &cloexec));
+ g_assert_false (cloexec);
+ }
+}
+
+static void
+test_close_all (Fixture *f,
+ gconstpointer context G_GNUC_UNUSED)
+{
+ size_t i;
+
+ fixture_open_some_fds (f);
+
+ for (i = 0; i < f->n_fds; i++)
+ g_assert_true (check_valid_fd (f->fds[i], NULL));
+
+ _dbus_close_all ();
+
+ for (i = 0; i < f->n_fds; i++)
+ {
+ g_assert_false (check_valid_fd (f->fds[i], NULL));
+ /* Don't re-close the fd in teardown */
+ f->fds[i] = -1;
+ }
+}
+
+static void
+test_set_all_close_on_exec (Fixture *f,
+ gconstpointer context G_GNUC_UNUSED)
+{
+ size_t i;
+
+ fixture_open_some_fds (f);
+
+ for (i = 0; i < f->n_fds; i++)
+ {
+ gboolean cloexec;
+
+ g_assert_true (check_valid_fd (f->fds[i], &cloexec));
+ g_assert_false (cloexec);
+ }
+
+ _dbus_fd_set_all_close_on_exec ();
+
+ for (i = 0; i < f->n_fds; i++)
+ {
+ gboolean cloexec;
+
+ g_assert_true (check_valid_fd (f->fds[i], &cloexec));
+ g_assert_true (cloexec);
+ }
+}
+#endif
+
static void
teardown (Fixture *f G_GNUC_UNUSED,
gconstpointer context G_GNUC_UNUSED)
{
+#ifdef G_OS_UNIX
+ size_t i;
+
+ for (i = 0; i < f->n_fds; i++)
+ {
+ if (f->fds[i] >= 0)
+ _dbus_close (f->fds[i], NULL);
+ }
+
+ g_free (f->fds);
+#endif
}
int
@@ -201,6 +327,13 @@ main (int argc,
g_test_add ("/sysdeps/command_for_pid",
Fixture, NULL, setup, test_command_for_pid, teardown);
+#ifdef G_OS_UNIX
+ g_test_add ("/sysdeps/close_all",
+ Fixture, NULL, setup, test_close_all, teardown);
+ g_test_add ("/sysdeps/set_all_close_on_exec",
+ Fixture, NULL, setup, test_set_all_close_on_exec, teardown);
+#endif
+
ret = g_test_run ();
dbus_shutdown ();
return ret;
diff --git a/test/internals/syslog.c b/test/internals/syslog.c
index 93f885a4..28267f14 100644
--- a/test/internals/syslog.c
+++ b/test/internals/syslog.c
@@ -2,6 +2,7 @@
*
* Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Copyright © 2011 Nokia Corporation
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/test/internals/userdb.c b/test/internals/userdb.c
new file mode 100644
index 00000000..905791b3
--- /dev/null
+++ b/test/internals/userdb.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright © 2023 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <config.h>
+
+#include <glib.h>
+
+#include <dbus/dbus.h>
+#include "dbus/dbus-sysdeps.h"
+#include "test-utils-glib.h"
+
+#ifdef DBUS_UNIX
+#include <errno.h>
+#include <pwd.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "dbus/dbus-sysdeps-unix.h"
+#include "dbus/dbus-userdb.h"
+#endif
+
+typedef struct
+{
+ int dummy;
+} Fixture;
+
+static void
+setup (Fixture *f G_GNUC_UNUSED,
+ gconstpointer context G_GNUC_UNUSED)
+{
+}
+
+static void
+test_groups_from_uid (Fixture *f,
+ gconstpointer context G_GNUC_UNUSED)
+{
+ DBusError error = DBUS_ERROR_INIT;
+ dbus_gid_t *gids = NULL;
+ int n_gids = -1;
+ dbus_bool_t ret;
+#ifdef DBUS_UNIX
+ int i;
+#endif
+
+ /* We assume that uid 0 (root) is available on all Unix systems,
+ * so this should succeed */
+ ret = _dbus_unix_groups_from_uid (0, &gids, &n_gids, &error);
+
+#ifdef DBUS_UNIX
+ test_assert_no_error (&error);
+ g_assert_true (ret);
+ g_assert_cmpint (n_gids, >=, 0);
+
+ g_test_message ("Groups of uid 0:");
+
+ for (i = 0; i < n_gids; i++)
+ {
+ g_test_message ("[%d]: %ld", i, (long) gids[i]);
+ g_assert_cmpint (gids[i], >=, 0);
+ }
+#else
+ g_assert_cmpstr (error.name, ==, DBUS_ERROR_NOT_SUPPORTED);
+ g_assert_false (ret);
+ g_test_message ("Getting Unix groups on Windows failed as expected: %s: %s",
+ error.name, error.message);
+ g_assert_null (gids);
+ g_assert_cmpint (n_gids, <=, 0);
+#endif
+
+ dbus_free (gids);
+ dbus_error_free (&error);
+
+#ifdef DBUS_UNIX
+ /* Assume that the current uid is something sensible */
+ ret = _dbus_unix_groups_from_uid (geteuid (), &gids, &n_gids, &error);
+ test_assert_no_error (&error);
+ g_assert_true (ret);
+ g_assert_cmpint (n_gids, >=, 0);
+
+ g_test_message ("Groups of uid %ld:", (long) geteuid ());
+
+ for (i = 0; i < n_gids; i++)
+ {
+ g_test_message ("[%d]: %ld", i, (long) gids[i]);
+ g_assert_cmpint (gids[i], >=, 0);
+ }
+
+ g_test_message ("Total: %i groups", n_gids);
+
+ dbus_free (gids);
+ dbus_error_free (&error);
+
+ errno = 0;
+
+ /* arbitrarily chosen, probably isn't a valid uid */
+ if (getpwuid (31337) == NULL)
+ {
+ g_test_message ("uid 31337 doesn't exist: %s",
+ errno == 0 ? "(no errno)" : g_strerror (errno));
+ ret = _dbus_unix_groups_from_uid (31337, &gids, &n_gids, &error);
+ g_assert_nonnull (error.name);
+ g_assert_nonnull (error.message);
+ g_assert_false (ret);
+ g_test_message ("Getting groups from non-uid failed as expected: %s: %s",
+ error.name, error.message);
+ /* The Unix implementation always clears gids/n_gids,
+ * even on failure, and even if they were uninitialized */
+ g_assert_null (gids);
+ g_assert_cmpint (n_gids, ==, 0);
+
+ dbus_free (gids);
+ dbus_error_free (&error);
+ }
+ else
+ {
+ g_test_skip ("against our expectations, uid 31337 exists on this system");
+ }
+#endif
+}
+
+static void
+teardown (Fixture *f G_GNUC_UNUSED,
+ gconstpointer context G_GNUC_UNUSED)
+{
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ int ret;
+
+ test_init (&argc, &argv);
+
+ g_test_add ("/userdb/groups_from_uid",
+ Fixture, NULL, setup, test_groups_from_uid, teardown);
+
+ ret = g_test_run ();
+ dbus_shutdown ();
+ return ret;
+}
diff --git a/test/internals/variant.c b/test/internals/variant.c
index e5135429..7e16495a 100644
--- a/test/internals/variant.c
+++ b/test/internals/variant.c
@@ -1,6 +1,7 @@
/* Regression test for DBusVariant
*
* Copyright © 2017 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/test/loopback.c b/test/loopback.c
index f89f5a95..6c6d5a9b 100644
--- a/test/loopback.c
+++ b/test/loopback.c
@@ -3,6 +3,7 @@
* Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Copyright © 2010-2012 Nokia Corporation
* Copyright © 2015 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -61,6 +62,37 @@ assert_no_error (const DBusError *e)
g_error ("expected success but got error: %s: %s", e->name, e->message);
}
+/* these are macros so they get the right line number */
+
+#define assert_method_reply(m, sender, destination, signature) \
+do { \
+ g_assert_cmpstr (dbus_message_type_to_string (dbus_message_get_type (m)), \
+ ==, dbus_message_type_to_string (DBUS_MESSAGE_TYPE_METHOD_RETURN)); \
+ g_assert_cmpstr (dbus_message_get_sender (m), ==, sender); \
+ g_assert_cmpstr (dbus_message_get_destination (m), ==, destination); \
+ g_assert_cmpstr (dbus_message_get_path (m), ==, NULL); \
+ g_assert_cmpstr (dbus_message_get_interface (m), ==, NULL); \
+ g_assert_cmpstr (dbus_message_get_member (m), ==, NULL); \
+ g_assert_cmpstr (dbus_message_get_signature (m), ==, signature); \
+ g_assert_cmpint (dbus_message_get_serial (m), !=, 0); \
+ g_assert_cmpint (dbus_message_get_reply_serial (m), !=, 0); \
+} while (0)
+
+#define assert_error_reply(m, sender, destination, error_name) \
+do { \
+ g_assert_cmpstr (dbus_message_type_to_string (dbus_message_get_type (m)), \
+ ==, dbus_message_type_to_string (DBUS_MESSAGE_TYPE_ERROR)); \
+ g_assert_cmpstr (dbus_message_get_sender (m), ==, sender); \
+ g_assert_cmpstr (dbus_message_get_destination (m), ==, destination); \
+ g_assert_cmpstr (dbus_message_get_error_name (m), ==, error_name); \
+ g_assert_cmpstr (dbus_message_get_path (m), ==, NULL); \
+ g_assert_cmpstr (dbus_message_get_interface (m), ==, NULL); \
+ g_assert_cmpstr (dbus_message_get_member (m), ==, NULL); \
+ g_assert_cmpstr (dbus_message_get_signature (m), ==, "s"); \
+ g_assert_cmpint (dbus_message_get_serial (m), !=, 0); \
+ g_assert_cmpint (dbus_message_get_reply_serial (m), !=, 0); \
+} while (0)
+
static DBusHandlerResult
server_message_cb (DBusConnection *server_conn,
DBusMessage *message,
@@ -99,9 +131,10 @@ setup (Fixture *f,
dbus_error_init (&f->e);
g_queue_init (&f->server_messages);
- if ((g_str_has_prefix (addr, "tcp:") ||
- g_str_has_prefix (addr, "nonce-tcp:")) &&
- !test_check_tcp_works ())
+ if ((g_str_has_prefix (addr, "unix:") && !test_check_af_unix_works ()) ||
+ ((g_str_has_prefix (addr, "tcp:") ||
+ g_str_has_prefix (addr, "nonce-tcp:")) &&
+ !test_check_tcp_works ()))
{
f->skip = TRUE;
return;
@@ -116,7 +149,6 @@ setup (Fixture *f,
test_server_setup (f->ctx, f->server);
}
-#ifdef DBUS_UNIX
static void
setup_runtime (Fixture *f,
gconstpointer addr)
@@ -131,6 +163,7 @@ setup_runtime (Fixture *f,
/* we're relying on being single-threaded for this to be safe */
f->saved_runtime_dir = g_strdup (g_getenv ("XDG_RUNTIME_DIR"));
g_setenv ("XDG_RUNTIME_DIR", f->tmp_runtime_dir, TRUE);
+ g_test_message ("XDG_RUNTIME_DIR %s", f->tmp_runtime_dir);
setup (f, addr);
@@ -140,9 +173,12 @@ setup_runtime (Fixture *f,
listening_at = dbus_server_get_address (f->server);
g_test_message ("listening at %s", listening_at);
g_assert (g_str_has_prefix (listening_at, "unix:path="));
+#ifndef DBUS_WIN
+ /* FIXME: on gitlab CI win32, it doesn't use runtime dir, why..? */
g_assert (strstr (listening_at, "dbus%3ddaemon%3dtest.") != NULL);
- g_assert (strstr (listening_at, "/bus,") != NULL ||
- g_str_has_suffix (listening_at, "/bus"));
+ g_assert (strstr (listening_at, DBUS_DIR_SEPARATOR_S "bus,") != NULL ||
+ g_str_has_suffix (listening_at, DBUS_DIR_SEPARATOR_S "bus"));
+#endif
dbus_free (listening_at);
}
@@ -166,11 +202,12 @@ setup_no_runtime (Fixture *f,
g_test_message ("listening at %s", listening_at);
/* we have fallen back to something in /tmp, either abstract or not */
g_assert (g_str_has_prefix (listening_at, "unix:"));
- g_assert (strstr (listening_at, "=/tmp/") != NULL);
+#ifdef DBUS_UNIX
+ g_assert (strstr (listening_at, "=/tmp" DBUS_DIR_SEPARATOR_S) != NULL);
+#endif
dbus_free (listening_at);
}
-#endif
static void
test_connect (Fixture *f,
@@ -221,8 +258,7 @@ test_connect (Fixture *f,
g_assert_cmpstr (dbus_address_entry_get_value (entries[0], "noncefile"),
!=, NULL);
}
-#ifdef DBUS_UNIX
- else if (g_strcmp0 (listening_address, "unix:tmpdir=/tmp") == 0)
+ else if (g_str_has_prefix (listening_address, "unix:tmpdir="))
{
g_assert_cmpstr (dbus_address_entry_get_method (entries[0]), ==, "unix");
@@ -231,7 +267,7 @@ test_connect (Fixture *f,
const char *abstract = dbus_address_entry_get_value (entries[0],
"abstract");
- g_assert_true (g_str_has_prefix (abstract, "/tmp/dbus-"));
+ g_assert_true (g_str_has_prefix (abstract, "/tmp" DBUS_DIR_SEPARATOR_S "dbus-"));
g_assert_cmpstr (dbus_address_entry_get_value (entries[0], "path"),
==, NULL);
}
@@ -241,26 +277,29 @@ test_connect (Fixture *f,
"path");
g_assert_nonnull (path);
- g_assert_true (g_str_has_prefix (path, "/tmp/dbus-"));
+#ifdef DBUS_UNIX
+ g_assert_true (g_str_has_prefix (path, "/tmp" DBUS_DIR_SEPARATOR_S "dbus-"));
+#endif
}
}
- else if (g_strcmp0 (listening_address, "unix:dir=/tmp") == 0)
+ else if (g_str_has_prefix (listening_address, "unix:dir="))
{
const char *path = dbus_address_entry_get_value (entries[0],
"path");
g_assert_cmpstr (dbus_address_entry_get_method (entries[0]), ==, "unix");
g_assert_nonnull (path);
- g_assert_true (g_str_has_prefix (path, "/tmp/dbus-"));
+#ifdef DBUS_UNIX
+ g_assert_true (g_str_has_prefix (path, "/tmp" DBUS_DIR_SEPARATOR_S "dbus-"));
+#endif
}
- else if (g_strcmp0 (listening_address,
- "unix:runtime=yes;unix:tmpdir=/tmp") == 0)
+ else if (g_str_has_prefix (listening_address,
+ "unix:runtime=yes;unix:tmpdir="))
{
g_assert_cmpstr (dbus_address_entry_get_method (entries[0]), ==, "unix");
/* No particular statement about the path here: for that see
* setup_runtime() and setup_no_runtime() */
}
-#endif
else
{
g_assert_not_reached ();
@@ -416,6 +455,59 @@ test_message (Fixture *f,
}
static void
+test_builtin_filters (Fixture *f,
+ gconstpointer addr)
+{
+ dbus_bool_t have_mem;
+ dbus_uint32_t serial;
+ DBusMessage *ping;
+ DBusMessage *m;
+
+ if (f->skip)
+ return;
+
+ test_connect (f, addr);
+
+ ping = dbus_message_new_method_call (NULL, "/foo", DBUS_INTERFACE_PEER,
+ "Ping");
+
+ dbus_connection_set_builtin_filters_enabled (f->client_conn, TRUE);
+
+ have_mem = dbus_connection_send (f->server_conn, ping, &serial);
+ g_assert (have_mem);
+ g_assert (serial != 0);
+
+ while (g_queue_get_length (&f->server_messages) < 1)
+ test_main_context_iterate (f->ctx, TRUE);
+
+ m = g_queue_pop_head (&f->server_messages);
+ assert_method_reply (m, NULL, NULL, "");
+ dbus_message_unref (m);
+
+ m = g_queue_pop_head (&f->server_messages);
+ g_assert (m == NULL);
+
+ dbus_connection_set_builtin_filters_enabled (f->client_conn, FALSE);
+
+ have_mem = dbus_connection_send (f->server_conn, ping, &serial);
+ g_assert (have_mem);
+ g_assert (serial != 0);
+
+ while (g_queue_get_length (&f->server_messages) < 1)
+ test_main_context_iterate (f->ctx, TRUE);
+
+ m = g_queue_pop_head (&f->server_messages);
+ assert_error_reply (m, NULL, NULL,
+ "org.freedesktop.DBus.Error.UnknownMethod");
+ dbus_message_unref (m);
+
+ m = g_queue_pop_head (&f->server_messages);
+ g_assert (m == NULL);
+
+ dbus_message_unref (ping);
+}
+
+static void
teardown (Fixture *f,
gconstpointer addr G_GNUC_UNUSED)
{
@@ -441,7 +533,6 @@ teardown (Fixture *f,
test_main_context_unref (f->ctx);
}
-#ifdef DBUS_UNIX
static void
teardown_no_runtime (Fixture *f,
gconstpointer addr)
@@ -479,13 +570,20 @@ teardown_runtime (Fixture *f,
g_free (f->saved_runtime_dir);
g_free (f->tmp_runtime_dir);
}
-#endif
int
main (int argc,
char **argv)
{
int ret;
+#ifdef DBUS_UNIX
+ char *tmp = _dbus_strdup ("/tmp");
+#else
+ char *tmp = dbus_address_escape_value (g_get_tmp_dir ());
+#endif
+ gchar *unix_tmpdir = g_strdup_printf ("unix:tmpdir=%s", tmp);
+ gchar *unix_dir = g_strdup_printf ("unix:dir=%s", tmp);
+ gchar *unix_runtime_or_fallback = g_strdup_printf ("unix:runtime=yes;%s", unix_tmpdir);
test_init (&argc, &argv);
@@ -502,28 +600,34 @@ main (int argc,
g_test_add ("/message/bad-guid/tcp", Fixture, "tcp:host=127.0.0.1", setup,
test_bad_guid, teardown);
-#ifdef DBUS_UNIX
- g_test_add ("/connect/unix/tmpdir", Fixture, "unix:tmpdir=/tmp", setup,
+ g_test_add ("/connect/unix/tmpdir", Fixture, unix_tmpdir, setup,
test_connect, teardown);
- g_test_add ("/message/unix/tmpdir", Fixture, "unix:tmpdir=/tmp", setup,
+ g_test_add ("/message/unix/tmpdir", Fixture, unix_tmpdir, setup,
test_message, teardown);
- g_test_add ("/connect/unix/dir", Fixture, "unix:dir=/tmp", setup,
+ g_test_add ("/connect/unix/dir", Fixture, unix_dir, setup,
test_connect, teardown);
- g_test_add ("/message/unix/dir", Fixture, "unix:dir=/tmp", setup,
+ g_test_add ("/message/unix/dir", Fixture, unix_dir, setup,
test_message, teardown);
g_test_add ("/connect/unix/runtime", Fixture,
- "unix:runtime=yes;unix:tmpdir=/tmp", setup_runtime, test_connect,
+ unix_runtime_or_fallback, setup_runtime, test_connect,
teardown_runtime);
g_test_add ("/connect/unix/no-runtime", Fixture,
- "unix:runtime=yes;unix:tmpdir=/tmp", setup_no_runtime, test_connect,
+ unix_runtime_or_fallback, setup_no_runtime, test_connect,
teardown_no_runtime);
- g_test_add ("/message/bad-guid/unix", Fixture, "unix:tmpdir=/tmp", setup,
+ g_test_add ("/message/bad-guid/unix", Fixture, unix_tmpdir, setup,
test_bad_guid, teardown);
-#endif
+
+ g_test_add ("/builtin-filters", Fixture, "tcp:host=127.0.0.1", setup,
+ test_builtin_filters, teardown);
ret = g_test_run ();
dbus_shutdown ();
+
+ g_free (unix_tmpdir);
+ g_free (unix_dir);
+ g_free (unix_runtime_or_fallback);
+ dbus_free (tmp);
return ret;
}
diff --git a/test/manual-authz.c b/test/manual-authz.c
index ee9bc52f..7e82dc60 100644
--- a/test/manual-authz.c
+++ b/test/manual-authz.c
@@ -2,6 +2,7 @@
*
* Copyright © 2010-2011 Nokia Corporation
* Copyright © 2012 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/test/manual-backtrace.c b/test/manual-backtrace.c
index 0cc1499d..0b89d1c6 100644
--- a/test/manual-backtrace.c
+++ b/test/manual-backtrace.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2015 Ralf Habacker <ralf.habacker@freenet.de>
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/test/manual-dir-iter.c b/test/manual-dir-iter.c
index 85081748..87517aa7 100644
--- a/test/manual-dir-iter.c
+++ b/test/manual-dir-iter.c
@@ -1,3 +1,7 @@
+/*
+ * Copyright 2014 Ralf Habacker
+ * SPDX-License-Identifier: MIT
+ */
#include <config.h>
#include "test-utils.h"
diff --git a/test/manual-paths.c b/test/manual-paths.c
index 225ab1e8..0334c712 100644
--- a/test/manual-paths.c
+++ b/test/manual-paths.c
@@ -1,4 +1,8 @@
/*
+ * Copyright 2015 Ralf Habacker
+ * Copyright 2015-2020 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ *
* Simple manual paths check
*
* syntax: manual-paths
diff --git a/test/manual-tcp.c b/test/manual-tcp.c
index 64691c9d..7012614d 100644
--- a/test/manual-tcp.c
+++ b/test/manual-tcp.c
@@ -1,4 +1,7 @@
/*
+ * Copyright 2015 Ralf Habacker
+ * SPDX-License-Identifier: MIT
+ *
* Simple manual tcp check
*
* supports:
diff --git a/test/marshal.c b/test/marshal.c
index a1e0589d..6bba7aa9 100644
--- a/test/marshal.c
+++ b/test/marshal.c
@@ -2,6 +2,7 @@
*
* Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Copyright © 2010-2011 Nokia Corporation
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 00000000..11773f9e
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,763 @@
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+###############################################################################
+# Tests installation
+
+install_tests = get_option('installed_tests')
+
+test_exec_dir = get_option('libexecdir') / 'installed-tests' / 'dbus'
+test_meta_dir = get_option('datadir') / 'installed-tests' / 'dbus'
+
+###############################################################################
+# Test configuration needs some specific keys
+
+test_data_config = configuration_data()
+test_data_config.merge_from(data_config)
+
+test_data_config.set('EXEEXT', exe_ext)
+# / '' to convert \-separated dir to /-separated dir on win32
+test_data_config.set('DBUS_TEST_EXEC', meson.current_build_dir() / '')
+test_data_config.set('DBUS_TEST_DATA', meson.current_build_dir() / 'data')
+
+
+test_env = environment()
+
+test_env.set('DBUS_TOP_SRCDIR', meson.project_source_root())
+test_env.set('DBUS_TEST_SRCDIR', meson.current_source_dir())
+test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
+
+test_env.set('DBUS_TOP_BUILDDIR', meson.project_build_root())
+test_env.set('DBUS_TEST_HOMEDIR', meson.project_build_root() / 'dbus')
+test_env.set('HOME', meson.project_build_root() / 'dbus')
+# Tests in bus/config-parser.c rely on this specific value
+test_env.set('DBUS_TEST_BUILDDIR', meson.current_build_dir())
+test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
+test_env.set('DBUS_TEST_EXEC', meson.current_build_dir())
+test_env.set('DBUS_TEST_DATA', meson.current_build_dir() / 'data')
+
+if message_bus
+ test_env.set('DBUS_TEST_DAEMON', dbus_daemon.full_path())
+endif
+
+if tools
+ test_env.set('DBUS_TEST_DBUS_MONITOR', dbus_monitor.full_path())
+ test_env.set('DBUS_TEST_DBUS_SEND', dbus_send.full_path())
+endif
+
+if message_bus and tools
+ test_env.set('DBUS_TEST_DBUS_LAUNCH', dbus_launch.full_path())
+endif
+
+if platform_unix and tools
+ test_env.set('DBUS_TEST_DBUS_UUIDGEN', dbus_uuidgen.full_path())
+endif
+
+if platform_windows
+ # test-autolaunch-win relies on being able to find the just-built
+ # dbus-daemon in the PATH
+ if build_machine.system().contains('windows')
+ test_env.prepend('PATH', meson.project_build_root() / 'bus')
+ else
+ # Assume we'll use Wine to run tests while cross-compiling
+ test_env.prepend(
+ 'WINEPATH',
+ 'Z:' + meson.project_build_root() / 'bus',
+ separator: ';',
+ )
+ endif
+endif
+
+# Tests in bus/config-parser.c rely on these specific values for XDG_*
+test_env.set('XDG_DATA_HOME', meson.current_build_dir() / 'XDG_DATA_HOME')
+test_env.set('XDG_RUNTIME_DIR', meson.current_build_dir() / 'XDG_RUNTIME_DIR')
+xdg_data_dirs = [
+ meson.current_build_dir() / 'XDG_DATA_DIRS',
+ meson.current_build_dir() / 'XDG_DATA_DIRS2'
+]
+test_env.set('XDG_DATA_DIRS', xdg_data_dirs)
+
+test_env.set('DBUS_SESSION_BUS_ADDRESS', 'do-not-use-real-session:')
+
+test_env.set('DBUS_FATAL_WARNINGS', '1')
+test_env.set('DBUS_TEST_UNINSTALLED', '1')
+
+xdgdir = custom_target('gen-xdgdir',
+ command: [
+ python,
+ files('mkdir-m700.py'),
+ meson.current_build_dir() / 'XDG_RUNTIME_DIR',
+ ],
+ output: 'XDG_RUNTIME_DIR'
+)
+
+installed_tests = []
+
+if meson.version().version_compare('>=0.63') and meson.version().version_compare('<0.63.1')
+ # Work around https://github.com/mesonbuild/meson/issues/10577
+ test_protocol = 'exitcode'
+elif platform_windows
+ # Work around https://gitlab.gnome.org/GNOME/glib/-/issues/2746
+ test_protocol = 'exitcode'
+else
+ test_protocol = 'tap'
+endif
+
+###############################################################################
+# Dbus testutils
+
+
+libdbus_testutils_sources = [
+ 'disable-crash-handling.c',
+ 'test-utils.c',
+]
+
+if use_glib
+ libdbus_testutils_sources += 'test-utils-glib.c'
+endif
+
+libdbus_testutils = static_library('dbus-testutils',
+ libdbus_testutils_sources,
+
+ include_directories: root_include,
+ link_with: [
+ libdbus,
+ libdbus_internal,
+ ],
+ dependencies: [
+ glib,
+ gio,
+ dbus_dependencies,
+ ],
+)
+
+
+###############################################################################
+# Test tools
+
+# these binaries are used in tests but are not themselves tests
+test_exit = executable('test-exit',
+ 'test-exit.c',
+ include_directories: root_include,
+ link_with: libdbus_testutils,
+ dependencies: dbus_dependencies,
+)
+test_names = executable('test-names',
+ 'test-names.c',
+ include_directories: root_include,
+ link_with: libdbus_testutils,
+ dependencies: dbus_dependencies,
+)
+test_privserver = executable('test-privserver',
+ 'test-privserver.c',
+ include_directories: root_include,
+ link_with: libdbus_testutils,
+ dependencies: dbus_dependencies,
+)
+# This helper is meant to crash, so if we're compiling the rest with
+# AddressSanitizer, we need to stop it from catching the SIGSEGV and
+# turning it into _exit(1).
+# We have to compile a separate copy of disable-crash-handling.c for
+# test-segfault rather than using libdbus-testutils, because
+# otherwise it would fail to link when using the AddressSanitizer.
+test_segfault = executable('test-segfault',
+ 'test-segfault.c', 'disable-crash-handling.c',
+ include_directories: root_include,
+ dependencies: dbus_dependencies,
+ override_options: ['b_sanitize=none'],
+)
+test_shell_service = executable('test-shell-service',
+ 'test-shell-service.c',
+ include_directories: root_include,
+ link_with: libdbus_testutils,
+ dependencies: dbus_dependencies,
+)
+
+if use_traditional_activation
+ test_spawn = executable('test-spawn',
+ 'spawn-test.c',
+ include_directories: root_include,
+ link_with: libdbus_testutils,
+ dependencies: dbus_dependencies,
+ )
+endif
+if use_traditional_activation and platform_unix
+ launch_helper_for_tests = executable('launch-helper-for-tests',
+ 'bus/launch-helper-for-tests.c',
+ include_directories: root_include,
+ link_with: liblaunch_helper_internal,
+ dependencies: dbus_dependencies,
+ )
+ test_data_config.set('TEST_LAUNCH_HELPER_BINARY', launch_helper_for_tests.full_path())
+else
+ # Dummy value, should not be used in practice
+ test_data_config.set('TEST_LAUNCH_HELPER_BINARY', '/bin/false')
+endif
+
+if message_bus and tools and platform_unix and use_glib
+ test_apparmor_activation = executable('test-apparmor-activation',
+ 'sd-activation.c',
+ include_directories: root_include,
+ c_args: '-DDBUS_TEST_APPARMOR_ACTIVATION',
+ link_with: libdbus_testutils,
+ dependencies: [
+ glib, gio,
+ apparmor,
+ ],
+ install: install_tests,
+ install_dir: test_exec_dir,
+ )
+endif
+
+###############################################################################
+# Subdirectories need utilities above.
+
+subdir('data')
+
+# the "name-test" subdir in fact contains a bunch of tests now that need a
+# temporary bus to be running to do stuff with. The directory should be renamed.
+if message_bus and tools
+ subdir('name-test')
+endif
+
+tests = []
+
+if embedded_tests
+
+ tests += [
+ {
+ 'name': 'marshal-recursive',
+ 'srcs': [
+ 'internals/dbus-marshal-recursive-util.c',
+ 'internals/marshal-recursive.c',
+ ],
+ 'link': [ libdbus_testutils, ],
+ 'install': false,
+ 'timeout': 60,
+ },
+ {
+ 'name': 'message-internals',
+ 'srcs': [
+ 'internals/dbus-marshal-recursive-util.c',
+ 'internals/dbus-message-factory.c',
+ 'internals/dbus-message-util.c',
+ 'internals/message-internals.c',
+ ],
+ 'link': [ libdbus_testutils, ],
+ 'install': false,
+ 'suite': ['slow'],
+ },
+ ]
+
+ if message_bus
+ tests += [
+ {
+ 'name': 'bus',
+ 'srcs': [ 'bus/main.c', 'bus/common.c' ],
+ 'link': [ libdbus_testutils, libdbus_daemon_internal, ],
+ 'install': false,
+ },
+ {
+ 'name': 'bus-dispatch-sha1',
+ 'srcs': [ 'bus/dispatch-sha1.c', 'bus/common.c' ],
+ 'link': [ libdbus_testutils, libdbus_daemon_internal, ],
+ 'install': false,
+ 'suite': ['slow'],
+ },
+ ]
+ endif
+
+ if use_traditional_activation
+ tests += [
+ {
+ 'name': 'bus-normal-activation',
+ 'srcs': [ 'bus/normal-activation.c', 'bus/common.c' ],
+ 'link': [ libdbus_testutils, libdbus_daemon_internal, ],
+ 'install': false,
+ 'suite': ['slow'],
+ 'timeout': 1000,
+ },
+ ]
+ endif
+
+ if platform_unix
+ tests += [
+ {
+ 'name': 'counter',
+ 'srcs': [ 'internals/counter.c' ],
+ 'link': [ libdbus_testutils, ],
+ },
+ ]
+ endif
+
+ if use_traditional_activation and platform_unix
+ tests += [
+ {
+ 'name': 'bus-failed-helper-activation',
+ 'srcs': [ 'bus/failed-helper-activation.c', 'bus/common.c' ],
+ 'link': [ libdbus_testutils, libdbus_daemon_internal, ],
+ 'install': false,
+ },
+ {
+ 'name': 'bus-helper-activation',
+ 'srcs': [ 'bus/helper-activation.c', 'bus/common.c' ],
+ 'link': [ libdbus_testutils, libdbus_daemon_internal, ],
+ 'install': false,
+ 'suite': ['slow'],
+ 'timeout': 1000,
+ },
+ {
+ 'name': 'bus-launch-helper-oom',
+ 'srcs': [ 'bus/launch-helper-oom.c' ],
+ 'link': [ libdbus_testutils, liblaunch_helper_internal, ],
+ 'install': false,
+ },
+ {
+ 'name': 'bus-system',
+ 'srcs': [ 'bus/system.c', ],
+ 'link': [ libdbus_testutils, liblaunch_helper_internal, ],
+ 'install': false,
+ },
+ {
+ 'name': 'spawn-oom',
+ 'srcs': [ 'internals/spawn-oom.c', ],
+ 'link': [ libdbus_testutils, ],
+ 'install': false,
+ }
+ ]
+ endif
+endif
+
+tests += [
+ {
+ 'name': 'test-service',
+ 'srcs': [ 'test-service.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'install': true,
+ 'test': false,
+ },
+ {
+ 'name': 'test-sleep-forever',
+ 'srcs': [ 'test-sleep-forever.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'install': true,
+ 'test': false,
+ }
+]
+
+tests += [
+ {
+ 'name': 'atomic',
+ 'srcs': [ 'internals/atomic.c' ],
+ 'link': [ libdbus_testutils, ],
+ },
+ {
+ 'name': 'hash',
+ 'srcs': [ 'internals/hash.c' ],
+ 'link': [ libdbus_testutils, ],
+ },
+ {
+ 'name': 'misc-internals',
+ 'srcs': [
+ 'internals/address.c',
+ 'internals/dbus-auth-script.c',
+ 'internals/dbus-auth-util.c',
+ 'internals/dbus-credentials-util.c',
+ 'internals/dbus-marshal-byteswap-util.c',
+ 'internals/dbus-marshal-recursive-util.c',
+ 'internals/dbus-marshal-validate-util.c',
+ 'internals/dbus-string-util.c',
+ 'internals/dbus-sysdeps-util.c',
+ 'internals/mempool.c',
+ 'internals/misc-internals.c',
+ 'internals/sha.c',
+ ],
+ 'link': [ libdbus_testutils, ],
+ },
+ {
+ 'name': 'shell',
+ 'srcs': [ 'shell-test.c' ],
+ 'link': [ libdbus_testutils, ],
+ },
+ {
+ 'name': 'strings',
+ 'srcs': [ 'internals/strings.c' ],
+ 'link': [ libdbus_testutils, ],
+ },
+ {
+ 'name': 'printf',
+ 'srcs': [ 'internals/printf.c' ],
+ 'link': [ libdbus_testutils, ],
+ },
+ {
+ 'name': 'manual-backtrace',
+ 'srcs': [ 'manual-backtrace.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'test': false,
+ },
+ {
+ 'name': 'manual-dir-iter',
+ 'srcs': [ 'manual-dir-iter.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'test': false,
+ },
+ {
+ 'name': 'manual-tcp',
+ 'srcs': [ 'manual-tcp.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'test': false,
+ }
+]
+
+if platform_windows
+ tests += [
+ {
+ 'name': 'manual-paths',
+ 'srcs': [ 'manual-paths.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'test': false,
+ }
+ ]
+endif
+
+if use_glib
+ tests += [
+ {
+ 'name': 'assertions',
+ 'srcs': [ 'internals/assertions.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ },
+ {
+ 'name': 'corrupt',
+ 'srcs': [ 'corrupt.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ },
+ {
+ 'name': 'dbus-daemon',
+ 'srcs': [ 'dbus-daemon.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ 'suite': ['runs-dbus-daemon', 'slow'],
+ },
+ {
+ 'name': 'dbus-daemon-eavesdrop',
+ 'srcs': [ 'dbus-daemon-eavesdrop.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ 'suite': ['runs-dbus-daemon'],
+ },
+ {
+ 'name': 'desktop-file',
+ 'srcs': [ 'internals/desktop-file.c' ],
+ 'link': [ libdbus_testutils, libdbus_internal, ],
+ 'deps': [ glib, gio, ],
+ },
+ {
+ 'name': 'fdpass',
+ 'srcs': [ 'fdpass.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ },
+ {
+ 'name': 'header-fields',
+ 'srcs': [ 'header-fields.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ 'suite': ['runs-dbus-daemon', 'slow'],
+ },
+ {
+ 'name': 'message',
+ 'srcs': [ 'message.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ },
+ {
+ 'name': 'monitor',
+ 'srcs': [ 'monitor.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ 'suite': ['runs-dbus-daemon'],
+ 'timeout': 45,
+ },
+ {
+ 'name': 'loopback',
+ 'srcs': [ 'loopback.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ },
+ {
+ 'name': 'marshal',
+ 'srcs': [ 'marshal.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ },
+ {
+ 'name': 'refs',
+ 'srcs': [ 'internals/refs.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ 'suite': ['slow'],
+ },
+ {
+ 'name': 'relay',
+ 'srcs': [ 'relay.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ 'timeout': 60,
+ },
+ {
+ 'name': 'server-oom',
+ 'srcs': [ 'internals/server-oom.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ },
+ {
+ 'name': 'syntax',
+ 'srcs': [ 'syntax.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ },
+ {
+ 'name': 'sysdeps',
+ 'srcs': [ 'internals/sysdeps.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ },
+ {
+ 'name': 'syslog',
+ 'srcs': [ 'internals/syslog.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ },
+ {
+ 'name': 'uid-permissions',
+ 'srcs': [ 'uid-permissions.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ 'suite': ['runs-dbus-daemon'],
+ },
+ {
+ 'name': 'userdb',
+ 'srcs': [ 'internals/userdb.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ },
+ {
+ 'name': 'variant',
+ 'srcs': [ 'internals/variant.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ },
+ {
+ 'name': 'manual-authz',
+ 'srcs': [ 'manual-authz.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ 'test': false,
+ },
+ {
+ 'name': 'manual-test-thread-blocking',
+ 'srcs': [ 'thread-blocking.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ 'test': false,
+ },
+ ]
+
+ if platform_unix
+ tests += [
+ { 'name': 'containers',
+ 'srcs': [ 'containers.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ 'suite': ['runs-dbus-daemon'],
+ },
+ { 'name': 'sd-activation',
+ 'srcs': [ 'sd-activation.c' ],
+ 'link': [ libdbus_testutils, ],
+ 'deps': [ glib, gio, ],
+ 'suite': ['runs-dbus-daemon'],
+ },
+ ]
+
+ endif
+endif
+
+foreach test: tests
+ name = test.get('name')
+ srcs = test.get('srcs')
+ link = test.get('link', [])
+ deps = test.get('deps', [])
+ suites = test.get('suite', ['dbus'])
+ install = test.get('install', true)
+
+ if suites.contains('runs-dbus-daemon') and not (message_bus and tools)
+ continue
+ endif
+
+ if test.get('test', true)
+ exe_name = 'test-' + name
+ else
+ exe_name = name
+ endif
+
+ if 'slow' in suites
+ timeout = 300
+ else
+ timeout = 30
+ endif
+
+ timeout = test.get('timeout', timeout)
+
+ test_exe = executable(exe_name,
+ srcs,
+ link_with: link,
+ dependencies: deps,
+ include_directories: root_include,
+ install: install_tests and install,
+ install_dir: test_exec_dir,
+ )
+
+ # Some binaries are used in tests but are not themselves tests,
+ # and some might be "as-installed" integration tests that aren't
+ # guaranteed to work at build-time
+ if test.get('build_time_test', true) and test.get('test', true)
+ test(name,
+ test_exe,
+ args: ['--tap'],
+ env: test_env,
+ protocol: test_protocol,
+ suite: suites,
+ timeout: timeout,
+ )
+ endif
+
+ if install and test.get('test', true)
+ installed_tests += [{
+ 'name': exe_name,
+ 'exe': exe_name + exe_ext,
+ }]
+ endif
+endforeach
+
+
+###############################################################################
+# Scripts
+
+scripts = []
+
+if message_bus and tools and platform_unix and use_glib
+ scripts += [
+ { 'name': 'test-dbus-daemon-fork.sh', },
+ { 'name': 'transient-services.sh',
+ 'subdir': 'integration',
+ 'build_time_test': false },
+ { 'name': 'test-apparmor-activation.sh',
+ 'build_time_test': false },
+ ]
+
+ # Testing dbus-launch relies on special code in that binary.
+ if embedded_tests
+ scripts += { 'name': 'test-dbus-launch-eval.sh' }
+ endif
+ if embedded_tests and use_x11_autolaunch
+ scripts += { 'name': 'test-dbus-launch-x11.sh' }
+ endif
+endif
+
+foreach script: scripts
+ name = script.get('name')
+ install = script.get('install', true)
+ suites = script.get('suite', ['dbus'])
+ test_subdir = script.get('subdir', '')
+
+ if test_subdir == ''
+ install_dir = test_exec_dir
+ else
+ install_dir = test_exec_dir / test_subdir
+ endif
+
+ if install_tests and install
+ install_data(test_subdir / name,
+ install_mode: 'rwxr-xr-x',
+ install_dir: install_dir,
+ )
+ installed_tests += [{
+ 'name': name,
+ 'subdir': test_subdir,
+ }]
+ endif
+
+ # Some scripts might be used in tests but not themselves tests,
+ # and some are "as-installed" integration tests that aren't
+ # guaranteed to work at build-time
+ if script.get('build_time_test', true) and script.get('test', true)
+ test(name,
+ find_program(script.get('subdir', '.') / name),
+ env: test_env,
+ depends: xdgdir,
+ suite: suites,
+ )
+ endif
+endforeach
+
+
+foreach test_case: installed_tests
+ name = test_case.get('name')
+ exe = test_case.get('exe', name)
+ test_subdir = test_case.get('subdir', '')
+
+ if test_subdir == ''
+ exe = get_option('prefix') / test_exec_dir / exe
+ install_dir = test_meta_dir
+ else
+ exe = get_option('prefix') / test_exec_dir / test_subdir / exe
+ install_dir = test_meta_dir / test_subdir
+ endif
+
+ meta_config = configuration_data()
+ meta_config.set('command',
+ 'env @0@ --tap'.format(exe),
+ )
+ configure_file(
+ input : 'meta_template.test.in',
+ output: name + '.test',
+ configuration: meta_config,
+ install: install_tests,
+ install_dir: install_dir,
+ )
+
+ meta_config = configuration_data()
+ meta_config.set('command',
+ 'env DBUS_TEST_EXEC=@0@ DBUS_TEST_DATA=@0@/data @1@ --tap'.format(
+ get_option('prefix') / test_exec_dir, exe,
+ ))
+ configure_file(
+ input : 'meta_template.test.in',
+ output: name + '_with_config.test',
+ configuration: meta_config,
+ install: install_tests,
+ install_dir: install_dir,
+ )
+
+endforeach
diff --git a/test/message.c b/test/message.c
index 9aee025c..88616b5b 100644
--- a/test/message.c
+++ b/test/message.c
@@ -1,6 +1,7 @@
/* Targeted unit tests for OOM paths in DBusMessage
*
* Copyright © 2017 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -28,9 +29,11 @@
#include <string.h>
#include <glib.h>
+#include <glib/gstdio.h>
#include <dbus/dbus.h>
#include "dbus/dbus-internals.h"
+#include "dbus/dbus-message-internal.h"
#include "dbus/dbus-pipe.h"
#include "test-utils-glib.h"
@@ -178,6 +181,206 @@ out:
return !g_test_failed ();
}
+static void iterate_fully (DBusMessageIter *iter,
+ int n_elements);
+
+/* Iterate over @iter. If n_elements >= 0, then @iter is
+ * expected to yield exactly @n_elements elements. */
+static void
+iterate_fully (DBusMessageIter *iter,
+ int n_elements)
+{
+ int i = 0;
+
+ while (TRUE)
+ {
+ int arg_type = dbus_message_iter_get_arg_type (iter);
+ dbus_bool_t should_have_next;
+ dbus_bool_t had_next;
+
+ if (arg_type == DBUS_TYPE_INVALID)
+ return; /* end of iteration */
+
+ if (dbus_type_is_container (arg_type))
+ {
+ DBusMessageIter sub = DBUS_MESSAGE_ITER_INIT_CLOSED;
+ int n_contained = -1;
+
+ switch (arg_type)
+ {
+ case DBUS_TYPE_ARRAY:
+ /* This is only allowed for arrays */
+ n_contained = dbus_message_iter_get_element_count (iter);
+ g_assert_cmpint (n_contained, >=, 0);
+ break;
+
+ case DBUS_TYPE_VARIANT:
+ n_contained = 1;
+ break;
+
+ case DBUS_TYPE_STRUCT:
+ break;
+
+ case DBUS_TYPE_DICT_ENTRY:
+ n_contained = 2;
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+
+ dbus_message_iter_recurse (iter, &sub);
+ iterate_fully (&sub, n_contained);
+ }
+ else
+ {
+ DBusBasicValue value;
+
+ dbus_message_iter_get_basic (iter, &value);
+
+ if (arg_type == DBUS_TYPE_UNIX_FD && value.fd >= 0)
+ {
+ GError *error = NULL;
+
+ g_close (value.fd, &error);
+ g_assert_no_error (error);
+ }
+ }
+
+ should_have_next = dbus_message_iter_has_next (iter);
+ had_next = dbus_message_iter_next (iter);
+ g_assert_cmpint (had_next, ==, should_have_next);
+ g_assert_cmpint (had_next, ==,
+ (dbus_message_iter_get_arg_type (iter) != DBUS_TYPE_INVALID));
+ i += 1;
+ }
+
+ if (n_elements >= 0)
+ g_assert_cmpuint (n_elements, ==, i);
+}
+
+/* Return TRUE if the right thing happens, but the right thing might include
+ * OOM. */
+static dbus_bool_t
+test_valid_message_blobs (void *message_name,
+ dbus_bool_t have_memory)
+{
+ gchar *path = NULL;
+ gchar *contents = NULL;
+ gsize len = 0;
+ DBusMessage *m = NULL;
+ DBusMessageIter iter = DBUS_MESSAGE_ITER_INIT_CLOSED;
+ GError *error = NULL;
+ DBusError e = DBUS_ERROR_INIT;
+ dbus_bool_t ok = TRUE;
+ gchar *filename = NULL;
+
+ filename = g_strdup_printf ("%s.message-raw", (const char *) message_name);
+ path = g_test_build_filename (G_TEST_DIST, "data", "valid-messages",
+ filename, NULL);
+ g_file_get_contents (path, &contents, &len, &error);
+ g_assert_no_error (error);
+ g_assert_cmpuint (len, <, (gsize) INT_MAX);
+
+ m = dbus_message_demarshal (contents, (int) len, &e);
+
+ if (m == NULL)
+ {
+ if (dbus_error_has_name (&e, DBUS_ERROR_NO_MEMORY) && !have_memory)
+ {
+ g_test_message ("Out of memory (not a problem)");
+ goto out;
+ }
+
+ g_test_message ("Parsing %s reported unexpected error %s: %s",
+ path, e.name, e.message);
+ g_test_fail ();
+ ok = FALSE;
+ goto out;
+ }
+
+ g_test_message ("Successfully parsed %s", path);
+ test_assert_no_error (&e);
+
+ if (dbus_message_iter_init (m, &iter))
+ g_assert_cmpint (dbus_message_iter_get_arg_type (&iter), !=, DBUS_TYPE_INVALID);
+ else
+ g_assert_cmpint (dbus_message_iter_get_arg_type (&iter), ==, DBUS_TYPE_INVALID);
+
+ iterate_fully (&iter, -1);
+
+out:
+ dbus_clear_message (&m);
+ dbus_error_free (&e);
+ g_free (path);
+ g_free (contents);
+ g_free (filename);
+ return ok;
+}
+
+/* Return TRUE if the right thing happens, but the right thing might include
+ * OOM. */
+static dbus_bool_t
+test_invalid_message_blobs (void *message_name,
+ dbus_bool_t have_memory)
+{
+ gchar *path = NULL;
+ gchar *contents = NULL;
+ gsize len = 0;
+ DBusMessage *m = NULL;
+ GError *error = NULL;
+ DBusError e = DBUS_ERROR_INIT;
+ dbus_bool_t ok = TRUE;
+ gchar *filename = NULL;
+
+ filename = g_strdup_printf ("%s.message-raw", (const char *) message_name);
+ path = g_test_build_filename (G_TEST_DIST, "data", "invalid-messages",
+ filename, NULL);
+ g_file_get_contents (path, &contents, &len, &error);
+ g_assert_no_error (error);
+ g_assert_cmpuint (len, <, (gsize) INT_MAX);
+
+ m = dbus_message_demarshal (contents, (int) len, &e);
+
+ if (m != NULL)
+ {
+ g_test_message ("Parsing %s reported that it was valid", path);
+ g_test_fail ();
+ ok = FALSE;
+
+ /* Attempt to reproduce dbus#413 */
+ _dbus_message_remove_unknown_fields (m);
+
+ goto out;
+ }
+
+ if (dbus_error_has_name (&e, DBUS_ERROR_NO_MEMORY) && !have_memory)
+ {
+ g_test_message ("Out of memory (not a problem)");
+ goto out;
+ }
+
+ if (dbus_error_has_name (&e, DBUS_ERROR_INVALID_ARGS))
+ {
+ g_test_message ("Parsing %s reported error as expected: %s: %s",
+ path, e.name, e.message);
+ goto out;
+ }
+
+ g_test_message ("Parsing %s reported unexpected error %s: %s",
+ path, e.name, e.message);
+ g_test_fail ();
+ ok = FALSE;
+
+out:
+ dbus_clear_message (&m);
+ dbus_error_free (&e);
+ g_free (path);
+ g_free (contents);
+ g_free (filename);
+ return ok;
+}
+
/* Similar to test_array(), but making use of
* dbus_message_iter_abandon_container_if_open().
*
@@ -255,12 +458,21 @@ out:
typedef struct
{
- const gchar *name;
+ gchar *name;
DBusTestMemoryFunction function;
const void *data;
} OOMTestCase;
static void
+oom_test_case_free (gpointer data)
+{
+ OOMTestCase *test = data;
+
+ g_free (test->name);
+ g_free (test);
+}
+
+static void
test_oom_wrapper (gconstpointer data)
{
const OOMTestCase *test = data;
@@ -285,18 +497,35 @@ add_oom_test (const gchar *name,
* _dbus_get_malloc_blocks_outstanding() */
OOMTestCase *test_case = g_new0 (OOMTestCase, 1);
- test_case->name = name;
+ test_case->name = g_strdup (name);
test_case->function = function;
test_case->data = data;
g_test_add_data_func (name, test_case, test_oom_wrapper);
g_queue_push_tail (test_cases_to_free, test_case);
}
+static const char *valid_messages[] =
+{
+ "byteswap-fd-index",
+ "minimal",
+};
+
+static const char *invalid_messages[] =
+{
+ "boolean-has-no-value",
+ "fixed-array-not-divisible",
+ "issue418",
+ "mis-nested-sig",
+ "truncated-variant-sig",
+ "zero-length-variant-sig",
+};
+
int
main (int argc,
char **argv)
{
int ret;
+ gsize i;
test_init (&argc, &argv);
@@ -307,9 +536,25 @@ main (int argc,
add_oom_test ("/message/fd", test_fd, NULL);
add_oom_test ("/message/zero-iter", test_zero_iter, NULL);
+ for (i = 0; i < G_N_ELEMENTS (valid_messages); i++)
+ {
+ gchar *path = g_strdup_printf ("/message/valid/%s", valid_messages[i]);
+
+ add_oom_test (path, test_valid_message_blobs, valid_messages[i]);
+ g_free (path);
+ }
+
+ for (i = 0; i < G_N_ELEMENTS (invalid_messages); i++)
+ {
+ gchar *path = g_strdup_printf ("/message/invalid/%s", invalid_messages[i]);
+
+ add_oom_test (path, test_invalid_message_blobs, invalid_messages[i]);
+ g_free (path);
+ }
+
ret = g_test_run ();
- g_queue_free_full (test_cases_to_free, g_free);
+ g_queue_free_full (test_cases_to_free, oom_test_case_free);
dbus_shutdown ();
return ret;
}
diff --git a/test/meta_template.test.in b/test/meta_template.test.in
new file mode 100644
index 00000000..31915278
--- /dev/null
+++ b/test/meta_template.test.in
@@ -0,0 +1,4 @@
+[Test]
+Type=session
+Output=TAP
+Exec=@command@
diff --git a/test/mkdir-m700.py b/test/mkdir-m700.py
new file mode 100755
index 00000000..d8ebddbe
--- /dev/null
+++ b/test/mkdir-m700.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python3
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+
+import os
+import sys
+
+# Note that we can't create the XDG_RUNTIME_DIR with permissions 0700
+# on MSYS2, which rejects attempts to change permissions, hence "|| true".
+os.makedirs(sys.argv[1], exist_ok=True)
+
+try:
+ os.chmod(sys.argv[1], 0o700)
+except OSError:
+ pass
diff --git a/test/monitor.c b/test/monitor.c
index eb11eb81..f685221a 100644
--- a/test/monitor.c
+++ b/test/monitor.c
@@ -2,6 +2,7 @@
*
* Copyright © 2010-2011 Nokia Corporation
* Copyright © 2015 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -155,6 +156,21 @@ static Config side_effects_config = {
TRUE
};
+static dbus_bool_t
+config_forbids_name_acquired_signal (const Config *config)
+{
+ if (config == NULL)
+ return FALSE;
+
+ if (config->config_file == NULL)
+ return FALSE;
+
+ if (strcmp (config->config_file, forbidding_config.config_file) == 0)
+ return TRUE;
+
+ return FALSE;
+}
+
static inline const char *
not_null2 (const char *x,
const char *fallback)
@@ -196,6 +212,10 @@ _log_message (DBusMessage *m,
not_null (dbus_message_get_signature (m)));
g_test_message ("\terror name: %s",
not_null (dbus_message_get_error_name (m)));
+ g_test_message ("\tserial number: %u",
+ dbus_message_get_serial (m));
+ g_test_message ("\tin reply to: %u",
+ dbus_message_get_reply_serial (m));
if (strcmp ("s", dbus_message_get_signature (m)) == 0)
{
@@ -249,9 +269,6 @@ do { \
#define assert_name_acquired(m) \
do { \
- DBusError _e = DBUS_ERROR_INIT; \
- const char *_s; \
- \
g_assert_cmpstr (dbus_message_type_to_string (dbus_message_get_type (m)), \
==, dbus_message_type_to_string (DBUS_MESSAGE_TYPE_SIGNAL)); \
g_assert_cmpstr (dbus_message_get_sender (m), ==, DBUS_SERVICE_DBUS); \
@@ -261,7 +278,14 @@ do { \
g_assert_cmpstr (dbus_message_get_signature (m), ==, "s"); \
g_assert_cmpint (dbus_message_get_serial (m), !=, 0); \
g_assert_cmpint (dbus_message_get_reply_serial (m), ==, 0); \
+} while (0)
+
+#define assert_unique_name_acquired(m) \
+do { \
+ DBusError _e = DBUS_ERROR_INIT; \
+ const char *_s; \
\
+ assert_name_acquired (m); \
dbus_message_get_args (m, &_e, \
DBUS_TYPE_STRING, &_s, \
DBUS_TYPE_INVALID); \
@@ -329,6 +353,21 @@ do { \
g_assert_cmpint (dbus_message_get_reply_serial (m), !=, 0); \
} while (0)
+/* forbidding.conf does not allow receiving NameAcquired, so if we are in
+ * that configuration, then dbus-daemon synthesizes an error reply to itself
+ * and sends that to monitors */
+#define expect_name_acquired_error(queue, in_reply_to) \
+do { \
+ DBusMessage *message; \
+ \
+ message = g_queue_pop_head (queue); \
+ assert_error_reply (message, DBUS_SERVICE_DBUS, DBUS_SERVICE_DBUS, \
+ DBUS_ERROR_ACCESS_DENIED); \
+ g_assert_cmpint (dbus_message_get_reply_serial (message), ==, \
+ dbus_message_get_serial (in_reply_to)); \
+ dbus_message_unref (message); \
+} while (0)
+
/* This is called after processing pending replies to our own method
* calls, but before anything else.
*/
@@ -339,6 +378,9 @@ monitor_filter (DBusConnection *connection,
{
Fixture *f = user_data;
+ g_test_message ("Monitor received message:");
+ log_message (message);
+
g_assert_cmpstr (dbus_message_get_interface (message), !=,
"com.example.Tedious");
@@ -505,7 +547,7 @@ become_monitor (Fixture *f,
int i;
dbus_uint32_t zero = 0;
- dbus_connection_set_route_peer_messages (f->monitor, TRUE);
+ dbus_connection_set_builtin_filters_enabled (f->monitor, FALSE);
if (config == NULL)
config = f->config;
@@ -720,6 +762,11 @@ test_become_monitor (Fixture *f,
test_assert_no_error (&f->e);
g_assert_cmpint (ret, ==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
+ /* If the policy forbids receiving NameAcquired, then we'll never
+ * receive it, so behave as though we had */
+ if (config_forbids_name_acquired_signal (f->config))
+ got_unique = got_a = got_b = got_c = TRUE;
+
while (!got_unique || !got_a || !got_b || !got_c)
{
if (g_queue_is_empty (&f->monitored))
@@ -1371,6 +1418,7 @@ test_dbus_daemon (Fixture *f,
{
DBusMessage *m;
int res;
+ size_t n_expected;
if (f->address == NULL)
return;
@@ -1386,7 +1434,12 @@ test_dbus_daemon (Fixture *f,
test_assert_no_error (&f->e);
g_assert_cmpint (res, ==, DBUS_RELEASE_NAME_REPLY_RELEASED);
- while (g_queue_get_length (&f->monitored) < 8)
+ n_expected = 8;
+
+ if (config_forbids_name_acquired_signal (context))
+ n_expected += 1;
+
+ while (g_queue_get_length (&f->monitored) < n_expected)
test_main_context_iterate (f->ctx, TRUE);
m = g_queue_pop_head (&f->monitored);
@@ -1399,10 +1452,12 @@ test_dbus_daemon (Fixture *f,
"NameOwnerChanged", "sss", NULL);
dbus_message_unref (m);
- /* FIXME: should we get this? */
m = g_queue_pop_head (&f->monitored);
- assert_signal (m, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS,
- "NameAcquired", "s", f->sender_name);
+ assert_name_acquired (m);
+
+ if (config_forbids_name_acquired_signal (f->config))
+ expect_name_acquired_error (&f->monitored, m);
+
dbus_message_unref (m);
m = g_queue_pop_head (&f->monitored);
@@ -1624,8 +1679,14 @@ static void
expect_new_connection (Fixture *f)
{
DBusMessage *m;
+ size_t n_expected;
- while (g_queue_get_length (&f->monitored) < 4)
+ n_expected = 4;
+
+ if (config_forbids_name_acquired_signal (f->config))
+ n_expected += 1;
+
+ while (g_queue_get_length (&f->monitored) < n_expected)
test_main_context_iterate (f->ctx, TRUE);
m = g_queue_pop_head (&f->monitored);
@@ -1642,7 +1703,11 @@ expect_new_connection (Fixture *f)
dbus_message_unref (m);
m = g_queue_pop_head (&f->monitored);
- assert_name_acquired (m);
+ assert_unique_name_acquired (m);
+
+ if (config_forbids_name_acquired_signal (f->config))
+ expect_name_acquired_error (&f->monitored, m);
+
dbus_message_unref (m);
}
@@ -1981,6 +2046,8 @@ main (int argc,
setup, test_method_call, teardown);
g_test_add ("/monitor/forbidden-method", Fixture, &forbidding_config,
setup, test_forbidden_method_call, teardown);
+ g_test_add ("/monitor/forbidden-reply", Fixture, &forbidding_config,
+ setup, test_dbus_daemon, teardown);
g_test_add ("/monitor/dbus-daemon", Fixture, NULL,
setup, test_dbus_daemon, teardown);
g_test_add ("/monitor/selective", Fixture, &selective_config,
diff --git a/test/name-test/CMakeLists.txt b/test/name-test/CMakeLists.txt
index e7c62587..098993ae 100644
--- a/test/name-test/CMakeLists.txt
+++ b/test/name-test/CMakeLists.txt
@@ -1,6 +1,10 @@
add_definitions(${DBUS_INTERNAL_CLIENT_DEFINITIONS})
-add_helper_executable(test-autolaunch test-autolaunch.c dbus-testutils)
+if(WIN32)
+ add_test_executable(test-autolaunch-win test-autolaunch-win.c ${DBUS_INTERNAL_LIBRARIES} dbus-testutils)
+else()
+ add_helper_executable(test-autolaunch test-autolaunch.c dbus-testutils)
+endif()
add_session_test_executable(test-ids test-ids.c ${DBUS_INTERNAL_LIBRARIES})
add_session_test_executable(test-pending-call-disconnected test-pending-call-disconnected.c ${DBUS_INTERNAL_LIBRARIES})
@@ -10,7 +14,7 @@ if(ENABLE_TRADITIONAL_ACTIVATION)
add_session_test_executable(test-pending-call-timeout test-pending-call-timeout.c ${DBUS_INTERNAL_LIBRARIES})
endif()
add_session_test_executable(test-shutdown test-shutdown.c dbus-testutils)
-if (ENABLE_TRADITIONAL_ACTIVATION)
+if(ENABLE_TRADITIONAL_ACTIVATION)
add_session_test_executable(test-privserver-client test-privserver-client.c dbus-testutils)
add_session_test_executable(test-thread-init test-threads-init.c ${DBUS_INTERNAL_LIBRARIES})
endif()
diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am
deleted file mode 100644
index 81938778..00000000
--- a/test/name-test/Makefile.am
+++ /dev/null
@@ -1,111 +0,0 @@
-AM_CPPFLAGS = \
- -I$(top_srcdir) \
- $(CODE_COVERAGE_CPPFLAGS) \
- $(DBUS_STATIC_BUILD_CPPFLAGS) \
- $(VALGRIND_CFLAGS) \
- -DDBUS_COMPILATION \
- $(NULL)
-
-AM_CFLAGS = \
- $(CODE_COVERAGE_CFLAGS) \
- $(SANITIZE_CFLAGS) \
- $(NULL)
-
-# if assertions are enabled, improve backtraces
-AM_LDFLAGS = @R_DYNAMIC_LDFLAG@
-
-TEST_EXTENSIONS = .sh
-
-LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/build-aux/tap-driver.sh
-SH_LOG_DRIVER = $(LOG_DRIVER)
-
-LOG_COMPILER = \
- @abs_top_builddir@/tools/dbus-run-session$(EXEEXT) \
- --config-file=@abs_top_builddir@/test/data/valid-config-files/tmp-session.conf \
- --dbus-daemon=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT) \
- -- \
- $(NULL)
-SH_LOG_COMPILER = $(SHELL)
-
-## note that TESTS has special meaning (stuff to use in make check)
-## so if adding tests not to be run in make check, don't add them to
-## TESTS
-TESTS =
-
-if DBUS_ENABLE_EMBEDDED_TESTS
-if DBUS_UNIX
-AM_TESTS_ENVIRONMENT = \
- export DBUS_SESSION_BUS_ADDRESS=do-not-use-real-session:; \
- export DBUS_TOP_BUILDDIR=@abs_top_builddir@; \
- export DBUS_TOP_SRCDIR=@abs_top_srcdir@; \
- export PATH="@abs_top_builddir@/bus:$$PATH"; \
- export DBUS_TEST_DATA=@abs_top_builddir@/test/data; \
- export DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT); \
- export DBUS_TEST_DBUS_LAUNCH=@abs_top_builddir@/tools/dbus-launch$(EXEEXT); \
- export XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR; \
- unset DBUS_SESSION_BUS_ADDRESS; \
- unset DBUS_SESSION_BUS_PID; \
- $(NULL)
-
-TESTS += \
- run-test.sh \
- run-test-systemserver.sh \
- test-ids \
- test-pending-call-disconnected \
- test-shutdown \
- $(NULL)
-
-if ENABLE_TRADITIONAL_ACTIVATION
-TESTS += \
- test-pending-call-dispatch \
- test-pending-call-timeout \
- test-privserver-client \
- test-threads-init \
- $(NULL)
-endif
-endif
-endif
-
-EXTRA_DIST=run-test.sh run-test-systemserver.sh
-
-if DBUS_ENABLE_EMBEDDED_TESTS
-
-## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we
-## build even when not doing "make check"
-noinst_PROGRAMS=test-pending-call-dispatch test-pending-call-timeout test-pending-call-disconnected test-threads-init test-ids test-shutdown test-privserver-client test-autolaunch
-
-test_pending_call_dispatch_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- $(top_builddir)/dbus/libdbus-1.la \
- $(NULL)
-test_pending_call_timeout_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- $(top_builddir)/dbus/libdbus-1.la \
- $(NULL)
-test_pending_call_disconnected_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- $(top_builddir)/dbus/libdbus-1.la \
- $(NULL)
-test_threads_init_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- $(top_builddir)/dbus/libdbus-1.la \
- $(NULL)
-test_ids_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- $(top_builddir)/dbus/libdbus-1.la \
- $(NULL)
-
-test_shutdown_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- ../libdbus-testutils.la \
- $(NULL)
-test_privserver_client_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- ../libdbus-testutils.la \
- $(NULL)
-test_autolaunch_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- ../libdbus-testutils.la \
- $(NULL)
-
-endif
diff --git a/test/name-test/meson.build b/test/name-test/meson.build
new file mode 100644
index 00000000..969636ad
--- /dev/null
+++ b/test/name-test/meson.build
@@ -0,0 +1,103 @@
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+
+if embedded_tests
+
+ tests = [
+ 'test-ids',
+ 'test-pending-call-disconnected',
+ 'test-shutdown',
+ ]
+
+ if platform_windows
+ tests += ['test-autolaunch-win']
+ else
+ tests += ['test-autolaunch']
+ endif
+
+ if use_traditional_activation
+ tests += [
+ 'test-pending-call-dispatch',
+ 'test-pending-call-timeout',
+ 'test-privserver-client',
+ 'test-threads-init',
+ ]
+ endif
+
+ foreach test: tests
+ test_exe = executable(test,
+ test + '.c',
+ include_directories: root_include,
+ link_with: [
+ libdbus,
+ libdbus_internal,
+ libdbus_testutils,
+ ],
+ dependencies: dbus_dependencies,
+ )
+
+ if test == 'test-autolaunch'
+ # This one is run from run-test.sh, not directly
+ continue
+ endif
+
+ if test == 'test-pending-call-timeout'
+ timeout = 75
+ suites = ['name-test', 'slow']
+ else
+ timeout = 30
+ suites = ['name-test']
+ endif
+
+ test(test,
+ dbus_run_session,
+ args: [
+ '--config-file=@0@'.format(
+ meson.project_build_root()/'test/data/valid-config-files/tmp-session.conf'),
+ '--dbus-daemon=@0@'.format(dbus_daemon.full_path()),
+ '--',
+ test_exe,
+ ],
+ env: test_env,
+ protocol: test_protocol,
+ suite: suites,
+ timeout: timeout,
+ )
+ endforeach
+
+
+ if platform_unix
+ test('run-test',
+ find_program('run-test.sh'),
+ env: test_env,
+ protocol: test_protocol,
+ suite: 'name-test',
+ )
+
+ test('run-test-systemserver',
+ find_program('run-test-systemserver.sh'),
+ env: test_env,
+ protocol: test_protocol,
+ suite: 'name-test',
+ )
+ endif
+endif
diff --git a/test/name-test/run-test-systemserver.sh b/test/name-test/run-test-systemserver.sh
index d8515a8c..c114322c 100755
--- a/test/name-test/run-test-systemserver.sh
+++ b/test/name-test/run-test-systemserver.sh
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/bin/sh
SCRIPTNAME=$0
MODE=$1
@@ -14,7 +14,7 @@ if test -z "$DBUS_TEST_NAME_IN_SYS_RUN_TEST"; then
DBUS_TEST_NAME_IN_SYS_RUN_TEST=1
export DBUS_TEST_NAME_IN_SYS_RUN_TEST
exec $DBUS_TOP_SRCDIR/tools/run-with-tmp-session-bus.sh $SCRIPTNAME $MODE
-fi
+fi
if test -n "$DBUS_TEST_MONITOR"; then
dbus-monitor --session >&2 &
@@ -52,7 +52,12 @@ dbus_send_test () {
shift 3
e=0
echo "# running test $t"
- "${DBUS_TOP_BUILDDIR}/libtool" --mode=execute $DEBUG "$DBUS_TOP_BUILDDIR/tools/dbus-send" "$@" > output.tmp 2>&1 || e=$?
+ if [ -f "${DBUS_TOP_BUILDDIR}/libtool" ]; then
+ "${DBUS_TOP_BUILDDIR}/libtool" --mode=execute $DEBUG "$DBUS_TOP_BUILDDIR/tools/dbus-send" "$@" > output.tmp 2>&1 || e=$?
+ else
+ "$DBUS_TOP_BUILDDIR/tools/dbus-send" "$@" > output.tmp 2>&1 || e=$?
+ fi
+
if [ $e != $expected_exit ]; then
sed -e 's/^/# /' < output.tmp
interpret_result "1" "$t" "$@" "(expected exit status $expected_exit, got $e)"
diff --git a/test/name-test/run-test.sh b/test/name-test/run-test.sh
index 9c6a55cc..a96db46a 100755
--- a/test/name-test/run-test.sh
+++ b/test/name-test/run-test.sh
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/bin/sh
SCRIPTNAME=$0
MODE=$1
@@ -12,7 +12,7 @@ if test -z "$DBUS_TEST_NAME_IN_RUN_TEST"; then
DBUS_TEST_NAME_IN_RUN_TEST=1
export DBUS_TEST_NAME_IN_RUN_TEST
exec $DBUS_TOP_SRCDIR/tools/run-with-tmp-session-bus.sh $SCRIPTNAME $MODE
-fi
+fi
if test -n "$DBUS_TEST_MONITOR"; then
dbus-monitor --session >&2 &
@@ -48,7 +48,11 @@ c_test () {
shift
e=0
echo "# running test $t"
- "${DBUS_TOP_BUILDDIR}/libtool" --mode=execute $DEBUG "$DBUS_TOP_BUILDDIR/test/name-test/$t" "$@" >&2 || e=$?
+ if [ -f "${DBUS_TOP_BUILDDIR}/libtool" ]; then
+ "${DBUS_TOP_BUILDDIR}/libtool" --mode=execute $DEBUG "$DBUS_TOP_BUILDDIR/test/name-test/$t" "$@" >&2 || e=$?
+ else
+ "$DBUS_TOP_BUILDDIR/test/name-test/$t" "$@" >&2 || e=$?
+ fi
echo "# exit status $e"
interpret_result "$e" "$t" "$@"
}
diff --git a/test/name-test/test-autolaunch-win.c b/test/name-test/test-autolaunch-win.c
new file mode 100644
index 00000000..b2a7e9c7
--- /dev/null
+++ b/test/name-test/test-autolaunch-win.c
@@ -0,0 +1,343 @@
+/*
+ * Copyright © 2018-2022 Ralf Habacker <ralf.habacker@freenet.de>
+ * SPDX-License-Identifier: MIT
+ */
+
+/**
+ * This test checks whether a client can connect to a dbus daemon configured
+ * for a default, user-defined and installation path related autostart and
+ * whether it can connect to a server having a different autolaunch
+ * configuration.
+ */
+
+#include "config.h"
+
+#include "dbus/dbus-file.h"
+#include "dbus/dbus-internals.h"
+#include "dbus/dbus-sysdeps.h"
+#include "dbus/dbus-test-tap.h"
+#include "dbus/dbus-test.h"
+#include "dbus/dbus.h"
+#include "test/test-utils.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+/* dbus_bus_get does not work yet */
+static dbus_bool_t use_bus_get = FALSE;
+
+static int add_wait_time = 0;
+
+#define oom() _dbus_test_fatal ("Out of memory")
+
+static dbus_bool_t
+call_method (DBusConnection *conn,
+ DBusError *error,
+ int timeout,
+ const char *interface,
+ const char *method_str)
+{
+ DBusMessage *method;
+ DBusMessage *reply;
+ dbus_bool_t result = TRUE;
+
+ dbus_error_init (error);
+
+ method = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ interface,
+ method_str);
+
+ reply = dbus_connection_send_with_reply_and_block (conn, method, timeout, error);
+ dbus_message_unref (method);
+ if (reply == NULL)
+ {
+ result = FALSE;
+ goto out;
+ }
+
+ /* ..._send_with_reply_and_block converts ERROR messages into errors */
+ _dbus_assert (dbus_message_get_type (reply) != DBUS_MESSAGE_TYPE_ERROR);
+ dbus_message_unref (reply);
+ result = TRUE;
+
+out:
+ _DBUS_ASSERT_ERROR_XOR_BOOL (error, result);
+ return result;
+}
+
+static dbus_bool_t
+_server_check_connection (DBusConnection *conn,
+ DBusError *error)
+{
+ if (use_bus_get)
+ return call_method (conn, error, -1, DBUS_INTERFACE_PEER, "GetMachineId");
+ else
+ return call_method (conn, error, -1, DBUS_INTERFACE_DBUS, "Hello");
+}
+
+static HANDLE autolaunch_handle = NULL;
+
+static dbus_bool_t
+_server_shutdown (DBusConnection *conn,
+ const char *scope,
+ int timeout,
+ DBusError *error)
+{
+ _dbus_assert (autolaunch_handle != NULL);
+
+ _dbus_test_diag ("Shutting down dbus-daemon (handle=%p)", autolaunch_handle);
+ if (!TerminateProcess (autolaunch_handle, 1))
+ _dbus_test_fatal ("Unable to terminate dbus-daemon (handle=%p) : %s",
+ /* this string is leaked, but we're crashing anyway */
+ autolaunch_handle, _dbus_win_error_string (GetLastError ()));
+
+ _dbus_test_diag ("Return value from closing autolaunch_handle is %d", CloseHandle (autolaunch_handle));
+ autolaunch_handle = NULL;
+ _dbus_test_win_set_autolaunch_handle_location (NULL);
+ return TRUE;
+}
+
+typedef enum
+{
+ RUN_TEST_DEFAULT = 0,
+ RUN_TEST_EXPECT_CONNECTION_TO_FAIL = (1 << 0),
+} RunTestFlags;
+
+static dbus_bool_t
+check_results (DBusConnection *conn,
+ DBusString *server_address,
+ DBusString *address,
+ const char *scope,
+ RunTestFlags flags,
+ DBusError *error)
+{
+ if (add_wait_time)
+ _dbus_sleep_milliseconds (add_wait_time);
+
+ if (dbus_error_is_set (error))
+ _dbus_test_diag ("Error is set: %s %s", error->name, error->message);
+
+ if (conn == NULL)
+ {
+ if (!dbus_error_is_set (error))
+ _dbus_test_fatal ("Failed to autolaunch session bus and no error was set");
+
+ if (flags & RUN_TEST_EXPECT_CONNECTION_TO_FAIL)
+ return TRUE;
+
+ _dbus_test_diag ("autolaunch unexpectedly failed: %s: %s", error->name, error->message);
+ return FALSE;
+ }
+ else
+ {
+ if (dbus_error_is_set (error))
+ _dbus_test_fatal ("Successfully autolaunched session bus but error was set: %s: %s", error->name, error->message);
+
+ if (flags & RUN_TEST_EXPECT_CONNECTION_TO_FAIL)
+ {
+ _dbus_test_diag ("autolaunch unexpectedly succeeded");
+ return FALSE;
+ }
+ _dbus_test_diag ("Client connection succeeded - uses '%s'", _dbus_string_get_const_data (address));
+ }
+
+ if (add_wait_time)
+ _dbus_sleep_milliseconds (add_wait_time);
+
+ _dbus_test_diag ("Server returned bus address '%s'", _dbus_string_get_const_data (server_address));
+ if (!_server_check_connection (conn, error))
+ {
+ _dbus_test_diag ("Could not execute server function");
+ return FALSE;
+ }
+ else
+ _dbus_test_diag ("Calling server function succeeded");
+
+ return TRUE;
+}
+
+static dbus_bool_t
+run_test (const char *server_scope, const char *scope, const char *test_data_dir, RunTestFlags flags)
+{
+ DBusConnection *conn = NULL;
+ DBusError error;
+ DBusString server_address = _DBUS_STRING_INIT_INVALID;
+ DBusString address = _DBUS_STRING_INIT_INVALID;
+ DBusString session_parameter = _DBUS_STRING_INIT_INVALID;
+ dbus_bool_t result = FALSE;
+ TestMainContext *ctx;
+ _dbus_assert (test_data_dir);
+
+ ctx = test_main_context_get ();
+
+ dbus_error_init (&error);
+
+ if (!_dbus_string_init (&server_address))
+ oom ();
+
+ if (!_dbus_string_init (&address))
+ oom ();
+
+ _dbus_test_diag ("run test");
+
+ if (*server_scope != '\0')
+ {
+ if (!_dbus_string_append_printf (&server_address, "autolaunch:scope=%s", server_scope))
+ oom ();
+ }
+ else if (!_dbus_string_append_printf (&server_address, "autolaunch:"))
+ {
+ oom ();
+ }
+
+ if (*scope != '\0')
+ {
+ if (!_dbus_string_append_printf (&address, "autolaunch:scope=%s", scope))
+ oom ();
+ }
+ else if (!_dbus_string_append_printf (&address, "autolaunch:"))
+ {
+ oom ();
+ }
+
+ if (!_dbus_string_init (&session_parameter))
+ oom ();
+
+ /* We haven't implemented any form of escaping quotes,
+ * but Windows doesn't allow filenames to contain quotes
+ * so it shouldn't matter. */
+ _dbus_test_check (strchr (test_data_dir, '"') == NULL);
+
+ _dbus_test_check (strchr (_dbus_string_get_const_data (&server_address), '"') == NULL);
+
+ if (!_dbus_string_append_printf (&session_parameter, "\"--config-file=%s/%s\" \"--address=%s\"", test_data_dir, "valid-config-files/listen-autolaunch-win.conf", _dbus_string_get_const_data (&server_address)))
+ {
+ oom ();
+ }
+
+ _dbus_test_win_autolaunch_set_command_line_parameter (_dbus_string_get_const_data (&session_parameter));
+
+ _dbus_test_diag ("Autolaunch handle initially %p", autolaunch_handle);
+ _dbus_test_win_set_autolaunch_handle_location (&autolaunch_handle);
+
+ if (use_bus_get)
+ {
+ dbus_setenv ("DBUS_SESSION_BUS_ADDRESS", _dbus_string_get_const_data (&address));
+ _dbus_test_diag ("got env %s", getenv ("DBUS_SESSION_BUS_ADDRESS"));
+ conn = dbus_bus_get_private (DBUS_BUS_SESSION, &error);
+ dbus_connection_set_exit_on_disconnect (conn, FALSE);
+ }
+ else
+ {
+ conn = dbus_connection_open_private (_dbus_string_get_const_data (&address), &error);
+ }
+
+ _dbus_test_diag ("After attempting to connect: autolaunch handle is %p", autolaunch_handle);
+ if (conn)
+ test_connection_setup (ctx, conn);
+
+ result = check_results (conn, &server_address, &address, scope, flags, &error);
+
+ if (conn)
+ {
+ _dbus_test_diag("Shutdown connection '%p'", conn);
+ test_connection_shutdown (ctx, conn);
+ dbus_connection_close (conn);
+ dbus_connection_unref (conn);
+ }
+
+ _server_shutdown (conn, scope, -1, &error);
+ _dbus_test_diag ("server has been shut down");
+
+ _dbus_string_free (&address);
+ _dbus_string_free (&server_address);
+ _dbus_string_free (&session_parameter);
+
+ test_main_context_unref (ctx);
+
+ return result;
+}
+
+static dbus_bool_t
+run_test_okay (const char *scope, const char *test_data_dir)
+{
+ return run_test (scope, scope, test_data_dir, RUN_TEST_DEFAULT);
+}
+
+static dbus_bool_t
+_dbus_autolaunch_default_test (const char *test_data_dir)
+{
+ return run_test_okay ("", test_data_dir);
+}
+
+static dbus_bool_t
+_dbus_autolaunch_custom_scope_test (const char *test_data_dir)
+{
+ return run_test_okay ("123", test_data_dir);
+}
+
+static dbus_bool_t
+_dbus_autolaunch_install_path_scope_test (const char *test_data_dir)
+{
+ return run_test_okay ("*install-path", test_data_dir);
+}
+
+static dbus_bool_t
+_dbus_autolaunch_user_scope_test (const char *test_data_dir)
+{
+ return run_test_okay ("*user", test_data_dir);
+}
+
+static dbus_bool_t
+_dbus_autolaunch_loop_test (const char *test_data_dir, dbus_bool_t same_scope)
+{
+ int i;
+ int max = 10;
+
+ for (i = 0; i < max; i++)
+ {
+ char s[2] = { i+'A', 0 };
+ if (!run_test_okay (same_scope ? "A" : s, test_data_dir))
+ _dbus_test_not_ok ("%d", max);
+ else
+ _dbus_test_ok ("%d", max);
+ if (add_wait_time)
+ _dbus_sleep_milliseconds (add_wait_time);
+ }
+ return TRUE;
+}
+
+static dbus_bool_t
+_dbus_autolaunch_same_scope_loop_test (const char *test_data_dir)
+{
+ return _dbus_autolaunch_loop_test (test_data_dir, TRUE);
+}
+
+static dbus_bool_t
+_dbus_autolaunch_different_scope_loop_test (const char *test_data_dir)
+{
+ return _dbus_autolaunch_loop_test (test_data_dir, FALSE);
+}
+
+static DBusTestCase tests[] = {
+ { "default", _dbus_autolaunch_default_test },
+ { "custom", _dbus_autolaunch_custom_scope_test },
+ { "install-path", _dbus_autolaunch_install_path_scope_test },
+ { "user", _dbus_autolaunch_user_scope_test },
+ { "loop", _dbus_autolaunch_same_scope_loop_test },
+ { "different-scope-loop", _dbus_autolaunch_different_scope_loop_test },
+};
+
+int
+main (int argc,
+ char **argv)
+{
+ return _dbus_test_main (argc, argv, _DBUS_N_ELEMENTS (tests), tests,
+ DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS,
+ NULL, NULL);
+}
diff --git a/test/name-test/test-autolaunch.c b/test/name-test/test-autolaunch.c
index 61760555..202e5043 100644
--- a/test/name-test/test-autolaunch.c
+++ b/test/name-test/test-autolaunch.c
@@ -1,3 +1,9 @@
+/*
+ * Copyright 2008 Red Hat, Inc.
+ * Copyright 2011-2017 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ */
+
#include "config.h"
#include <stdio.h>
diff --git a/test/name-test/test-ids.c b/test/name-test/test-ids.c
index 37c76835..48b0b3c1 100644
--- a/test/name-test/test-ids.c
+++ b/test/name-test/test-ids.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright 2007 Red Hat, Inc.
+ * Copyright 2016-2018 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ */
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/test/name-test/test-pending-call-disconnected.c b/test/name-test/test-pending-call-disconnected.c
index 6ef04b6b..0123cc6a 100644
--- a/test/name-test/test-pending-call-disconnected.c
+++ b/test/name-test/test-pending-call-disconnected.c
@@ -1,6 +1,7 @@
/*
* Copyright © 2006 Red Hat Inc.
* Copyright © 2017 Shin-ichi MORITA <shin1morita@gmail.com>
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/test/name-test/test-pending-call-dispatch.c b/test/name-test/test-pending-call-dispatch.c
index e30d1f74..fbc437b7 100644
--- a/test/name-test/test-pending-call-dispatch.c
+++ b/test/name-test/test-pending-call-dispatch.c
@@ -1,5 +1,6 @@
/*
* Copyright © 2006 Red Hat Inc.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -105,8 +106,10 @@ _run_iteration (DBusConnection *conn)
int
main (int argc, char *argv[])
{
- long start_tv_sec, start_tv_usec;
- long end_tv_sec, end_tv_usec;
+ dbus_int64_t start_tv_sec;
+ long start_tv_usec;
+ dbus_int64_t end_tv_sec;
+ long end_tv_usec;
int i;
DBusMessage *method;
DBusConnection *conn;
@@ -132,7 +135,7 @@ main (int argc, char *argv[])
/* run 100 times to make sure */
for (i = 0; i < 100; i++)
{
- long delta;
+ dbus_int64_t delta;
_dbus_get_monotonic_time (&start_tv_sec, &start_tv_usec);
_run_iteration (conn);
@@ -140,7 +143,7 @@ main (int argc, char *argv[])
/* we just care about seconds */
delta = end_tv_sec - start_tv_sec;
- printf ("ok %d - %lis\n", i + 1, delta);
+ printf ("ok %d - %" DBUS_INT64_MODIFIER "is\n", i + 1, delta);
if (delta >= 5)
{
printf ("Bail out! Looks like we might have been be stuck in poll ***\n");
diff --git a/test/name-test/test-pending-call-timeout.c b/test/name-test/test-pending-call-timeout.c
index c47ba3f2..a91b37ae 100644
--- a/test/name-test/test-pending-call-timeout.c
+++ b/test/name-test/test-pending-call-timeout.c
@@ -71,8 +71,10 @@ _run_iteration (DBusConnection *conn)
int
main (int argc, char *argv[])
{
- long start_tv_sec, start_tv_usec;
- long end_tv_sec, end_tv_usec;
+ dbus_int64_t start_tv_sec;
+ long start_tv_usec;
+ dbus_int64_t end_tv_sec;
+ long end_tv_usec;
int i;
DBusMessage *method;
DBusConnection *conn;
@@ -93,7 +95,7 @@ main (int argc, char *argv[])
/* run 100 times to make sure */
for (i = 0; i < 100; i++)
{
- long delta;
+ dbus_int64_t delta;
_dbus_get_monotonic_time (&start_tv_sec, &start_tv_usec);
_run_iteration (conn);
@@ -101,7 +103,7 @@ main (int argc, char *argv[])
/* we just care about seconds */
delta = end_tv_sec - start_tv_sec;
- printf ("ok %d - %lis\n", i + 1, delta);
+ printf ("ok %d - %" DBUS_INT64_MODIFIER "is\n", i + 1, delta);
}
method = dbus_message_new_method_call ("org.freedesktop.TestSuiteEchoService",
diff --git a/test/name-test/test-shutdown.c b/test/name-test/test-shutdown.c
index 26b61008..880cb807 100644
--- a/test/name-test/test-shutdown.c
+++ b/test/name-test/test-shutdown.c
@@ -1,3 +1,9 @@
+/*
+ * Copyright 2008 Red Hat, Inc.
+ * Copyright 2016-2018 Collabora Ltd.
+ * Copyright 2018 Ralf Habacker
+ * SPDX-License-Identifier: MIT
+ */
#include <config.h>
#include <dbus/dbus-valgrind-internal.h>
diff --git a/test/name-test/test-threads-init.c b/test/name-test/test-threads-init.c
index fa90ca72..ca0ea3e8 100644
--- a/test/name-test/test-threads-init.c
+++ b/test/name-test/test-threads-init.c
@@ -1,3 +1,9 @@
+/*
+ * Copyright 2006 Red Hat, Inc.
+ * Copyright 2013-2018 Collabora Ltd.
+ * Copyright 2017 Endless OS Foundation, LLC
+ * SPDX-License-Identifier: MIT
+ */
/**
* Test to make sure late thread initialization works
*/
diff --git a/test/relay.c b/test/relay.c
index 044260af..484dc9b5 100644
--- a/test/relay.c
+++ b/test/relay.c
@@ -2,6 +2,7 @@
*
* Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Copyright © 2010-2011 Nokia Corporation
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -129,9 +130,10 @@ setup (Fixture *f,
dbus_error_init (&f->e);
g_queue_init (&f->messages);
- if ((g_str_has_prefix (address, "tcp:") ||
- g_str_has_prefix (address, "nonce-tcp:")) &&
- !test_check_tcp_works ())
+ if ((g_str_has_prefix (address, "unix:") && !test_check_af_unix_works ()) ||
+ ((g_str_has_prefix (address, "tcp:") ||
+ g_str_has_prefix (address, "nonce-tcp:")) &&
+ !test_check_tcp_works ()))
{
f->skip = TRUE;
return;
@@ -338,6 +340,12 @@ main (int argc,
char **argv)
{
int ret;
+#ifdef DBUS_UNIX
+ char *tmp = _dbus_strdup ("/tmp");
+#else
+ char *tmp = dbus_address_escape_value (g_get_tmp_dir ());
+#endif
+ gchar *unix_tmpdir = g_strdup_printf ("unix:tmpdir=%s", tmp);
test_init (&argc, &argv);
@@ -348,16 +356,16 @@ main (int argc,
g_test_add ("/limit/tcp", Fixture, "tcp:host=127.0.0.1", setup,
test_limit, teardown);
-#ifdef DBUS_UNIX
- g_test_add ("/connect/unix", Fixture, "unix:tmpdir=/tmp", setup,
+ g_test_add ("/connect/unix", Fixture, unix_tmpdir, setup,
test_connect, teardown);
- g_test_add ("/relay/unix", Fixture, "unix:tmpdir=/tmp", setup,
+ g_test_add ("/relay/unix", Fixture, unix_tmpdir, setup,
test_relay, teardown);
- g_test_add ("/limit/unix", Fixture, "unix:tmpdir=/tmp", setup,
+ g_test_add ("/limit/unix", Fixture, unix_tmpdir, setup,
test_limit, teardown);
-#endif
ret = g_test_run ();
dbus_shutdown ();
+ g_free (unix_tmpdir);
+ dbus_free (tmp);
return ret;
}
diff --git a/test/sd-activation.c b/test/sd-activation.c
index e02e3013..57673af9 100644
--- a/test/sd-activation.c
+++ b/test/sd-activation.c
@@ -5,6 +5,7 @@
*
* Copyright © 2010-2011 Nokia Corporation
* Copyright © 2015 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/test/syntax.c b/test/syntax.c
index 17fcba4e..b62d3e42 100644
--- a/test/syntax.c
+++ b/test/syntax.c
@@ -2,6 +2,7 @@
*
* Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Copyright © 2010-2011 Nokia Corporation
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -155,12 +156,22 @@ const char * const invalid_bus_names[] = {
const char * const valid_signatures[] = {
"",
"a{sv}",
+ "a{s(i)}",
+ "a(sa{ii})",
NULL
};
const char * const invalid_signatures[] = {
"a",
"a{s_}",
+ "a{s(i}",
+ "a{s(i})",
+ "a{s(i)",
+ "a{s(i})",
+ "a(sa{ii)",
+ "a(sa{ii)}",
+ ")",
+ "}",
NULL
};
diff --git a/test/test-apparmor-activation.sh b/test/test-apparmor-activation.sh
index ffc12534..86335a51 100644
--- a/test/test-apparmor-activation.sh
+++ b/test/test-apparmor-activation.sh
@@ -1,6 +1,7 @@
#!/bin/sh
# Copyright © 2016 Collabora Ltd.
+# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
diff --git a/test/test-dbus-daemon-fork.sh b/test/test-dbus-daemon-fork.sh
index 1a7175de..5c05e2ba 100755
--- a/test/test-dbus-daemon-fork.sh
+++ b/test/test-dbus-daemon-fork.sh
@@ -1,6 +1,7 @@
#!/bin/sh
# Copyright © 2016 Collabora Ltd.
+# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
diff --git a/test/test-dbus-launch-eval.sh b/test/test-dbus-launch-eval.sh
index cd960650..c338cd45 100755
--- a/test/test-dbus-launch-eval.sh
+++ b/test/test-dbus-launch-eval.sh
@@ -1,6 +1,7 @@
#!/bin/sh
# Copyright © 2016 Collabora Ltd.
+# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
diff --git a/test/test-dbus-launch-x11.sh b/test/test-dbus-launch-x11.sh
index 48c2718c..e57831e0 100755
--- a/test/test-dbus-launch-x11.sh
+++ b/test/test-dbus-launch-x11.sh
@@ -1,6 +1,7 @@
#!/bin/sh
# Copyright © 2016 Collabora Ltd.
+# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
diff --git a/test/test-exit.c b/test/test-exit.c
index b4f967ae..52de21fd 100644
--- a/test/test-exit.c
+++ b/test/test-exit.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright 2003 Red Hat, Inc.
+ * SPDX-License-Identifier: MIT
+ */
+
#include "config.h"
/* This is a process that just exits with a failure code */
diff --git a/test/test-platform-mutex.c b/test/test-platform-mutex.c
new file mode 100644
index 00000000..af3a8070
--- /dev/null
+++ b/test/test-platform-mutex.c
@@ -0,0 +1,281 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/* test-platform-mutex.c
+ *
+ * Copyright © 2022 Ralf Habacker <ralf.habacker@freenet.de>
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+#include <config.h>
+
+#include "dbus/dbus-internals.h"
+#include "dbus/dbus-spawn.h"
+#include "dbus/dbus-sysdeps.h"
+#include "dbus/dbus-test.h"
+#include "test/test-utils.h"
+
+#define fail_if_mutex_is_null(a) if (a == NULL) _dbus_test_fatal ("Could not create cmutex")
+
+
+static dbus_bool_t
+_dbus_check_cmutex_new (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ DBusCMutex *mutex = NULL;
+ int count;
+
+ count = _dbus_get_check_failed_count ();
+ mutex = _dbus_platform_cmutex_new ();
+ fail_if_mutex_is_null (mutex);
+ _dbus_platform_cmutex_free (mutex);
+ return _dbus_get_check_failed_count () == count;
+}
+
+static dbus_bool_t
+_dbus_check_cmutex_lock (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ DBusCMutex *mutex = NULL;
+ int count;
+
+ count = _dbus_get_check_failed_count ();
+ mutex = _dbus_platform_cmutex_new ();
+ fail_if_mutex_is_null (mutex);
+ _dbus_platform_cmutex_lock (mutex);
+ _dbus_platform_cmutex_unlock (mutex);
+ _dbus_platform_cmutex_free (mutex);
+ return _dbus_get_check_failed_count () == count;
+}
+
+#ifdef DBUS_WIN
+static dbus_bool_t
+_dbus_check_cmutex_lock_null_pointer (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ DBusCMutex *mutex = NULL;
+ int count;
+
+ count = _dbus_get_check_failed_count ();
+ _dbus_platform_cmutex_lock (mutex);
+ return _dbus_get_check_failed_count () - count == 1;
+}
+
+static dbus_bool_t
+_dbus_check_cmutex_double_lock (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ DBusCMutex *mutex = NULL;
+ int count;
+
+ count = _dbus_get_check_failed_count ();
+ mutex = _dbus_platform_cmutex_new ();
+ fail_if_mutex_is_null (mutex);
+ _dbus_platform_cmutex_lock (mutex);
+ _dbus_platform_cmutex_lock (mutex);
+ _dbus_platform_cmutex_unlock (mutex);
+ _dbus_platform_cmutex_unlock (mutex);
+ _dbus_platform_cmutex_free (mutex);
+ return _dbus_get_check_failed_count () == count;
+}
+
+static dbus_bool_t
+_dbus_check_cmutex_unlock_null_pointer (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ DBusCMutex *mutex = NULL;
+ int count;
+
+ count = _dbus_get_check_failed_count ();
+ _dbus_platform_cmutex_unlock (mutex);
+ return _dbus_get_check_failed_count () - count == 1;
+}
+
+static dbus_bool_t
+_dbus_check_cmutex_null_free (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ DBusCMutex *mutex = NULL;
+ int count;
+
+ count = _dbus_get_check_failed_count ();
+ _dbus_platform_cmutex_free (mutex); /* programming error (NULL isn't a mutex) */
+ return _dbus_get_check_failed_count () - count == 1;
+}
+
+static dbus_bool_t
+_dbus_check_cmutex_double_free (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ DBusCMutex *mutex = NULL;
+ int count;
+
+ mutex = _dbus_platform_cmutex_new ();
+ fail_if_mutex_is_null (mutex);
+ count = _dbus_get_check_failed_count ();
+ _dbus_platform_cmutex_free (mutex);
+ if (_dbus_get_check_failed_count () - count > 0)
+ {
+ _dbus_test_not_ok ("free'ing mutex failed");
+ return FALSE;
+ }
+ _dbus_platform_cmutex_free (mutex);
+ return _dbus_get_check_failed_count () - count == 1;
+}
+#else
+/*
+ * #NULL pointers of type DBusCMutex cannot be tested on unix-like
+ * operating systems, because they are pointing to a data structure
+ * and would cause a segment violation when accessed.
+ */
+#endif
+
+static dbus_bool_t
+_dbus_check_rmutex_new (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ DBusRMutex *mutex = NULL;
+ int count;
+
+ count = _dbus_get_check_failed_count ();
+ mutex = _dbus_platform_rmutex_new ();
+ fail_if_mutex_is_null (mutex);
+ _dbus_platform_rmutex_free (mutex);
+ return _dbus_get_check_failed_count () == count;
+}
+
+static dbus_bool_t
+_dbus_check_rmutex_lock (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ DBusRMutex *mutex = NULL;
+ int count;
+
+ count = _dbus_get_check_failed_count ();
+ mutex = _dbus_platform_rmutex_new ();
+ fail_if_mutex_is_null (mutex);
+ _dbus_platform_rmutex_lock (mutex);
+ _dbus_platform_rmutex_unlock (mutex);
+ _dbus_platform_rmutex_free (mutex);
+ return _dbus_get_check_failed_count () == count;
+}
+#ifdef DBUS_WIN
+static dbus_bool_t
+_dbus_check_rmutex_lock_null_pointer (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ DBusRMutex *mutex = NULL;
+ int count;
+
+ count = _dbus_get_check_failed_count ();
+ _dbus_platform_rmutex_lock (mutex);
+ return _dbus_get_check_failed_count () - count == 1;
+}
+#endif
+
+static dbus_bool_t
+_dbus_check_rmutex_double_lock (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ DBusRMutex *mutex = NULL;
+ int count;
+
+ count = _dbus_get_check_failed_count ();
+ mutex = _dbus_platform_rmutex_new ();
+ fail_if_mutex_is_null (mutex);
+ _dbus_platform_rmutex_lock (mutex);
+ _dbus_platform_rmutex_lock (mutex);
+ _dbus_platform_rmutex_unlock (mutex);
+ _dbus_platform_rmutex_unlock (mutex);
+ _dbus_platform_rmutex_free (mutex);
+ return _dbus_get_check_failed_count () == count;
+}
+
+#ifdef DBUS_WIN
+static dbus_bool_t
+_dbus_check_rmutex_unlock_null_pointer (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ DBusRMutex *mutex = NULL;
+ int count;
+
+ count = _dbus_get_check_failed_count ();
+ _dbus_platform_rmutex_unlock (mutex);
+ return _dbus_get_check_failed_count () - count == 1;
+}
+
+static dbus_bool_t
+_dbus_check_rmutex_null_free (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ DBusRMutex *mutex = NULL;
+ int count;
+
+ count = _dbus_get_check_failed_count ();
+ _dbus_platform_rmutex_free (mutex); /* programming error (NULL isn't a mutex) */
+ return _dbus_get_check_failed_count () - count == 1;
+}
+
+static dbus_bool_t
+_dbus_check_rmutex_double_free (const char *test_data_dir _DBUS_GNUC_UNUSED)
+{
+ DBusRMutex *mutex = NULL;
+ int count;
+
+ mutex = _dbus_platform_rmutex_new ();
+ fail_if_mutex_is_null (mutex);
+ count = _dbus_get_check_failed_count ();
+ _dbus_platform_rmutex_free (mutex);
+ if (_dbus_get_check_failed_count () - count > 0)
+ {
+ _dbus_test_not_ok ("free'ing mutex failed");
+ return FALSE;
+ }
+ _dbus_platform_rmutex_free (mutex);
+ return _dbus_get_check_failed_count () - count == 1;
+}
+#else
+/*
+ * #NULL pointers of type DBusRMutex cannot be tested on unix-like
+ * operating systems, because they are pointing to a data structure
+ * and would cause a segment violation when accessed.
+ */
+#endif
+
+static DBusTestCase tests[] =
+{
+ { "cmutex_new", _dbus_check_cmutex_new},
+ { "cmutex_lock", _dbus_check_cmutex_lock},
+#ifdef DBUS_WIN
+ { "cmutex_lock_null_pointer", _dbus_check_cmutex_lock_null_pointer},
+ { "cmutex_double_lock", _dbus_check_cmutex_double_lock},
+ { "cmutex_unlock_null_pointer", _dbus_check_cmutex_unlock_null_pointer},
+ { "cmutex_null_free", _dbus_check_cmutex_null_free},
+ { "cmutex_double_free", _dbus_check_cmutex_double_free},
+#endif
+ { "rmutex_new", _dbus_check_rmutex_new},
+ { "rmutex_lock", _dbus_check_rmutex_lock},
+#ifdef DBUS_WIN
+ { "rmutex_lock_null_pointer", _dbus_check_rmutex_lock_null_pointer},
+#endif
+ { "rmutex_double_lock", _dbus_check_rmutex_double_lock},
+#ifdef DBUS_WIN
+ { "rmutex_unlock_null_pointer", _dbus_check_rmutex_unlock_null_pointer},
+ { "rmutex_null_free", _dbus_check_rmutex_null_free},
+ { "rmutex_double_free", _dbus_check_rmutex_double_free},
+#endif
+};
+
+int
+main (int argc,
+ char **argv)
+{
+ dbus_setenv ("DBUS_FATAL_WARNINGS", "0");
+
+ return _dbus_test_main (argc, argv, _DBUS_N_ELEMENTS (tests), tests,
+ DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS,
+ NULL, NULL);
+}
diff --git a/test/test-privserver.c b/test/test-privserver.c
index 3c512d99..fadc6cbf 100644
--- a/test/test-privserver.c
+++ b/test/test-privserver.c
@@ -3,6 +3,7 @@
* Copyright 2010 Ralf Habacker
* Copyright 2016-2018 Collabora Ltd.
* Copyright 2017 Endless Mobile, Inc.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -51,6 +52,14 @@ struct TestServiceData
};
static void
+test_service_data_free (TestServiceData *self)
+{
+ _dbus_loop_unref (self->loop);
+ dbus_free (self->private_addr);
+ dbus_free (self);
+}
+
+static void
new_connection_callback (DBusServer *server,
DBusConnection *new_connection,
void *data)
@@ -105,7 +114,6 @@ main (int argc, char *argv[])
{
DBusServer *server;
DBusError error;
- DBusLoop *loop;
DBusConnection *session;
TestServiceData *testdata;
@@ -117,16 +125,17 @@ main (int argc, char *argv[])
dbus_error_init (&error);
- loop = _dbus_loop_new ();
-
testdata = dbus_new (TestServiceData, 1);
- testdata->loop = loop;
+ testdata->loop = _dbus_loop_new ();
+
+ if (testdata->loop == NULL)
+ die ("out of memory");
session = dbus_bus_get (DBUS_BUS_SESSION, &error);
if (!session)
die ("couldn't access session bus");
- test_connection_setup (loop, session);
+ test_connection_setup (testdata->loop, session);
dbus_bus_request_name (session, "org.freedesktop.DBus.TestSuite.PrivServer", 0, &error);
if (dbus_error_is_set (&error))
@@ -135,11 +144,7 @@ main (int argc, char *argv[])
if (!dbus_connection_add_filter (session, filter_session_message, testdata, NULL))
die ("couldn't add filter");
-#ifdef DBUS_CMAKE
server = dbus_server_listen (TEST_LISTEN, &error);
-#else
- server = dbus_server_listen ("unix:tmpdir=/tmp", &error);
-#endif
if (!server)
die ("%s", error.message);
testdata->private_addr = dbus_server_get_address (server);
@@ -148,23 +153,21 @@ main (int argc, char *argv[])
dbus_server_set_new_connection_function (server, new_connection_callback,
testdata, NULL);
- test_server_setup (loop, server);
+ test_server_setup (testdata->loop, server);
fprintf (stderr, "server running mainloop\n");
- _dbus_loop_run (loop);
+ _dbus_loop_run (testdata->loop);
fprintf (stderr, "server mainloop quit\n");
- test_server_shutdown (loop, server);
+ test_server_shutdown (testdata->loop, server);
- test_connection_shutdown (loop, session);
+ test_connection_shutdown (testdata->loop, session);
dbus_connection_unref (session);
dbus_server_unref (server);
- _dbus_loop_unref (loop);
-
- dbus_free (testdata);
+ test_service_data_free (testdata);
return 0;
}
diff --git a/test/test-segfault.c b/test/test-segfault.c
index 5c559ccb..ef905c58 100644
--- a/test/test-segfault.c
+++ b/test/test-segfault.c
@@ -10,15 +10,16 @@
int
main (int argc, char **argv)
{
- char *p;
-
_dbus_disable_crash_handling ();
#ifdef HAVE_RAISE
raise (SIGSEGV);
+#else
+ {
+ volatile char *p = NULL;
+ *p = 'a';
+ }
#endif
- p = NULL;
- *p = 'a';
-
+
return 0;
}
diff --git a/test/test-utils-glib.c b/test/test-utils-glib.c
index 2aafb03e..1d469c7b 100644
--- a/test/test-utils-glib.c
+++ b/test/test-utils-glib.c
@@ -2,6 +2,7 @@
*
* Copyright © 2010-2011 Nokia Corporation
* Copyright © 2013-2015 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -40,6 +41,7 @@
# include <unistd.h>
# include <sys/socket.h>
# include <sys/types.h>
+# include <sys/wait.h>
# include <pwd.h>
#endif
@@ -66,6 +68,61 @@ _test_assert_no_error (const DBusError *e,
}
#ifdef DBUS_UNIX
+static gboolean
+can_become_user_or_skip (uid_t uid)
+{
+ gchar *message;
+ pid_t child_pid;
+ pid_t pid;
+ int wstatus;
+
+ /* We can't switch to the uid without affecting the whole process,
+ * which we don't necessarily want to do, so try it in a child process. */
+ child_pid = fork ();
+
+ if (child_pid < 0)
+ g_error ("fork: %s", g_strerror (errno));
+
+ if (child_pid == 0)
+ {
+ /* Child process: try to become uid, exit 0 on success, exit with
+ * status = errno on failure */
+
+ if (setuid (uid) != 0)
+ {
+ /* make sure we report failure even if errno is wrong */
+ if (errno == 0)
+ errno = EPERM;
+
+ _exit (errno);
+ }
+
+ /* success */
+ _exit (0);
+ }
+
+ /* Parent process: wait for child and report result */
+
+ pid = waitpid (child_pid, &wstatus, 0);
+ g_assert_cmpuint (child_pid, ==, pid);
+
+ if (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) == 0)
+ return TRUE;
+
+ if (WIFEXITED (wstatus))
+ message = g_strdup_printf ("unable to become uid %lu: %s",
+ (unsigned long) uid,
+ g_strerror (WEXITSTATUS (wstatus)));
+ else
+ message = g_strdup_printf ("unable to become uid %lu: unknown wait status %d",
+ (unsigned long) uid,
+ wstatus);
+
+ g_test_skip (message);
+ g_free (message);
+ return FALSE;
+}
+
static void
child_setup (gpointer user_data)
{
@@ -141,6 +198,9 @@ spawn_dbus_daemon (const gchar *binary,
return NULL;
}
+ if (!can_become_user_or_skip (pwd->pw_uid))
+ return NULL;
+
if (user == TEST_USER_ROOT_DROP_TO_MESSAGEBUS)
{
/* Let the dbus-daemon start as root and drop privileges
@@ -163,6 +223,9 @@ spawn_dbus_daemon (const gchar *binary,
return NULL;
}
+ if (!can_become_user_or_skip (pwd->pw_uid))
+ return NULL;
+
break;
case TEST_USER_ME:
@@ -491,16 +554,20 @@ become_other_user (TestUser user,
}
/* Undo the effect of a successful call to become_other_user() */
+#if defined(HAVE_GETRESUID) && defined(HAVE_SETRESUID) && defined(__linux__)
static void
back_to_root (void)
{
-#if defined(HAVE_GETRESUID) && defined(HAVE_SETRESUID) && defined(__linux__)
- if (setresuid (0, 0, 0) != 0)
- g_error ("setresuid(0, 0, 0): %s", g_strerror (errno));
+ if (setresuid(0, 0, 0) != 0)
+ g_error ("setresuid(0, 0, 0): %s", g_strerror(errno));
+}
#else
+_DBUS_GNUC_NORETURN static void
+back_to_root (void)
+{
g_error ("become_other_user() cannot succeed on this platform");
-#endif
}
+#endif
/*
* Raise G_IO_ERROR_NOT_SUPPORTED if the requested user is impossible.
@@ -899,6 +966,25 @@ test_check_tcp_works (void)
#endif
}
+gboolean
+test_check_af_unix_works (void)
+{
+#if defined(G_OS_WIN32) && !defined(HAVE_AFUNIX_H)
+ /* AFUNIX support is compiled out, skip system check */
+ return FALSE;
+#else
+#ifdef G_OS_WIN32
+ SOCKET fd = socket (AF_UNIX, SOCK_STREAM, 0);
+ closesocket (fd);
+ return fd != INVALID_SOCKET;
+#else
+ int fd = socket (AF_UNIX, SOCK_STREAM, 0);
+ close (fd);
+ return fd >= 0;
+#endif
+#endif
+}
+
/*
* Store the result of an async operation. @user_data is a pointer to a
* variable that can store @result, initialized to %NULL.
diff --git a/test/test-utils-glib.h b/test/test-utils-glib.h
index c4a2c543..427f7d53 100644
--- a/test/test-utils-glib.h
+++ b/test/test-utils-glib.h
@@ -2,6 +2,7 @@
*
* Copyright © 2010-2011 Nokia Corporation
* Copyright © 2013-2015 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
@@ -126,11 +127,24 @@ backported_g_steal_pointer (gpointer pointer_to_pointer)
}
#endif
+#ifndef g_assert_true
+#define g_assert_true(a) g_assert (a)
+#endif
+
+#ifndef g_assert_false
+#define g_assert_false(a) g_assert (!(a))
+#endif
+
+#ifndef g_assert_null
+#define g_assert_null(a) g_assert ((a) == NULL)
+#endif
+
#ifndef g_assert_nonnull
-#define g_assert_nonnull(a) g_assert (a != NULL)
+#define g_assert_nonnull(a) g_assert ((a) != NULL)
#endif
gboolean test_check_tcp_works (void);
+gboolean test_check_af_unix_works (void);
void test_store_result_cb (GObject *source_object,
GAsyncResult *result,
diff --git a/test/test-utils.c b/test/test-utils.c
index c8884da4..17febc8b 100644
--- a/test/test-utils.c
+++ b/test/test-utils.c
@@ -647,6 +647,53 @@ _dbus_check_fdleaks_leave (DBusInitialFDs *fds,
#endif
}
+static void
+_dbus_test_help_page (const char *appname)
+{
+ fprintf(stdout, "%s [<options>] [<test-data-dir>] [<specific-test>]\n", appname);
+ fprintf(stdout, "Options:\n");
+ fprintf(stdout, " --help this page\n");
+ fprintf(stdout, " --list-tests show available tests\n");
+ fprintf(stdout, " --tap expect test data dir to be set by environment variable DBUS_TEST_DATA\n");
+ fprintf(stdout, "Environment variables:\n");
+ fprintf(stdout, " DBUS_TEST_ONLY=<specific-test> set specific test to run\n");
+ fprintf(stdout, " DBUS_TEST_DATA=<test-data-dir> set test data dir (required when using --tap)\n");
+}
+
+static void
+_dbus_test_show_available_tests (size_t n_tests,
+ const DBusTestCase *tests)
+{
+ size_t i;
+
+ for (i = 0; i < n_tests; i++)
+ {
+ if (tests[i].name == NULL)
+ break;
+
+ fprintf(stdout, "%s\n", tests[i].name);
+ }
+}
+
+static const DBusTestCase *
+_dbus_test_find_test (size_t n_tests,
+ const DBusTestCase *tests,
+ const char *specific_test)
+{
+ size_t i;
+
+ for (i = 0; i < n_tests; i++)
+ {
+ if (tests[i].name == NULL)
+ break;
+
+ if (strcmp (specific_test, tests[i].name) == 0)
+ return &tests[i];
+ }
+ return NULL;
+}
+
+
/*
* _dbus_test_main:
* @argc: number of command-line arguments
@@ -684,6 +731,18 @@ _dbus_test_main (int argc,
setlocale(LC_ALL, "");
#endif
+ if (argc > 1 && strcmp (argv[1], "--help") == 0)
+ {
+ _dbus_test_help_page (argv[0]);
+ exit(0);
+ }
+
+ else if (argc > 1 && strcmp (argv[1], "--list-tests") == 0)
+ {
+ _dbus_test_show_available_tests (n_tests, tests);
+ exit (0);
+ }
+
/* We can't assume that strings from _dbus_getenv() will remain valid
* forever, because some tests call setenv(), which is allowed to
* reallocate the entire environment block, and in Wine it seems that it
@@ -701,8 +760,11 @@ _dbus_test_main (int argc,
if (test_data_dir != NULL)
_dbus_test_diag ("Test data in %s", test_data_dir);
else if (flags & DBUS_TEST_FLAGS_REQUIRE_DATA)
- _dbus_test_fatal ("Must specify test data directory as argv[1] or "
- "in DBUS_TEST_DATA environment variable");
+ {
+ _dbus_test_help_page (argv[0]);
+ _dbus_test_fatal ("Must specify test data directory as argv[1] or "
+ "in DBUS_TEST_DATA environment variable");
+ }
else
_dbus_test_diag ("No test data!");
@@ -711,6 +773,15 @@ _dbus_test_main (int argc,
else
specific_test = strdup0_or_die (_dbus_getenv ("DBUS_TEST_ONLY"));
+ /* check that test is present */
+ if (specific_test)
+ {
+ if (_dbus_test_find_test (n_tests, tests, specific_test) == NULL)
+ {
+ _dbus_test_fatal ("Invalid test name '%s' specified", specific_test);
+ }
+ }
+
/* Some NSS modules like those for sssd and LDAP might allocate fds
* on a one-per-process basis. Make sure those have already been
* allocated before we enter the code under test, so that they don't
@@ -730,7 +801,7 @@ _dbus_test_main (int argc,
for (i = 0; i < n_tests; i++)
{
- long before, after;
+ dbus_int64_t before, after;
DBusInitialFDs *initial_fds = NULL;
if (tests[i].name == NULL)
@@ -761,7 +832,7 @@ _dbus_test_main (int argc,
_dbus_get_monotonic_time (&after, NULL);
- _dbus_test_diag ("%s test took %ld seconds",
+ _dbus_test_diag ("%s test took %" DBUS_INT64_MODIFIER "d seconds",
tests[i].name, after - before);
if (test_post_hook)
diff --git a/test/thread-blocking.c b/test/thread-blocking.c
index 69395f35..883015cd 100644
--- a/test/thread-blocking.c
+++ b/test/thread-blocking.c
@@ -6,6 +6,8 @@
* Copyright © 2018 Manish Narang <manrock007@gmail.com>
* Copyright © 2018 Collabora Ltd.
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -233,6 +235,8 @@ test_threads (Fixture *f,
f->client_caller_threads[i] = g_thread_new (name,
client_caller_thread_cb,
f);
+
+ g_free (name);
}
/* Wait for all caller threads to exit */
diff --git a/test/uid-permissions.c b/test/uid-permissions.c
index b48ab048..e2688bd0 100644
--- a/test/uid-permissions.c
+++ b/test/uid-permissions.c
@@ -3,6 +3,7 @@
* Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Copyright © 2010-2011 Nokia Corporation
* Copyright © 2015 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/test/use-as-subproject/.gitignore b/test/use-as-subproject/.gitignore
new file mode 100644
index 00000000..2c32b030
--- /dev/null
+++ b/test/use-as-subproject/.gitignore
@@ -0,0 +1,5 @@
+# Copyright 2023 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+
+/_build/
+/subproject/
diff --git a/test/use-as-subproject/config.h b/test/use-as-subproject/config.h
new file mode 100644
index 00000000..e5e5c74e
--- /dev/null
+++ b/test/use-as-subproject/config.h
@@ -0,0 +1,6 @@
+/*
+ * Copyright 2023 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ */
+
+#error Should not use superproject generated config.h to compile libdbus
diff --git a/test/use-as-subproject/dummy-config.h.in b/test/use-as-subproject/dummy-config.h.in
new file mode 100644
index 00000000..e5e5c74e
--- /dev/null
+++ b/test/use-as-subproject/dummy-config.h.in
@@ -0,0 +1,6 @@
+/*
+ * Copyright 2023 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ */
+
+#error Should not use superproject generated config.h to compile libdbus
diff --git a/test/use-as-subproject/meson.build b/test/use-as-subproject/meson.build
new file mode 100644
index 00000000..8111e9ee
--- /dev/null
+++ b/test/use-as-subproject/meson.build
@@ -0,0 +1,38 @@
+# Copyright 2023 Collabora Ltd.
+# Copyright (c) 2023 SUSE LLC
+# SPDX-License-Identifier: MIT
+
+project(
+ 'use-libdbus-as-subproject',
+ 'c',
+ version : '0',
+ meson_version : '>=0.49.0'
+)
+add_project_arguments('-D_GNU_SOURCE', language : 'c')
+
+configure_file(
+ copy : true,
+ input : 'dummy-config.h.in',
+ output : 'config.h',
+)
+
+libdbus_dep = dependency(
+ 'dbus-1',
+ required: true,
+ fallback: ['dbus', 'libdbus_dep'],
+ default_options: [
+ 'default_library=static',
+ 'embedded_tests=false',
+ 'message_bus=false',
+ 'modular_tests=disabled',
+ 'tools=false',
+ ],
+)
+
+executable(
+ 'use-libdbus',
+ 'use-libdbus.c',
+ dependencies : [
+ libdbus_dep
+ ]
+)
diff --git a/test/use-as-subproject/use-libdbus.c b/test/use-as-subproject/use-libdbus.c
new file mode 100644
index 00000000..3acbde1c
--- /dev/null
+++ b/test/use-as-subproject/use-libdbus.c
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2023 SUSE LLC
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <assert.h>
+#include <dbus/dbus.h>
+
+int main(void)
+{
+ DBusMessage *m = NULL;
+
+ m = dbus_message_new_signal ("/", "com.example.Interface", "Signal");
+ assert (m != NULL);
+ dbus_message_unref (m);
+ return 0;
+}
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 43d4df43..5caf5de5 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -57,6 +57,8 @@ set(dbus_cleanup_sockets_SOURCES
set(dbus_run_session_SOURCES
dbus-run-session.c
+ tool-common.c
+ tool-common.h
)
set(dbus_uuidgen_SOURCES
diff --git a/tools/Makefile.am b/tools/Makefile.am
deleted file mode 100644
index 1337ebce..00000000
--- a/tools/Makefile.am
+++ /dev/null
@@ -1,153 +0,0 @@
-AM_CPPFLAGS = \
- -I$(top_srcdir) \
- $(CODE_COVERAGE_CPPFLAGS) \
- $(DBUS_STATIC_BUILD_CPPFLAGS) \
- $(DBUS_X_CFLAGS) \
- -DDBUS_COMPILATION \
- -DDBUS_MACHINE_UUID_FILE=\""$(localstatedir)/lib/dbus/machine-id"\" \
- $(NULL)
-
-AM_CFLAGS = \
- $(CODE_COVERAGE_CFLAGS) \
- $(SANITIZE_CFLAGS) \
- $(NULL)
-
-# if assertions are enabled, improve backtraces
-AM_LDFLAGS = @R_DYNAMIC_LDFLAG@
-
-bin_PROGRAMS = \
- dbus-launch \
- dbus-monitor \
- dbus-run-session \
- dbus-send \
- dbus-test-tool \
- dbus-update-activation-environment \
- $(NULL)
-
-if DBUS_UNIX
-bin_PROGRAMS += \
- dbus-cleanup-sockets \
- dbus-uuidgen \
- $(NULL)
-endif
-
-dbus_send_SOURCES= \
- dbus-print-message.c \
- dbus-print-message.h \
- dbus-send.c \
- tool-common.c \
- tool-common.h \
- $(NULL)
-
-dbus_monitor_SOURCES = \
- dbus-monitor.c \
- dbus-print-message.c \
- dbus-print-message.h \
- tool-common.c \
- tool-common.h \
- $(NULL)
-
-if DBUS_WIN
-dbus_launch_SOURCES= \
- dbus-launch-win.c \
- dbus-launch.h
-else
-dbus_launch_SOURCES= \
- dbus-launch.c \
- dbus-launch-x11.c \
- dbus-launch.h \
- tool-common.c \
- tool-common.h \
- $(NULL)
-endif
-
-dbus_launch_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- $(NULL)
-dbus_launch_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- $(top_builddir)/dbus/libdbus-1.la \
- $(DBUS_X_LIBS) \
- $(NULL)
-
-dbus_run_session_SOURCES = \
- dbus-run-session.c
-
-dbus_run_session_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- $(top_builddir)/dbus/libdbus-internal.la \
- $(NULL)
-
-dbus_cleanup_sockets_SOURCES= \
- dbus-cleanup-sockets.c
-
-dbus_uuidgen_SOURCES= \
- dbus-uuidgen.c
-
-dbus_send_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- $(top_builddir)/dbus/libdbus-1.la \
- $(NULL)
-
-dbus_monitor_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- $(top_builddir)/dbus/libdbus-1.la \
- $(NETWORK_libs) \
- $(NULL)
-
-dbus_uuidgen_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- $(top_builddir)/dbus/libdbus-1.la \
- $(NULL)
-
-examplesdir = ${docdir}/examples
-dist_examples_SCRIPTS = \
- GetAllMatchRules.py \
- $(NULL)
-
-dbus_test_tool_SOURCES = \
- dbus-echo.c \
- dbus-spam.c \
- tool-common.c \
- tool-common.h \
- test-tool.c \
- test-tool.h \
- $(NULL)
-dbus_test_tool_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- $(top_builddir)/dbus/libdbus-1.la \
- $(NULL)
-
-dbus_update_activation_environment_SOURCES = \
- dbus-update-activation-environment.c \
- tool-common.c \
- tool-common.h \
- $(NULL)
-dbus_update_activation_environment_LDADD = \
- $(CODE_COVERAGE_LIBS) \
- $(top_builddir)/dbus/libdbus-1.la \
- $(NULL)
-
-if DBUS_WIN
-SUFFIXES = .rc
-
-.rc.o:
- $(RC) $< -o $@
-
-nodist_dbus_update_activation_environment_SOURCES = disable-uac.rc
-
-disable-uac.rc: Win32.Manifest
- echo '1 24 "$<"' > $@
-endif
-
-EXTRA_DIST = run-with-tmp-session-bus.sh strtoll.c strtoull.c Win32.Manifest
-CLEANFILES = \
- run-with-tmp-session-bus.conf \
- $(nodist_dbus_update_activation_environment_SOURCES)
-
-# create the /var/lib/dbus directory for dbus-uuidgen
-install-data-local:
- $(MKDIR_P) $(DESTDIR)$(localstatedir)/lib/dbus
-
-installcheck-local:
- test -d $(DESTDIR)$(localstatedir)/lib/dbus
diff --git a/tools/build-timestamp.py b/tools/build-timestamp.py
new file mode 100755
index 00000000..f4dc5a00
--- /dev/null
+++ b/tools/build-timestamp.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+import datetime
+import os
+
+if 'SOURCE_DATE_EPOCH' in os.environ:
+ stamp = int(os.environ['SOURCE_DATE_EPOCH'])
+ dt = datetime.datetime.utcfromtimestamp(stamp)
+else:
+ dt = datetime.datetime.now()
+
+print(dt.isoformat(timespec='minutes'))
diff --git a/tools/check-runstatedir.sh b/tools/check-runstatedir.sh
new file mode 100755
index 00000000..75eb713d
--- /dev/null
+++ b/tools/check-runstatedir.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+
+# Usage: check-runstatedir.sh /run/dbus/system_bus_socket
+
+set -e
+set -u
+
+same_file () {
+ # Many shells implement test -ef (test whether two names point to
+ # the same file), but POSIX doesn't require it, so fall back to
+ # comparing realpath output if necessary. We prefer test -ef if
+ # available, since it does the right thing for bind-mounts, not just
+ # symlinks
+ if test / -ef / 2>/dev/null; then
+ test "$1" -ef "$2"
+ else
+ test "$(realpath "$1")" = "$(realpath "$2")"
+ fi
+}
+
+if [ -e /run ] && [ -e /var/run ] && ! same_file /run /var/run; then
+ echo
+ echo "WARNING: /run and /var/run are not the same directory."
+ echo "| Tools that do not agree on whether a socket is in /run or in"
+ echo "| /var/run will fail to interoperate."
+ echo "| Ask your OS distributor to make these two directories equivalent"
+ echo "| via a symbolic link or bind mount: there is no useful reason to"
+ echo "| make them different."
+ echo
+fi
+
+system_socket="$1"
+
+case "$system_socket" in
+ (/run/dbus/system_bus_socket)
+ # --with-system-socket=/run/dbus/system_bus_socket
+ if ! same_file /run /var/run; then
+ echo
+ echo "WARNING: system bus socket: /run/dbus/system_bus_socket"
+ echo "| The system bus has been configured to listen on"
+ echo "| /run/dbus/system_bus_socket, but /run is not the same"
+ echo "| as /var/run on this system."
+ echo "|"
+ echo "| Most D-Bus implementations will expect to find the D-Bus"
+ echo "| system bus socket at /var/run/dbus/system_bus_socket."
+ echo "| Consider creating a symbolic link."
+ echo
+ fi
+ ;;
+
+ (/var/run/dbus/system_bus_socket)
+ # e.g. --localstatedir=/var
+ if ! same_file /run /var/run; then
+ echo
+ echo "NOTE: system bus socket: /var/run/dbus/system_bus_socket"
+ echo "| The system bus has been configured to listen on"
+ echo "| /var/run/dbus/system_bus_socket, but /run is not the same"
+ echo "| as /var/run on this system."
+ echo "|"
+ echo "| Some D-Bus implementations might expect to find the"
+ echo "| D-Bus system bus socket at /run/dbus/system_bus_socket."
+ echo "| Consider creating a symbolic link."
+ echo
+ fi
+ ;;
+
+ (*)
+ # e.g. --prefix=/opt/dbus
+ echo
+ echo "NOTE: system bus listens on $system_socket"
+ echo "| This build of dbus will not interoperate with the well-known"
+ echo "| system bus socket, /var/run/dbus/system_bus_socket."
+ echo
+ ;;
+esac
diff --git a/tools/ci-build.sh b/tools/ci-build.sh
index f77f11c2..ea6b35a2 100755
--- a/tools/ci-build.sh
+++ b/tools/ci-build.sh
@@ -1,7 +1,8 @@
-#!/bin/bash
+#!/usr/bin/env bash
# Copyright © 2015-2016 Collabora Ltd.
# Copyright © 2020 Ralf Habacker <ralf.habacker@freenet.de>
+# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
@@ -28,6 +29,12 @@ set -x
NULL=
+if [ "$(uname -s || true)" = Linux ]; then
+ export LANG=C.UTF-8
+ export LANGUAGE=C.UTF-8
+ export LC_ALL=C.UTF-8
+fi
+
##
## initialize support to run cross compiled executables
##
@@ -74,22 +81,17 @@ init_wine() {
}
# ci_buildsys:
-# Build system under test: autotools or cmake
-: "${ci_buildsys:=autotools}"
+# Build system under test: meson or cmake
+: "${ci_buildsys:=meson}"
+
+# ci_compiler:
+# Compiler used to build dbus: gcc or clang
+: "${ci_compiler:=gcc}"
# ci_distro:
# OS distribution in which we are testing
-# Typical values: ubuntu, debian; maybe fedora in future
-: "${ci_distro:=ubuntu}"
-
-# ci_docker:
-# If non-empty, this is the name of a Docker image. ci-install.sh will
-# fetch it with "docker pull" and use it as a base for a new Docker image
-# named "ci-image" in which we will do our testing.
-#
-# If empty, we test on "bare metal".
-# Typical values: ubuntu:xenial, debian:jessie-slim
-: "${ci_docker:=}"
+# Typical values: auto (detect at runtime), ubuntu, debian; maybe fedora in future
+: "${ci_distro:=auto}"
# ci_host:
# See ci-install.sh
@@ -110,40 +112,43 @@ init_wine() {
# ci_suite:
# OS suite (release, branch) in which we are testing.
-# Typical values for ci_distro=debian: sid, jessie
-# Typical values for ci_distro=fedora might be 25, rawhide
-: "${ci_suite:=xenial}"
+# Typical values: auto (detect at runtime), ci_distro=debian: bullseye, buster, ci_distro=fedora: 35, rawhide
+: "${ci_suite:=auto}"
# ci_test:
# If yes, run tests; if no, just build
: "${ci_test:=yes}"
+# ci_cmake_junit_output:
+# If non-empty, emit JUnit XML output from CTest tests to that file
+# Note: requires CMake 3.21 or newer.
+: "${ci_cmake_junit_output:=}"
+
# ci_test_fatal:
# If yes, test failures break the build; if no, they are reported but ignored
: "${ci_test_fatal:=yes}"
# ci_variant:
-# One of debug, reduced, legacy, production
+# One of debug, reduced, legacy, production, production-no-upload-docs
: "${ci_variant:=production}"
# ci_runtime:
# One of static, shared; used for windows cross builds
: "${ci_runtime:=static}"
-if [ -n "$ci_docker" ]; then
- exec docker run \
- --env=ci_buildsys="${ci_buildsys}" \
- --env=ci_docker="" \
- --env=ci_host="${ci_host}" \
- --env=ci_parallel="${ci_parallel}" \
- --env=ci_sudo=yes \
- --env=ci_test="${ci_test}" \
- --env=ci_test_fatal="${ci_test_fatal}" \
- --env=ci_variant="${ci_variant}" \
- --env=ci_runtime="${ci_runtime}" \
- --privileged \
- ci-image \
- tools/ci-build.sh
+# print used command line
+set +x; env | awk 'BEGIN { s = "" } $1 ~ /^ci_/ { s=s " " $0} END { print s " " SCRIPT }' SCRIPT=$0; set -x
+
+# choose distribution
+if [ "$ci_distro" = "auto" ]; then
+ ci_distro=$(. /etc/os-release; echo ${ID} | sed 's, ,_,g')
+ echo "detected ci_distro as '${ci_distro}'"
+fi
+
+# choose suite
+if [ "$ci_suite" = "auto" ]; then
+ ci_suite=$(. /etc/os-release; if test -v VERSION_CODENAME; then echo ${VERSION_CODENAME}; else echo ${VERSION_ID}; fi)
+ echo "detected ci_suite as '${ci_suite}'"
fi
maybe_fail_tests () {
@@ -152,25 +157,18 @@ maybe_fail_tests () {
fi
}
-# Generate config.h.in and configure. We do this for both Autotools and
-# CMake builds, so that the CMake build can compare config.h.in with its
-# own checks.
-NOCONFIGURE=1 ./autogen.sh
+srcdir="$(pwd)"
-case "$ci_buildsys" in
- (cmake-dist)
- # clean up directories from possible previous builds
- rm -rf ci-build-dist
- # Do an Autotools `make dist`, then build *that* with CMake,
- # to assert that our official release tarballs will be enough
- # to build with CMake.
- mkdir -p ci-build-dist
- ( cd ci-build-dist; ../configure )
- make -C ci-build-dist dist
- tar --xz -xvf ci-build-dist/dbus-1.*.tar.xz
- cd dbus-1.*/
- ;;
-esac
+# setup default ci_builddir, if not present
+if [ -z "$ci_builddir" ]; then
+ ci_builddir=${srcdir}/ci-build-${ci_variant}-${ci_host}
+fi
+# clean up directories from possible previous builds
+rm -rf "$ci_builddir"
+# create build directory
+mkdir -p "$ci_builddir"
+# use absolute path
+ci_builddir="$(realpath "$ci_builddir")"
#
# cross compile setup
@@ -201,58 +199,197 @@ case "$ci_host" in
;;
esac
-srcdir="$(pwd)"
-# clean up directories from possible previous builds
-rm -rf ci-build-${ci_variant}-${ci_host}
-mkdir -p ci-build-${ci_variant}-${ci_host}
-cd ci-build-${ci_variant}-${ci_host}
+cd "$ci_builddir"
+
+case "$ci_host" in
+ (*-w64-mingw32)
+ # If we're dynamically linking libgcc, make sure Wine will find it
+ if [ "$ci_test" = yes ]; then
+ if [ "${ci_distro%%-*}" = opensuse ] && [ "${ci_host%%-*}" = x86_64 ]; then
+ export WINEARCH=win64
+ fi
+ libgcc_path=
+ if [ "$ci_runtime" = "shared" ]; then
+ libgcc_path=$(dirname "$("${ci_host}-gcc" -print-libgcc-file-name)")
+ fi
+ init_wine \
+ "${ci_builddir}/bin" \
+ "${ci_builddir}/subprojects/expat-2.4.8" \
+ "${ci_builddir}/subprojects/glib-2.72.2/gio" \
+ "${ci_builddir}/subprojects/glib-2.72.2/glib" \
+ "${ci_builddir}/subprojects/glib-2.72.2/gmodule" \
+ "${ci_builddir}/subprojects/glib-2.72.2/gobject" \
+ "${ci_builddir}/subprojects/glib-2.72.2/gthread" \
+ "${dep_prefix}/bin" \
+ ${libgcc_path:+"$libgcc_path"}
+ fi
+ ;;
+esac
+
+# Allow overriding make (e.g. on FreeBSD it has to be set to gmake)
+: "${make:=make}"
+export MAKE=${make}
+make="${make} -j${ci_parallel} V=1 VERBOSE=1"
-make="make -j${ci_parallel} V=1 VERBOSE=1"
+export UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1
case "$ci_buildsys" in
- (autotools)
+ (cmake)
+ cmdwrapper=
+ cmake=cmake
+ case "$ci_host" in
+ (*-w64-mingw32)
+ # CFLAGS and CXXFLAGS does do work, checked with cmake 3.15
+ export LDFLAGS="-${ci_runtime}-libgcc"
+ if [ "${ci_distro%%-*}" = opensuse ]; then
+ if [ "${ci_host%%-*}" = x86_64 ]; then
+ cmake=mingw64-cmake
+ else
+ cmake=mingw32-cmake
+ fi
+ cmdwrapper="xvfb-run -a"
+ fi
+ set _ "$@"
+ if [ "$ci_distro" != "opensuse" ]; then
+ set "$@" -D CMAKE_TOOLCHAIN_FILE="${srcdir}/cmake/${ci_host}.cmake"
+ fi
+ set "$@" -D CMAKE_PREFIX_PATH="${dep_prefix}"
+ if [ "$ci_local_packages" = yes ]; then
+ set "$@" -D CMAKE_INCLUDE_PATH="${dep_prefix}/include"
+ set "$@" -D CMAKE_LIBRARY_PATH="${dep_prefix}/lib"
+ set "$@" -D EXPAT_LIBRARY="${dep_prefix}/lib/libexpat.dll.a"
+ set "$@" -D GLIB2_LIBRARIES="${dep_prefix}/lib/libglib-2.0.dll.a ${dep_prefix}/lib/libgobject-2.0.dll.a ${dep_prefix}/lib/libgio-2.0.dll.a"
+ fi
+ if [ "$ci_test" = yes ]; then
+ set "$@" -D DBUS_USE_WINE=1
+ # test-dbus-daemon needs more time on Windows
+ export DBUS_TEST_TIMEOUT_MULTIPLIER=2
+ fi
+ shift
+ ;;
+ esac
+
+ $cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_WERROR=ON -S "$srcdir" -B "$ci_builddir" "$@"
+
+ ${make}
+ # The test coverage for OOM-safety is too verbose to be useful on
+ # travis-ci.
+ export DBUS_TEST_MALLOC_FAILURES=0
+ ctest_args="-VV --timeout 180"
+ if [ -n "$ci_cmake_junit_output" ]; then
+ ctest_args="--output-junit $ci_cmake_junit_output $ctest_args"
+ fi
+
+ [ "$ci_test" = no ] || $cmdwrapper ctest $ctest_args || maybe_fail_tests
+ ${make} install DESTDIR=$(pwd)/DESTDIR
+ ( cd DESTDIR && find . -ls)
+ ;;
+
+ (meson)
+ # The test coverage for OOM-safety is too verbose to be useful on
+ # travis-ci, and too slow when running under wine.
+ export DBUS_TEST_MALLOC_FAILURES=0
+
+ meson_setup=
+ cross_file=
+
+ # openSUSE has convenience wrappers that run Meson with appropriate
+ # cross options
+ case "$ci_host" in
+ (i686-w64-mingw32)
+ meson_setup=mingw32-meson
+ ;;
+ (x86_64-w64-mingw32)
+ meson_setup=mingw64-meson
+ ;;
+ esac
+
+ case "$ci_host" in
+ (*-w64-mingw32)
+ cross_file="${srcdir}/maint/${ci_host}.txt"
+ # openSUSE's wrappers are designed for building predictable
+ # RPM packages, so they set --auto-features=enabled -
+ # but that includes some things that make no sense on
+ # Windows.
+ set -- -Dapparmor=disabled "$@"
+ set -- -Depoll=disabled "$@"
+ set -- -Dinotify=disabled "$@"
+ set -- -Dkqueue=disabled "$@"
+ set -- -Dlaunchd=disabled "$@"
+ set -- -Dlibaudit=disabled "$@"
+ set -- -Dselinux=disabled "$@"
+ set -- -Dsystemd=disabled "$@"
+ set -- -Dx11_autolaunch=disabled "$@"
+ # We seem to have trouble finding libexpat.dll when
+ # cross-building for Windows and running tests with Wine.
+ set -- -Dexpat:default_library=static "$@"
+ ;;
+ esac
+
+ case "$ci_distro" in
+ (debian*|ubuntu*)
+ # We know how to install python3-mallard-ducktype
+ ;;
+ (*)
+ # TODO: We don't know the openSUSE equivalent of
+ # python3-mallard-ducktype
+ set -- -Dducktype_docs=disabled "$@"
+ ;;
+ esac
+
+ set -- -Dmodular_tests=enabled "$@"
+ # By default, the Meson build would install these into
+ # /lib/systemd, overwriting any systemd units that might have
+ # come from the container's base OS. Install into our prefix instead,
+ # keeping the CI installation separate from the container's base OS
+ # while still allowing systemd to see the units. (dbus#470)
+ set -- -Dsystemd_system_unitdir=/usr/local/lib/systemd/system "$@"
+ set -- -Dsystemd_user_unitdir=/usr/local/lib/systemd/user "$@"
+
case "$ci_variant" in
(debug)
- # Full developer/debug build.
- set _ "$@"
- set "$@" --enable-developer --enable-tests
- # Enable optional features that are off by default
+ set -- -Dasserts=true "$@"
+ set -- -Dembedded_tests=true "$@"
+ set -- -Dverbose_mode=true "$@"
+
case "$ci_host" in
- *-w64-mingw32)
+ (*-w64-mingw32)
;;
- *)
- set "$@" --enable-containers
- set "$@" --enable-user-session
- set "$@" SANITIZE_CFLAGS="-fsanitize=address -fsanitize=undefined -fPIE -pie"
+ (*)
+ set -- -Db_sanitize=address,undefined "$@"
+
+ # https://github.com/mesonbuild/meson/issues/764
+ if [ "$ci_compiler" = "clang" ]; then
+ set -- -Db_lundef=false "$@"
+ fi
+
+ set -- -Db_pie=true "$@"
+ set -- -Duser_session=true "$@"
;;
esac
+
shift
- # The test coverage for OOM-safety is too
- # verbose to be useful on travis-ci.
- export DBUS_TEST_MALLOC_FAILURES=0
;;
-
- (reduced)
+ (reduced)
# A smaller configuration than normal, with
# various features disabled; this emulates
# an older system or one that does not have
# all the optional libraries.
set _ "$@"
# No LSMs (the production build has both)
- set "$@" --disable-selinux --disable-apparmor
+ set "$@" -Dselinux=disabled -Dapparmor=disabled
# No inotify (we will use dnotify)
- set "$@" --disable-inotify
+ set "$@" -Dinotify=disabled
# No epoll or kqueue (we will use poll)
- set "$@" --disable-epoll --disable-kqueue
+ set "$@" -Depoll=disabled -Dkqueue=disabled
# No special init system support
- set "$@" --disable-launchd --disable-systemd
+ set "$@" -Dlaunchd=disabled -Dsystemd=disabled
# No libaudit or valgrind
- set "$@" --disable-libaudit --without-valgrind
+ set "$@" -Dlibaudit=disabled -Dvalgrind=disabled
# Disable optional features, some of which are on by
# default
- set "$@" --disable-containers
- set "$@" --disable-stats
- set "$@" --disable-user-session
+ set "$@" -Dstats=false
+ set "$@" -Duser_session=false
shift
;;
@@ -260,148 +397,106 @@ case "$ci_buildsys" in
# An unrealistically cut-down configuration,
# to check that it compiles and works.
set _ "$@"
- # Disable native atomic operations on Unix
- # (armv4, as used as the baseline for Debian
- # armel, is one architecture that really
- # doesn't have them)
- set "$@" dbus_cv_sync_sub_and_fetch=no
- # Disable getrandom syscall
- set "$@" ac_cv_func_getrandom=no
# No epoll, kqueue or poll (we will fall back
# to select, even on Unix where we would
# usually at least have poll)
- set "$@" --disable-epoll --disable-kqueue
- set "$@" CPPFLAGS=-DBROKEN_POLL=1
+ set "$@" -Depoll=disabled -Dkqueue=disabled
+ export CPPFLAGS=-DBROKEN_POLL=1
# Enable SELinux and AppArmor but not
# libaudit - that configuration has sometimes
# failed
- set "$@" --enable-selinux --enable-apparmor
- set "$@" --disable-libaudit --without-valgrind
+ set "$@" -Dselinux=enabled -Dapparmor=enabled
+ set "$@" -Dlibaudit=disabled -Dvalgrind=disabled
# No directory monitoring at all
- set "$@" --disable-inotify --disable-dnotify
+ set "$@" -Dinotify=disabled
# No special init system support
- set "$@" --disable-launchd --disable-systemd
+ set "$@" -Dlaunchd=disabled -Dsystemd=disabled
# No X11 autolaunching
- set "$@" --disable-x11-autolaunch
- # Re-enable the deprecated pam_console support to make
- # sure it still builds
- set "$@" --with-console-auth-dir=/var/run/console
+ set "$@" -Dx11_autolaunch=disabled
# Leave stats, user-session, etc. at default settings
# to check that the defaults can compile on an old OS
shift
;;
+ esac
+ case "$ci_compiler" in
+ (clang)
+ export CC=clang
+ ;;
(*)
;;
esac
- case "$ci_host" in
- (*-w64-mingw32)
- set _ "$@"
- set "$@" --build="$(build-aux/config.guess)"
- set "$@" --host="${ci_host}"
- set "$@" CFLAGS=-${ci_runtime}-libgcc
- set "$@" CXXFLAGS=-${ci_runtime}-libgcc
- # don't run tests yet, Wine needs Xvfb and
- # more msys2 libraries
- ci_test=no
- # don't "make install" system-wide
- ci_sudo=no
- shift
- ;;
- esac
+ # Debian doesn't have similar convenience wrappers, but we can use
+ # a cross-file
+ if [ -z "$meson_setup" ] || ! command -v "$meson_setup" >/dev/null; then
+ meson_setup="meson setup"
- ../configure \
- --enable-installed-tests \
- --enable-maintainer-mode \
- --enable-modular-tests \
- "$@"
+ if [ -n "$cross_file" ]; then
+ set -- --cross-file="$cross_file" "$@"
+ fi
+ fi
- ${make}
- [ "$ci_test" = no ] || ${make} check || maybe_fail_tests
- cat test/test-suite.log || :
- [ "$ci_test" = no ] || ${make} distcheck || maybe_fail_tests
+ # We assume this when we set LD_LIBRARY_PATH for as-installed
+ # testing, below
+ set -- "$@" --libdir=lib
- ${make} install DESTDIR=$(pwd)/DESTDIR
- ( cd DESTDIR && find . -ls )
+ # openSUSE's mingw*-meson wrappers are designed for self-contained
+ # package building, so they include --wrap-mode=nodownload. Switch
+ # the wrap mode back, so we can use wraps.
+ set -- "$@" --wrap=default
- case "$ci_suite" in
- (jessie|xenial|stretch)
- # these are too old for maintainer-upload-docs
- ;;
+ $meson_setup "$@" "$srcdir"
+ meson compile -v
- (*)
- # assume Ubuntu 18.04 'bionic', Debian 10 'buster' or newer
- ${make} -C doc dbus-docs.tar.xz
- tar -C $(pwd)/DESTDIR -xf doc/dbus-docs.tar.xz
- ( cd DESTDIR/dbus-docs && find . -ls )
- ;;
- esac
+ # This is too slow and verbose to keep enabled at the moment
+ export DBUS_TEST_MALLOC_FAILURES=0
- if [ "$ci_sudo" = yes ] && [ "$ci_test" = yes ]; then
- sudo ${make} install
+ [ "$ci_test" = no ] || meson test --print-errorlogs
+ DESTDIR=DESTDIR meson install
+ ( cd DESTDIR && find . -ls)
+
+ if [ "$ci_sudo" = yes ] && [ "$ci_test" = yes ] && [ "$ci_host" = native ]; then
+ sudo meson install
+ fi
+ ;;
+esac
+
+case "$ci_buildsys" in
+ (meson*)
+ if [ "$ci_sudo" = yes ] && [ "$ci_test" = yes ] && [ "$ci_host" = native ]; then
sudo env LD_LIBRARY_PATH=/usr/local/lib \
/usr/local/bin/dbus-uuidgen --ensure
- LD_LIBRARY_PATH=/usr/local/lib ${make} installcheck || \
- maybe_fail_tests
- cat test/test-suite.log || :
- # re-run them with gnome-desktop-testing
+ # Run "as-installed" tests with gnome-desktop-testing.
+ # Also, one test needs a finite fd limit to be useful, so we
+ # can set that here.
env LD_LIBRARY_PATH=/usr/local/lib \
+ bash -c 'ulimit -S -n 1024; ulimit -H -n 4096; exec "$@"' bash \
gnome-desktop-testing-runner -d /usr/local/share dbus/ || \
maybe_fail_tests
- # these tests benefit from being re-run as root, and one
- # test needs a finite fd limit to be useful
- sudo env LD_LIBRARY_PATH=/usr/local/lib \
- bash -c 'ulimit -S -n 1024; ulimit -H -n 4096; exec "$@"' bash \
+ # Some tests benefit from being re-run as non-root, if we were
+ # not already...
+ if [ "$(id -u)" = 0 ] && [ "$ci_in_docker" = yes ]; then
+ sudo -u user \
+ env LD_LIBRARY_PATH=/usr/local/lib \
gnome-desktop-testing-runner -d /usr/local/share \
- dbus/test-dbus-daemon_with_config.test \
- dbus/test-uid-permissions_with_config.test || \
- maybe_fail_tests
- fi
- ;;
-
- (cmake|cmake-dist)
- cmdwrapper=
- case "$ci_host" in
- (*-w64-mingw32)
- # CFLAGS and CXXFLAGS does do work, checked with cmake 3.15
- export LDFLAGS="-${ci_runtime}-libgcc"
- # enable tests if supported
- if [ "$ci_test" = yes ]; then
- libgcc_path=
- if [ "$ci_runtime" = "shared" ]; then
- libgcc_path=$(dirname "$("${ci_host}-gcc" -print-libgcc-file-name)")
- fi
- init_wine "${dep_prefix}/bin" "$(pwd)/bin" ${libgcc_path:+"$libgcc_path"}
- cmdwrapper="xvfb-run -a"
- fi
- set _ "$@"
- set "$@" -D CMAKE_TOOLCHAIN_FILE="${srcdir}/cmake/${ci_host}.cmake"
- set "$@" -D CMAKE_PREFIX_PATH="${dep_prefix}"
- if [ "$ci_local_packages" = yes ]; then
- set "$@" -D CMAKE_INCLUDE_PATH="${dep_prefix}/include"
- set "$@" -D CMAKE_LIBRARY_PATH="${dep_prefix}/lib"
- set "$@" -D EXPAT_LIBRARY="${dep_prefix}/lib/libexpat.dll.a"
- set "$@" -D GLIB2_LIBRARIES="${dep_prefix}/lib/libglib-2.0.dll.a ${dep_prefix}/lib/libgobject-2.0.dll.a ${dep_prefix}/lib/libgio-2.0.dll.a"
- fi
- if [ "$ci_test" = yes ]; then
- set "$@" -D DBUS_USE_WINE=1
- fi
- shift
- ;;
- esac
-
- cmake "$@" -DCMAKE_VERBOSE_MAKEFILE=ON ..
+ dbus/test-dbus-daemon_with_config.test \
+ || maybe_fail_tests
+ fi
- ${make}
- # The test coverage for OOM-safety is too verbose to be useful on
- # travis-ci.
- export DBUS_TEST_MALLOC_FAILURES=0
- [ "$ci_test" = no ] || $cmdwrapper ctest -VV --timeout 180 || maybe_fail_tests
- ${make} install DESTDIR=$(pwd)/DESTDIR
- ( cd DESTDIR && find . -ls)
+ # ... while other tests benefit from being re-run as root, if
+ # we were not already
+ if [ "$(id -u)" != 0 ]; then
+ sudo env LD_LIBRARY_PATH=/usr/local/lib \
+ bash -c 'ulimit -S -n 1024; ulimit -H -n 4096; exec "$@"' bash \
+ gnome-desktop-testing-runner -d /usr/local/share \
+ dbus/test-dbus-daemon_with_config.test \
+ dbus/test-uid-permissions_with_config.test || \
+ maybe_fail_tests
+ fi
+ fi
;;
esac
diff --git a/tools/ci-install.sh b/tools/ci-install.sh
index d6c8246f..d4980f49 100755
--- a/tools/ci-install.sh
+++ b/tools/ci-install.sh
@@ -1,6 +1,7 @@
-#!/bin/bash
+#!/usr/bin/env bash
# Copyright © 2015-2016 Collabora Ltd.
+# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
@@ -29,14 +30,8 @@ NULL=
# ci_distro:
# OS distribution in which we are testing
-# Typical values: ubuntu, debian; maybe fedora in future
-: "${ci_distro:=ubuntu}"
-
-# ci_docker:
-# If non-empty, this is the name of a Docker image. ci-install.sh will
-# fetch it with "docker pull" and use it as a base for a new Docker image
-# named "ci-image" in which we will do our testing.
-: "${ci_docker:=}"
+# Typical values: auto, ubuntu, debian, ; maybe fedora in future
+: "${ci_distro:=auto}"
# ci_host:
# Either "native", or an Autoconf --host argument to cross-compile
@@ -44,8 +39,7 @@ NULL=
: "${ci_host:=native}"
# ci_in_docker:
-# Used internally by ci-install.sh. If yes, we are inside the Docker image
-# (ci_docker is empty in this case).
+# "yes" if we are running inside a Docker image.
: "${ci_in_docker:=no}"
# ci_local_packages:
@@ -54,31 +48,37 @@ NULL=
# ci_suite:
# OS suite (release, branch) in which we are testing.
-# Typical values for ci_distro=debian: sid, jessie
-# Typical values for ci_distro=fedora might be 25, rawhide
-: "${ci_suite:=xenial}"
+# Typical values: auto (detect at runtime), ci_distro=debian: bullseye, buster, ci_distro=fedora: 35, rawhide
+: "${ci_suite:=auto}"
# ci_variant:
# One of debug, reduced, legacy, production
: "${ci_variant:=production}"
+# print used command line
+set +x; env | awk 'BEGIN { s = "" } $1 ~ /^ci_/ { s=s " " $0} END { print s " " SCRIPT }' SCRIPT=$0; set -x
+
if [ $(id -u) = 0 ]; then
sudo=
else
sudo=sudo
fi
-if [ -n "$ci_docker" ]; then
- sed \
- -e "s/@ci_distro@/${ci_distro}/" \
- -e "s/@ci_docker@/${ci_docker}/" \
- -e "s/@ci_suite@/${ci_suite}/" \
- < tools/ci-Dockerfile.in > Dockerfile
- exec docker build -t ci-image .
+
+# choose distribution
+if [ "$ci_distro" = "auto" ]; then
+ ci_distro=$(. /etc/os-release; echo ${ID} | sed 's, ,_,g')
+ echo "detected ci_distro as '${ci_distro}'"
+fi
+
+# choose suite
+if [ "$ci_suite" = "auto" ]; then
+ ci_suite=$(. /etc/os-release; if test -v VERSION_CODENAME; then echo ${VERSION_CODENAME}; else echo ${VERSION_ID}; fi)
+ echo "detected ci_suite as '${ci_suite}'"
fi
case "$ci_distro" in
- (debian|ubuntu)
+ (debian*|ubuntu*)
# Don't ask questions, just do it
sudo="$sudo env DEBIAN_FRONTEND=noninteractive"
@@ -87,18 +87,6 @@ case "$ci_distro" in
$sudo sed -i -e 's/httpredir\.debian\.org/deb.debian.org/g' \
/etc/apt/sources.list
- case "$ci_suite" in
- (xenial)
- # Ubuntu 16.04 didn't have the wine32, wine64 packages
- wine32=wine:i386
- wine64=wine:amd64
- ;;
- (*)
- wine32=wine32
- wine64=wine64
- ;;
- esac
-
case "$ci_host" in
(i686-w64-mingw32)
$sudo dpkg --add-architecture i386
@@ -117,7 +105,7 @@ case "$ci_distro" in
"${packages[@]}"
binutils-mingw-w64-i686
g++-mingw-w64-i686
- $wine32 wine
+ wine32 wine
)
;;
(x86_64-w64-mingw32)
@@ -125,7 +113,7 @@ case "$ci_distro" in
"${packages[@]}"
binutils-mingw-w64-x86-64
g++-mingw-w64-x86-64
- $wine64 wine
+ wine64 wine
)
;;
esac
@@ -141,10 +129,9 @@ case "$ci_distro" in
packages=(
"${packages[@]}"
adduser
- autoconf-archive
- automake
- autotools-dev
+ ca-certificates
ccache
+ clang
cmake
debhelper
dh-autoreconf
@@ -153,8 +140,10 @@ case "$ci_distro" in
docbook-xsl
doxygen
dpkg-dev
+ ducktype
g++
gcc
+ git
gnome-desktop-testing
libapparmor-dev
libaudit-dev
@@ -164,6 +153,9 @@ case "$ci_distro" in
libselinux1-dev
libsystemd-dev
libx11-dev
+ llvm
+ meson
+ ninja-build
sudo
valgrind
wget
@@ -171,43 +163,159 @@ case "$ci_distro" in
xmlto
xsltproc
xvfb
+ yelp-tools
zstd
)
- case "$ci_suite" in
- (stretch)
- # Debian 9 'stretch' didn't have the ducktype package
+ $sudo apt-get -qq -y --no-install-recommends install "${packages[@]}"
+
+ if [ "$ci_in_docker" = yes ]; then
+ # Add the user that we will use to do the build inside the
+ # Docker container, and let them use sudo
+ if ! getent passwd user > /dev/null; then
+ adduser --disabled-password --gecos "" user
+ fi
+ echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/nopasswd
+ chmod 0440 /etc/sudoers.d/nopasswd
+ fi
+ ;;
+
+ (opensuse*)
+ zypper="/usr/bin/zypper --non-interactive"
+ # system
+ packages=(
+ sudo
+ )
+
+ # build system
+ packages=(
+ "${packages[@]}"
+ cmake
+ meson
+ )
+
+ # docs
+ packages=(
+ "${packages[@]}"
+ docbook_4
+ docbook-xsl-stylesheets
+ doxygen
+ libqt5-qttools
+ libxslt-tools
+ yelp-tools
+ )
+
+ # dbus (autogen.sh)
+ packages=(
+ "${packages[@]}"
+ which
+ )
+
+ # choose distribution
+ id=$(. /etc/os-release; echo ${ID} | sed 's, ,_,g')
+ case "$id" in
+ (opensuse-leap)
+ version=$(. /etc/os-release; echo ${VERSION_ID} | sed 's, ,_,g')
+ repo="openSUSE_Leap_$version"
+ # Use a newer CMake (3.21) version for JUnit XML support on openSUSE Leap.
+ if ! zypper lr windows_mingw > /dev/null; then
+ $zypper ar --refresh --no-gpgcheck \
+ "https://download.opensuse.org/repositories/windows:/mingw/$repo/windows:mingw.repo"
+ fi
+ ;;
+ (opensuse-tumbleweed)
+ repo="openSUSE_Tumbleweed"
+ ;;
+ (*)
+ echo "ci_suite not specified, please choose one from 'leap' or 'tumbleweed'"
+ exit 1
+ ;;
+ esac
+
+ case "$ci_host" in
+ (*-w64-mingw32)
+ # cross
+ packages=(
+ "${packages[@]}"
+ wine
+ xvfb-run
+ )
+
+ # add required repos
+ if [ "${ci_host%%-*}" = x86_64 ]; then
+ bits="64"
+ else
+ bits="32"
+ fi
+ if ! zypper lr "windows_mingw_win${bits}" > /dev/null; then
+ $zypper ar --refresh --no-gpgcheck \
+ "https://download.opensuse.org/repositories/windows:/mingw:/win${bits}/$repo/windows:mingw:win${bits}.repo"
+ fi
+ packages=(
+ "${packages[@]}"
+ mingw${bits}-cross-cmake
+ mingw${bits}-cross-gcc-c++
+ mingw${bits}-cross-meson
+ mingw${bits}-cross-pkgconf
+ mingw${bits}-glib2-devel
+ mingw${bits}-libexpat-devel
+ )
;;
(*)
- # assume Ubuntu 18.04 'bionic', Debian 10 'buster' or newer
packages=(
"${packages[@]}"
- ducktype yelp-tools
+ gcc-c++
+ glib2-devel
+ libX11-devel
+ libexpat-devel
+ systemd-devel
)
;;
esac
-
- $sudo apt-get -qq -y --no-install-recommends install "${packages[@]}"
+ $zypper install --allow-vendor-change "${packages[@]}"
if [ "$ci_in_docker" = yes ]; then
# Add the user that we will use to do the build inside the
# Docker container, and let them use sudo
- adduser --disabled-password --gecos "" user
+ if ! getent passwd user >/dev/null; then
+ useradd -m user
+ passwd -ud user
+ fi
echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/nopasswd
chmod 0440 /etc/sudoers.d/nopasswd
fi
+ ;;
- # manual package setup
- case "$ci_suite" in
- (jessie|xenial)
- # autoconf-archive in Debian 8 and Ubuntu 16.04 is too old,
- # use the one from Debian 9 instead
- wget http://deb.debian.org/debian/pool/main/a/autoconf-archive/autoconf-archive_20160916-1_all.deb
- $sudo dpkg -i autoconf-archive_*_all.deb
- rm autoconf-archive_*_all.deb
- ;;
- esac
+ (freebsd*)
+ $sudo pkg update
+ $sudo pkg upgrade -y
+ packages=(
+ bash
+ cmake
+ docbook-xml
+ docbook-xsl
+ expat
+ glib
+ git
+ gmake
+ libX11
+ libxslt
+ meson
+ ninja
+ pkgconf
+ python3
+ xmlto
+ )
+ $sudo pkg install -y "${packages[@]}"
+ ;;
+esac
+
+#
+# manual package setup
+#
+case "$ci_distro" in
+ (debian*|ubuntu*)
# Make sure we have a messagebus user, even if the dbus package
# isn't installed
@@ -215,6 +323,23 @@ case "$ci_distro" in
--disabled-password --group messagebus
;;
+ (opensuse*)
+ # test-bus depends on group 'bin'
+ $sudo getent group bin >/dev/null || /usr/sbin/groupadd -r bin
+ # Make sure we have a messagebus user, even if the dbus package
+ # isn't installed
+ getent group messagebus >/dev/null || /usr/sbin/groupadd -r messagebus
+ getent passwd messagebus >/dev/null || /usr/sbin/useradd -r -s /usr/bin/false -c "User for D-Bus" -d /run/dbus -g messagebus messagebus
+ ;;
+
+ (freebsd*)
+
+ # Make sure we have a messagebus user, even if the dbus package
+ # isn't installed (using the same UID/GID as the dbus package).
+ pw groupshow messagebus || $sudo pw groupadd -n messagebus -g 556
+ pw usershow messagebus || $sudo pw useradd -n messagebus -u 556 -c "D-BUS Daemon User" -d /nonexistent -s /usr/sbin/nologin -g 556
+ ;;
+
(*)
echo "Don't know how to set up ${ci_distro}" >&2
exit 1
@@ -224,31 +349,42 @@ esac
if [ "$ci_local_packages" = yes ]; then
case "$ci_host" in
(*-w64-mingw32)
- mirror=http://repo.msys2.org/mingw/${ci_host%%-*}
+ cpu="${ci_host%%-*}"
+ mirror="https://repo.msys2.org/mingw/$cpu"
dep_prefix=$(pwd)/${ci_host}-prefix
+ # clean install dir, if present
+ rm -rf ${dep_prefix}
install -d "${dep_prefix}"
+ wget -O files.lst ${mirror}
+ sed 's,^<a href=",,g;s,">.*$,,g' files.lst | grep -v "\.db" | grep -v "\.files" | grep ".*zst$" | sort > filenames.lst
packages=(
- bzip2-1.0.8-2
- expat-2.2.10-1
- gcc-libs-10.2.0-6
- gettext-0.19.8.1-10
- glib2-2.66.4-1
- iconv-1.16-2
- libffi-3.3-2
- libiconv-1.16-2
- libwinpthread-git-8.0.0.5906.c9a21571-1
- pcre-8.44-2
- zlib-1.2.11-8
+ bzip2
+ expat
+ gcc-libs
+ gettext
+ glib2
+ iconv
+ libffi
+ libiconv
+ libwinpthread-git
+ pcre
+ pcre2
+ zlib
)
for pkg in "${packages[@]}" ; do
- wget ${mirror}/mingw-w64-${ci_host%%-*}-${pkg}-any.pkg.tar.zst
- tar -C ${dep_prefix} --strip-components=1 -xvf mingw-w64-${ci_host%%-*}-${pkg}-any.pkg.tar.zst
+ filename=$(grep -F "mingw-w64-${cpu}-${pkg}-" filenames.lst | tail -1)
+ if [ -z ${filename} ]; then
+ echo "could not find filename for package '${pkg}'"
+ exit 1
+ fi
+ # Remove previously downloaded file, which can happen
+ # when run locally
+ if [ -f ${filename} ]; then
+ rm -rf ${filename}
+ fi
+ wget ${mirror}/${filename}
+ tar -C ${dep_prefix} --strip-components=1 -xvf ${filename}
done
-
- # limit access rights
- if [ "$ci_in_docker" = yes ]; then
- chown -R user "${dep_prefix}"
- fi
;;
esac
fi
diff --git a/tools/cmake-format b/tools/cmake-format
index 9ccf1653..e9c85722 100755
--- a/tools/cmake-format
+++ b/tools/cmake-format
@@ -2,17 +2,14 @@
#
# cmake-format - a simple cmake formatter
#
-# Copyright (c) 2019 Ralf Habacker <ralf.habacker@freenet.de>
-#
-# SPDX-License-Identifier: BSD
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
+# Copyright (c) 2019,2021 Ralf Habacker <ralf.habacker@freenet.de>
#
+# SPDX-License-Identifier: BSD-3-Clause
if test -z "$1"; then
echo "format cmake files by Ralf Habacker"
echo
- echo "Usage: $0 --all | --end-args | --indents | --keyword-case | --keyword-spaces | --tabs | --trailing-spaces"
+ echo "Usage: $0 --all | --end-args | --indents | --keyword-case | --keyword-spaces | --tabs | --trailing-spaces [<source-dir>]"
echo
echo "command line parameter:"
echo " --all all above"
@@ -23,6 +20,8 @@ if test -z "$1"; then
echo " --tabs replace tabs by 4 spaces"
echo " --trailing-spaces remove trailing spaces"
echo " --check-indents check indents"
+ echo " [<source-dir>] specify root dir to perform the requested action (optional)"
+ echo " If not specified, dbus source dir root is used"
exit 1
fi
@@ -76,34 +75,53 @@ for j in $(echo $KEYWORDS); do
fi
done
expke=$exp
+func=
if test "$1" == "--all"; then
- exp="${expt}${expts}${expku}${expki}${expks}${expke}"
+ exp="${expt};${expts}${expku}${expki}${expks}${expke}"
+ func=$1
+ shift
elif test "$1" == "--end-args"; then
exp=$expke
+ func=$1
+ shift
elif test "$1" == "--indents"; then
exp=$expki
+ func=$1
+ shift
elif test "$1" == "--keyword-case"; then
exp=$expku
+ func=$1
+ shift
elif test "$1" == "--keyword-spaces"; then
exp=$expks
+ func=$1
+ shift
elif test "$1" == "--tabs"; then
exp=$expt
+ func=$1
+ shift
elif test "$1" == "--trailing-spaces"; then
exp=$expts
+ func=$1
+ shift
+elif test "$1" == "--check-indents"; then
+ echo "locations with unusual indention level changes, please inspect"
+ func=$1
+ shift
fi
# setup dir to apply
-s=$(dirname $0)
-root=$(realpath $s/..)
+if test -n "$1"; then
+ root=$1
+else
+ s=$(dirname $0)
+ root=$(realpath $s/..)
+fi
#echo $exp
#echo $root
-if test "$1" = "--check-indents"; then
- echo "locations with unusual indention level changes, please inspect"
-fi
-
# script for checking indents
awk='BEGIN { debug=0; indent=0 }
$0 ~ /^ {0}/ && $0 !~ /^$/{ indent=0; }
@@ -118,7 +136,7 @@ debug == 1 { print FILENAME "[" NR "]:" indent " " oldindent ": " $0; }
# apply to cmake related files
for i in $(find $root -name 'CMakeLists.txt' -o -name '*.cmake' | grep -v README.cmake | grep -v config.h.cmake | grep -v bat.cmake | grep -v '/Find'); do
# apply style
- if ! test "$1" = "--check-indents"; then
+ if ! test "$func" = "--check-indents"; then
sed -i "$exp" $i
else
gawk "$awk" $i
diff --git a/tools/dbus-cleanup-sockets.c b/tools/dbus-cleanup-sockets.c
index 356c18fd..f8e1cbcc 100644
--- a/tools/dbus-cleanup-sockets.c
+++ b/tools/dbus-cleanup-sockets.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2003 Red Hat, Inc.
* Copyright (C) 2002 Michael Meeks
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
* Note that this file is NOT licensed under the Academic Free License,
* as it is based on linc-cleanup-sockets which is LGPL.
diff --git a/tools/dbus-echo.c b/tools/dbus-echo.c
index 917d983c..1e0f03c2 100644
--- a/tools/dbus-echo.c
+++ b/tools/dbus-echo.c
@@ -4,6 +4,7 @@
* Copyright © 2003 Philip Blundell <philb@gnu.org>
* Copyright © 2011 Nokia Corporation
* Copyright © 2014 Collabora Ltd.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/tools/dbus-launch-win.c b/tools/dbus-launch-win.c
index 34837c12..ae055c56 100644
--- a/tools/dbus-launch-win.c
+++ b/tools/dbus-launch-win.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2007 Ralf Habacker <ralf.habacker@freenet.de>
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tools/dbus-launch-x11.c b/tools/dbus-launch-x11.c
index 0b5d2928..6b1fc476 100644
--- a/tools/dbus-launch-x11.c
+++ b/tools/dbus-launch-x11.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2006 Thiago Macieira <thiago@kde.org>
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -37,6 +39,8 @@
#include <X11/Xlib.h>
#include <X11/Xatom.h>
+#include "dbus/dbus-internals.h"
+
Display *xdisplay = NULL;
static Atom selection_atom;
static Atom address_atom;
@@ -333,7 +337,7 @@ x11_get_address (char **paddress, pid_t *pid, long *wid)
XA_CARDINAL, &type, &format, &items, &after,
(unsigned char **) &data);
if (result == Success && type != None && after == 0 && data != NULL && format == 32)
- *pid = (pid_t) *(long*) data;
+ *pid = (pid_t) *(long*) (void*) data;
XFree (data);
}
@@ -451,7 +455,24 @@ x11_save_address (char *address, pid_t pid, long *wid)
int
x11_init (void)
{
- return open_x11 () != NULL && init_x_atoms (xdisplay);
+ int ok;
+
+ /*
+ * The X11 connection is opened and never closed. Because dbus-launch
+ * forks and continues to run non-trivial code in a forked child, it is
+ * not clear whether (or where) it would be safe to close it; instead, we
+ * leave it open until process exit, at which point the socket is cleaned
+ * up by the kernel.
+ *
+ * Any memory allocated for the X11 connection is only allocated once per
+ * run of dbus-launch, so there's no need to keep track of it, and we can
+ * silence memory leak warnings from AddressSanitizer as uninteresting.
+ */
+ _DBUS_BEGIN_IGNORE_LEAKS;
+ ok = open_x11 () != NULL && init_x_atoms (xdisplay);
+ _DBUS_END_IGNORE_LEAKS;
+
+ return ok;
}
void
diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c
index f1a5b970..45eca5ec 100644
--- a/tools/dbus-launch.c
+++ b/tools/dbus-launch.c
@@ -4,6 +4,8 @@
* Copyright (C) 2003, 2006 Red Hat, Inc.
* Copyright (C) 2006 Thiago Macieira <thiago@kde.org>
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
@@ -843,12 +845,10 @@ main (int argc, char **argv)
int bus_pid_to_babysitter_pipe[2];
int bus_address_to_launcher_pipe[2];
char *config_file;
- dbus_bool_t user_bus_supported = FALSE;
- DBusString user_bus;
+ dbus_bool_t existing_bus_supported = FALSE;
+ DBusString existing_bus;
const char *error_str;
-#ifdef DBUS_BUILD_X11
DBusError error = DBUS_ERROR_INIT;
-#endif
exit_with_session = FALSE;
config_file = NULL;
@@ -1009,31 +1009,20 @@ main (int argc, char **argv)
if (autolaunch)
{
-#ifndef DBUS_BUILD_X11
- fprintf (stderr, "Autolaunch requested, but X11 support not compiled in.\n"
- "Cannot continue.\n");
- exit (1);
-#else /* DBUS_BUILD_X11 */
-#ifndef DBUS_ENABLE_X11_AUTOLAUNCH
- fprintf (stderr, "X11 autolaunch support disabled at compile time.\n");
- exit (1);
-#else /* DBUS_ENABLE_X11_AUTOLAUNCH */
- char *address;
- pid_t pid;
- long wid;
-
if (get_machine_uuid () == NULL)
{
fprintf (stderr, "Machine UUID not provided as arg to --autolaunch\n");
exit (1);
}
- if (!_dbus_string_init (&user_bus))
+ if (!_dbus_string_init (&existing_bus))
tool_oom ("initializing");
/* If we have an XDG_RUNTIME_DIR and it contains a suitable socket,
* dbus-launch --autolaunch can use it, since --autolaunch implies
* "I'm OK with getting a bus that is already active".
+ * Similarly, if we're on macOS with launchd enabled, we can reuse
+ * that here.
*
* (However, plain dbus-launch without --autolaunch must not do so,
* because that would break lots of regression tests, which often
@@ -1044,21 +1033,23 @@ main (int argc, char **argv)
* on the X11 display and in ~/.dbus/session-bus, for full
* backwards compatibility.
*/
- if (!_dbus_lookup_user_bus (&user_bus_supported, &user_bus, &error))
+ if (!_dbus_lookup_session_address (&existing_bus_supported,
+ &existing_bus, &error))
{
fprintf (stderr, "%s\n", error.message);
exit (1);
}
- else if (user_bus_supported)
+ else if (existing_bus_supported)
{
- verbose ("=== Using existing user bus \"%s\"\n",
- _dbus_string_get_const_data (&user_bus));
+ verbose ("=== Using existing session bus \"%s\"\n",
+ _dbus_string_get_const_data (&existing_bus));
}
else
{
- _dbus_string_free (&user_bus);
+ _dbus_string_free (&existing_bus);
}
+#if defined(DBUS_BUILD_X11) && defined(DBUS_ENABLE_X11_AUTOLAUNCH)
verbose ("Autolaunch enabled (using X11).\n");
if (!exit_with_x11)
{
@@ -1066,27 +1057,38 @@ main (int argc, char **argv)
exit_with_x11 = TRUE;
}
- if (!x11_init ())
- {
- fprintf (stderr, "Autolaunch error: X11 initialization failed.\n");
- exit (1);
- }
+ if (x11_init ())
+ {
+ char *address;
+ pid_t pid;
+ long wid;
- if (!x11_get_address (&address, &pid, &wid))
- {
- fprintf (stderr, "Autolaunch error: X11 communication error.\n");
- exit (1);
- }
+ _dbus_assert (xdisplay != NULL);
+ verbose ("Connected to X11 display\n");
- if (address != NULL)
- {
- verbose ("dbus-daemon is already running. Returning existing parameters.\n");
- pass_info (runprog, address, pid, wid, c_shell_syntax,
- bourne_shell_syntax, binary_syntax, argc, argv, remaining_args);
- exit (0);
- }
-#endif /* DBUS_ENABLE_X11_AUTOLAUNCH */
-#endif /* DBUS_BUILD_X11 */
+ if (!x11_get_address (&address, &pid, &wid))
+ {
+ fprintf (stderr, "dbus-launch: Autolaunch error: X11 communication error.\n");
+ exit (1);
+ }
+
+ if (address != NULL)
+ {
+ verbose ("dbus-daemon is already running. Returning existing parameters.\n");
+ pass_info (runprog, address, pid, wid, c_shell_syntax,
+ bourne_shell_syntax, binary_syntax, argc, argv,
+ remaining_args);
+ exit (0);
+ }
+ }
+ else
+ {
+ verbose ("Failed to connect to X11 display\n");
+ _dbus_assert (xdisplay == NULL);
+ }
+#else
+ verbose ("X11 autolaunch disabled at compile time, skipping that.\n");
+#endif /* DBUS_BUILD_X11 && DBUS_ENABLE_X11_AUTOLAUNCH */
}
else if (exit_with_x11)
{
@@ -1121,6 +1123,23 @@ main (int argc, char **argv)
}
#endif /* DBUS_BUILD_X11 */
+ if (autolaunch && !existing_bus_supported)
+ {
+#if defined(DBUS_BUILD_X11) && defined(DBUS_ENABLE_X11_AUTOLAUNCH)
+ if (xdisplay == NULL)
+ {
+ fprintf (stderr,
+ "dbus-launch: No existing session bus was found, and "
+ "failed to connect to X11 display.\n");
+ exit (1);
+ }
+#else
+ fprintf (stderr,
+ "dbus-launch: No existing session bus was found, and X11 "
+ "autolaunch support was disabled at compile time.\n");
+ exit (1);
+#endif
+ }
if (pipe (bus_pid_to_launcher_pipe) < 0 ||
pipe (bus_address_to_launcher_pipe) < 0 ||
@@ -1203,16 +1222,16 @@ main (int argc, char **argv)
close (bus_pid_to_babysitter_pipe[READ_END]);
close (bus_pid_to_babysitter_pipe[WRITE_END]);
- /* If we have a user bus and want to use it, do so instead of
+ /* If we have an existing bus and want to use it, do so instead of
* exec'ing a new dbus-daemon. */
- if (autolaunch && user_bus_supported)
+ if (autolaunch && existing_bus_supported)
{
do_write (bus_pid_to_launcher_pipe[WRITE_END], "0\n", 2);
close (bus_pid_to_launcher_pipe[WRITE_END]);
do_write (bus_address_to_launcher_pipe[WRITE_END],
- _dbus_string_get_const_data (&user_bus),
- _dbus_string_get_length (&user_bus));
+ _dbus_string_get_const_data (&existing_bus),
+ _dbus_string_get_length (&existing_bus));
do_write (bus_address_to_launcher_pipe[WRITE_END], "\n", 1);
close (bus_address_to_launcher_pipe[WRITE_END]);
diff --git a/tools/dbus-launch.h b/tools/dbus-launch.h
index 56596d26..81dde587 100644
--- a/tools/dbus-launch.h
+++ b/tools/dbus-launch.h
@@ -3,6 +3,8 @@
*
* Copyright (C) 2006 Thiago Macieira <thiago@kde.org>
*
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
+ *
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c
index fcc923ee..df860f2c 100644
--- a/tools/dbus-monitor.c
+++ b/tools/dbus-monitor.c
@@ -2,6 +2,7 @@
/* dbus-monitor.c Utility program to monitor messages on the bus
*
* Copyright (C) 2003 Philip Blundell <philb@gnu.org>
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -53,7 +54,8 @@ monitor_filter_func (DBusConnection *connection,
DBusMessage *message,
void *user_data)
{
- long sec = 0, usec = 0;
+ dbus_int64_t sec = 0;
+ long usec = 0;
_dbus_get_real_time (&sec, &usec);
@@ -93,9 +95,9 @@ profile_print_headers (void)
static void
profile_print_with_attrs (const char *type, DBusMessage *message,
- long sec, long usec, ProfileAttributeFlags attrs)
+ dbus_int64_t sec, long usec, ProfileAttributeFlags attrs)
{
- printf ("%s\t%ld.%06ld", type, sec, usec);
+ printf ("%s\t%" DBUS_INT64_MODIFIER "d.%06ld", type, sec, usec);
if (attrs & PROFILE_ATTRIBUTE_FLAG_SERIAL)
printf ("\t%u", dbus_message_get_serial (message));
@@ -128,7 +130,8 @@ static void
print_message_profile (DBusMessage *message)
{
static dbus_bool_t first = TRUE;
- long sec = 0, usec = 0;
+ dbus_int64_t sec = 0;
+ long usec = 0;
if (first)
{
@@ -173,7 +176,7 @@ print_message_profile (DBusMessage *message)
PROFILE_ATTRIBUTE_FLAG_MEMBER);
break;
default:
- printf ("%s\t%ld.%06ld", "tun", sec, usec);
+ printf ("%s\t%" DBUS_INT64_MODIFIER "d.%06ld", "tun", sec, usec);
break;
}
}
@@ -218,7 +221,8 @@ binary_filter_func (DBusConnection *connection,
{
case BINARY_MODE_PCAP:
{
- long tv_sec, tv_usec;
+ dbus_int64_t tv_sec;
+ long tv_usec;
/* seconds, microseconds, bytes captured (possibly truncated),
* original length.
* http://wiki.wireshark.org/Development/LibpcapFileFormat
@@ -494,7 +498,7 @@ main (int argc, char *argv[])
/* Receive o.fd.Peer messages as normal messages, rather than having
* libdbus handle them internally, which is the wrong thing for
* a monitor */
- dbus_connection_set_route_peer_messages (connection, TRUE);
+ dbus_connection_set_builtin_filters_enabled (connection, FALSE);
if (!dbus_connection_add_filter (connection, filter_func,
_DBUS_INT_TO_POINTER (binary_mode), NULL))
diff --git a/tools/dbus-print-message.c b/tools/dbus-print-message.c
index 2ce7f68b..08517a6f 100644
--- a/tools/dbus-print-message.c
+++ b/tools/dbus-print-message.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2003 Philip Blundell <philb@gnu.org>
* Copyright (C) 2003 Red Hat, Inc.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -43,15 +44,6 @@
#include <inttypes.h>
#endif
-#if defined(DBUS_WIN)
-#if !defined(PRId64)
-#define PRId64 "I64d"
-#endif
-#if !defined(PRIu64)
-#define PRIu64 "I64u"
-#endif
-#endif
-
#ifndef HAVE_SOCKLEN_T
#define socklen_t int
#endif
@@ -401,7 +393,7 @@ print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth)
{
dbus_int64_t val;
dbus_message_iter_get_basic (iter, &val);
- printf ("int64 %" PRId64 "\n", val);
+ printf ("int64 %" DBUS_INT64_MODIFIER "d\n", val);
break;
}
@@ -409,7 +401,7 @@ print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth)
{
dbus_uint64_t val;
dbus_message_iter_get_basic (iter, &val);
- printf ("uint64 %" PRIu64 "\n", val);
+ printf ("uint64 %" DBUS_INT64_MODIFIER "u\n", val);
break;
}
@@ -538,7 +530,7 @@ print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth)
}
void
-print_message (DBusMessage *message, dbus_bool_t literal, long sec, long usec)
+print_message (DBusMessage *message, dbus_bool_t literal, dbus_int64_t sec, long usec)
{
DBusMessageIter iter;
const char *sender;
@@ -553,7 +545,7 @@ print_message (DBusMessage *message, dbus_bool_t literal, long sec, long usec)
{
if (sec != 0 || usec != 0)
{
- printf ("%s time=%ld.%06ld sender=%s -> destination=%s",
+ printf ("%s time=%" DBUS_INT64_MODIFIER "d.%06ld sender=%s -> destination=%s",
type_to_name (message_type), sec, usec,
sender ? sender : "(null sender)",
destination ? destination : "(null destination)");
diff --git a/tools/dbus-print-message.h b/tools/dbus-print-message.h
index d45bc79d..cf628761 100644
--- a/tools/dbus-print-message.h
+++ b/tools/dbus-print-message.h
@@ -3,6 +3,7 @@
*
* Copyright (C) 2003 Philip Blundell <philb@gnu.org>
* Copyright (C) 2003 Red Hat, Inc.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,6 +27,6 @@
#include <string.h>
#include <dbus/dbus.h>
-void print_message (DBusMessage *message, dbus_bool_t literal, long sec, long usec);
+void print_message (DBusMessage *message, dbus_bool_t literal, dbus_int64_t sec, long usec);
#endif /* DBUS_PRINT_MESSAGE_H */
diff --git a/tools/dbus-run-session.c b/tools/dbus-run-session.c
index d401e23e..b70b22f1 100644
--- a/tools/dbus-run-session.c
+++ b/tools/dbus-run-session.c
@@ -4,7 +4,9 @@
* Copyright © 2003-2006 Red Hat, Inc.
* Copyright © 2006 Thiago Macieira <thiago@kde.org>
* Copyright © 2011-2012 Nokia Corporation
- * Copyright © 2018 Ralf Habacker
+ * Copyright © 2018, 2021 Ralf Habacker
+ *
+ * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
*
* Licensed under the Academic Free License version 2.1
*
@@ -47,6 +49,8 @@
#include "dbus/dbus.h"
#include "dbus/dbus-internals.h"
+#include "tool-common.h"
+
#define MAX_ADDR_LEN 512
#define PIPE_READ_END 0
#define PIPE_WRITE_END 1
@@ -101,7 +105,7 @@ version (void)
"Copyright (C) 2003-2006 Red Hat, Inc.\n"
"Copyright (C) 2006 Thiago Macieira\n"
"Copyright © 2011-2012 Nokia Corporation\n"
- "Copyright © 2018 Ralf Habacker\n"
+ "Copyright © 2018, 2021 Ralf Habacker\n"
"\n"
"This is free software; see the source for copying conditions.\n"
"There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
@@ -381,19 +385,22 @@ run_session (const char *dbus_daemon,
char **argv,
int prog_arg)
{
- char *dbus_daemon_argv[4];
+ char *dbus_daemon_argv[5];
int ret = 127;
HANDLE server_handle = NULL;
HANDLE app_handle = NULL;
+ HANDLE ready_event_handle = NULL;
DWORD exit_code;
DBusString argv_strings[4];
DBusString address;
char **env = NULL;
DBusHashTable *env_table = NULL;
- long sec,usec;
+ dbus_int64_t sec;
+ long usec;
dbus_bool_t result = TRUE;
char *key = NULL;
char *value = NULL;
+ DBusError error;
if (!_dbus_string_init (&argv_strings[0]))
result = FALSE;
@@ -401,11 +408,20 @@ run_session (const char *dbus_daemon,
result = FALSE;
if (!_dbus_string_init (&argv_strings[2]))
result = FALSE;
+ if (!_dbus_string_init (&argv_strings[3]))
+ result = FALSE;
if (!_dbus_string_init (&address))
result = FALSE;
if (!result)
goto out;
+ /* The handle of this event is used by the dbus daemon
+ * to signal that connections are ready. */
+ dbus_error_init (&error);
+ ready_event_handle = _dbus_win_event_create_inheritable (&error);
+ if (ready_event_handle == NULL)
+ goto out;
+
/* run dbus daemon */
_dbus_get_real_time (&sec, &usec);
/* On Windows it's difficult to make use of --print-address to
@@ -414,23 +430,62 @@ run_session (const char *dbus_daemon,
* mechanism, with a unique scope that is shared by this dbus-daemon,
* the app process that defines its lifetime, and any other child
* processes they might have. */
- _dbus_string_append_printf (&address, "autolaunch:scope=dbus-tmp-session-%ld%ld-" DBUS_PID_FORMAT, sec, usec, _dbus_getpid ());
+ _dbus_string_append_printf (&address, "autolaunch:scope=dbus-tmp-session-%" DBUS_INT64_MODIFIER "d%ld-" DBUS_PID_FORMAT, sec, usec, _dbus_getpid ());
_dbus_string_append_printf (&argv_strings[0], "%s", dbus_daemon);
if (config_file != NULL)
_dbus_string_append_printf (&argv_strings[1], "--config-file=%s", config_file);
else
_dbus_string_append_printf (&argv_strings[1], "--session");
_dbus_string_append_printf (&argv_strings[2], "--address=%s", _dbus_string_get_const_data (&address));
+ _dbus_string_append_printf (&argv_strings[3], "--ready-event-handle=%p", ready_event_handle);
dbus_daemon_argv[0] = _dbus_string_get_data (&argv_strings[0]);
dbus_daemon_argv[1] = _dbus_string_get_data (&argv_strings[1]);
dbus_daemon_argv[2] = _dbus_string_get_data (&argv_strings[2]);
- dbus_daemon_argv[3] = NULL;
+ dbus_daemon_argv[3] = _dbus_string_get_data (&argv_strings[3]);
+ dbus_daemon_argv[4] = NULL;
- server_handle = _dbus_spawn_program (dbus_daemon, dbus_daemon_argv, NULL);
- if (!server_handle)
+ server_handle = _dbus_spawn_program (dbus_daemon, dbus_daemon_argv, NULL, TRUE, &error);
+ if (server_handle == NULL)
+ goto out;
+
+ /* wait until dbus-daemon is ready for connections */
+ if (ready_event_handle != NULL)
{
- _dbus_win_stderr_win_error (me, "Could not start dbus daemon", GetLastError ());
- goto out;
+ DWORD status;
+ HANDLE events[2];
+
+ _dbus_verbose ("Wait until dbus-daemon is ready for connections (event handle %p)\n", ready_event_handle);
+
+ events[0] = ready_event_handle;
+ events[1] = server_handle;
+ status = WaitForMultipleObjects (2, events, FALSE, 30000);
+
+ switch (status)
+ {
+ case WAIT_OBJECT_0:
+ /* ready event signalled, everything is okay */
+ break;
+
+ case WAIT_OBJECT_0 + 1:
+ /* dbus-daemon process has exited */
+ dbus_set_error (&error, DBUS_ERROR_SPAWN_CHILD_EXITED, "dbus-daemon exited before signalling ready");
+ goto out;
+
+ case WAIT_FAILED:
+ _dbus_win_set_error_from_last_error (&error, "Unable to wait for server readiness (handle %p)", ready_event_handle);
+ goto out;
+
+ case WAIT_TIMEOUT:
+ /* GetLastError() is not set */
+ dbus_set_error (&error, DBUS_ERROR_TIMEOUT, "Timed out waiting for server readiness or exit (handle %p)", ready_event_handle);
+ goto out;
+
+ default:
+ /* GetLastError() is probably not set? */
+ dbus_set_error (&error, DBUS_ERROR_FAILED, "Unknown result '%lu' while waiting for server readiness (handle %p)", status, ready_event_handle);
+ goto out;
+ }
+ _dbus_verbose ("Got signal that dbus-daemon is ready for connections\n");
}
/* run app */
@@ -474,30 +529,33 @@ run_session (const char *dbus_daemon,
if (!env)
goto out;
- app_handle = _dbus_spawn_program (argv[prog_arg], argv + prog_arg, env);
- if (!app_handle)
- {
- _dbus_win_stderr_win_error (me, "unable to start child process", GetLastError ());
- goto out;
- }
+ app_handle = _dbus_spawn_program (argv[prog_arg], argv + prog_arg, env, FALSE, &error);
+ if (app_handle == NULL)
+ goto out;
WaitForSingleObject (app_handle, INFINITE);
if (!GetExitCodeProcess (app_handle, &exit_code))
{
- _dbus_win_stderr_win_error (me, "could not fetch exit code", GetLastError ());
+ _dbus_win_set_error_from_last_error (&error, "Could not fetch exit code");
goto out;
}
ret = exit_code;
out:
+ if (dbus_error_is_set (&error))
+ tool_stderr_error (me, &error);
+ dbus_error_free (&error);
TerminateProcess (server_handle, 0);
if (server_handle != NULL)
CloseHandle (server_handle);
if (app_handle != NULL)
CloseHandle (app_handle);
+ if (ready_event_handle != NULL)
+ _dbus_win_event_free (ready_event_handle, NULL);
_dbus_string_free (&argv_strings[0]);
_dbus_string_free (&argv_strings[1]);
_dbus_string_free (&argv_strings[2]);
+ _dbus_string_free (&argv_strings[3]);
_dbus_string_free (&address);
dbus_free_string_array (env);
if (env_table != NULL)
diff --git a/tools/dbus-send.c b/tools/dbus-send.c
index 343fd75a..7750ac61 100644
--- a/tools/dbus-send.c
+++ b/tools/dbus-send.c
@@ -2,6 +2,7 @@
/* dbus-send.c Utility program to send messages from the command line
*
* Copyright (C) 2003 Philip Blundell <philb@gnu.org>
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,18 +28,6 @@
#include <dbus/dbus.h>
#include "dbus/dbus-internals.h"
-#ifndef HAVE_STRTOLL
-#undef strtoll
-#define strtoll mystrtoll
-#include "strtoll.c"
-#endif
-
-#ifndef HAVE_STRTOULL
-#undef strtoull
-#define strtoull mystrtoull
-#include "strtoull.c"
-#endif
-
#ifdef DBUS_WINCE
#ifndef strdup
#define strdup _strdup
@@ -69,6 +58,8 @@ handle_oom (dbus_bool_t success)
}
}
+static int type_from_name (const char *arg, dbus_bool_t allow_container_types);
+
static void
append_arg (DBusMessageIter *iter, int type, const char *value)
{
@@ -151,6 +142,33 @@ append_arg (DBusMessageIter *iter, int type, const char *value)
}
break;
+ case DBUS_TYPE_VARIANT:
+ {
+ DBusMessageIter subiter;
+
+ char sig[2] = "\0\0";
+ char *subtype = strdup (value);
+ char *c = NULL;
+
+ handle_oom (subtype != NULL);
+ c = strchr (subtype, ':');
+ if (!c)
+ {
+ fprintf (stderr, "%s: missing variant subtype specifier\n",
+ appname);
+ exit (1);
+ }
+ *c = '\0';
+
+ sig[0] = (char) type_from_name (subtype, TRUE);
+
+ handle_oom (dbus_message_iter_open_container (iter, DBUS_TYPE_VARIANT,
+ sig, &subiter));
+ append_arg (&subiter, sig[0], c + 1);
+ free (subtype);
+ ret = dbus_message_iter_close_container (iter, &subiter);
+ break;
+ }
default:
fprintf (stderr, "%s: Unsupported data type %c\n", appname, (char) type);
exit (1);
@@ -210,7 +228,7 @@ append_dict (DBusMessageIter *iter, int keytype, int valtype, const char *value)
}
static int
-type_from_name (const char *arg)
+type_from_name (const char *arg, dbus_bool_t allow_container_types)
{
int type;
if (!strcmp (arg, "string"))
@@ -235,6 +253,16 @@ type_from_name (const char *arg)
type = DBUS_TYPE_BOOLEAN;
else if (!strcmp (arg, "objpath"))
type = DBUS_TYPE_OBJECT_PATH;
+ else if (!strcmp(arg, "variant"))
+ {
+ if (!allow_container_types)
+ {
+ fprintf (stderr, "%s: A variant cannot be the key in a dictionary\n", appname);
+ exit (1);
+ }
+
+ type = DBUS_TYPE_VARIANT;
+ }
else
{
fprintf (stderr, "%s: Unknown type \"%s\"\n", appname, arg);
@@ -417,6 +445,13 @@ main (int argc, char *argv[])
usage (1);
}
+ if (!dbus_validate_path (path, &error))
+ {
+ fprintf (stderr, "%s\n", error.message);
+ dbus_error_free (&error);
+ exit (1);
+ }
+
if (address != NULL)
{
connection = dbus_connection_open (address, &error);
@@ -481,7 +516,23 @@ main (int argc, char *argv[])
exit (1);
}
*last_dot = '\0';
-
+
+ if (!dbus_validate_interface (name, &error))
+ {
+ /* Typically this is "Interface name was not valid: \"xxx\""
+ * so we don't need to prefix anything special */
+ fprintf (stderr, "%s\n", error.message);
+ dbus_error_free (&error);
+ exit (1);
+ }
+
+ if (!dbus_validate_member (last_dot + 1, &error))
+ {
+ fprintf (stderr, "Invalid method name: %s\n", error.message);
+ dbus_error_free (&error);
+ exit (1);
+ }
+
message = dbus_message_new_method_call (NULL,
path,
name,
@@ -501,7 +552,21 @@ main (int argc, char *argv[])
exit (1);
}
*last_dot = '\0';
-
+
+ if (!dbus_validate_interface (name, &error))
+ {
+ fprintf (stderr, "%s\n", error.message);
+ dbus_error_free (&error);
+ exit (1);
+ }
+
+ if (!dbus_validate_member (last_dot + 1, &error))
+ {
+ fprintf (stderr, "Invalid signal name: %s\n", error.message);
+ dbus_error_free (&error);
+ exit (1);
+ }
+
message = dbus_message_new_signal (path, name, last_dot + 1);
handle_oom (message != NULL);
}
@@ -572,7 +637,7 @@ main (int argc, char *argv[])
if (arg[0] == 0)
type2 = DBUS_TYPE_STRING;
else
- type2 = type_from_name (arg);
+ type2 = type_from_name (arg, FALSE);
if (container_type == DBUS_TYPE_DICT_ENTRY)
{
@@ -585,7 +650,7 @@ main (int argc, char *argv[])
exit (1);
}
*(c++) = 0;
- secondary_type = type_from_name (arg);
+ secondary_type = type_from_name (arg, TRUE);
sig[0] = DBUS_DICT_ENTRY_BEGIN_CHAR;
sig[1] = type2;
sig[2] = secondary_type;
@@ -648,7 +713,8 @@ main (int argc, char *argv[])
if (reply)
{
- long sec, usec;
+ dbus_int64_t sec;
+ long usec;
_dbus_get_real_time (&sec, &usec);
print_message (reply, print_reply_literal, sec, usec);
diff --git a/tools/dbus-spam.c b/tools/dbus-spam.c
index 192911cb..7c0a7168 100644
--- a/tools/dbus-spam.c
+++ b/tools/dbus-spam.c
@@ -4,6 +4,7 @@
* Copyright © 2003 Philip Blundell <philb@gnu.org>
* Copyright © 2011 Nokia Corporation
* Copyright © 2014 Collabora Ltd.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/tools/dbus-update-activation-environment.c b/tools/dbus-update-activation-environment.c
index 452e5053..4c585b45 100644
--- a/tools/dbus-update-activation-environment.c
+++ b/tools/dbus-update-activation-environment.c
@@ -3,6 +3,7 @@
* systemd, activation environment
*
* Copyright © 2014-2015 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
diff --git a/tools/dbus-uuidgen.c b/tools/dbus-uuidgen.c
index 6d8d97a2..e20f48aa 100644
--- a/tools/dbus-uuidgen.c
+++ b/tools/dbus-uuidgen.c
@@ -2,6 +2,7 @@
/* dbus-uuidgen.c Utility program to create UUIDs
*
* Copyright (C) 2006 Red Hat, Inc.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/tools/disable-uac.rc b/tools/disable-uac.rc
new file mode 100644
index 00000000..af23c7e8
--- /dev/null
+++ b/tools/disable-uac.rc
@@ -0,0 +1 @@
+1 24 "Win32.Manifest"
diff --git a/tools/docker/windows/Dockerfile b/tools/docker/windows/Dockerfile
new file mode 100644
index 00000000..53be741b
--- /dev/null
+++ b/tools/docker/windows/Dockerfile
@@ -0,0 +1,65 @@
+# escape=`
+
+FROM 'mcr.microsoft.com/windows/servercore:ltsc2022'
+
+# Make sure any failure in PowerShell scripts is fatal
+SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
+ENV ErrorActionPreference='Stop'
+
+# Install Chocolatey
+RUN iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
+# Install required packages
+RUN choco install -y vcredist140
+RUN choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System'
+RUN choco install -y git --params '/NoAutoCrlf /NoCredentialManager /NoShellHereIntegration /NoGuiHereIntegration /NoShellIntegration'
+RUN choco install -y windows-sdk-8.1
+RUN choco install -y python3
+RUN choco install -y msys2 --params '/NoPath /NoUpdate /InstallDir:C:\\msys64'
+
+RUN 'git config --global user.email "cirunner@dbus.freedesktop.org"; git config --global user.name "D-Bus CI system"'
+
+RUN pip3 install meson
+# FIXME: Python fails to validate SSL certificates, for unclear reasons
+# try various ways to update the store, certifi-win32 seems to work as long as we fetch before
+# See also: https://bugs.python.org/issue36011
+RUN pip3 install --upgrade certifi
+RUN pip3 install python-certifi-win32
+RUN (New-Object System.Net.WebClient).DownloadString('https://sourceforge.net/projects/pcre/files/pcre/8.37/pcre-8.37.tar.gz.sig') >$null
+RUN (New-Object System.Net.WebClient).DownloadString('https://wrapdb.mesonbuild.com/v2/pcre_8.37-2/get_patch') >$null
+RUN (New-Object System.Net.WebClient).DownloadString('https://zlib.net/fossils/') >$null
+
+# MinGW environment
+RUN c:\msys64\usr\bin\bash -lc 'pacman -S --noconfirm mingw-w64-ucrt-x86_64-toolchain expat glib2-devel ninja'
+
+# Visual Studio can't be installed with choco.
+# It depends on dotnetfx v4.8.0.20190930, which requires a reboot: dotnetfx (exit code 3010)
+# https://github.com/microsoft/vs-dockerfiles/blob/main/native-desktop/
+# Set up environment to collect install errors.
+COPY Install.cmd C:\TEMP\
+ADD https://aka.ms/vscollect.exe C:\TEMP\collect.exe
+# Download channel for fixed install.
+ARG CHANNEL_URL=https://aka.ms/vs/15/release/channel
+ADD ${CHANNEL_URL} C:\TEMP\VisualStudio.chman
+# Download and install Build Tools for Visual Studio 2017 for native desktop workload.
+ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
+RUN C:\TEMP\Install.cmd C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
+ --channelUri C:\TEMP\VisualStudio.chman `
+ --installChannelUri C:\TEMP\VisualStudio.chman `
+ --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended`
+ --installPath C:\BuildTools
+
+# Upstream expat doesn't ship devel? let's build it then...
+# ADD https://github.com/libexpat/libexpat/releases/download/R_2_4_1/expat-win32bin-2.4.1.exe C:\TEMP\expat.exe
+# RUN C:\TEMP\expat.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-
+RUN git clone --depth 1 --branch R_2_4_2 https://github.com/libexpat/libexpat
+WORKDIR "/libexpat/expat"
+RUN cmake --install-prefix c:/ -G '"Visual Studio 15 2017 Win64"' .
+RUN cmake --build . --config Release
+RUN cmake --install . --config Release
+
+# Build glib for MSVC
+RUN git clone --depth 1 --branch 2.70.2 https://gitlab.gnome.org/GNOME/glib.git \glib
+WORKDIR "/glib"
+RUN cmd /c 'C:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=amd64 & meson setup builddir'
+RUN meson compile -C builddir
+RUN meson install --no-rebuild -C builddir
diff --git a/tools/docker/windows/Install.cmd b/tools/docker/windows/Install.cmd
new file mode 100644
index 00000000..bbd0b3c6
--- /dev/null
+++ b/tools/docker/windows/Install.cmd
@@ -0,0 +1,19 @@
+@rem Copyright (C) Microsoft Corporation. All rights reserved.
+@rem https://github.com/MicrosoftDocs/visualstudio-docs/blob/main/docs/install/advanced-build-tools-container.md#install-script
+@rem Licensed under the MIT license.
+@rem SPDX-License-Identifier: MIT
+
+@if not defined _echo echo off
+setlocal enabledelayedexpansion
+
+call %*
+if "%ERRORLEVEL%"=="3010" (
+ exit /b 0
+) else (
+ if not "%ERRORLEVEL%"=="0" (
+ set ERR=%ERRORLEVEL%
+ call C:\TEMP\collect.exe -zip:C:\vslogs.zip
+
+ exit /b !ERR!
+ )
+)
diff --git a/tools/docker/windows/container.ps1 b/tools/docker/windows/container.ps1
new file mode 100644
index 00000000..d5de9ffc
--- /dev/null
+++ b/tools/docker/windows/container.ps1
@@ -0,0 +1,60 @@
+# Copied from mesa, big kudos
+#
+# https://gitlab.freedesktop.org/mesa/mesa/-/blob/master/.gitlab-ci/windows/mesa_container.ps1
+# https://gitlab.freedesktop.org/mesa/mesa/-/blob/34e3e164936d1d3cef267da7780e87f062fedf39/.gitlab-ci/windows/mesa_container.ps1
+
+# Implements the equivalent of ci-templates container-ifnot-exists, using
+# Docker directly as we don't have buildah/podman/skopeo available under
+# Windows, nor can we execute Docker-in-Docker
+$registry_uri = $args[0]
+$registry_username = $args[1]
+$registry_password = $args[2]
+$registry_user_image = $args[3]
+$registry_central_image = $args[4]
+$dockerfile = $args[5]
+
+docker --config "windows-docker.conf" login -u "$registry_username" -p "$registry_password" "$registry_uri"
+if (!$?) {
+ Write-Host "docker login failed to $registry_uri"
+ Exit 1
+}
+
+# if the image already exists, don't rebuild it
+docker --config "windows-docker.conf" pull "$registry_user_image"
+if ($?) {
+ Write-Host "User image $registry_user_image already exists; not rebuilding"
+ docker --config "windows-docker.conf" logout "$registry_uri"
+ Exit 0
+}
+
+# if the image already exists upstream, copy it
+docker --config "windows-docker.conf" pull "$registry_central_image"
+if ($?) {
+ Write-Host "Copying central image $registry_central_image to user image $registry_user_image"
+ docker --config "windows-docker.conf" tag "$registry_central_image" "$registry_user_image"
+ docker --config "windows-docker.conf" push "$registry_user_image"
+ $pushstatus = $?
+ docker --config "windows-docker.conf" logout "$registry_uri"
+ if (!$pushstatus) {
+ Write-Host "Pushing image to $registry_user_image failed"
+ Exit 1
+ }
+ Exit 0
+}
+
+Write-Host "No image found at $registry_user_image or $registry_central_image; rebuilding"
+docker --config "windows-docker.conf" build $DOCKER_BUILD_ARGS --no-cache -t "$registry_user_image" -f "$dockerfile" "./tools/docker/windows"
+if (!$?) {
+ Write-Host "Container build failed"
+ docker --config "windows-docker.conf" logout "$registry_uri"
+ Exit 1
+}
+Get-Date
+
+docker --config "windows-docker.conf" push "$registry_user_image"
+$pushstatus = $?
+docker --config "windows-docker.conf" logout "$registry_uri"
+if (!$pushstatus) {
+ Write-Host "Pushing image to $registry_user_image failed"
+ Exit 1
+}
diff --git a/tools/meson-compat-install-emptydirs.py b/tools/meson-compat-install-emptydirs.py
new file mode 100755
index 00000000..45ae62de
--- /dev/null
+++ b/tools/meson-compat-install-emptydirs.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+
+# Compatibility shim for installing empty directories with Meson < 0.60
+
+import os
+import sys
+from pathlib import Path
+
+for d in sys.argv[1].split(':'):
+ if os.path.isabs(d):
+ p = Path(d)
+ d = p.relative_to(p.anchor)
+ dest = os.path.join(os.environ.get('DESTDIR', '/'), d)
+ else:
+ dest = os.path.join(os.environ['MESON_INSTALL_DESTDIR_PREFIX'], d)
+
+ os.makedirs(dest, mode=0o755, exist_ok=True)
diff --git a/tools/meson-compat-install-symlink.py b/tools/meson-compat-install-symlink.py
new file mode 100755
index 00000000..69ff2a66
--- /dev/null
+++ b/tools/meson-compat-install-symlink.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+# Copyright 2022 Simon McVittie
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+
+# Compatibility shim for installing symlinks with Meson < 0.61
+
+import os
+import sys
+from pathlib import Path
+
+link_name, d, pointing_to = sys.argv[1:]
+
+if os.path.isabs(d):
+ p = Path(d)
+ d = p.relative_to(p.anchor)
+ dest = os.path.join(os.environ.get('DESTDIR', '/'), d)
+else:
+ dest = os.path.join(os.environ['MESON_INSTALL_DESTDIR_PREFIX'], d)
+
+os.makedirs(dest, mode=0o755, exist_ok=True)
+os.symlink(pointing_to, os.path.join(dest, link_name))
diff --git a/tools/meson.build b/tools/meson.build
new file mode 100644
index 00000000..5d78d93a
--- /dev/null
+++ b/tools/meson.build
@@ -0,0 +1,116 @@
+# Copyright © 2019-2020 Salamandar <felix@piedallu.me>
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+if not platform_windows
+ dbus_cleanup_sockets = executable('dbus-cleanup-sockets',
+ 'dbus-cleanup-sockets.c',
+ include_directories: root_include,
+ install: true,
+ )
+endif
+
+if platform_windows
+ dbus_launch_sources = [
+ 'dbus-launch-win.c'
+ ]
+else
+ dbus_launch_sources = [
+ 'dbus-launch.c',
+ 'dbus-launch-x11.c',
+ 'tool-common.c',
+ ]
+endif
+
+if message_bus
+ dbus_launch = executable('dbus-launch',
+ dbus_launch_sources,
+ include_directories: root_include,
+ link_with: libdbus,
+ dependencies: [ x11, ],
+ install: true,
+ )
+endif
+
+dbus_monitor = executable('dbus-monitor',
+ 'dbus-print-message.c',
+ 'dbus-monitor.c',
+ 'tool-common.c',
+ include_directories: root_include,
+ link_with: libdbus,
+ install: true,
+)
+
+if message_bus
+ dbus_run_session = executable('dbus-run-session',
+ 'dbus-run-session.c',
+ 'tool-common.c',
+ include_directories: root_include,
+ link_with: libdbus_internal,
+ install: true,
+ )
+endif
+
+dbus_send = executable('dbus-send',
+ 'dbus-print-message.c',
+ 'dbus-send.c',
+ 'tool-common.c',
+ include_directories: root_include,
+ link_with: libdbus,
+ install: true,
+)
+
+dbus_test_tool = executable('dbus-test-tool',
+ 'dbus-echo.c',
+ 'dbus-spam.c',
+ 'test-tool.c',
+ 'tool-common.c',
+ include_directories: root_include,
+ link_with: libdbus,
+ install: true,
+)
+
+dbus_update_activation_environment = executable('dbus-update-activation-environment',
+ 'dbus-update-activation-environment.c',
+ 'tool-common.c',
+ platform_windows ? windows.compile_resources('disable-uac.rc') : [],
+ include_directories: root_include,
+ link_with: libdbus,
+ install: true,
+)
+
+if not platform_windows
+ dbus_uuidgen = executable('dbus-uuidgen',
+ 'dbus-uuidgen.c',
+ include_directories: root_include,
+ link_with: libdbus,
+ install: true,
+ )
+endif
+
+
+install_data('GetAllMatchRules.py',
+ install_dir: docs_dir / 'examples',
+)
+
+# Create the empty directory to hold the machine ID
+install_emptydirs += [
+ get_option('localstatedir') / 'lib' / 'dbus',
+]
diff --git a/tools/strtoll.c b/tools/strtoll.c
deleted file mode 100644
index 00f14c3c..00000000
--- a/tools/strtoll.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include <limits.h>
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#include <stdlib.h>
-#ifdef DBUS_WINCE
-#include <windows.h>
-#endif
-
-#ifndef isspace
-#define isspace(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n')
-#endif
-
-/* Minimum and maximum values a `signed long long int' can hold. */
-#ifndef LLONG_MAX
-# define LLONG_MAX 9223372036854775807LL
-#endif
-
-#ifndef LLONG_MIN
-# define LLONG_MIN (-LLONG_MAX - 1LL)
-#endif
-/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */
-#ifndef ULLONG_MAX
-# define ULLONG_MAX 18446744073709551615ULL
-#endif
-/*
- * Convert a string to a long long integer.
- *
- * Assumes that the upper and lower case
- * alphabets and digits are each contiguous.
- */
-long long strtoll (const char*, char **, int);
-
-long long
-strtoll(const char * nptr, char ** endptr, int base)
-{
- const char *s;
- unsigned long long acc;
- char c;
- unsigned long long cutoff;
- int neg, any, cutlim;
-
- /*
- * Skip white space and pick up leading +/- sign if any.
- * If base is 0, allow 0x for hex and 0 for octal, else
- * assume decimal; if base is already 16, allow 0x.
- */
- s = nptr;
- do {
- c = *s++;
- } while (isspace((unsigned char)c));
- if (c == '-') {
- neg = 1;
- c = *s++;
- } else {
- neg = 0;
- if (c == '+')
- c = *s++;
- }
- if ((base == 0 || base == 16) &&
- c == '0' && (*s == 'x' || *s == 'X') &&
- ((s[1] >= '0' && s[1] <= '9') ||
- (s[1] >= 'A' && s[1] <= 'F') ||
- (s[1] >= 'a' && s[1] <= 'f'))) {
- c = s[1];
- s += 2;
- base = 16;
- }
- if (base == 0)
- base = c == '0' ? 8 : 10;
- acc = any = 0;
- if (base < 2 || base > 36)
- goto noconv;
-
- /*
- * Compute the cutoff value between legal numbers and illegal
- * numbers. That is the largest legal value, divided by the
- * base. An input number that is greater than this value, if
- * followed by a legal input character, is too big. One that
- * is equal to this value may be valid or not; the limit
- * between valid and invalid numbers is then based on the last
- * digit. For instance, if the range for quads is
- * [-9223372036854775808..9223372036854775807] and the input base
- * is 10, cutoff will be set to 922337203685477580 and cutlim to
- * either 7 (neg==0) or 8 (neg==1), meaning that if we have
- * accumulated a value > 922337203685477580, or equal but the
- * next digit is > 7 (or 8), the number is too big, and we will
- * return a range error.
- *
- * Set 'any' if any `digits' consumed; make it negative to indicate
- * overflow.
- */
- cutoff = neg ? (unsigned long long)-(LLONG_MIN + LLONG_MAX) + LLONG_MAX
- : LLONG_MAX;
- cutlim = cutoff % base;
- cutoff /= base;
- for ( ; ; c = *s++) {
- if (c >= '0' && c <= '9')
- c -= '0';
- else if (c >= 'A' && c <= 'Z')
- c -= 'A' - 10;
- else if (c >= 'a' && c <= 'z')
- c -= 'a' - 10;
- else
- break;
- if (c >= base)
- break;
- if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
- any = -1;
- else {
- any = 1;
- acc *= base;
- acc += c;
- }
- }
- if (any < 0) {
- acc = neg ? LLONG_MIN : LLONG_MAX;
-#ifdef DBUS_WINCE
- SetLastError (ERROR_ARITHMETIC_OVERFLOW);
-#else
- errno = ERANGE;
-#endif
- } else if (!any) {
-noconv:
-#ifdef DBUS_WINCE
- SetLastError (ERROR_INVALID_PARAMETER);
-#else
- errno = EINVAL;
-#endif
- } else if (neg)
- acc = -acc;
- if (endptr != NULL)
- *endptr = (char *)(any ? s - 1 : nptr);
- return (acc);
-}
diff --git a/tools/strtoull.c b/tools/strtoull.c
deleted file mode 100644
index 35595542..00000000
--- a/tools/strtoull.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include <limits.h>
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#include <stdlib.h>
-#ifdef DBUS_WINCE
-#include <windows.h>
-#endif
-
-#ifndef isspace
-#define isspace(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n')
-#endif
-
-/* Minimum and maximum values a `signed long long int' can hold. */
-#ifndef LLONG_MAX
-# define LLONG_MAX 9223372036854775807LL
-#endif
-
-#ifndef LLONG_MIN
-# define LLONG_MIN (-LLONG_MAX - 1LL)
-#endif
-/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */
-#ifndef ULLONG_MAX
-# define ULLONG_MAX 18446744073709551615ULL
-#endif
-
-/*
- * Convert a string to an unsigned long long integer.
- *
- * Assumes that the upper and lower case
- * alphabets and digits are each contiguous.
- */
-unsigned long long strtoull (const char *, char **, int);
-
-unsigned long long
-strtoull(const char * nptr, char ** endptr, int base)
-{
- const char *s;
- unsigned long long acc;
- char c;
- unsigned long long cutoff;
- int neg, any, cutlim;
-
- /*
- * See strtoq for comments as to the logic used.
- */
- s = nptr;
- do {
- c = *s++;
- } while (isspace((unsigned char)c));
- if (c == '-') {
- neg = 1;
- c = *s++;
- } else {
- neg = 0;
- if (c == '+')
- c = *s++;
- }
- if ((base == 0 || base == 16) &&
- c == '0' && (*s == 'x' || *s == 'X') &&
- ((s[1] >= '0' && s[1] <= '9') ||
- (s[1] >= 'A' && s[1] <= 'F') ||
- (s[1] >= 'a' && s[1] <= 'f'))) {
- c = s[1];
- s += 2;
- base = 16;
- }
- if (base == 0)
- base = c == '0' ? 8 : 10;
- acc = any = 0;
- if (base < 2 || base > 36)
- goto noconv;
-
- cutoff = ULLONG_MAX / base;
- cutlim = ULLONG_MAX % base;
- for ( ; ; c = *s++) {
- if (c >= '0' && c <= '9')
- c -= '0';
- else if (c >= 'A' && c <= 'Z')
- c -= 'A' - 10;
- else if (c >= 'a' && c <= 'z')
- c -= 'a' - 10;
- else
- break;
- if (c >= base)
- break;
- if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
- any = -1;
- else {
- any = 1;
- acc *= base;
- acc += c;
- }
- }
- if (any < 0) {
- acc = ULLONG_MAX;
-#ifdef DBUS_WINCE
- SetLastError (ERROR_ARITHMETIC_OVERFLOW);
-#else
- errno = ERANGE;
-#endif
- } else if (!any) {
-noconv:
-#ifdef DBUS_WINCE
- SetLastError (ERROR_INVALID_PARAMETER);
-#else
- errno = EINVAL;
-#endif
- } else if (neg)
- acc = -acc;
- if (endptr != NULL)
- *endptr = (char *)(any ? s - 1 : nptr);
- return (acc);
-}
diff --git a/tools/test-tool.c b/tools/test-tool.c
index 149c10ab..47d0b4bf 100644
--- a/tools/test-tool.c
+++ b/tools/test-tool.c
@@ -4,6 +4,7 @@
* Copyright © 2003 Philip Blundell <philb@gnu.org>
* Copyright © 2011 Nokia Corporation
* Copyright © 2014 Collabora Ltd.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/tools/test-tool.h b/tools/test-tool.h
index 8143cd50..f42ed67b 100644
--- a/tools/test-tool.h
+++ b/tools/test-tool.h
@@ -4,6 +4,7 @@
* Copyright © 2003 Philip Blundell <philb@gnu.org>
* Copyright © 2011 Nokia Corporation
* Copyright © 2014 Collabora Ltd.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/tools/tool-common.c b/tools/tool-common.c
index 32020324..aa923639 100644
--- a/tools/tool-common.c
+++ b/tools/tool-common.c
@@ -4,6 +4,7 @@
* Copyright © 2003 Philip Blundell <philb@gnu.org>
* Copyright © 2011 Nokia Corporation
* Copyright © 2014 Collabora Ltd.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -80,3 +81,10 @@ tool_write_all (int fd,
return TRUE;
}
+
+void
+tool_stderr_error (const char *context,
+ DBusError *error)
+{
+ fprintf (stderr, "%s: %s: %s\n", context, error->name, error->message);
+}
diff --git a/tools/tool-common.h b/tools/tool-common.h
index e6397ffb..813ffeae 100644
--- a/tools/tool-common.h
+++ b/tools/tool-common.h
@@ -4,6 +4,7 @@
* Copyright © 2003 Philip Blundell <philb@gnu.org>
* Copyright © 2011 Nokia Corporation
* Copyright © 2014 Collabora Ltd.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -34,5 +35,6 @@
void tool_oom (const char *doing) _DBUS_GNUC_NORETURN;
dbus_bool_t tool_write_all (int fd, const void *buf, size_t size);
+void tool_stderr_error (const char *context, DBusError *error);
#endif