summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* gobject: Allow install_properties with 1 GParamSpecwip/nielsdg/install-properties-singleNiels De Graef2019-10-291-1/+1
| | | | | | | | | `g_object_install_properties()` can be used to install multiple properties at once, _and_ to allow an optimization for property notification. Arguably, using it over `g_object_install_property()` is best practice. That being said, you can't use it if you have only a single property that is installed (yet), due to a precondition check for more than 1 pspecs.
* Merge branch '1912-gdbus-peer-test' into 'master'Simon McVittie2019-10-292-19/+54
|\ | | | | | | | | | | | | tests: Isolate directories in gdbus-peer test Closes #1912 See merge request GNOME/glib!1192
| * tests: Isolate directories in gdbus-peer testPhilip Withnall2019-10-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So that the tests all end up using separate `.dbus-keyring` directories, and hence not racing to create and acquire lock files, use `G_TEST_OPTION_ISOLATE_DIRS` to ensure they all run in separate disposable directories. This has the added benefit of meaning they don’t touch the developer’s actual `$HOME` directory. This reduces the false-failure rate of `gdbus-peer` by a factor of 9 for me on my local machine. Signed-off-by: Philip Withnall <withnall@endlessm.com> Fixes: #1912
| * tests: Move main loop and test GUID into test functions in gdbus-peerPhilip Withnall2019-10-281-8/+37
| | | | | | | | | | | | | | | | | | | | | | | | There’s actually no need for them to be global or reused between unit tests, so move them inside the test functions. This is one step towards eliminating shared state between the unit tests. Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #1912
| * gdbusauthmechanismsha1: Create .dbus-keyrings directory recursivelyPhilip Withnall2019-10-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | If the directory is overridden, for example when running tests, the parent directory of `.dbus-keyrings` (i.e. the fake `$HOME` directory) might not exist. Create it automatically. This should realistically not have an effect on non-test code. Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #1912
| * gdbusauthmechanismsha1: Remove unnecessary g_warning() callsPhilip Withnall2019-10-281-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | These can be hit in the tests (if multiple tests run in parallel are racing for `~/.dbus-keyrings/org_gtk_gdbus_general.lock` for a prolonged period) and will cause spurious test failures due to the use of `G_DEBUG=fatal-warnings`. Instead, allow the error messages to be inspected programmatically. Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #1912
* | Merge branch '1318-dbus-server-race' into 'master'Simon McVittie2019-10-291-22/+23
|\ \ | | | | | | | | | | | | | | | | | | gdbusserver: Keep a strong reference to the server in callbacks Closes #1318 See merge request GNOME/glib!1193
| * | gdbusserver: Keep a strong reference to the server in callbacksPhilip Withnall2019-10-281-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `on_run()` function could be executed in any worker thread from the `GThreadedSocketListener`, but didn’t previously hold a strong reference to the `GDBusServer`, which meant the server could be finalised in another thread while `on_run()` was still running. This was not ideal. Hold a strong reference to the `GDBusServer` while the socket listener is listening, i.e. between every paired call to `g_dbus_server_start()` and `g_dbus_server_stop()`. Signed-off-by: Philip Withnall <withnall@endlessm.com> Fixes: #1318
| * | gdbusserver: Delete socket and nonce file when stopping serverPhilip Withnall2019-10-281-13/+16
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than when finalising it. They should be automatically recreated if the server is re-started. This is important for ensuring that all externally visible behaviour of the `GDBusServer` is synchronised with calls to g_dbus_server_{start,stop}(). Finalisation of the server object could happen an arbitrarily long time after g_dbus_server_stop() is called. Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #1318
* | Merge branch 'issue1831' into 'master'Philip Withnall2019-10-285-6/+641
|\ \ | | | | | | | | | | | | | | | | | | Avoid race condition authenticating GDBusServer with libdbus client (#1831) Closes #1831 See merge request GNOME/glib!1176
| * | Add a test for GDBusServer authenticationSimon McVittie2019-10-282-1/+500
| | | | | | | | | | | | | | | | | | | | | | | | | | | In particular, if libbdus is available, we test interoperability with a libdbus client: see GNOME/glib#1831. Because that issue describes a race condition, we do each test repeatedly to try to hit the failing case. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * | GDBus: prefer getsockopt()-style credentials-passing APIsSimon McVittie2019-10-282-2/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conceptually, a D-Bus server is really trying to determine the credentials of (the process that initiated) a connection, not the credentials that the process had when it sent a particular message. Ideally, it does this with a getsockopt()-style API that queries the credentials of the connection's initiator without requiring any particular cooperation from that process, avoiding a class of possible failures. The leading '\0' in the D-Bus protocol is primarily a workaround for platforms where the message-based credentials-passing API is strictly better than the getsockopt()-style API (for example, on FreeBSD, SCM_CREDS includes a process ID but getpeereid() does not), or where the getsockopt()-style API does not exist at all. As a result libdbus, the reference implementation of D-Bus, does not implement Linux SCM_CREDENTIALS at all - it has no reason to do so, because the SO_PEERCRED socket option is equally informative. This change makes GDBusServer on Linux more closely match the behaviour of libdbus. In particular, GNOME/glib#1831 indicates that when a libdbus client connects to a GDBus server, recvmsg() sometimes yields a SCM_CREDENTIALS message with cmsg_data={pid=0, uid=65534, gid=65534}. I think this is most likely a race condition in the early steps to connect: client server connect accept send '\0' <- race -> set SO_PASSCRED = 1 receive '\0' If the server wins the race: client server connect accept set SO_PASSCRED = 1 send '\0' receive '\0' then everything is fine. However, if the client wins the race: client server connect accept send '\0' set SO_PASSCRED = 1 receive '\0' then the kernel does not record credentials for the message containing '\0' (because SO_PASSCRED was 0 at the time). However, by the time the server receives the message, the kernel knows that credentials are desired. I would have expected the kernel to omit the credentials header in this case, but it seems that instead, it synthesizes a credentials structure with a dummy process ID 0, a dummy uid derived from /proc/sys/kernel/overflowuid and a dummy gid derived from /proc/sys/kernel/overflowgid. In an unconfigured GDBusServer, hitting this race condition results in falling back to DBUS_COOKIE_SHA1 authentication, which in practice usually succeeds in authenticating the peer's uid. However, we encourage AF_UNIX servers on Unix platforms to allow only EXTERNAL authentication as a security-hardening measure, because DBUS_COOKIE_SHA1 relies on a series of assumptions including a cryptographically strong PRNG and a shared home directory with no write access by others, which are not necessarily true for all operating systems and users. EXTERNAL authentication will fail if the server cannot determine the client's credentials. In particular, this caused a regression when CVE-2019-14822 was fixed in ibus, which appears to be resolved by this commit. Qt clients (which use libdbus) intermittently fail to connect to an ibus server (which uses GDBusServer), because ibus no longer allows DBUS_COOKIE_SHA1 authentication or non-matching uids. Signed-off-by: Simon McVittie <smcv@collabora.com> Closes: https://gitlab.gnome.org/GNOME/glib/issues/1831
| * | credentials: Invalid Linux struct ucred means "no information"Simon McVittie2019-10-281-3/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Linux, if getsockopt SO_PEERCRED is used on a TCP socket, one might expect it to fail with an appropriate error like ENOTSUP or EPROTONOSUPPORT. However, it appears that in fact it succeeds, but yields a credentials structure with pid 0, uid -1 and gid -1. These are not real process, user and group IDs that can be allocated to a real process (pid 0 needs to be reserved to give kill(0) its documented special semantics, and similarly uid and gid -1 need to be reserved for setresuid() and setresgid()) so it is not meaningful to signal them to high-level API users. An API user with Linux-specific knowledge can still inspect these fields via g_credentials_get_native() if desired. Similarly, if SO_PASSCRED is used to receive a SCM_CREDENTIALS message on a receiving Unix socket, but the sending socket had not enabled SO_PASSCRED at the time that the message was sent, it is possible for it to succeed but yield a credentials structure with pid 0, uid /proc/sys/kernel/overflowuid and gid /proc/sys/kernel/overflowgid. Even if we were to read those pseudo-files, we cannot distinguish between the overflow IDs and a real process that legitimately has the same IDs (typically they are set to 'nobody' and 'nogroup', which can be used by a real process), so we detect this situation by noticing that pid == 0, and to save syscalls we do not read the overflow IDs from /proc at all. This results in a small API change: g_credentials_is_same_user() now returns FALSE if we compare two credentials structures that are both invalid. This seems like reasonable, conservative behaviour: if we cannot prove that they are the same user, we should assume they are not. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * | gcredentialsprivate: Document the various private macrosSimon McVittie2019-10-281-0/+59
| | | | | | | | | | | | Signed-off-by: Simon McVittie <smcv@collabora.com>
* | | Merge branch 'ci-libdbus' into 'master'Simon McVittie2019-10-282-0/+2
|\ \ \ | | | | | | | | | | | | | | | | ci: Add libdbus development files to CI Docker images See merge request GNOME/glib!1177
| * | | ci: Add libdbus development files to CI Docker imagesSimon McVittie2019-10-212-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | We use these to test interoperability between libdbus and GDBus. Signed-off-by: Simon McVittie <smcv@collabora.com>
* | | | Merge branch '954-spawn-poll' into 'master'Simon McVittie2019-10-281-14/+13
|\ \ \ \ | |_|_|/ |/| | | | | | | | | | | | | | | | | | | gspawn: Port to g_poll() from select() Closes #954 See merge request GNOME/glib!1183
| * | | gspawn: Port to g_poll() from select()Philip Withnall2019-10-251-14/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes the limitation of select() that only FDs with values lower than FD_SETSIZE can be used. Previously, if the out/err pipe FDs had high values (which could happen if a large process, like Firefox, was spawning subprocesses while having a lot of FDs open), GLib would abort due to an assertion failure in libc. Signed-off-by: Philip Withnall <withnall@endlessm.com> Fixes: #954
* | | | Merge branch '1916-objcopy-cross-compilation' into 'master'Simon McVittie2019-10-283-2/+6
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tests: Use objcopy from the cross-compilation file, if configured Closes #1916 See merge request GNOME/glib!1188
| * | | | docs: Add objcopy to example cross-compilation filePhilip Withnall2019-10-282-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #1916
| * | | | tests: Use objcopy from the cross-compilation file, if configuredPhilip Withnall2019-10-281-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Otherwise we’ll end up using the host’s `objcopy`, which will output object files in the wrong format. Signed-off-by: Philip Withnall <withnall@endlessm.com> Fixes: #1916
* | | | | Merge branch '1897-assert-cmpmem-nonnull' into 'master'Simon McVittie2019-10-281-1/+1
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gtestutils: Add additional non-NULL check in g_assert_cmpmem() Closes #1897 See merge request GNOME/glib!1191
| * | | | | gtestutils: Add additional non-NULL check in g_assert_cmpmem()Philip Withnall2019-10-281-1/+1
| | |_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The compiler can’t work out from the combination of other conditions that it’s not possible for (m2 == NULL) to hold true when memcmp() is called, so add an explicit condition. Signed-off-by: Philip Withnall <withnall@endlessm.com> Fixes: #1897
* | | | | Merge branch '1911-flags-enums-leak' into 'master'Emmanuele Bassi2019-10-281-2/+8
|\ \ \ \ \ | |/ / / / |/| | | | | | | | | | | | | | gparamspecs: Fix type class leaks on error handling paths See merge request GNOME/glib!1189
| * | | | gparamspecs: Fix type class leaks on error handling pathsPhilip Withnall2019-10-281-2/+8
| |/ / / | | | | | | | | | | | | | | | | | | | | Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #1911
* | | | Merge branch 'fbsd_build' into 'master'Philip Withnall2019-10-281-0/+16
|\ \ \ \ | |/ / / |/| | | | | | | | | | | Update documentation with FreeBSD build instructions See merge request GNOME/glib!1120
| * | | Update documentation with FreeBSD build instructionsrim2019-09-301-0/+16
| | | |
* | | | Merge branch 'ossfuzz-10286-variant-parser-recursion' into 'master'Philip Withnall2019-10-253-18/+65
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | gvariant: Limit recursion in g_variant_parse() See merge request GNOME/glib!1173
| * | | | gvariant: Limit recursion in g_variant_parse()Philip Withnall2019-10-183-18/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The token parsing done by g_variant_parse() uses recursive function calls, so at some point it will hit the stack limit. As with previous changes to `GVariantType` parsing (commit 7c4e6e9fbe4), limit the level of nesting of containers parsed by g_variant_parse() to something reasonable. We guarantee 64 levels of nesting, which should be enough for anyone, and is the same as what we guarantee for types. oss-fuzz#10286 Signed-off-by: Philip Withnall <withnall@endlessm.com>
* | | | | Merge branch 'gtimezone' into 'master'Philip Withnall2019-10-251-2/+31
|\ \ \ \ \ | |_|_|/ / |/| | | | | | | | | | | | | | syscall flood on every time*() function call See merge request GNOME/glib!1105
| * | | | gtimezone: Cache UTC and local TZ indefinitelyrim2019-10-251-2/+31
|/ / / / | | | | | | | | | | | | Previously, these GTimeZone objects were being cached in the `time_zones` cache, but dropped from it when their final ref was dropped (which was frequently). That meant additional reads of `/etc/localtime` next time they were created, which was noticeable on profiles. Keep a permanent ref to the UTC and local timezones.
* | | | Merge branch 'source-thread-safety-docs' into 'master'Sebastian Dröge2019-10-251-3/+17
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | gmain: Clarify thread safety of some common GSource functions See merge request GNOME/glib!1181
| * | | | gmain: Clarify thread safety of some common GSource functionsPhilip Withnall2019-10-251-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See https://stackoverflow.com/q/58555626/2931197. Signed-off-by: Philip Withnall <withnall@endlessm.com>
* | | | | Merge branch 'wip/hadess/fix-api-docs-typo' into 'master'Sebastian Dröge2019-10-251-1/+1
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | gio: Fix typo in URL See merge request GNOME/glib!1182
| * | | | | gio: Fix typo in URLBastien Nocera2019-10-251-1/+1
|/ / / / / | | | | | | | | | | | | | | | Left-over quote in URL.
* | | | | Merge branch 'main-context-pusher' into 'master'Sebastian Dröge2019-10-244-0/+120
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | gmain: Add GMainContextPusher convenience API See merge request GNOME/glib!983
| * | | | | gmain: Add GMainContextPusher convenience APIPhilip Withnall2019-10-234-0/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is like `GMutexLocker`, in that if you are able to use `g_autoptr()`, it makes popping a `GMainContext` off the thread-default main context stack easier when exiting a function. A few uses of `G_GNUC_{BEGIN,END}_IGNORE_DEPRECATIONS` are needed to avoid warnings when building apps against GLib with `GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_64`. Signed-off-by: Philip Withnall <withnall@endlessm.com>
| * | | | | glib: Ignore deprecations when declaring autocleanupsPhilip Withnall2019-10-231-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We may need to declare autocleanups for new types, which will be marked as ‘deprecated’ if the code which includes GLib doesn’t declare a high enough `GLIB_VERSION_MAX_ALLOWED`. Despite that, we still need to declare the autocleanups. Signed-off-by: Philip Withnall <withnall@endlessm.com>
* | | | | | Merge branch 'wip/smcv/array-memcpy-ub' into 'master'Sebastian Dröge2019-10-241-2/+2
|\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | array: Avoid use of memcpy(dest, NULL, 0) See merge request GNOME/glib!1180
| * | | | | | array: Avoid use of memcpy(dest, NULL, 0)Simon McVittie2019-10-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | glibc declares memcpy() with the first two arguments (the pointers) annotated as non-null via an attribute, which results in the undefined behaviour sanitizer considering it to be UB to pass a null pointer in the second argument, even if we are copying 0 bytes (and hence not actually dereferencing the pointer). This shows up in array-test when run with the undefined behaviour sanitizer. Signed-off-by: Simon McVittie <smcv@collabora.com>
* | | | | | | Merge branch 'wip/array-doc-comments' into 'master'Philip Withnall2019-10-242-4/+154
|\ \ \ \ \ \ \ | |/ / / / / / |/| | | | | | | | | | | | | | | | | | | | Improve GPtrArray doc-comments See merge request GNOME/glib!1179
| * | | | | | array: Add tests based on the g_ptr_array_sort[_with_data] doc-commentsSimon McVittie2019-10-242-0/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note that I deliberately haven't used g_autoptr here, because while we encourage GLib users to use g_autoptr in their own code, GLib itself still supports being compiled in environments like MSVC that can't support g_autoptr. Signed-off-by: Simon McVittie <smcv@collabora.com>
| * | | | | | array: Fix handling of user_data in doc-commentSimon McVittie2019-10-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The user_data for g_ptr_array_sort_with_data is passed directly, not with an extra layer of pointer like the data pointers. Signed-off-by: Simon McVittie <smcv@collabora.com> Fixes: 52c130f8
| * | | | | | array: Remove unnecessary casts from doc-commentsSimon McVittie2019-10-241-2/+2
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let's not encourage library users to sprinkle casts through their code when they don't need to. Signed-off-by: Simon McVittie <smcv@collabora.com> Fixes: 52c130f8
* | | | | | Update Catalan translationJordi Mas2019-10-231-2/+2
| |/ / / / |/| | | |
* | | | | Merge branch '1813-option-context-annotations' into 'master'Sebastian Dröge2019-10-221-2/+2
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | goption: Add missing (array) annotation to add_main_entries() Closes #1813 See merge request GNOME/glib!942
| * | | | | goption: Add missing (array) annotation to add_main_entries()Philip Withnall2019-06-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Philip Withnall <withnall@endlessm.com> Fixes: #1813
* | | | | | Merge branch '1836-dbus-connection-docs' into 'master'Sebastian Dröge2019-10-221-1/+1
|\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gdbusconnection: Clarify nullability in a documentation comment Closes #1836 See merge request GNOME/glib!1003
| * | | | | | gdbusconnection: Clarify nullability in a documentation commentPhilip Withnall2019-07-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The comment previously said ‘never %NULL’, but it wasn’t clear whether this meant `(not nullable)` or `(not optional)`. From looking at the code, it means `(not optional)`. Clarify things by removing the prose. The annotations themselves should be clear and explicit enough. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1836
* | | | | | | Merge branch 'testfilemonitor-leaks' into 'master'Sebastian Dröge2019-10-221-0/+2
|\ \ \ \ \ \ \ | |_|_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | Fix some minor leaks in testfilemonitor See merge request GNOME/glib!1167