summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2018-03-14Add clang-format supportclang-formatRalf Habacker3-0/+105
After trying astyle, indent and uncrustify it turned out that clang-format gives the best result so far. With the current configuration file .clang-format code formatting with make 'clang-format', which has been introduced with this commit, may not be applicable to all files, but gives some insights about style differences. and may help Reformatting single files or parts of files as a preparation for creating patches may be more applicable. The added clang configuration can also be used from development IDE's like QtCreator by enabling the Beautifier plugin and selecting 'file' from the list of predefined styles. Code formatting of single files can be processed by selecting menu entry Extra->Beautifier->ClangFormat->Format Current File or Extra->Beautifier->ClangFormat->Format At Cursor.
2018-03-13Update NEWS for fd.o#61922, #103387Simon McVittie1-0/+23
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-03-12DBusSocket helpers: Declare as _DBUS_GNUC_WARN_UNUSED_RESULTSimon McVittie1-0/+7
There is no point in calling these functions for their side-effects, because they don't have any. Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-12Add version info to installed executables for cmake build system on WindowsRalf Habacker6-15/+80
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de> Reviewed-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103387
2018-03-12Windows _dbus_connect_tcp_socket_with_nonce: Simplify initialization of ↵Ralf Habacker1-10/+1
variable noncefileStr This optimization has been detected while comparing the related unix implemention. Reviewed-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-12Remove obsolete call to _dbus_string_free() in unix variant of ↵Ralf Habacker1-1/+0
_dbus_connect_tcp_socket_with_nonce A DBusString that was initialized with a constant doesn't hold any allocated memory, so it doesn't need to be freed. Reviewed-by: Simon McVittie <smcv@collabora.com> https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-12Windows _dbus_listen_tcp_socket: Set socket options SO_REUSEADDR and TCP_NODELAYRalf Habacker1-0/+18
Reviewed-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-12Windows _dbus_listen_tcp_socket: Use AF_UNSPEC if family is unspecifiedRalf Habacker1-1/+1
Now that we cope with getting WSAEADDRNOTAVAIL when trying to listen on ::1 with IPv6 disabled, and gracefully fall back to only listening on 127.0.0.1, we can use AF_UNSPEC like the corresponding Unix code does. Reviewed-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-12Windows _dbus_connect_tcp_socket_with_nonce: Keep error code for 'Unknown ↵Ralf Habacker1-1/+1
address family' in sync with unix Reviewed-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-12Windows _dbus_connect_tcp_socket_with_nonce: Combine all connect() errorsRalf Habacker1-15/+49
Previously, we took the errno from the most recent connect() error, and used a more generic diagnostic message. Reviewed-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-12Windows _dbus_listen_tcp_socket: Treat bind() failures as non-fatalRalf Habacker1-32/+77
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922 Reviewed-by: Simon McVittie <smcv@collabora.com>
2018-03-10Unix _dbus_connect_tcp_socket_with_nonce: Combine all connect() errorsSimon McVittie1-4/+33
Previously, we took the errno from the most recent connect() error, and used a more generic diagnostic message. Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> Signed-off-by: Simon McVittie <smcv@collabora.com> https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-10Unix _dbus_connect_tcp_socket_with_nonce: Always goto outSimon McVittie1-7/+12
This will make it easier to do single-exit-path cleanup. Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> Signed-off-by: Simon McVittie <smcv@collabora.com> https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-09sysdeps-unix: Treat bind() failures as non-fatalSimon McVittie3-21/+131
When we use AF_UNSPEC, we are likely to get multiple addresses back from getaddrinfo(), and perhaps we won't be able to use them all. Give that failure mode, or any other bind() failure, the same treatment as EADDRINUSE failures here and all connect() failures in _dbus_connect_tcp_socket_with_nonce(): if any address succeeds, then the overall operation succeeds, but if all of them fail, then the overall operation fails. I've made _dbus_combine_tcp_errors() generic enough that _dbus_connect_tcp_socket_with_nonce() could use it too, although that isn't implemented here. Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> [smcv: Adjust commit message] Signed-off-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-09sysdeps-unix: Set more specific IP-related errors when listeningSimon McVittie3-6/+50
When we have resolved a hostname/port pair to a list of IPv4 or IPv6 addresses, if we are unable to listen on a a specific one of those addresses, we should report which one. When IPv6 is disabled for the loopback interface, this changes the diagnostic from: Failed to bind socket "localhost:1234": Cannot assign requested address to the more informative Failed to bind socket "::1" port 1234: Cannot assign requested address Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-09_dbus_append_address_from_socket: Factor out inet_sockaddr_to_stringSimon McVittie3-19/+121
Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-09Windows: Target Windows Vista or higherSimon McVittie3-6/+5
This will give us the RFC-2553 inet_ntop() interface. Windows Vista extended security support ended in 2017, but we don't actually need anything from versions newer than Vista yet. Loosely based on part of a patch by Ralf Habacker. Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-09_dbus_get_low_level_socket_errno: AddSimon McVittie3-0/+30
Some libdbus functions have as their API "this function sets errno", but that just leads to strangeness on Windows, where socket (Winsock) functions don't actually set errno themselves, leading to those functions having to copy the Winsock error into errno to fake the Unix-like behaviour. With hindsight, that was probably a bad idea. This function should be portable enough to be used with functions that are essentially the same on Unix and Windows, like inet_ntop(). Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-09_dbus_append_address_from_socket: Correct misleading error messageSimon McVittie1-1/+1
If what actually failed was reading the address from the socket, we might as well say so. Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-09_dbus_append_address_from_socket: Make control flow clearerSimon McVittie1-11/+44
In the current implementation, we can reach the "err" label either because we ran out of memory, or because we got a socket error from getsockname() or inet_ntop(), and we blindly assume that running out of memory will set ENOMEM. However, that isn't actually true: when we are simulating OOM in dbus_malloc(), the fake OOM doesn't set ENOMEM. Handle the OOM condition explicitly instead. In the AF_UNIX case, the break statement is no longer reached at all, so leave a comment there. In the AF_INET and AF_INET6 cases, if inet_ntop() fails, explicitly goto err instead of using break (this has the same practical effect) to make it clearer that we are going to the "socket error" code path. Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-06Add _dbus_clear_loop and _dbus_clear_watchLaurent Bigonville2-0/+14
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92831 [smcv: Fix variable names] Reviewed-by: Simon McVittie <smcv@collabora.com>
2018-03-02Update NEWS for fd.o #103737, #104641Simon McVittie1-1/+13
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-03-02bus driver: Use DBusCredentials to fill credentials structureSimon McVittie4-49/+44
Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737
2018-03-02sysdeps: Document what _dbus_credentials_new_from_current_process hasSimon McVittie2-3/+9
It only has the most important credentials, not the full set. Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737
2018-03-02bus: Get loginfo string bits from DBusCredentialsSimon McVittie1-19/+25
This saves a couple of _dbus_strdup/dbus_free pairs. Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737
2018-03-02bus: Try to get groups directly from credentials, not userdbSimon McVittie1-0/+32
If we avoid consulting the userdb, then it's one less chance to deadlock. Signed-off-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737 Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-03-02loopback test: Display credentials receivedSimon McVittie1-0/+28
Signed-off-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737 Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-03-02DBusCredentials: Add _dbus_clear_credentials()Simon McVittie1-0/+7
Not to be confused with _dbus_credentials_clear(), which does something different (this is a little unfortunate, but the fact that they take different types should clarify which is which). Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737
2018-03-02credentials: Add test coverage for stringificationSimon McVittie1-1/+68
Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737
2018-03-02_dbus_credentials_to_string_append: Remove useless join = FALSESimon McVittie1-4/+0
It can't actually matter in practice, because we never know the Unix uid and Unix groups but not pid, and we never have a Windows SID and also a Linux security label; but resetting join to FALSE can only ever result in us outputting something like "foo=123bar=456" instead of the intended form with a space in the middle. Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737
2018-03-02credentials: Add test coverage for groupsSimon McVittie1-7/+83
Signed-off-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737 Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-03-02sysdeps: Get complete group vector from Linux SO_PEERGROUPS if possibleSimon McVittie4-0/+262
Signed-off-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737 Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-03-02DBusTransport, DBusConnection: Add internal getter for the credentialsSimon McVittie4-0/+40
We have a lot of dbus_connection_get_foo() and _dbus_transport_get_foo() that are actually rather redundant. Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737
2018-03-02bus: Also tell systemd before we shut downSimon McVittie4-0/+19
Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104641
2018-03-02bus: Also tell systemd when we're reloadingSimon McVittie4-0/+41
Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104641
2018-03-02bus: Notify systemd when we are readySimon McVittie6-0/+24
Signed-off-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104641 Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-03-02bus: Don't pass systemd environment variables to activated servicesSimon McVittie1-0/+30
Signed-off-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104641 Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-03-02Start developing 1.13.4Simon McVittie2-1/+6
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-03-011.13.2Simon McVittie2-4/+6
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-03-01Avoid -Wunused-function for iterate_both_main_loops() without containersSimon McVittie1-0/+2
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-02-23Clarify NEWS entry for #105165Simon McVittie1-1/+3
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-02-20Update NEWS for #105165Simon McVittie1-0/+6
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-02-20Add a unit test for the dbus-daemon resetting its fd limitSimon McVittie7-15/+141
Reviewed-by: David King <dking@redhat.com> [smcv: Fix typo in cmake macro name] Signed-off-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=105165
2018-02-20cmake: Check for getrlimit, setrlimitSimon McVittie2-0/+4
This gives us feature parity with the Autotools build system for this particular area, and in particular means a system dbus-daemon built with cmake can expand its fd limit. Signed-off-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=105165
2018-02-20bus: raise fd limits before dropping privsDavid King1-2/+5
Startup ordering was changed in #92832 to ensure that SELinux audit messages could be sent. As a side effect, the raising of file descriptor limits was moved to after the dropping of root privileges, resulting in the limit change always failing. Move the raise_file_descriptor_limit() call to ensure that it is called before dropping root privileges. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=105165 Bug-RedHat: https://bugzilla.redhat.com/show_bug.cgi?id=1529044 [smcv: Call raise_file_descriptor_limit() even if !context->user] Reviewed-by: Simon McVittie <smcv@collabora.com>
2018-02-20Update NEWS for fd.o #101899Simon McVittie1-1/+6
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-02-16test/containers: Test the new header fieldSimon McVittie1-0/+118
Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101899
2018-02-16containers: Add a method to ask to be sent the connection instance headerSimon McVittie5-1/+78
Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101899
2018-02-16DBusMessage: Add a header field for the container instanceSimon McVittie6-3/+76
In the bus daemon, don't pass through the container instance path: if there's any value here at all, we want to be able to guarantee that we sent it (in a later commit). Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101899
2018-02-16bus_transaction_send: Take sender and destination connectionsSimon McVittie3-17/+18
We'll need this if we want to stamp optional header fields on the message according to the preferences of the recipient(s). Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101899