Commit Graph

6429 Commits

Author SHA1 Message Date
Philip Withnall
217f1ea3fb Merge branch 'wip/tintou/gdesktopappinfo-nullable' into 'master'
gdesktopappinfo: Add several nullable annotation to GAppInfo getters

See merge request GNOME/glib!1463
2020-05-07 10:31:53 +00:00
Philip Withnall
e4e875a91f Merge branch 'wip/smcv/credentials-docs' into 'master'
GCredentials documentation fixes

See merge request GNOME/glib!1456
2020-05-07 10:29:21 +00:00
Philip Withnall
5bef5628f5 Merge branch 'mcatanzaro/verify-chain-docs' into 'master'
Improve documentation of g_tls_database_verify_chain()

See merge request GNOME/glib!1475
2020-05-07 09:48:11 +00:00
Corentin Noël
0663a9bd56 gdesktopappinfo: Add several nullable annotation to GAppInfo getters
Some functions can return a NULL GAppInfo when the conditions given as arguments are not met.
2020-05-07 10:30:39 +01:00
Simon McVittie
e33b0d0410 GCredentials: Document when NETBSD_UNPCBID was added
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-05-07 10:25:14 +01:00
Simon McVittie
3e61acddc5 GCredentials: Format C library type names as code
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-05-07 10:25:14 +01:00
Philip Withnall
f9ab23465e Merge branch 'mcatanzaro/client-connection-validation-flags' into 'master'
Improve documentation of client connection validation flags

See merge request GNOME/glib!1479
2020-05-07 08:53:38 +00:00
Michael Catanzaro
33c9c305e3 Improve documentation of g_tls_database_verify_chain()
It is critical to mention how the identity parameter is expected to be
handled. In particular, if identity is not passed, then the identity of
the server certificate will not be checked at all. This is in contrast
to the connection-level APIs, which are supposed to be fail-safe. The
database and certificate-level APIs are more manual.
2020-05-07 09:52:47 +01:00
Michael Catanzaro
407b86afb8 Improve documentation of client connection validation flags
Validation fails if ANY of the flags are set. Not if they're ALL set.
This is obvious and no programmer would be confused, but let's fix it
anyway.
2020-05-05 13:58:07 -05:00
Philip Withnall
662771464a gdbusauthmechanismsha1: Reduce syscalls from ensure_keyring_directory()
There’s no need to call `access()` and then `stat()` on the keyring
directory to check that it exists, is a directory, and has the right
permissions. Just call `stat()`.

This eliminates one potential TOCTTOU race in this code.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1954
2020-05-05 16:07:32 +01:00
Philip Withnall
ed81cbc9b5 gdbusauthmechanismsha1: Fix race in keyring_acquire_lock()
There was a time-of-check-to-time-of-use (TOCTTOU) race in the keyring
lock code, where it would check the existence of the lock file using
`access()`, then proceed to call `open(O_CREAT | O_EXCL)` to try and
create the lock file once `access()` showed that it didn’t exist.

The problem is that, because this is happening in a shared directory
(`~/.dbus-keyrings`), another process could quite legitimately create
the lock file in the meantime.

Instead, unconditionally call `open()` and ignore errors from it (which
will be returned if the lock file already exists) until it succeeds (or
the code times out).

This eliminates the TOCTTOU race, and simplifies the timeout behaviour
so there aren’t two loops (check for existence, try to create)
happening. It brings this code in line with what dbus.git does (see
`_dbus_keyring_lock()`).

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1954
2020-05-05 16:07:32 +01:00
Philip Withnall
d6bab03150 gdbusauthmechanismsha1: Fix keyring lock file permissions
Why should it have the sticky bit set? dbus.git sets permissions 0600;
so should GLib.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-05 16:07:32 +01:00
Philip Withnall
f4dc46db45 gdbusauthmechanismsha1: Fix return type in precondition guards
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-05 16:07:32 +01:00
Philip Withnall
6bf221c441 tests: Isolate directory access for gdbus-server-auth test
When multiple tests were run in parallel, this would race on its access
to `~/.dbus-keyrings` to authenticate with the D-Bus server, since the
keyring directory was not appropriately sandboxed to the unit test.

Use `G_TEST_OPTION_ISOLATE_DIRS` to automatically isolate each unit
test’s directory usage.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1954
2020-05-05 16:07:32 +01:00
Philip Withnall
6978a4f87a tests: Fix a memory leak in gdbus-server-auth
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-05 16:07:32 +01:00
Simon McVittie
da84e9eb26 Merge branch 'wip/pwithnall/2092-stupid-dbus-tests-again' into 'master'
tests: Fix remaining race in gdbus-connection filter test

Closes #1957 and #2092

See merge request GNOME/glib!1476
2020-05-05 14:52:09 +00:00
Philip Withnall
2f171d0ed4 tests: Fix remaining race in gdbus-connection filter test
Commit 721e385 left one remaining race in the filter test, with a
comment associated with it. Unfortunately, the (seemingly unrelated)
changes in #1841 to `GCancellable` seem to have made this remaining race
a lot more likely to fail on FreeBSD than before.

What’s likely to have happened (although I was unable to reproduce the
failure, due to not having a FreeBSD system; I was only able to
reproduce the problem as a 3/1000 failure on Linux, which is still worth
fixing) is that the atomic write of the `FilterData.serial` to be
expected by the filter function sometimes happened after the filter
function had executed, so the expected message was dropped and didn’t
result in an update to the `FilterData` state.

Rework the test so that instead of setting some expectations (on
`FilterData`) in one thread and then checking them in another thread,
the worker thread just unconditionally returns messages from the filter
function to the main thread, and then the main thread checks whether the
expected one has been filtered.

With this change applied, the `gdbus-connection` test passes 5000 times
in a row for me, on Linux; and doesn’t seem to fail any more on the
FreeBSD CI machines over a few runs. (Previously it failed on 4/5 runs.)

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #2092
Fixes: #1957
2020-05-05 13:29:29 +01:00
Philip Withnall
1e598b98e3 Merge branch 'desktop-search-docs' into 'master'
gdesktopappinfo: Note that search results are not filtered

See merge request GNOME/glib!1455
2020-05-05 09:21:18 +00:00
Philip Withnall
5314a20389 gdesktopappinfo: Note that search results are not filtered
Mention in the documentation that (presumably for performance reasons)
the search results from `g_desktop_app_info_search()` are not filtered
by executable presence or hidden attribute.

Perhaps they should be in future, but for now we should at least
document it.

Spotted by Will Thompson.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-05 09:29:50 +01:00
Philip Withnall
fecaa5a5ea Merge branch 'imports' into 'master'
Don't fail a test if optional dependencies are not present

Closes #2083

See merge request GNOME/glib!1448
2020-05-01 17:05:05 +00:00
Martin Storsjö
6cae01c2f5 Silence clang errors about -Wformat-nonliteral due to missing intermediate attributes
By default, meson builds glib with -Werror=format=2, which
implies -Werror=format-nonliteral. With these flags, clang errors
out on e.g. the g_message_win32_error function, due to "format
string is not a string literal". This function takes a format
string, and passes the va_list of the arguments onwards to
g_strdup_vprintf, which is annotated with printf attributes.

When passing a string+va_list to another function, GCC doesn't warn
with -Wformat-nonliteral. Clang however does warn, unless the
functions themselves (g_message_win32_error and set_error) are decorated
with similar printf attributes (to force the same checks upon the
caller) - see
https://clang.llvm.org/docs/AttributeReference.html#format
for reference.

Adding these attributes revealed one existing mismatched format string
(fixed in the preceding commit).
2020-04-27 16:26:04 +03:00
Martin Storsjö
5ed1e39865 gregistrysettings: Fix a mismatched error format string 2020-04-27 16:26:04 +03:00
Ross Burton
2709d5e1bb gio/tests/memory-monitor-*.py.in: skip if 3rd party modules not available
The GIO tests memory-monitor-dbus and memory-monitor-portal use a number
of third party Python modules that may not be present when running the
test case.

Instead of failing due to missing imports, catch the ImportError and
mock a test case that skips.  This can't use the usual unittest.skip
logic because the test case class itself uses a 3rd party module.

Closes #2083.
2020-04-23 15:01:25 +01:00
Philip Withnall
de8708cd95 Merge branch 'wip/oholy/fast-content-type' into 'master'
gfile: Fallback to fast-content-type if content-type is not set

See merge request GNOME/glib!1442
2020-04-14 15:48:43 +00:00
Philip Withnall
fa76bde252 Merge branch 'tap' into 'master'
gio: use TAPTestRunner in the memory monitor tests

See merge request GNOME/glib!1443
2020-04-09 14:33:09 +00:00
Ross Burton
1fcd32a159 gio: use TAPTestRunner in the memory monitor tests
There are two memory monitor tests that use Python's unittest module directly,
but GLib tests should be outputting TAP.  Use the embedded TAPTestRunner to
ensure that TAP is output for these tests too.
2020-04-09 14:55:39 +01:00
Philip Withnall
683cf4c642 Merge remote-tracking branch 'gvdb/master' into update-gvdb
Bring in uninitialised memory fixes from
https://gitlab.gnome.org/GNOME/gvdb/issues/2.
2020-04-09 13:10:30 +01:00
Philip Withnall
82a557502d Merge branch '1841-cancellable-race-fix' into 'master'
Resolve "Signal handler disconnection race when finalising GCancellableSource"

Closes #1841

See merge request GNOME/glib!1400
2020-04-09 12:00:52 +00:00
Ondrej Holy
461052f66e gfile: Fallback to fast-content-type if content-type is not set
The G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE attribute doesn't have to be
always set. See https://gitlab.gnome.org/GNOME/gvfs/-/merge_requests/68
for more details. In that case, the g_file_query_default_handler function
fails with the "No application is registered as handling this file" error.
Let's fallback to the "standard::fast-content-type" attribute instead to
fix issues when opening such files.

https://gitlab.gnome.org/GNOME/nautilus/-/issues/1425
2020-04-07 14:56:49 +02:00
Xavier Claessens
10280deebd Meson: Override every dependency glib provides
Meson 0.54.0 added a new method meson.override_dependency() that must be
used to ensure dependency consistency. This patch ensures a project that
depends on glib will never link to a mix of system and subproject
libraries. It would happen in such cases:

The system has glib 2.40 installed, and a project does:
dependency('glib-2.0', version: '>=2.60',
  fallback: ['glib', 'glib_dep'])
dependency('gobject-2.0')

The first call will configure glib subproject because the system libglib
is too old, but the 2nd call will return system libgobject.

By overriding 'gobject-2.0' dependency while configuring glib subproject
during the first call, meson knows that on the 2nd call it must return
the subproject dependency instead of system dependency.

This also has the nice side effect that with Meson >0.54.0 an
application depending on glib can declare the fallback without knowing
the dependency variable name: dependency('glib-2.0', fallback: 'glib').
2020-04-05 00:34:04 -04:00
Sebastian Dröge
dde780fd1b Merge branch '2081-dbus-error-messages' into 'master'
gdbusmessage: Fix swapped signatures in error messages

Closes #2081

See merge request GNOME/glib!1435
2020-04-03 12:35:58 +00:00
Sebastian Dröge
5a540c8bca Merge branch 'dbus-signal-sender-nullability' into 'master'
gdbusconnection: Clarify nullability of SignalInstance.sender

See merge request GNOME/glib!1434
2020-04-03 12:11:58 +00:00
Sebastian Dröge
87cd6a4a19 Merge branch 'fix-buildtype-usage' into 'master'
meson: Fix buildtype usage

See merge request GNOME/glib!1433
2020-04-03 11:58:56 +00:00
Philip Withnall
8f938ebe27 gdbusmessage: Fix swapped signatures in error messages
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #2081
2020-04-03 12:42:49 +01:00
Philip Withnall
5a74c2f445 gdbusconnection: Clarify nullability of SignalInstance.sender
Following on from !1425.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-04-03 12:16:49 +01:00
Nirbheek Chauhan
b462e2c80c meson: Use the b_vscrt option for selecting the CRT
This option has been available since 0.48, and we should use it
instead of only guessing based on buildtype.
2020-04-03 16:39:22 +05:30
Corentin Noël
565ba0dbd1 gdbusconnection: GDBusSignalCallback can have a NULL sender_name
On a peer GDBusConnection, the returned sender_name can be NULL
2020-04-03 08:01:44 +02:00
Philip Withnall
f6ed9503d0 gicon: Clarify GVariant refcounting in docs
Slightly unexpectedly, `g_icon_serialize()` doesn’t produce a floating
`GVariant`, it produces one with full ownership and returns that. That’s
not the convention for `GVariant` return values from functions which
build variants, but there’s nothing we can do to change this now as that
would be an API break.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-03-31 14:27:00 +01:00
Philip Withnall
721e385593 tests: Use atomics for shared data in gdbus-connection test
D-Bus filter functions run in a worker thread. The `gdbus-connection`
test was sharing a `FilterData` struct between the main thread and the
filter function, which was occasionally (on the order of 0.01% of test
runs) causing spurious test failures due to racing on reads/writes of
`num_handled`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #480
2020-03-17 15:22:04 +00:00
Philip Withnall
0d567c784d tests: Port gdbus-connection to use g_assert_*() rather than g_assert()
g_assert() can be compiled out with G_DISABLE_ASSERT, which renders the
test rather useless.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #480
2020-03-17 15:21:51 +00:00
Phil Clayton
1dfdb75073 ginetaddress, ginetsocketaddress: Add missing (nullable) annotations
In both modules, new_from_string() may return NULL.
2020-03-17 11:14:51 +00:00
Matthew Leeds
c1f8f06432 gapplication: Fix a minor typo in the documentation 2020-03-10 15:40:02 -07:00
Sebastian Dröge
711de654e2 Merge branch '1986-socks-version' into 'master'
gsocks5proxy: Fix SOCKS5 username/password authentication

Closes #1986

See merge request GNOME/glib!1391
2020-03-10 15:11:09 +00:00
Philip Withnall
267a245eec gsocks5proxy: Return G_IO_ERROR_PROXY_NEED_AUTH if anonymous auth fails
If a username and password are specified by the caller, `GSocks5Proxy`
tells the server that it supports anonymous *and* username/password
authentication, and the server can choose which it prefers.

Otherwise, `GSocks5Proxy` only says that it supports anonymous
authentication. If that’s not acceptable to the server, the code was
previously returning `G_IO_ERROR_PROXY_AUTH_FAILED`. That error code
doesn’t indicate to the caller that authentication might succeed were
they to provide a username and password.

Change the error handling to make that clearer. A fuller solution would
be to expose more of the method negotiation in the `GSocks5Proxy` API,
so that the caller can specify ahead of time which authentication
methods they want to use. That can follow in issue #2059 though.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1988
2020-03-10 11:38:43 +00:00
Sebastian Dröge
879f3cd0d2 Merge branch '2057-malloc-trim' into 'master'
gmemorymonitor: Mention malloc_trim() in the documentation

Closes #2057

See merge request GNOME/glib!1410
2020-03-09 20:37:20 +00:00
Philip Withnall
16c60289a4 gmemorymonitor: Mention malloc_trim() in the documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #2057
2020-03-09 20:07:43 +00:00
Patrick Griffis
455e6211cb gdummytlsconnection: Add missing overrides for ALPN properties 2020-03-06 19:26:13 -08:00
Philip Withnall
42c7e89228 Merge branch 'w32-fileinfo-mtime-usec' into 'master'
Support nanoseconds in stat timestamps on Windows

See merge request GNOME/glib!1329
2020-03-06 12:58:00 +00:00
Philip Withnall
28133feb4a Merge branch '2051-unix-output-stream-fsync' into 'master'
gunix{input|output}stream: Drop custom close_{async|finish}() methods

Closes #2051

See merge request GNOME/glib!1401
2020-03-04 15:35:47 +00:00
Philip Withnall
8f16a89817 Merge branch '2038-tls-connection-annotations' into 'master'
gtlsconnection: Add missing (nullable) annotations

Closes #2038

See merge request GNOME/glib!1368
2020-03-04 14:15:07 +00:00