Commit Graph

7216 Commits

Author SHA1 Message Date
Léo Stefanesco
497c511a98 Fix giomodule.cache being wrongly considered stale
In ostree based systems, such as flatpak and fedora silverblue, the
time of modification of every system file is epoch 0, including
giomodule.cache, which means that every module is loaded and unloaded
every time.

The solution is to use the change time of the file as well. In a typical
system, it is equal to the mtime, and in an ostree based system, since
the directory is mounted as read-only, the user cannot add a module and
we must assume that the cache file corresponds to the modules.
2020-07-03 15:16:33 +02:00
Philip Withnall
582ffcd6ea Merge branch 'cancellable-test-debugging' into 'master'
tests: Fix intermittent failure in GCancellableSource test

Closes #1764

See merge request GNOME/glib!1539
2020-06-25 13:02:18 +00:00
Ruslan Marchenko
44524b9daa Add g_(d)tls_connection_get_channel_binding_data calls and enums
* Add g_tls_connection_get_channel_binding_data API call
 * Add g_dtls_connection_get_channel_binding_data API call
 * Add get_binding_data method to GTlsConnection class
 * Add get_binding_data method to GDtlsConnection interface
 * Add GTlsChannelBindingType enum with tls-unique and
   tls-server-end-point types
 * Add GTlsChannelBindingError enum and G_TLS_CHANNEL_BINDING_ERROR
   quark
 * Add new API calls to documentation reference gio-sections-common
2020-06-25 12:40:34 +00:00
Philip Withnall
ee3216b31b tests: Iterate the GMainContext directly rather than using a GMainLoop
This speeds up the `cancellable` test a little by stopping waiting for
the threads to start up as soon as they have started, rather than after
an arbitrary timeout.

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

Helps: #1764
2020-06-25 13:12:51 +01:00
Philip Withnall
5e49d53cd5 tests: Use G_SOURCE_CONTINUE/G_SOURCE_REMOVE instead of booleans
This makes no functional difference, but clarifies the code a little.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-06-25 13:12:51 +01:00
Philip Withnall
a956b096af tests: Use atomics to access counter shared between threads
This should fix some sporadic test failures in this test, although I
can’t be sure as I was unable to reproduce the original failure.

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

Closes: #1764
2020-06-25 13:12:51 +01:00
Philip Withnall
5571aaa1c5 tests: Use g_test_message() rather than g_printerr() in cancellable test
This makes sure the message gets formatted correctly and sent to the
right log file.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-06-25 13:12:51 +01:00
Philip Withnall
5b12608157 tests: Fix intermittent failure in GCancellableSource test
It seems that allowing the GCancellable to be finalised in either the
main thread or the worker thread sometimes leads to crashes when running
on CI.

I cannot reproduce these crashes locally, and various analyses with
memcheck, drd and helgrind have failed to give any clues.

Fix this for this particular test case by deferring destruction of the
`GCancellable` instances until after the worker thread has joined.
That’s OK because this test is specifically checking a race between
`g_cancellable_cancel()` and disposal of a `GCancellableSource`.

The underlying bug remains unfixed, though, and I can only hope that we
eventually find a reliable way of reproducing it so it can be analysed
and fixed.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-06-25 13:12:51 +01:00
Philip Withnall
a63efa4291 tree: Fix various ableist language
In almost all cases, rewording the documentation/comments made things
more specific and a little clearer.

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

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1544#note_846645
2020-06-23 10:49:44 +01:00
Philip Withnall
97b5bc4a01 Merge branch 'wip/oholy/remote-attribute-fixes' into 'master'
Various GLocalFile fixes related to the filesystem::remote attribute

See merge request GNOME/glib!1534
2020-06-19 10:08:03 +00:00
Ondrej Holy
92c9960521 glocalfile: Add SMB on the list of remote filesystems
The G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE is set to TRUE only for NFS
filesystem types currently. Let's add also SMB filesystem types. This
also changes g_local_file_is_nfs_home function logic to handle only
NFS filesystems.
2020-06-19 11:35:09 +02:00
Ondrej Holy
a8f97cbe8e glocalfile: Rename g_local_file_is_remote
The g_local_file_is_remote function is misleading as it works only for
NFS filesystem types and only for locations in home directorly. Let's
rename it to g_local_file_is_nfs_home to make it obvious.
2020-06-19 11:34:42 +02:00
Ondrej Holy
f489f6c4ee glocalfile: Do not call statfs/statvfs several times
statfs/statvfs is called several times when querying filesystem info.
This is because the G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE attribute is set
over is_remote_fs function, which calls statfs/statvfs again. Let's use
the already known fstype instead of redundant statfs/statvfs calls.
This also changes g_local_file_is_remote implementation to use
g_local_file_query_filesystem_info to obtain fstype, which allows to
remove duplicated code from is_remote_fs function.
2020-06-19 11:34:40 +02:00
Michael Catanzaro
75359441cd Fix issue in GSocketAddressEnumerator documentation
We should stop iterating the enumerator the first time it returns NULL,
even if error is set.

Fixes #1982
2020-06-18 13:30:40 -05:00
Philip Withnall
39f047e821 gsocket: Add missing check_socket() checks
This makes no great difference, just increases robustness a bit.

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

Closes: #1339
2020-06-18 12:52:39 +01:00
Ondrej Holy
706dc6b5aa glocalfile: Fix G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE outside home
The G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE currently works only for locations
in the home directory. Let's make it work also for files outside the home
directory.
2020-06-18 13:12:07 +02:00
Ondrej Holy
d067b5390a glocalfile: Remove redundant private header
There are glocalfile.h and glocalfileprivate.h header files currently.
None of those header files is public, so it doesn't make sense to have
two private headers for glocalfile.c. Let's remove glocalfileprivate.h.
2020-06-18 13:12:06 +02:00
Ondrej Holy
387709338c glocalfile: Handle smb2 filesystem type
`G_FILE_ATTRIBUTE_FILESYSTEM_TYPE` is not set for CIFS mounts with
`vers=2.0` option, or newer. Add `smb2` to the list of known filesystems.
It is also reported by `stat -f`:
https://github.com/coreutils/coreutils/blob/master/src/stat.c
2020-06-18 13:12:06 +02:00
Philip Withnall
00bfb3ab44 tree: Fix various typos and outdated terminology
This was mostly machine generated with the following command:
```
codespell \
    --builtin clear,rare,usage \
    --skip './po/*' --skip './.git/*' --skip './NEWS*' \
    --write-changes .
```
using the latest git version of `codespell` as per [these
instructions](https://github.com/codespell-project/codespell#user-content-updating).

Then I manually checked each change using `git add -p`, made a few
manual fixups and dropped a load of incorrect changes.

There are still some outdated or loaded terms used in GLib, mostly to do
with git branch terminology. They will need to be changed later as part
of a wider migration of git terminology.

If I’ve missed anything, please file an issue!

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-06-12 15:01:08 +01:00
Michael Catanzaro
4db1336ff6 gtlsconnection: Improve documentation of peer-certificate[-errors]
In glib-networking#127, it was reported that we don't properly implement
the documented behavior of these properties. However, we cannot fix it
because libsoup relies on the implemented behavior, and it's hard to
change that without cascading breakage. The practical solution is to
adjust our documentation to match reality. There should be no downsides
to this, and compat risk of changing the documentation is much smaller
than risk of changing the implementation, so I think this is the best we
can make of an unfortunate situation. See glib-networking#127 for full
discussion and glib-networking#129 for the regression when we attempted
to match the documented behavior.
2020-06-10 09:56:47 -05:00
Simon McVittie
44c004c84e Normalize C source files to end with exactly one newline
Some editors automatically remove trailing blank lines, or
automatically add a trailing newline to avoid having a trailing
non-blank line that is not terminated by a newline. To avoid unrelated
whitespace changes when users of such editors contribute to GLib,
let's pre-emptively normalize all files.

Unlike more intrusive whitespace normalization like removing trailing
whitespace from each line, this seems unlikely to cause significant
issues with cherry-picking changes to stable branches.

Implemented by:

    find . -name '*.[ch]' -print0 | \
    xargs -0 perl -0777 -p -i -e 's/\n+\z//g; s/\z/\n/g'

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-06-10 09:48:02 +01:00
Avinash Sonawane
e91f4ac961 docs: Add (nullable) annotations 2020-06-05 18:40:37 +05:30
Руслан Ижбулатов
8651bee90f GWin32RegistryKey: Move assertions
While these assertions look right at the first glance,
they actually crash the program. That's because GObject
insists on initializing all construct-only properties
to their default values, which results in
g_win32_registry_key_set_property() being called multiple
times with NULL string, once for each unset property.

If "path" is actually set by the caller, a subsequent
call to set "path-utf16" to NULL will fail an assertion,
since absolute_path is already non-NULL.

With assertions moved the set-to-NULL calls bail out before
an assertion is made.
2020-06-05 10:31:25 +00:00
Sebastian Dröge
4556bf1e24 gthreadedsocketservice: Mark source_object of run signal as nullable 2020-06-02 13:40:54 +03:00
Nirbheek Chauhan
caec84ae1e Merge branch 'gdbus-codegen-exporting' into 'master'
Make symbols generated by gdbus-codegen exportable on Visual Studio-style builds

See merge request GNOME/glib!1452
2020-05-28 13:01:46 +00:00
Chun-wei Fan
a94f32f140 gdbus-object-manager-example: Fix build on Visual Studio
This ensures that we do really export the symbols for Visual
Studio-style builds, by using _GLIB_EXTERN to decorate the generated
prototypes and including config.h so that we are sure the symbols are
actually exported.
2020-05-28 17:20:22 +08:00
Chun-wei Fan
d955719f04 gdbus-codegen: Allow decorating symbols in headers
This adds three options to gdbus-codegen so that we may be able to
use a self-defined symbol decorator, such as _GLIB_EXTERN, to decorate
the generated prototypes, to be used possibly to export the symbols, if
needed.

The other two options allows including headers that are required for the
specified symbol decorator to be usable and preprocessor macros that are
required for the symbol decorator to be defined appropriately, also when
needed.
2020-05-28 17:20:22 +08:00
Chun-wei Fan
47716bcec9 glib-compile-resources: Fix exporting on Visual Studio
Have the generated .c code decorate the prototypes with "G_MODULE_EXPORT"
instead of "extern" when --internal is not being used, so that we also
export the symbols from the generated code on Visual Studio-style
compilers.  If --internal is used, we decorate the prototypes with
"G_GNUC_INTERNAL", as we did before.

Note that since the generated .c code does not attempt to include the
generated headers (if one is also generated), the gnerated headers are
still generated as they were before.
2020-05-23 10:35:05 +08:00
Philip Withnall
2ba0f14b52 Merge branch 'w32reg-mui' into 'master'
MUI capabilities for GWin32RegistryKey

See merge request GNOME/glib!1341
2020-05-22 16:21:41 +00:00
Руслан Ижбулатов
f77a6a1626 GWin32AppInfo: Drop read_resource_string(), use GWin32RegistryKey
Now GWin32RegistryKey can internally do the same thing that
read_resource_string() does, and more.
2020-05-22 14:17:12 +00:00
Sebastian Dröge
2730e5dcc3 Merge branch 'fix-file-test' into 'master'
tests: Speed up the file test and make it more reliable

See merge request GNOME/glib!1508
2020-05-22 10:54:58 +00:00
Philip Withnall
26c433d26c tests: Speed up the file test and make it more reliable
Sometimes this test was timing out due to the file monitor notifications
taking longer than the arbitrary 2s delay before ending the test and
checking its results at the end of `iclosed_cb()`.

Avoid that timing-dependence by ending the test when the expected file
monitor notifications are seen, or after a 10s timeout (if so, the test
is failed).

This makes the test run 4× faster in the normal case, as it’s no longer
waiting for a timeout to elapse if the file monitor notifications come
in sooner.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-22 11:05:27 +01:00
Philip Withnall
43969bf41a tests: Port file test 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>
2020-05-22 11:04:34 +01:00
Philip Withnall
9f27f49e34 tests: Speed up the cancellable test
The test added for #1841 spawned 100000 threads. That was fine on a
desktop machine, but on a heavily loaded CI machine, it could result in
large (and unpredictable) slowdowns, resulting in the test taking over
120s in about 1 in 5 runs, and hence failing that CI pipeline due to a
timeout. When passing normally on CI, the test would take around 90s.

Here’s a histogram of time per iteration on a failing (timed out) test
run. Each iteration is one thread spawn:

  Iteration duration (µs) | Frequency
  ------------------------+----------
                     ≤100 |     0
                  100–200 | 30257
                  200–400 | 13696
                  400–800 |  1046
                 800–1000 |   123
                1000–2000 |   583
                2000–4000 |  3779
                4000–8000 |  4972
               8000–10000 |  1027
              10000–20000 |  2610
              20000–40000 |   650
              40000–80000 |    86
             80000–100000 |    10
            100000–200000 |     2
                  >200000 |     0

There’s no actual need for the test to spawn 100000 threads, so rewrite
it to reuse a single thread, and pass new data to that thread.

Reverting the original commit (e4a690f5dd) reproduces the failure on
100 out of 100 test runs with this commit applied, so the test still
works.

The test now takes 3s, rather than 11s, to run on my computer, and has
passed when run with `meson test --repeat 1000 cancellable`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-20 17:21:14 +01:00
Руслан Ижбулатов
a22a15dc5a GWin32RegistryKey: add MUI capabilities to get_value()
An extra argument to g_win32_registry_key_get_value_w() and
g_win32_registry_key_get_value() indicates that RegLoadMUIStringW()
should be used instead of RegQueryValueExW(). It only works on
strings, and automatically resolves resource strings (the ones
that start with "@").

The extra argument is needed to find resource DLLs that are only
specified by their relative name.
2020-05-20 14:23:49 +00:00
Dr. Michael Lauer
ec2f60a008 gio: add gcredential support for macOS
[smcv: Apply my review feedback from
<https://bugzilla.gnome.org/show_bug.cgi?id=668866>]

Co-authored-by: Simon McVittie <smcv@collabora.com>
Resolves: https://gitlab.gnome.org/GNOME/glib/issues/507
2020-05-07 14:19:16 +01:00
Simon McVittie
05cb229082 GCredentials: Add the concept of credentials that lack the process ID
struct xucred on macOS doesn't have the process ID, only the user ID
and groups.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-05-07 14:19:16 +01:00
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
Philip Withnall
0a2dc161c0 gunix{input|output}stream: Drop custom close_{async|finish}() methods
They were not actually asynchronous, and hence caused blocking in the
main thread. Deleting them means the default implementation of those
vfuncs is used, which runs the sync implementation in a thread — which
is what is wanted here.

Spotted by Benjamin Otte.

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

Fixes: #2051
2020-03-02 13:55:00 +00:00
Philip Withnall
b3b814f9c2 Merge branch 'wip/smcv/skip-low-mem' into 'master'
tests: Skip MemoryMonitor test if GObject-Introspection is too old

See merge request GNOME/glib!1397
2020-03-02 10:26:50 +00:00
Philip Withnall
e4a690f5dd gcancellable: Fix minor race between GCancellable and GCancellableSource
There’s a minor race condition between cancellation of a `GCancellable`,
and disposal/finalisation of a `GCancellableSource` in another thread.

Thread A                               Thread B
 g_cancellable_cancel(C)
 →cancellable_source_cancelled(C, S)
                                       g_source_unref(S)
                                       cancellable_source_dispose(S)
 →→g_source_ref(S)
 →→# S is invalid at this point; crash

Thankfully, the `GCancellable` sets `cancelled_running` while it’s
emitting the `cancelled` signal, so if `cancellable_source_dispose()` is
called while that’s high, we know that the thread which is doing the
cancellation has already started (or is committed to starting) calling
`cancellable_source_cancelled()`.

Fix the race by resurrecting the `GCancellableSource` in
`cancellable_source_dispose()`, and signalling this using
`GCancellableSource.resurrected_during_cancellation`. Check for that
flag in `cancellable_source_cancelled()` and ignore cancellation if it’s
set.

The modifications to `resurrected_during_cancellation` and the
cancellable source’s refcount have to be done with `cancellable_mutex`
held so that they are seen atomically by each thread. This should not
affect performance too much, as it only happens during cancellation or
disposal of a `GCancellableSource`.

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

Fixes: #1841
2020-02-29 20:15:39 +00:00
Philip Withnall
4093321c9a tests: Use g_assert_*() in cancellable test rather than g_assert()
`g_assert()` is compiled out if `G_DISABLE_ASSERT` is defined, and
`g_assert_*()` gives more detailed failure messages.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-28 16:06:46 +00:00
Sebastian Dröge
2cad4fb5bf Merge branch 'wip/hadess/avoid-all-remote-files-crash' into 'master'
gcontenttype: Fix crash in _get_generic_icon_name()

See merge request GNOME/glib!1398
2020-02-28 14:49:51 +00:00
Bastien Nocera
a7181ad397 gcontenttype: Fix crash in _get_generic_icon_name()
Guard against NULL type being passed to
g_content_type_get_generic_icon_name() just as we protect
g_content_type_get_description(), otherwise it will cause a crash.

See https://gitlab.gnome.org/GNOME/gtk/issues/2482
2020-02-28 15:09:50 +01:00
Jan Alexander Steffens (heftig)
7bdcfcf73a
tests: Move memory_monitor_tests under installed_tests_enabled
So they're not installed when the latter is disabled.
2020-02-28 14:10:25 +01:00
Simon McVittie
fdbd9ed7f7 tests: Skip MemoryMonitor test if GObject-Introspection is too old
Distributions will likely want to update GLib before
GObject-Introspection, to avoid circular dependencies.

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-02-28 12:42:36 +00:00
Philip Withnall
423b2bbc95 gsocks5proxy: Fix SOCKS5 username/password authentication
It was checking for the main SOCKS5 version number, rather than the
subnegotiation version number. The username/password authentication
protocol is described in https://tools.ietf.org/html/rfc1929.

Spotted and diagnosed by lovetox.

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

Fixes: #1986
2020-02-27 12:16:41 +00:00
Simon McVittie
70c5fd53e9 Merge branch 'test-dbus-posix_spawn' into 'master'
gtestdbus: Use posix_spawn() to spawn dbus-daemon

See merge request GNOME/glib!1388
2020-02-26 13:57:47 +00:00
Philip Withnall
eb867c3d2f gtestdbus: Use posix_spawn() to spawn dbus-daemon
This speeds up tests which use `GTestDBus` significantly.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-26 10:45:45 +00:00
Philip Withnall
99a325356d tests: Fix a compiler warning about string+int arithmetic
Clang warns about string+int not appending to the string (to try and
catch newbie mistakes). While this test didn’t expect that to happen, it
was substituting the same constant string in multiple places for no good
reason. Switch to a single static const string, which should also fix
the compiler warning.

We have to define the string length since it’s used in various
stack-allocated array lengths. This is the easiest fix without more
major refactoring of the test to be less 90s.

Also make things a bit more static.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 16:18:58 +00:00
Sebastian Dröge
2b06b6498b Merge branch 'speed-up-actions-test' into 'master'
tests: Speed up the GIO actions test

See merge request GNOME/glib!1298
2020-02-24 13:16:09 +00:00
Sebastian Dröge
1b06461104 Merge branch '1515-gdbus-threading-timeout' into 'master'
tests: Bump the refcount timeout in gdbus-threading

See merge request GNOME/glib!1382
2020-02-24 13:11:40 +00:00
Sebastian Dröge
e3c69acf01 Merge branch '938-gdbus-tool-message-bus-connections' into 'master'
gdbus-tool: Require message bus connections for most commands

Closes #938

See merge request GNOME/glib!926
2020-02-24 12:53:57 +00:00
Philip Withnall
238c774970 tests: Reduce iteration counts on gdbus-threading test
When running under CI, each iteration takes so long that the total test
time is around 200s. If the CI runner is highly loaded, this can tip it
over the timeout of 360s.

Reduce the iteration counts unless running the test thoroughly.

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

Helps: #1515
2020-02-24 12:24:02 +00:00
Philip Withnall
cfe8d423d4 tests: Bump the refcount timeout in gdbus-threading
Currently the test waits for 1s before deciding that a refcount has been
leaked. But slow test machines might take longer than that between
scheduling different threads to sort out the refcount, so increase the
timeout.

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

Helps: #1515
2020-02-24 11:37:36 +00:00
Emmanuele Bassi
8bf3a662c8 Merge branch 'gapplication-docs-typo' into 'master'
gapplication: Fix a minor typo in the documentation

See merge request GNOME/glib!1299
2020-02-24 11:20:51 +00:00
Philip Withnall
177851c9b7 gdbus-tool: Require message bus connections for most commands
Previously, if the `--address` option was passed to `gdbus-tool`, it
would treat the connection as peer to peer. However, almost all the
commands `gdbus-tool` supports require a message bus (introspection,
calling a method with a destination, etc.). Only the `signal` command
would ever work on a peer-to-peer connection (if no `--dest` was
specified).

So change the `--address` option to generally create message bus
connections.

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

Fixes: #938
2020-02-24 11:17:31 +00:00
Philip Withnall
f04e3077d9 gapplication: Fix a minor typo in the documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 10:20:33 +00:00
Philip Withnall
b604f008f7 gapplication: Improve formatting of variant formats in documentation
This makes the documentation a little easier to read.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 10:16:38 +00:00
Philip Withnall
325f1e3eb5 gapplication: Consistently use non-copying variant formats in docs
In particular, this fixes the invalid format string `&as`.

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

Fixes: #2044
2020-02-24 10:16:38 +00:00
Philip Withnall
55eb360c65 tests: Skip g-file-info-filesystem-readonly test if bindfs fails
bindfs is part of the setup process, so if it fails (as can happen if
the `fuse` kernel module has not been loaded — not much we can do about
that) then skip the test.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 09:08:20 +00:00
Philip Withnall
ab285899a6 gdbusconnection: Document main context iteration for unsubscriptions
Add a note to the documentation of
`g_dbus_connection_signal_unsubscribe()`, `g_bus_unwatch_name()` and
`g_bus_unown_name()` warning about the need to continue iterating the
caller’s thread-default `GMainContext` until the
unsubscribe/unwatch/unown operation is complete.

See the previous few commits and #1515 for an idea of the insidious bugs
that can be caused by not iterating the `GMainContext` until
everything’s synchronised.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 09:03:02 +00:00
Philip Withnall
0f0af5ae3a tests: Mark gdbus-threading as non-flaky any more
See previous commits and #1515.

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

Fixes: #1515
2020-02-24 09:03:02 +00:00
Philip Withnall
f74a987d21 tests: Use TestSignal rather than NameOwnerChanged to test signals
When testing that signals are delivered to the correct thread, and are
delivered the correct number of times, call `EmitSignal()` on the
`gdbus-testserver` to trigger a signal emission, and listen for that.

Previously, the code listened for `NameOwnerChanged` and connected to
the bus again to trigger emission of that. The problem with that is that
other things happening on the bus (for example, an old
`gdbus-testserver` instance disconnecting) can cause `NameOwnerChanged`
signal emissions. Sometimes, the `gdbus-threading` test was failing the
`signal_count == 1` assertion due to receiving more than one
`NameOwnerChanged` emission.

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

Helps: #1515
2020-02-24 09:03:02 +00:00
Philip Withnall
cd0ab355cd tests: Use GMainContext instead of GMainLoop in gdbus-threading
This is equivalent, but makes the loop exit conditions a little clearer,
since they’re actually in a `while` statement, rather than being a
`g_main_loop_quit()` call in a callback somewhere else in the file.

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

Helps: #1515
2020-02-24 09:03:02 +00:00
Philip Withnall
79ef610f03 tests: Wait until unsubscribing from a signal has completed
As with the previous commit, don’t stop iterating the `context` in
`test_delivery_in_thread_func()` until the unsubscription from a signal
is complete, and hence there’s a guarantee that no callbacks are pending
in the `thread_context`.

This commit uses the `GDestroyNotify` for
`g_dbus_connection_signal_subscribe()` as a synchronisation message from
the D-Bus worker thread to the `test_delivery_in_thread_func()` thread
to notify of signal unsubscription.

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

Fixes: #1515
2020-02-24 09:01:03 +00:00
Philip Withnall
af6dbece87 tests: Wait until unwatching the gdbus-testserver name has completed
Previously, the code in `ensure_gdbus_testserver_up()` created a proxy
object and watched its `name-owner` to see when the
`com.example.TestService` name appeared.

This ended up subscribing to three signals (one of them for name
ownership, and two unused for properties of the proxy), and was racy. In
particular, the `name-owner` property could be set before all D-Bus
messages had been processed — it could have been derived from getting
the owner of the name, for example.

This left unprocessed messages hanging around in the `context`, but that
context was never iterated again, which essentially leaked the
references held by those messages. That included a reference to the
`GDBusConnection`.

The first part of the fix is to simplify the code to use
`g_bus_watch_name_on_connection()`, so there’s only one signal
subscription to worry about.

The second part of the fix is to use the `GDestroyNotify` callback for
the watch data to be notified of when all D-Bus traffic has been
processed and the signal unsubscription is complete. At this point, it’s
guaranteed that there are no idle callbacks pending in the
`GMainContext`, since the `GDestroyNotify` callback is the last one
invoked on the `GMainContext`.

Essentially, this commit uses the `GDestroyNotify` callback as a
synchronisation message between the D-Bus worker thread and the thread
calling `ensure_gdbus_testserver_up()`.

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

Fixes: #1515
2020-02-24 09:01:03 +00:00
Philip Withnall
ac274b4005 tests: Add timeout to assert_connection_has_one_ref()
Iterate the given `context` while waiting, rather than sleeping. This
ensures that if the errant `GDBusConnection` ref is held by some pending
callback in the given `context`, it will actually be released.

Typically `context` is going to be the global default main context.

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

Helps: #1515
2020-02-24 09:00:59 +00:00
Philip Withnall
b2e543f6a4 tests: Take explicit connection and context when ensuring testserver up
This introduces no functional changes, but makes the code a little more
explicit about which connection and main context it’s operating on.

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

Helps: #1515
2020-02-24 07:46:22 +00:00
Philip Withnall
1a51681e6d gdbusconnection: Simplify some control flow
This removes an unhelpful `goto`. It introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 07:46:22 +00:00
Philip Withnall
bcee182a49 gdbusconnection: Drop an unnecessary GMainContext reference
`CallDestroyNotifyData` never uses that `GMainContext`, and holding a
ref to it could cause reference count cycles if the `GMainContext` is no
longer being iterated.

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

Helps: #1515
2020-02-24 07:46:22 +00:00
Philip Withnall
cc11c79e4b gdbusproxy: Simplify a pointer theft
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 07:46:22 +00:00
Philip Withnall
d9dab2b319 gdbusproxy: Tidy up some memory management code
Use `g_clear_object()` to tidy things up. This introduces no functional
changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 07:46:22 +00:00
Philip Withnall
72afc79346 gdbusproxy: Replace home-grown weak ref implementation with GWeakRef
The fix for bgo#651133 (commit 7e0f890e38) introduced a kind of weak
ref, which had to be thread-safe due to the fact that `GDBusProxy`
operates in one thread but can emit signals in another.

Since that commit, `GWeakRef` was added, which does the same thing. Drop
the custom code in favour of it; this should be functionally equivalent,
but using an RW lock rather than a basic mutex, which should reduce
contention.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 07:46:22 +00:00
Philip Withnall
b302ee956e tests: Move refcount checks to the end of each test in gdbus-threading
These checks used to be a precondition on test_threaded_singleton(); but
the earlier tests could leave the refcount of the shared connection in a
bad state, and this wouldn’t be caught until later.

Factor out the check, increase the iteration count to 1000 (so the check
blocks for up to 1s rather than 100ms), and call it in more places.

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

https://gitlab.gnome.org/GNOME/glib/issues/1515
2020-02-24 07:46:22 +00:00
Philip Withnall
6b786ac3e9 tests: Port gdbus-threading 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>

https://gitlab.gnome.org/GNOME/glib/issues/1515
2020-02-24 07:46:22 +00:00
Philip Withnall
4a1dcdfb7c Merge branch 'wip/oholy/gunixmountmonitor-thread-safe' into 'master'
gunixmounts: Make GUnixMountMonitor thread-safe

Closes #2030

See merge request GNOME/glib!1357
2020-02-18 10:17:24 +00:00
Ondrej Holy
501558eaa1 gunixmounts: Remove pending sources when finalizing
mtab_file_changed_id is	not currently removed when finalizing, which
could potentially lead to segfaults. Let's remove the source when
finalizing to avoid this.
2020-02-18 09:16:47 +01:00
Ondrej Holy
ab278c0072 gunixmounts: Prevent race when mtab file changed
mtab_file_changed_id might be set on thread default context, but it is
always cleared on the global context because of usage of g_idle_add. This
can cause the emission of redundant "mounts-change" signals. This should
not cause any issues to the client application, but let's attach the idle
source to the thread-default context instead to avoid those races for sure.
2020-02-18 09:16:47 +01:00
Ondrej Holy
898a9c332e gunixmounts: Prevent invalid time_read timestamps
The `get_mounts_timestamp()` function uses `mount_poller_time` when
`proc_mounts_watch_source` is set, but the `mount_poller_time` is not
initialized in the same time as `proc_mounts_watch_source`. This may
cause that zero, or some outdated value is returned. Let's initialize
`mount_poller_time` to prevent invalid values to be returned.
2020-02-18 09:10:03 +01:00
Ondrej Holy
972b977659 gunixmounts: Make GUnixMountMonitor thread-safe
The Nautilus test suite often crashes with "GLib-FATAL-CRITICAL:
g_source_is_destroyed: assertion 'g_atomic_int_get (&source->ref_count)
> 0' failed" if it is started with "GIO_USE_VOLUME_MONITOR=unix". This
is because GUnixMountMonitor is simultaneously used from multiple
threads over GLocalFile and GVolumeMonitor APIs. Let's add guards for
proc_mounts_watch_source and mount_poller_time variables to prevent
those crashes.

Fixes: https://gitlab.gnome.org/GNOME/glib/issues/2030
2020-02-18 09:09:50 +01:00
Philip Withnall
f0e7bc16ab Merge branch '1919-relative-paths' into 'master'
build: Rework path construction to reliably add prefix

Closes #1919

See merge request GNOME/glib!1369
2020-02-17 19:46:54 +00:00
Philip Withnall
1154a3b6fb gtlsconnection: Add missing (nullable) annotations
And the same set of annotations on `GDtlsConnection` too.

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

Fixes: #2038
2020-02-17 18:17:06 +00:00
Philip Withnall
ccbb2d8e8a gdbusnameowning: Subscribe to NameLost before calling RequestName
There was a slight race in name ownership: a gap between calling
`RequestName` (or receiving its reply) and subscribing to `NameLost`. In
that gap, another process could request and receive the name, and this
one wouldn’t know about it.

Fix that by subscribing to `NameAcquired` and `NameLost` before calling
`RequestName`, and then unsubscribing again if the subscriptions turn
out not to be necessary (if the process can’t own the requested name).

Spotted and diagnosed by Miika Karanki.

One of the tests needs an additional iteration of the main loop in order
to free all the signal closures before it can complete its checks.

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

Fixes: #1517
2020-02-16 10:00:31 +00:00
Philip Withnall
dff212effc Merge branch 'wip/tingping/socket-client-data-races-fix' into 'master'
gsocketclient: Refactor g_socket_client_connect_async()

Closes #1995, #1872, #1902, #1989, and #1871

See merge request GNOME/glib!1339
2020-02-14 19:10:59 +00:00
Patrick Griffis
2722620e32 Refactor g_socket_client_connect_async()
This is a fairly large refactoring. The highlights are:

- Removing in-progress connections/addresses from GSocketClientAsyncConnectData:

  This caused issues where multiple ConnectionAttempt's would step over eachother
  and modify shared state causing bugs like accidentally bypassing a set proxy.

  Fixes #1871
  Fixes #1989
  Fixes #1902

- Cancelling address enumeration on error/completion

- Queuing successful TCP connections and doing application layer work serially:

  This is more in the spirit of Happy Eyeballs but it also greatly simplifies
  the flow of connection handling so fewer tasks are happening in parallel
  when they don't need to be.

  The behavior also should more closely match that of g_socket_client_connect().

- Better track the state of address enumeration:

  Previously we were over eager to treat enumeration finishing as an error.

  Fixes #1872
  See also #1982

- Add more detailed documentation and logging.

Closes #1995
2020-02-14 18:15:20 +00:00
Philip Withnall
2b533ca99a gdesktopappinfo: Use sh rather than gio-launch-desktop
There were some problems about where to install `gio-launch-desktop` to
support multiarch systems without circular dependencies. Simon McVittie
suggested that, actually, given the current set of platforms supported
by `GDesktopAppInfo` (they’re all POSIX), we could just use `sh`.

That simplifies things nicely. `gio-launch-desktop` can always be
resurrected (and the multiarch debate continued and resolved) if needed
in future.

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

Fixes: #1633
2020-02-14 18:09:18 +00:00
Simon McVittie
b9d04b37b0 tests: Cope with having CAP_DAC_OVERRIDE, even if not euid 0
Some CI platforms invoke these tests with euid != 0 but with
capabilities. Detect whether we have Linux CAP_DAC_OVERRIDE or other
OSs' equivalents, and skip tests that rely on DAC permissions being
denied if we do have that privilege.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Fixes: https://gitlab.gnome.org/GNOME/glib/issues/2027
Fixes: https://gitlab.gnome.org/GNOME/glib/issues/2028
2020-02-13 17:33:45 +00:00
Philip Withnall
65be80c3ed build: Rework path construction to reliably add prefix
There were a couple of custom paths which could end up being relative,
rather than absolute, due to not properly prefixing them with
`get_option('prefix')`.

The use of `join_paths()` here correctly drops all path components
before the final absolute path in the list of arguments. So if someone
configures GLib with an absolute path for `gio_module_dir`, that will be
used unprefixed; but if someone configures with a relative path, it will
be prefixed by `get_option('prefix)`.

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

Fixes: #1919
2020-02-07 17:12:35 +00:00
Bastien Nocera
b7586da9bf tests: Fix timeouts not working in GMemoryMonitor tests
The loops should continue iterating if the timeout is non-zero and we're
still waiting for the updated value. Otherwise, if things break, we'll
be waiting until we receive a value that never arrives.
2020-02-04 17:28:07 +01:00
Ondrej Holy
a82372ba3e gio-tool-info: Print also root path if available
"gio info" got support to print information about mount points,
let's print also root path similarly as it is done by findmnt.
2020-02-03 12:22:43 +00:00
Simon McVittie
3e10ce89f4 gio-tool-info: Print unix mount information where available
"gio info" output doesn't contain any information about mount points, but
that information can be useful when debugging issues in facilities that
depend on knowing about mount points, such as the trash API.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Co-authored-by: Ondrej Holy <oholy@redhat.com>
2020-02-03 12:22:43 +00:00
Ondrej Holy
197ea9fe43 gfile: Fix g_file_peek_path() for remote locations
g_file_peek_path() doesn't work for GVfs locations on the first attempt,
because the compare-and-swap loop is broken before the return value is
set.
2020-02-03 11:09:25 +00:00
Ondrej Holy
b4f6333783 gfile: Do not return target-uri from g_file_peek_path()
Documentation says that g_file_peek_path() returns exactly the same
what g_file_get_path(), but this is not true. Apart from that the code
segfaults for some uris (e.g. for "trash:///"), it returns target-uri
for trash and recent schemes. This is unexpected and can lead to various
issues among others because the target-uri paths are not automatically
translated back to GDaemonFile as it is done with gvfsd-fuse paths.
g_file_get_path() returns NULL for trash and recent schemes, because
fuse paths are not provided for those schemes. So g_file_peek_path()
should return NULL as well. It is up to the concrete application to
use target-uri when appropriate.

This change was	made as a part of commit 4808a957, however, neither
the commit message, neither the corresponding bug doesn't mention this
crucial change and doesn't give any clear reasoning. So let's revert
this.
2020-02-03 11:09:25 +00:00
Emmanuele Bassi
f5f4828721 Remove global declaration of GMemoryMonitor
The GMemoryMonitor interface uses G_DECLARE_INTERFACE, which provides a
typedef for the interface dummy type. We declare the same type inside
the global giotypes.h header, which leads to typedef redeclaration
warnings on toolchains that do not support—intentionally or not—the C11
feature of typedef redefinition.

While we do have a toolchain requirement for C11 typedef redefinitions
listed on our wiki, we also suspended it temporarily to allow users of
non-C11 compilers to work on newer versions of GLib; so, let's keep them
working a while longer.
2020-01-31 14:29:15 +00:00
Philip Withnall
a0e74a8c47 Merge branch '1993-codegen-version-args' into 'master'
Rename gdbus-codegen --glib-min-version argument to --glib-min-required and add --glib-max-allowed

Closes #1993

See merge request GNOME/glib!1342
2020-01-31 13:49:20 +00:00
Philip Withnall
e855e30d6d Merge branch 'gtkdoc-check-fix' into 'master'
Various fixes to make gtkdoc-check pass on glib

See merge request GNOME/glib!978
2020-01-31 13:23:42 +00:00
Philip Withnall
c07d9434f4 Merge branch 'wip/oholy/gfile-docs' into 'master'
Symlink-related fixes for `g_file_move()`

Closes #986

See merge request GNOME/glib!900
2020-01-31 12:56:15 +00:00
Philip Withnall
087b9829f4 gdbus-codegen: Tidy up version comparisons
Python tuple comparisons actually do what we want for comparing major
and minor versions, so tidy things up by using that.

This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-31 12:23:50 +00:00
Philip Withnall
bb501bb8be Merge branch 'mcatanzaro/pkcs11-deferral' into 'master'
Revert "gtlscertificate: Add support for PKCS #11 backed certificates"

See merge request GNOME/glib!1347
2020-01-31 12:19:15 +00:00
Michael Catanzaro
d58e5de9e9 Revert "gtlscertificate: Add support for PKCS #11 backed certificates"
This reverts commit b6d8efbebc.

This GLib API is good, but the implentation is not ready, so there's no
reason to commit to the API in GLib 2.64. We can reland again when the
implementation is ready.

There are three problems: (a) The glib-networking implementation normally
works, but the test has been broken for a long time. I'm not comfortable
with adding a major new feature without a working test. This is
glib-networking#104. (b) The WebKit implementation never landed. There
is a working patch, but it hasn't been accepted upstream yet. This API
isn't needed in GLib until WebKit is ready to start using it.
https://bugs.webkit.org/show_bug.cgi?id=200805. (c) Similarly, even if
the WebKit API was ready, that itself isn't useful until an application
is ready to start using it, and the Epiphany level work never happened.

Let's try again for GLib 2.66. Reverting this commit now just means we
gain another six months before committing to the API forever. No reason
to keep this in GLib 2.64 when nothing is using it yet.
2020-01-30 04:19:22 -06:00
Руслан Ижбулатов
ac58ecbab0 W32 GLocalFileStat: remove compatibility time fields
Use tv_*tim.tv_sec everywhere.
2020-01-30 01:56:56 +00:00
Руслан Ижбулатов
0550104cf8 Support setting mtime and atime on local files on Windows
Since we (optionally) require nanosecond precision for this
(utimes() is used on *nix), use SetFileTime(), which nominally
has 100ns granularity (actual filesystem might be coarser), instead of
g_utime (), which only has 1-second granularity.
2020-01-30 01:33:10 +00:00
Руслан Ижбулатов
d09a6690e4 W32: add a test for setting file mtime 2020-01-30 01:33:09 +00:00
Руслан Ижбулатов
4fec9af198 W32: support nanoseconds in stat timestamps
Expand our private statbuf structure with st_mtim, st_atim and st_ctim
fields, which are structs that contain tv_sec and tv_nsec fields,
representing a timestamp with 1-second precision (same value as st_mtime, st_atime
and st_ctime) and a fraction of a second (in nanoseconds) that adds nanosecond
precision to the timestamp.

Because FILEETIME only has 100ns precision, this won't be very precise,
but it's better than nothing.

The private _g_win32_filetime_to_unix_time() function is modified
to also return the nanoseconds-remainder along with the seconds timestamp.

The timestamp struct that we're using is named gtimespec to ensure that
it doesn't clash with any existing timespec structs (MinGW-w64 has one,
MSVC doesn't).
2020-01-30 01:27:53 +00:00
Xavier Claessens
6e8a7c2cd4 doc: Add back gdbus-object-manager-example
This requires Meson 0.52.0 for the return value of gnome.gtkdoc().
2020-01-29 15:40:17 +01:00
Michael Catanzaro
394a72bc11 Fix crash caused by g_network_monitor_base_add_network()
This avoids a crash when starting Evolution, and fixes the
network-monitor and network-monitor-race test cases on my developer
workstation. (I assume the CI is not crashing due to lack of network
access there.)

Problem is that if a network already exists in the networks table,
g_hash_table_add() "destroys" (unrefs) it before adding the new one
(which we failed to ref before adding). This means we just accidentally
lost a ref. In practice, the network gets unexpectedly destroyed here
before returning.

Fixes #2020
2020-01-27 16:20:20 -06:00
Philip Withnall
9734e4854e gdbus-codegen: Add --glib-max-allowed argument
This complements the `--glib-min-required` argument, just like the
`GLIB_MIN_REQUIRED` and `GLIB_MAX_ALLOWED` preprocessor defines which
control access to APIs in C.

Currently, it doesn’t affect code generation at all. When we next change
code generation, we will need to gate any new API usage on this
argument.

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

Fixes: #1993
2020-01-27 10:42:26 +00:00
Philip Withnall
4d1c3e15f9 gdbus-codegen: Rename --glib-min-version to --glib-min-required
This makes it consistent with the `GLIB_MIN_REQUIRED` defines which are
used for API stability/versioning in C code.

It doesn’t otherwise change the behaviour of the `--glib-min-version`
argument.

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

Helps: #1993
2020-01-27 10:11:46 +00:00
Philip Withnall
4a488ced5d gnetworkmonitorbase: Use a hash table for storing networks
Rather than using an array, which requires a lot of iteration over it to
check whether a particular network is present. Using a hash table only
requires iteration in the can_reach() case, where we need to match a
mask in the networks array, rather than equal it.

This should improve performance for large numbers of routes.

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

Fixes: #1925
2020-01-22 11:14:34 +00:00
Philip Withnall
0d9d548932 Merge branch 'sizeof-member' into 'master'
Add and use g_sizeof_member() macro

See merge request GNOME/glib!1333
2020-01-22 11:07:03 +00:00
Sebastien Bacher
422e861633 tests: Skip GMemoryMonitor tests if xdg-desktop-portal is not available
It's useful to have glib tests passing even if you don't have a full
desktop stack available
2020-01-22 10:19:03 +02:00
Iain Lane
0d4f1a9b21
tests: Skip GMemoryMonitor tests if the dbusmock template is not available
This template is not currently in any released version of dbusmock.
2020-01-22 07:41:17 +00:00
Marc-André Lureau
fd61a21ecd Add and use G_SIZEOF_MEMBER() macro
A convenient macro present in the Linux kernel, named FIELD_SIZE() there.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-01-21 19:54:55 +04:00
Philip Withnall
4c1b675eac Merge branch '1232-object-manager-client-signal-race' into 'master'
gdbusobjectmanagerclient: Fix race in signal emission

Closes #1232

See merge request GNOME/glib!1335
2020-01-21 11:52:30 +00:00
Philip Withnall
5d32b99d0c Merge branch '604-dbus-name-watching-simplification' into 'master'
gdbusnamewatching: Check cancellation of a watch before calling back

Closes #604

See merge request GNOME/glib!1336
2020-01-21 11:15:36 +00:00
Philip Withnall
5853d5c8e4 gdbusobjectmanagerclient: Fix race in signal emission
Following on from #978, it seems that #1232 is another instance of the
same problem: signals emitted across threads can’t guarantee their user
data is kept alive between committing to emitting the signal and
actually invoking the callback in the relevant thread.

Fix that by using weak refs to the `GDBusObjectManagerClient` as the
user data for its signals, rather than no refs. Strong refs would create
an unbreakable reference count cycle.

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

Fixes: #1232
2020-01-21 11:07:21 +00:00
Philip Withnall
5c7a88e972 Merge branch '978-dbus-signal-emission-race' into 'master'
Fix race between D-Bus signal emission and unsubscription

Closes #978

See merge request GNOME/glib!1332
2020-01-21 10:43:39 +00:00
Philip Withnall
73a33e5019 gdbusnamewatching: Check cancellation of a watch before calling back
It’s possible for `g_bus_unwatch_name()` to be called after a
name-appeared or name-vanished handler has been scheduled to be called
in another thread, but before that callback is actually invoked. If so,
the subscribing thread will receive a callback after it’s called
`g_bus_unwatch_name()`, which is unexpected and could cause bugs.

Double-check `client->cancelled` in the target thread before actually
invoking the callback.

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

Fixes: #604
2020-01-20 19:19:30 +00:00
Philip Withnall
79792574d4 gdbusnamewatching: Remove a redundant function argument
It was always set to `FALSE`. This introduces no functional changes.

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

Helps: #604
2020-01-20 19:19:30 +00:00
Philip Withnall
03380a4928 tests: Fix header inclusion in win32-appinfo.c
This fixes the following build failure on FreeBSD:
```
  In file included from ../gio/tests/win32-appinfo.c:24:
  /usr/include/malloc.h:3:2: error: "<malloc.h> has been replaced by <stdlib.h>"
  #error "<malloc.h> has been replaced by <stdlib.h>"
```

Hopefully it doesn’t break Windows.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-20 15:22:03 +00:00
Philip Withnall
37b1acdf8c gdbusconnection: Document threading and refcounting for signals
This is essentially a mini writeup of #978.

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

Helps: #978
2020-01-20 15:13:52 +00:00
Philip Withnall
a434bfbb3d gdbusnameowning: Fix race between connection shutdown and NameLost
As with all D-Bus signal subscriptions, it’s possible for a signal
callback to be invoked in one thread (T1) while another thread (T2) is
unsubscribing from that signal. In this case, T1 is the main thread, and
T2 is the D-Bus connection worker thread which is unsubscribing all
signals as it’s in the process of closing.

Due to this possibility, all `user_data` for signal callbacks needs to
be referenced outside the lifecycle of the code which
subscribes/unsubscribes the signal. In other words, it’s not safe to
subscribe to a signal, store the subscription ID in a struct,
unsubscribe from the signal when freeing the struct, and dereference the
struct in the signal callback. The data passed to the signal callback
has to have its own strong reference.

Instead, it’s safe to subscribe to a signal and add a strong reference
to the struct, store the subscription ID in that struct, and unsubscribe
from the signal when the last external reference to your struct is
dropped. That unsubscription should break the refcount cycle between the
signal connection and the struct, and allow the struct to be completely
freed. Only with that approach is it safe to dereference the struct in
the signal callback, if there’s any possibility that the signal might be
unsubscribed from a separate thread.

The tests need specific additional main loop cycles to completely emit
the NameLost signal callback. Ideally they need refactoring, but this
will do (1000 test cycles passed).

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

Fixes: #978
2020-01-20 15:13:52 +00:00
Philip Withnall
4ec2175d21 gdbusconnection: Tidy up unsubscription code
This just removes a now-redundant intermediate array. This means that
the `SignalSubscriber` instances are now potentially freed a little
sooner, inside the locked segment, but they are already careful to only
call their `user_data_free_func` in the right thread. So that should not
deadlock.

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

Helps: #978
2020-01-20 15:13:52 +00:00
Philip Withnall
130455bbb2 gdbusconnection: Fix race when emitting D-Bus signal callbacks
Instead of storing a copy of the `callback` and `user_data` from a
`SignalSubscriber` in a `SignalInstance` struct (which is the closure
for signal callback data as it’s sent from the D-Bus worker thread to
the thread which originally subscribed to a signal), store a strong
reference to the `SignalSubscriber` struct itself.

This keeps the `SignalSubscriber` alive until the emission is
complete, which ensures that the `user_data` is not freed prematurely.
It also slightly reduces the allocation size of `SignalInstance` (not
that it matters).

This is threadsafe because the fields in `SignalSubscriber` are all
immutable after construction.

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

Helps: #978
2020-01-20 14:30:39 +00:00
Philip Withnall
bee27dd9f0 gdbusconnection: Tidy up destroy notification for signal subscriptions
Tie the destruction of the `user_data` to the destruction of the
`SignalSubscriber` struct. This is tidier, and ensures that the fields
in `SignalSubscriber` are all immutable after being set, so the
structure can safely be used across threads without locking.

It doesn’t matter which thread we call `call_destroy_notify()` in, since
it always defers calling `user_data_free_func` to the user-provided
`GMainContext`.

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

Helps: #978
2020-01-20 14:30:39 +00:00
Philip Withnall
9b1c8d7dd5 gdbusconnection: Allocate SignalSubscriber structs individually
The `SignalSubscriber` structs contain the callback and `user_data` of each
subscriber to a signal, along with the `guint id` token held by that
subscriber to identify their subscription. There are one or more
`SignalSubscriber` structs for a given signal match rule, which is
represented as a `SignalData` struct.

Previously, the `SignalSubscriber` structs were stored in a `GArray` in
the `SignalData` struct, to reduce the number of allocations needed
when subscribing to a signal.

However, this means that a `SignalSubscriber` struct cannot have a
lifetime which exceeds the `SignalData` which contains it. In order to
fix the race in #978, one thread needs to be able to unsubscribe from a
signal (destroying the `SignalData` struct) while zero or more other
threads are in the process of calling the callbacks from a previous
emission of that signal (using the callback and `user_data` from zero or
more `SignalSubscriber` structs). Multiple threads could be calling
callbacks because callbacks are invoked in the `GMainContext` which
originally made a subscription, and GDBus supports subscribing to a
signal from multiple threads. In that case, the callbacks are dispatched
to multiple threads.

In order to allow the `SignalSubscriber` structs to outlive the
`SignalData` which contained their old match rule, store them in a
`GPtrArray` in the `SignalData` struct, and refcount them individually.

This commit in itself should make no functional changes to how GDBus
works, but will allow following commits to do so.

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

Helps: #978
2020-01-20 14:30:39 +00:00
Philip Withnall
adee3b31dc Merge branch 'appinfo-rundll32' into 'master'
Add rundll32 support to GAppInfo

Closes #1932

See merge request GNOME/glib!1259
2020-01-20 10:36:29 +00:00
wouter bolsterlee
809a9210c3 Support multiple directories in GSETTINGS_SCHEMA_DIR
This adds support for specifying multiple directories in the
GSETTINGS_SCHEMA_DIR environment variable by separating the values
using G_SEARCHPATH_SEPARATOR_S (colon on UNIX-like systems).

While programs could already register multiple custom GSettings schema
directories, it was not possible to achieve the same without writing
custom code, e.g. when using the gsettings command line tool.

Fixes #1998.
2020-01-16 10:20:34 +00:00
Philip Withnall
321fea1c5e Merge branch 'wip/muktupavels/notifications' into 'master'
gfdonotificationbackend: remove notifications when bus name vanishes

See merge request GNOME/glib!1317
2020-01-16 06:52:16 +00:00
Руслан Ижбулатов
9d4d5dfca8 GWin32AppInfo: fix a potential memory leak
Make sure that hndexe_fc_basename is only allocated before it is
actually used.
2020-01-15 18:04:14 +00:00
Руслан Ижбулатов
9f070db4c5 GWin32AppInfo: Support rundll32-using applications
1) When parsing the executable name out of the command line,
see if the executable is rundll32.exe. If that is the case,
use the DLL name from its first argument as the "executable"
(this is used only for matching, and Windows Registry matches
these programs by their DLLs, so this is correct; for running
the application GLib would still use the command line, with
rundll32).

2) If an app runs with rundll32, ensure that rundll32 arguments
can be safely quoted. Otherwise GLib will break them with its
protective quotation.
2020-01-15 18:04:14 +00:00
Matthew Leeds
2a605f6e15 gdbus-codegen: Add call_flags and timeout_msec args
Currently the code generated by gdbus-codegen uses
G_DBUS_CALL_FLAGS_NONE in its D-Bus calls, which occur for each method
defined by the input XML, and for proxy_set_property functions. This
means that if the daemon which implements the methods checks for
G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION and only does interactive
authorization if that flag is present, users of the generated code have
no way to cause the daemon to use interactive authorization (e.g. polkit
dialogs).

If we simply changed the generated code to always use
G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, its users would have no
way to disallow interactive authorization (except for manually calling
the D-Bus method themselves).

So instead, this commit adds a GDBusCallFlags argument to method call
functions. Since this is an API break which will require changes in
projects using gdbus-codegen code, the change is conditional on the
command line argument --glib-min-version having the value 2.64 or
higher.

The impetus for this change is that I'm changing accountsservice to
properly respect G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, and
libaccountsservice uses generated code for D-Bus method calls. So
these changes will allow libaccountsservice to continue allowing
interactive authorization, and avoid breaking any users of it which
expect that. See
https://gitlab.freedesktop.org/accountsservice/accountsservice/merge_requests/46

It might make sense to also let GDBusCallFlags be specified for property
set operations, but that is not needed in the case of accountsservice,
and would require significant work and breaking API in multiple places.

Similarly, the generated code currently hard codes -1 as the timeout
value when calling g_dbus_proxy_call*(). Add a timeout_msec argument so
the user of the generated code can specify the timeout as well.

Also, test this new API. In gio/tests/codegen.py we test that the new
arguments are generated if and only of --glib-min-version is used with a
value greater than or equal to 2.64, and in gio/tests/meson.build we
test that the generated code with the new API can be linked against.

The test_unix_fd_list() test also needed modification to continue
working now that we're using gdbus-test-codegen.c with code generated
with --glib-min-version=2.64 in one test.

Finally, update the docs for gdbus-codegen to explain the effect of
using --glib-min-version 2.64, both from this commit and from
"gdbus-codegen: Emit GUnixFDLists if an arg has type `h` w/
min-version".
2020-01-15 09:37:41 -08:00
Alberts Muktupāvels
5d791352f2 gfdonotificationbackend: remove notifications when bus name vanishes
Notification id (notify_id) is generated by notification daemon and
is valid only while daemon is running. If notification backend will
resend/reuse existing notification id (replace_id) after notification
daemon has been restarted it could replace wrong notification as same
id now can be used by different notification.
2020-01-15 16:38:52 +02:00
Michael Catanzaro
bbbaae9fb7 Fully deprecate TLS rehandshakes
Previously, the documentation indicated that it was possible to call
g_tls_connection_handshake() after an initial handshake to trigger a
rehandshake, but only if TLS 1.2 or older is in use. However, there is
no documented way to ensure TLS 1.2 gets used. Nowadays, TLS 1.3 is used
by default.

I'm removing support for rehandshaking from glib-networking, as part of
a large refactoring where keeping rehandshakes would have entailed
significant additional complexity. So let's update the documentation to
indicate this is no longer ever supported. Applications should not
notice any difference.

Also, sync some previous handshake and rehandshake changes from
GTlsConnection to GDtlsConnection that were missed by mistake. I
try to remember to always update GDtlsConnection when touching
GTlsConnection documentation, but it's easy to forget.
2020-01-07 14:52:20 -06:00
Bastien Nocera
2394bc755a docs: Add full code example for GMemoryMonitor 2020-01-07 18:29:53 +01:00
Bastien Nocera
b04be9efc7 docs: Fix markup that led to unreadable example
We used XML to markup when we should have used our own brand of markdown
instead. This fixes the example being unreadable unless we trimmed the
XML away from it.
2020-01-07 18:29:53 +01:00
Philip Withnall
4151dfea82 Merge branch 'wip/hadess/test-fixes' into 'master'
gio: Fix socket test

See merge request GNOME/glib!1295
2020-01-07 16:21:20 +00:00
Bastien Nocera
e537716540 tests: Fix error path not setting an error
This failure path should have set the GError but did not.
2020-01-07 15:07:37 +00:00
Bastien Nocera
b3197f2740 tests: Fix incomplete failure check in socket test
For the check "if (error != NULL)" to work as expected, the
create_server() (and create_server_full()) functions need to make
sure to return an error for all the possible failures, but this
might not always be the case.

Catch all the failures by testing for a non-NULL return value if there
was no error.
2020-01-07 15:07:37 +00:00
Michael Catanzaro
cc3cf6b8b2 gsocketclient: run timeout source on the task's main context
This shouldn't make any difference, because this code should only ever
be running in the main context that was thread-default at the time the
task was created, so it should already match the task's context. But
let's make sure, just in case.
2020-01-07 15:05:22 +00:00
Philip Withnall
7d0a1c5c58 tests: Fix callback arguments in fake-document-portal
They didn’t match the prototype generated by `gdbus-codegen`, which
meant that the FD list was being iterated incorrectly. Secondly, the
document ID list returned by the method was not NULL terminated, which
could lead to reading off the end of the list.

Somehow, neither of these bugs caused problems on Linux, but they did
cause problems on FreeBSD.

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

Fixes: #1983
2020-01-07 11:20:45 +00:00
Michael Catanzaro
85c19a7977 Sync GDtlsConnection handshake docs with GTlsConnection
Sadly, I forgot to update the documentation of
g_dtls_connection_handshake() last time I touched
g_tls_connection_handshake().

Let's also drop mention of STARTTLS, since that would use normal TLS,
not DTLS.
2020-01-02 20:26:09 -06:00
Philip Withnall
c8d479d8b2 tests: Speed up the GIO actions test
Reduce the number of iterations of things sent over a mock session bus
from different threads, to avoid the test spending quite so long
contested over the `gsignal.c` lock.

The test now takes about 10 seconds, according to `time`, rather than
around 100 or longer.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-12-18 16:51:11 +00:00
Matthew Leeds
a28c34ba88 tests: Fix an error message set by foo_set_property()
The property name and value were mistakenly swapped.
2019-12-18 16:39:56 +00:00
James Henstridge
e24db62363 gio: do not cache document portal D-Bus proxy
By removing the cached global proxy in gdocumentportal.c, we can
re-enable the checks for proper shutdown of the session bus connection
in the dbus-appinfo.c test.
2019-12-17 21:03:03 +08:00
James Henstridge
926ff8c6a7 gio/tests: add a test for document portal use when launching flatpaks
We can't use session_bus_down() in the test since gdocumentportal.c
holds a reference to the session bus connection, preventing it from
being finalised.
2019-12-17 20:59:22 +08:00
James Henstridge
27db702ceb gio/tests: add a fake implementation of the document portal 2019-12-17 20:56:49 +08:00
James Henstridge
457d4c9fe0 gio: update dbus interfaces from xdg-desktop-portal tree
This removes the need to manually specify org.gtk.GDBus.C.UnixFD
annotations in the gdbus-codegen invocations.
2019-12-17 20:48:22 +08:00
Ondrej Holy
e6f5b9bf89 gio-tool-list: Add an option to print display names
There are some GVfs locations (i.e. google-drive://, recent://), where
G_FILE_ATTRIBUTE_STANDARD_NAME is something tottaly different than
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME. Thus it would be nice to have
an easy way to show the display names. The only way currently to show
the display names is to use --attributes option, which is a bit
cumbersome. Let's add new --show-display-names option.

https://gitlab.gnome.org/GNOME/gvfs/issues/402
2019-12-17 11:07:10 +01:00
Simon McVittie
5bae85eccc Merge branch 'ossfuzz-14870-dbus-message-variant-nesting' into 'master'
gdbusmessage: Limit recursion of variants in D-Bus messages

See merge request GNOME/glib!1201
2019-12-16 19:50:38 +00:00
Emmanuele Bassi
a172aa3662 Merge branch '1130-codegen-docs' into 'master'
Resolve "gdbus-codegen: Add an option to strictly generate markdown in source comments"

Closes #1130

See merge request GNOME/glib!1264
2019-12-16 12:39:23 +00:00
Philip Withnall
8deebeca17 Merge branch 'master' into 'master'
Fix typo: threfore -> therefore

Closes #1961

See merge request GNOME/glib!1285
2019-12-13 23:48:25 +00:00
Christoph Reiter
a8263add45 Merge branch 'fix-gio-module-path-msvc' into 'master'
giomodule: gio modules are no longer installed in bindir on MSVC

See merge request GNOME/glib!1254
2019-12-12 18:29:07 +00:00
Yaobin Wen
639b426742 Fix typo: threfore -> therefore
Closes GNOME/glib#1961
2019-12-12 16:33:33 +00:00
Emmanuele Bassi
f9bbee7db2 Merge branch '1726-codegen-glib-min-version' into 'master'
gdbus-codegen: Emit GUnixFDLists if an arg has type `h` w/ min-version

Closes #1726

See merge request GNOME/glib!1263
2019-12-12 12:49:34 +00:00
Philip Withnall
fcc1367383 Merge branch 'gtkdoc-check-fix' into 'master'
Various gtk-doc improvements

See merge request GNOME/glib!1277
2019-12-11 13:02:20 +00:00
Philip Withnall
2f6010eabf Merge branch 'wip/hadess/add-dbus-tests-debug' into 'master'
tests: Enable GDBus debug for a number of unreliable tests

See merge request GNOME/glib!1271
2019-12-11 12:52:55 +00:00
Philip Withnall
7a3c4a415c gtask: Fix GIR annotation
Spotted by gtk-doc.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-12-11 12:30:47 +00:00
Philip Withnall
fa4cbfdd94 glib: Sort #includes in top-level header files
This should shut the code style checker up every time someone adds a new
`#include`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-12-11 11:48:41 +00:00
Bastien Nocera
8e8ee82580 tests: Add GMemoryMonitor installed-tests
Those tests require Python, gobject-introspection and python-dbusmock
making them unsuitable to be run within the uninstalled test suite.

There are no restrictions of dependencies when it comes to installed
tests so use those to exercise GMemoryMonitor.
2019-12-11 11:44:42 +00:00
Bastien Nocera
e08b10e997 gio: Add stub test program for GMemoryMonitor
"memory-monitor --watch" will watch over any events coming from either
low-memory-monitor or the portal.
2019-12-11 11:44:42 +00:00
Bastien Nocera
cd6612dfb7 gio: Add GMemoryMonitor to monitor for low-memory
Add a memory monitor object, with D-Bus and Portal based
implementations. The D-Bus implementation uses the Linux-only
low-memory-monitor Freedesktop project.

Low Memory Monitor D-Bus API:
https://hadess.pages.freedesktop.org/low-memory-monitor/

Android API:
https://developer.android.com/reference/android/content/ComponentCallbacks2.html#onTrimMemory(int)

iOS API:
https://developer.apple.com/documentation/uikit/app_and_environment/managing_your_app_s_life_cycle/responding_to_memory_warnings

Win32 API:
https://docs.microsoft.com/en-us/dotnet/api/microsoft.win32.systemevents.lowmemory?view=netframework-4.8

Tizen API:
https://samsung.github.io/TizenFX/master/api/Tizen.Applications.EventManager.SystemEvents.LowMemory.html
2019-12-11 11:44:42 +00:00
Philip Withnall
57409724c6 Merge branch 'trash-portal-symlinks' into 'master'
trash portal: Don't follow symlinks

See merge request GNOME/glib!1274
2019-12-11 10:51:15 +00:00
Bastien Nocera
145dc5a49e gdbus: Fix runtime warning with debug enabled
With debug enabled, g_dbus_connection_call_done() will throw a
g_warning() if the call failed (on purpose or not) while trying to the
serial of a non-existant reply.

(/builds/GNOME/glib/_build/gio/tests/gdbus-connection:26921): GLib-GIO-CRITICAL **: 10:10:16.311: g_dbus_message_get_reply_serial: assertion 'G_IS_DBUS_MESSAGE (message)' failed
2019-12-11 11:42:03 +01:00
Philip Withnall
e3f80b9254 gdbus-codegen: Emit GUnixFDLists if an arg has type h w/ min-version
This is a reimplementation of commit
4aba03562b from Will Thompson, but
conditional on the caller passing `--glib-min-version 2.64` to
`gdbus-codegen` to explicitly opt-in to the new behaviour.

From the commit message for that commit:

Previously, if a method was not annotated with org.gtk.GDBus.C.UnixFD
then the generated code would never contain GUnixFDList parameters, even
if the method has 'h' (file descriptor) parameters. However, in this
case, the generated code is essentially useless: the method cannot be
called or handled except in degenerate cases where the file descriptors
are missing or ignored.

Check the argument types for 'h', and if present, generate code as if
org.gtk.GDBus.C.UnixFD annotation were specified.

Includes a unit test too.

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

Fixes: #1726
2019-12-11 10:40:07 +00:00
Philip Withnall
90f0733858 gdbus-codegen: Add a --glib-min-version argument
This can be used by callers to opt-in to backwards-incompatible changes
to the behaviour or output of `gdbus-codegen` in future. This commit
doesn’t introduce any such changes, though.

Documentation and unit tests included.

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

Helps: #1726
2019-12-11 10:40:07 +00:00
Bastien Nocera
8fd71dccc5 tests: Enable GDBus debug for a number of unreliable tests
As those tests keep failing in the CI, enable GDBus debugging to catch
some debug leads when the problems happen.
2019-12-11 11:04:10 +01:00
Matthias Clasen
c3ab139841 trash portal: Don't follow symlinks
We got a complaint here that trashing via the
portal deletes the target of a symlink, not the
symlink itself. It turns out that following the
symlink already happens on the glib side.

https://github.com/flatpak/xdg-desktop-portal/issues/412
2019-12-10 15:16:33 -05:00
Matthias Clasen
1503cfa36e Small doc correction
Add a transfer annotation to some GActionGroup apis.
2019-12-10 15:15:13 -05:00
Bastien Nocera
4d4ff213f2 tests: Correct static-link.py skipped status
Skipped tests use "77" as the return value, so return 77 instead of 0
when the static-link.py test gets skipped because of a missing
environment variable.
2019-12-04 14:06:23 +01:00
Bastien Nocera
fc95385627 tests: Don't run tests that require fuse on rootless containers
If the fuse module is loaded but /dev/fuse doesn't exist, it's likely
that we're running in a rootless container, or a badly setup one, and we
won't be able to use fuse, so skip this test.

This happened on my local system using podman running as a normal user,
but this apparently works as expected in our CI[1].

[1]: https://gitlab.gnome.org/GNOME/glib/merge_requests/466
2019-12-04 14:06:23 +01:00
Sebastian Dröge
96a0f3777c Merge branch 'gsource-dispose' into 'master'
Implement a dispose function for GSource

See merge request GNOME/glib!1175
2019-12-03 12:37:22 +00:00
Philip Withnall
a6c1ee22c1 gdbus-codegen: Drop DocBook warning tags from generated code
gtk-doc switched from DocBook to Markdown ages ago. There is no Markdown
equivalent for `<warning>`, so just drop it. It wasn’t adding anything
particularly valuable to the documentation.

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

Fixes: #1130
2019-12-02 16:48:32 +00:00
Philip Withnall
9a93fd93f0 gdbus-codegen: Remove DocBook link tags from generated code
gtk-doc long since switched to Markdown, so we shouldn’t be emitting
DocBook `<link>` tags.

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

Helps: #1130
2019-12-02 16:47:44 +00:00
Philip Withnall
41cabfaa98 tests: Add tests for the gdbus-codegen executable
Add a Python-based test wrapper for the `gdbus-codegen` executable,
similar to the existing tests for `glib-mkenums` and friends.

Add a few basic tests to begin with, but this doesn’t approach anywhere
near full coverage.

The next step is to move the existing Meson-based `gdbus-codegen` tests
from `gio/tests/meson.build` into the Python test suite.

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

Helps: #1612
2019-12-02 14:27:11 +00:00
Philip Withnall
8f4155c124 codegen: Require at least one interface file to be specified
Previously, running `gdbus-codegen` with no arguments would exit
successfully with no output. While technically correct, that seems
unhelpful.

Require at least one interface file to be specified, so the user gets an
error message if they don’t specify any.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-12-02 14:09:45 +00:00
Philip Withnall
921e6d1245 codegen: Drop gdbus-codegen version and input filename from output
It’s not particularly useful to put the gdbus-codegen version or the
name of the input file into the output from `gdbus-codegen`, and it
makes the output less reproducible. Drop it.

Also clarify the licensing.

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

Helps: #1612
2019-12-02 14:09:45 +00:00
Sebastian Dröge
b3de0c1090 Use GSource dispose function for safely disconnecting the GCancellable source cancelled signal handler
If not doing this it might happen that the cancelled signal is emitted
between reaching a reference count of 0 and finalizing the GSource, at
which point part of the GSource is already freed and calling any GSource
functions is dangerous.

Instead do this from the dispose function. At this time the GSource is
not partially freed yet and calling any GSource API is safe as long as
we ensure that we have a strong reference to the GSource before calling
any GSource API.
2019-11-29 20:56:38 +01:00
Ting-Wei Lan
6d734b895a kqueue: Do not return early from _kqsub_cancel
_kqsub_free assumes the caller has called _kqsub_cancel before calling
it. It checks if both 'deps' and 'fd' have been freed and aborts when
the condition is not met. Since the only caller of _kqsub_free is
g_kqueue_file_monitor_finalize, which does call _kqsub_cancel before
calling _kqsub_free, it seems to be correct for _kqsub_free to assert
values of these two members there.

However, it is possible for _kqsub_cancel to return early without
freeing any resource _kqsub_free expects to be freed. When the kevent
call fails, _kqsub_cancel does not free anything and _kqsub_free aborts
with assertion failure. This is an unexpected behavior, and it can be
fixed by always freeing resources in _kqsub_cancel.

Fixes: https://gitlab.gnome.org/GNOME/glib/issues/1935
2019-11-27 22:49:56 +08:00
Philip Withnall
a937e99ca5 Merge branch 'wip/oholy/gio-mount-uuid' into 'master'
gio-tool-mount: Allow mounting by the given UUID

See merge request GNOME/glib!1249
2019-11-27 12:50:58 +00:00
Ondrej Holy
dd49962eaf gio-tool-mount: Do not print anything if "gio mount -d" suceeded
"gio mount" doesn't print anything in case of success, however "gio mount -d"
prints "Mounted [id] at [mount_path]", which is inconsistent. It might probably
make sense for fstab volumes, but "gio mount -d" now support UUIDs which are
heavily used for daemon mounts and I think that it is not wise to print
"/run/user/$UID/gvfs" mount paths. The mount path can be still found over
"gio mount -l". Let's remove this message to make it more consistent.
2019-11-27 13:37:51 +01:00
Ondrej Holy
8c24b7cd6e gio-tool-mount: Allow mounting by the given UUID
"gio mount" only allows mounting volumes using device files, but not using
UUIDs. Volume monitors for various GVfs locations usually supports just UUIDs.
It would be handy to support them also for testing purposes (because
"g_file_mount_enclosing_volume()" does something else than "g_volume_mount()"
in case of shares provided by GOA volume monitor for example). Let's update
"-d" option to support also UUIDs.

https://gitlab.gnome.org/GNOME/gvfs/issues/251
2019-11-27 13:20:57 +01:00
Emmanuele Bassi
cc3716a943 Merge branch 'thread-safe-getpwnam' into 'master'
glocalvfs: Use thread-safe getpwnam_r() rather than getpwnam()

Closes #1687

See merge request GNOME/glib!681
2019-11-27 11:58:51 +00:00
Philip Withnall
34cb297a86 Merge branch 'wip/nielsdg/g-list-store-find' into 'master'
gliststore: Add item lookup functions

Closes #1011

See merge request GNOME/glib!1096
2019-11-27 11:22:56 +00:00
Nirbheek Chauhan
5f0d0efeb6 giomodule: gio modules are no longer installed in bindir on MSVC
Ever since the port to Meson, gio modules (f.ex., by glib-networking)
are installed inside libdir both for MinGW and MSVC.
2019-11-27 16:10:51 +05:30
Philip Withnall
bdf2583fbd glocalvfs: Use thread-safe getpwnam_r() rather than getpwnam()
It’s possible that one VFS operation will happen from a worker thread at
the same time as another is happening from the main thread, in which
case the static buffer which getpwnam() uses will be overwritten.
There’s a chance this will corrupt the results that one of the threads
receives.

Fix that by using the thread-safe getpwnam_r() version, via the new
g_unix_get_passwd_entry() function.

Fix the indentation of the surrounding block while we’re there.

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

Fixes: #1687
2019-11-26 12:17:04 +00:00
Bastien Nocera
3894335dc6 tests: Don't "timeout tests" by default
Those tests seem to regularly fail because a timeout (which we're
measuring outside the function that times out) is too long, which can
happen when the system is busy.

Don't run those tests unless "thorough" tests are requested. This
disables those tests by default.

Bail out! GLib-GIO:ERROR:../gio/tests/socket.c:1167:test_timed_wait: assertion failed (poll_duration < 112000): (114254 < 112000)
Bail out! GLib-GIO:ERROR:../gio/tests/cancellable.c:167:on_mock_operation_ready: assertion failed (error == (g-io-error-quark, 19)): error is NULL
2019-11-25 12:55:18 +01:00
Philip Withnall
7c77cdf9ba Merge branch 'objcpy-version' into 'master'
Enable test about objcopy if it supports the --add-symbol parameter

Closes #1895

See merge request GNOME/glib!1236
2019-11-21 12:34:15 +00:00
Iain Lane
50c215b14e Merge branch 'unix-mode-docs' into 'master'
gfileinfo: Clarify the documentation for G_FILE_ATTRIBUTE_UNIX_MODE

See merge request GNOME/glib!1242
2019-11-21 12:24:32 +00:00
Philip Withnall
f793319b17 gfileinfo: Clarify the documentation for G_FILE_ATTRIBUTE_UNIX_MODE
It’s not just the mode, it’s also the file type.

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

Helps: #1934
2019-11-21 11:24:08 +00:00
Ignacio Casal Quinteiro
5fe61e8c46 Enable test about objcopy if it supports the --add-symbol parameter
This fixes building in old systems like centos 6.

(With tweaks by Philip Withnall.)

Fixes: https://gitlab.gnome.org/GNOME/glib/issues/1895
2019-11-21 11:16:24 +00:00
Iain Lane
0c88825a75
test_copy_preserve_mode: Adjust for the previous revert
Now we're returning the file type again, we need to mask it out to
compare with the mode. We can also check that the statbuf said the file
is a regular file.

Related: #1934
2019-11-21 10:49:31 +00:00
Iain Lane
e330a99f7a
Revert "glocalfileinfo: Only return file mode, not type, as UNIX_MODE attribute"
This reverts commit bfdc5fc4fc.

This changes the semantics of G_FILE_ATTRIBUTE_ID_UNIX_MODE, and we've
already found one user of the previous semantics (ostree).

Closes #1934
2019-11-21 10:31:43 +00:00
Philip Withnall
eadc17f894 Merge branch 'wip/ernestask/bz-693576-annotations' into 'master'
Make GTask more binding-friendly

See merge request GNOME/glib!1216
2019-11-20 11:17:35 +00:00
Michael Catanzaro
d3768c89ae Merge branch 'mcatanzaro/copy-session-state' into 'master'
Improve documentation for footgun function g_tls_client_connection_copy_session_state()

See merge request GNOME/glib!1039
2019-11-18 21:14:37 +00:00
Michael Catanzaro
fb54646899 Improve documentation of g_tls_client_connection_copy_session_state()
This function has numerous undocumented limitations. In particular, it
is not possible to ensure this function actually does anything. Document
these problems.
2019-11-18 13:55:34 -06:00
Michael Catanzaro
9d2c949b54 gtlsclientconnection: use-ssl3 is now ignored
For many years after SSL 3.0 support was removed, we used this function
to indicate that we should perform protocol version fallback to the
lowest-supported protocol version, to workaround protocol version
intolerance. Nowadays this is no longer needed, and support has been
removed from glib-networking, so update the documentation.
2019-11-18 13:52:39 -06:00
Michael Catanzaro
8f88783a7f gtlsconnection: add missing G_PARAM_DEPRECATED
The use-system-certdb function has been deprecated since 2.30 and is
just missing the deprecation flag to warn developers.
2019-11-18 13:52:39 -06:00
Michael Catanzaro
7b3824fa62 gtlsconnection: add missing deprecation annotation
GTlsConnection:rehandshake-mode has been deprecated since 2.60 using
the G_PARAM_DEPRECATED flag, but I forgot to add the right annotation to
the documentation. Oops.

The associated getter/setter functions were both deprecated properly.
2019-11-18 13:52:39 -06:00
Michael Catanzaro
79999c8723 gtlsconnection: document rehandshake-mode is no longer supported 2019-11-18 13:52:39 -06:00
Philip Withnall
5054b48b7c gdbusmessage: Limit recursion of variants in D-Bus messages
This is the analogue of commit 7c4e6e9fbe, but applied to the
`GDBusMessage` parser, which does its own top-level parsing of the
variant format in D-Bus messages.

Previously, this code allowed arbitrary recursion of variant containers,
which could lead to a stack overflow. Now, that recursion is limited to
64 levels, as per the D-Bus specification:

https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-signature

This includes a new unit test.

oss-fuzz#14870

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-11-18 17:53:55 +00:00
Philip Withnall
b8f4c3596c Merge branch 'mcatanzaro/gtlsconnection-confusion' into 'master'
gtlsconnection: clarify handshake() documentation

See merge request GNOME/glib!1225
2019-11-15 10:45:17 +00:00
Garrett Regier
6cac760551 task: Add return/propagate API for GValue
This is useful for bindings.

Related: https://gitlab.gnome.org/GNOME/glib/issues/668
2019-11-15 10:37:42 +00:00
Philip Withnall
de2236584d tests: Tidy up test case naming in gdbus-serialization test
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-11-15 10:12:59 +00:00
Philip Withnall
96d792197a gdbusmessage: Move variable initialisation to declaration time
Tidies up the code a bit, but introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-11-15 10:12:59 +00:00
Michael Catanzaro
b75dd395ba gtlsconnection: clarify handshake() documentation
This tries to clarify some confusing aspects of the
g_tls_connection_handshake() that can trip up experienced developers.
2019-11-13 20:57:26 -06:00
Alex Samorukov
1bb1bcd814 Add NOTE_REVOKE to the list of the monitoring events 2019-11-11 17:59:31 +00:00
Garrett Regier
42369df7c6 task: Add scope annotation to run_in_thread{,_sync}()
Without specifying the scope, the two functions are non-introspectable
and GTask cannot be used meaningfully by bindings.

Related: https://gitlab.gnome.org/GNOME/glib/issues/668
2019-11-05 09:34:05 +01:00
Philip Withnall
963786f608 Merge branch 'wip/smcv/diagnose-bind-failure' into 'master'
gsocket: Improve diagnostics on bind() failure

See merge request GNOME/glib!1213
2019-11-04 16:59:16 +00:00
Philip Withnall
4d65f32703 Merge branch 'wip/smcv/cross-ld' into 'master'
Make ld executable configurable

See merge request GNOME/glib!1209
2019-11-04 16:26:24 +00:00
Simon McVittie
e08dffb71b gsocket: Improve diagnostics on bind() failure
This is in an attempt to diagnose GNOME/glib#1912.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-11-04 15:09:15 +00:00
Simon McVittie
81936ca580 Make ld executable configurable
Tools like this should be configurable in a cross or native file. In
particular, if we are cross-compiling (with an executable wrapper like
qemu-arm), the build system ld is not necessarily able to manipulate
host system objects.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-11-04 15:08:33 +00:00
Simon McVittie
49eccfbe70 gdbus-server-auth test: Include gcredentialsprivate.h
Otherwise we'll never test the EXTERNAL-only mode, because that relies
on testing the private macros
G_CREDENTIALS_UNIX_CREDENTIALS_MESSAGE_SUPPORTED and
G_CREDENTIALS_SOCKET_GET_CREDENTIALS_SUPPORTED.

Fixes: 9f962ebe "Add a test for GDBusServer authentication"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-11-04 15:07:23 +00:00
Simon McVittie
7021b84f10 gdbus-peer: Specifically listen on 127.0.0.1
This bypasses any issues we might have with containers where IPv6 is
returned by name resolution (particularly since GNOME/glib!616) but
doesn't necessarily actually work.

This comes at a minor test-coverage cost: we don't test GDBusServer's
default behaviour when told to listen on "tcp:" or "nonce-tcp:", and
on systems where IPv6 is available, we don't test it. If we want to
do those, we should perhaps do them in separate tests, and disable
those tests when binding to ::1 doesn't work.

Mitigates: GNOME/glib#1912
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-11-04 13:31:14 +00:00
Philip Withnall
9b8ff414c1 Merge branch 'no-more-automatic-GUnixFDList' into 'master'
Revert "gdbus-codegen: emit GUnixFDLists if an arg has type 'h'"

See merge request GNOME/glib!1171
2019-10-31 13:42:55 +00:00
Mattias Bengtsson
4aaeac5b3c gdbus-codegen: Safer header guards
Whitelist a safe set of characters for use in header guards instead of
maintaining a (growing) blacklist.

The whitelist is intentionally short since reading up on all
peculiarities of the C and C++ standard for identifiers is not my idea
of fun. :)

Fixes #1379
2019-10-31 12:50:30 +00:00
Philip Withnall
623bdfd7ab Merge branch 'wip/smcv/gdbus-tests' into 'master'
Fix GDBus test failures on non-Linux (in particular FreeBSD)

Closes #1920 and #1921

See merge request GNOME/glib!1197
2019-10-31 12:38:12 +00:00
Philip Withnall
1503547766 Merge branch 'param-value-default' into 'master'
Allow using an empty GValue with g_param_value_set_default()

See merge request GNOME/glib!1186
2019-10-31 10:22:57 +00:00
Philip Withnall
15818926b3 glocalfileinfo: Fix minor leak on error handling path for xattrs
Spotted by `scan-build`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-30 15:35:15 +00:00
Philip Withnall
465b4dadf3 tests: Use g_assert_*() rather than g_assert() in live-g-file test
g_assert() is compiled out by `G_DISABLE_ASSERT` and doesn’t give such
useful messages on failure.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-30 15:19:34 +00:00
Philip Withnall
c25e8ec1f2 tests: Drop pointless assignments
Or turn them into proper error checks. This shuts up some `scan-build`
warnings.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-30 15:19:34 +00:00
Philip Withnall
dd5132e041 tests: Tidy up GError assignment
No need to clear it to NULL before every time it’s used, since we assert
that it’s never set.

This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-30 15:19:34 +00:00
Simon McVittie
2b1e706b2f gdbus-server-auth test: Create temporary directory for Unix socket
This avoids failure to listen on the given address on non-Linux Unix
kernels, where abstract sockets do not exist and so unix:tmpdir is
equivalent to unix:dir.

To avoid bugs like this one recurring, run most of these tests using
the unix:dir address type, where Linux is equivalent to other Unix
kernels; just do one unix:tmpdir test, to check that we still
interoperate with libdbus when using abstract sockets on Linux.

Resolves: GNOME/glib#1920
Fixes: 9f962ebe "Add a test for GDBusServer authentication"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-10-29 16:36:19 +00:00
Simon McVittie
bab277fd50 gdbus-peer test: Use unix:dir address if exact format doesn't matter
Previously, we used unix:tmpdir, except in tests that verify that a
particular address type works (notably unix:dir). Now we use unix:dir
most of the time, and unix:tmpdir gets its own test instead.

This helps to ensure that the tests continue to work on non-Linux Unix
kernels, where abstract sockets do not exist and so unix:tmpdir is
equivalent to unix:dir, even in the common case where the developer has
only tried the test on Linux.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-10-29 16:35:46 +00:00
Simon McVittie
7c2e4095f4 gdbus-peer test: Stop GDBusServer before tearing down temporary directory
Otherwise, since GNOME/glib!1193, the listening socket won't be deleted,
and if we are not using abstract sockets (for example on *BSD), g_rmdir
will fail with ENOTEMPTY.

Fixes: 8e32b8e8 "gdbusserver: Delete socket and nonce file when stopping server"
Resolves: GNOME/glib#1921
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-10-29 16:35:06 +00:00
Simon McVittie
e1b7b1ac16 gdbus-peer test: Improve diagnostics if g_rmdir fails
Helps: GNOME/glib#1921
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-10-29 16:35:04 +00:00
Simon McVittie
4e8d058828 Merge branch '1912-gdbus-peer-test' into 'master'
tests: Isolate directories in gdbus-peer test

Closes #1912

See merge request GNOME/glib!1192
2019-10-29 08:37:22 +00:00
Simon McVittie
714f9f92b7 Merge branch '1318-dbus-server-race' into 'master'
gdbusserver: Keep a strong reference to the server in callbacks

Closes #1318

See merge request GNOME/glib!1193
2019-10-29 08:28:56 +00:00
Philip Withnall
0c07e672a2 gdbusserver: Keep a strong reference to the server in callbacks
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
2019-10-28 20:47:04 +00:00
Philip Withnall
8e32b8e87f gdbusserver: Delete socket and nonce file when stopping server
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
2019-10-28 20:47:04 +00:00
Philip Withnall
d44e00fb98 Merge branch 'issue1831' into 'master'
Avoid race condition authenticating GDBusServer with libdbus client (#1831)

Closes #1831

See merge request GNOME/glib!1176
2019-10-28 20:44:30 +00:00
Philip Withnall
6fb38c3f25 tests: Isolate directories in gdbus-peer test
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
2019-10-28 20:36:51 +00:00
Philip Withnall
833579d982 tests: Move main loop and test GUID into test functions in gdbus-peer
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
2019-10-28 20:17:07 +00:00
Philip Withnall
9df8d76c97 gdbusauthmechanismsha1: Create .dbus-keyrings directory recursively
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
2019-10-28 20:17:07 +00:00
Philip Withnall
ef3eec8a28 gdbusauthmechanismsha1: Remove unnecessary g_warning() calls
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
2019-10-28 20:17:07 +00:00
Simon McVittie
9f962ebeac Add a test for GDBusServer authentication
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>
2019-10-28 19:56:47 +00:00
Simon McVittie
ee502dbbe8 GDBus: prefer getsockopt()-style credentials-passing APIs
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
2019-10-28 19:56:00 +00:00
Simon McVittie
1485a97d80 credentials: Invalid Linux struct ucred means "no information"
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>
2019-10-28 19:55:47 +00:00
Simon McVittie
ef1035d9d8 gcredentialsprivate: Document the various private macros
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-10-28 19:54:08 +00:00
Philip Withnall
2d2e96dc51 tests: Use objcopy from the cross-compilation file, if configured
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
2019-10-28 12:08:48 +00:00
Emmanuele Bassi
ca1dbb38d8 tests: Do not init the default value
The call to g_param_value_set_default() will do that for us, now.
2019-10-26 14:06:31 +01:00
Bastien Nocera
0d3b1d55e9 gio: Fix typo in URL
Left-over quote in URL.
2019-10-25 15:09:08 +02:00
Sebastian Dröge
611ea6e805 Merge branch '1836-dbus-connection-docs' into 'master'
gdbusconnection: Clarify nullability in a documentation comment

Closes #1836

See merge request GNOME/glib!1003
2019-10-22 07:48:13 +00:00
Philip Withnall
b7e84fb903 testfilemonitor: Fix a trivial leak in the test
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1910
2019-10-18 17:02:57 +01:00
Will Thompson
43697d6b99 Revert "gdbus-codegen: emit GUnixFDLists if an arg has type 'h'"
This reverts commit 4aba03562b, preserving
the new tests but adjusting them to assert that the old behaviour is
restored.

As expected, there were a few projects which broke because of this.
Unfortunately, in one case the breakage crosses a project boundary:
sysprof ships D-Bus introspection XML, which is consumed by mutter and
passed through gdbus-codegen.

Since sysprof cannot add this annotation without breaking its existing
users, a warning is also not appropriate.

https://gitlab.gnome.org/GNOME/jhbuild/issues/41
https://gitlab.gnome.org/GNOME/sysprof/issues/17
https://gitlab.gnome.org/GNOME/glib/issues/1726
2019-10-18 10:30:00 +01:00
Philip Withnall
592a13b483 glocalfilemonitor: Keep a weak ref to the monitor in GFileMonitorSource
Previously we were keeping a pointer to the `GFileMonitor` in a
`GFileMonitorSource` instance, but since we weren’t keeping a strong
reference, that `GFileMonitor` instance could be finalised from another
thread at any point while the source was referring to it. Not good.

Use a weak reference, and upgrade it to a strong reference whenever the
`GFileMonitorSource` is referring to the file monitor.

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

Helps: #1903
2019-10-11 22:31:24 +01:00
Philip Withnall
5b07fc98e0 gdesktopappinfo: Cancel file monitor when resetting a DesktopFileDir
It’s not enough to unref the monitor, since the GLib worker thread might
still hold a reference to it.

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

Helps: #1903
2019-10-11 22:31:24 +01:00
Philip Withnall
bffe058550 gdesktopappinfo: Allocate DesktopFileDir structs dynamically
`DesktopFileDir` pointers are passed around between threads: they are
initially created on the main thread, but a pointer to them is passed to
the GLib worker thread in the file monitor callback
(`desktop_file_dir_changed()`).

Accordingly, the `DesktopFileDir` objects either have to be
 (1) immutable;
 (2) reference counted; or
 (3) synchronised between the two threads
to avoid one of them being used by one thread after being freed on
another. Option (1) changed with commit 99bc33b6 and is no longer an
option. Option (3) would mean blocking the main thread on the worker
thread, which would be hard to achieve and is against the point of
having a worker thread. So that leaves option (2), which is implemented
here.

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

Fixes: #1903
2019-10-11 22:31:24 +01:00
Milan Crha
822f8bae9e Fix use-after-free when calling g_dbus_connection_flush_sync()
When the _g_dbus_worker_flush_sync() schedules the 'data' and releases
the worker->write_lock, it is possible for the GDBus worker thread thread
to finish the D-Bus call and acquire the worker->write_lock before
the _g_dbus_worker_flush_sync() re-acquires it in the if (data != NULL) body.
When that happens, the ostream_flush_cb() increases the worker->write_num_messages_flushed
and then releases the worker->write_lock. The write lock is reacquired by
the _g_dbus_worker_flush_sync(), which sees that the while condition is satisfied,
thus it doesn't enter the loop body and immediately clears the data members and
frees the data structure itself. The ostream_flush_cb() is still ongoing, possibly
inside flush_data_list_complete(), where it accesses the FlushData, which can be
in any stage of being freed.

Instead, add an explicit boolean flag indicating when the flush is truly finished.

Closes #1896
2019-10-10 14:55:20 +00:00
Patrick Griffis
ea99872e45 Always resolve localhost to loopback address
This always resolves "localhost" to a loopback address which
has security benefits such as preventing a malicious dns server
redirecting local connections and allows software to assume
it is a secure hostname.

This is being adopted by web browsers:

- https://w3c.github.io/webappsec-secure-contexts/
- https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/RC9dSw-O3fE/E3_0XaT0BAAJ
- 8da2a80724
- https://bugs.webkit.org/show_bug.cgi?id=171934
- https://tools.ietf.org/html/draft-west-let-localhost-be-localhost-06
2019-10-10 14:32:18 +01:00
Patrick Griffis
01acb8907f tests: Don't block mainloop for delays in gnetworkaddress tests 2019-10-10 14:32:18 +01:00
Philip Withnall
8492df9f34 gdbusaddress: Validate the noncefile attribute of nonce-tcp addresses
Doing this mostly to fix a compiler warning about tautological
assignments on Android.

See the D-Bus specification:
https://dbus.freedesktop.org/doc/dbus-specification.html#transports-nonce-tcp-sockets

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-08 13:53:01 +01:00
Philip Withnall
e99003841a gdbusaddress: Collapse two translatable strings into one
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-08 13:51:57 +01:00
Philip Withnall
e257e17d2e inotify: Fix some enum comparisons to integers
`-1` isn’t a valid member of the enum, so cast to `int` first. This
fixes a compiler warning on Android.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-08 13:49:40 +01:00
Philip Withnall
0d94ee3bb4 Merge branch 'master' into 'master'
Erase GI annotation: skip g_cancellable_source_new

Closes #1877

See merge request GNOME/glib!1048
2019-10-08 10:33:40 +00:00
Philip Withnall
ab613ae805 Merge branch '1726-gdbus-codegen-h' into 'master'
Resolve "Warn when method/signal uses type 'h' but lacks GDBus.C.UnixFD annotation"

Closes #1726

See merge request GNOME/glib!1079
2019-10-08 10:26:45 +00:00
Philip Withnall
c88f106471 Merge branch 'wip/oholy/gio-completion' into 'master'
Several gio-tool bash completion fixes and improvements

See merge request GNOME/glib!1153
2019-10-07 09:23:41 +00:00
Philip Withnall
a350fa50a5 Merge branch 'winhttp-handle-null-prgname' into 'master'
gwinhttpvfs: Handle g_get_prgname() returning NULL

See merge request GNOME/glib!1152
2019-10-07 09:04:06 +00:00
Philip Withnall
acf55ad584 Merge branch 'solaris-build-fixes' into 'master'
Solaris build fixes

See merge request GNOME/glib!1146
2019-10-07 08:44:39 +00:00
Ondrej Holy
b3bf1e263e gio: Always include mounts in the results
Mounts are currently completed only if the prefix looks like scheme,
however, this doesn't work well if the mounts have also path component.
Let's always include them to fix this issue. The mounts are cached by the
volume monitors, so it should not significantly affect the performance.
2019-10-07 09:21:19 +02:00
Ondrej Holy
8bc52105ef gio: Complete also activation roots of volumes
Currently, "gio mount google-drive<tab>" isn't completed even though
that volume exists for google-drive://oholy@redhat.com/. Let's use
"gio mount -li" output to complete also activation roots of volumes.
2019-10-07 09:21:19 +02:00
Ondrej Holy
3a1492ec4f gio: Fix completion of URIs without hostname part
Currently, "gio list file:///h<tab>" doesn't complete "file:///home"
because the result of "dirname file:///h" is not "file:///" but "file:/",
which breaks the consequent logic. Let's subtract basename from the
path in order to workaround this issue.
2019-10-07 09:21:09 +02:00
Christoph Reiter
bf2a10211b gwinhttpvfs: Handle g_get_prgname() returning NULL
When prgname wasn't set NULL would be passed to g_utf8_to_utf16()
resulting in "g_utf8_to_utf16: assertion 'str != NULL' failed"
2019-10-06 20:05:44 +02:00
Simon McVittie
dd27d2beeb Merge branch 'patch-1' into 'master'
gio/gfile: fix parameter reference for value_p

See merge request GNOME/glib!1149
2019-10-06 13:18:44 +00:00
Simon McVittie
cb97f0e114 Merge branch 'dlech-master-patch-99473' into 'master'
gio/gfileinfo: fix parameter references

See merge request GNOME/glib!1148
2019-10-06 13:17:59 +00:00
Simon McVittie
5ac73a0972 Merge branch 'patch-2' into 'master'
gio/gfile: fix parameter references to @contents

See merge request GNOME/glib!1150
2019-10-06 13:17:17 +00:00
David Lechner
4723bf5720 gio/gfile: fix typo in doc comment
This fixes a typo in g_file_has_prefix() do comments.
2019-10-06 02:01:48 +00:00
David Lechner
f71eca16d5 gio/gfile: fix parameter references to @contents
Fix a number of occurrences where the parameter reference was missing the trailing 's'
2019-10-06 01:55:40 +00:00
David Lechner
5120f92c33 gio/gfile: fix parameter reference for value_p
This fixes a parameter reference to @value_p in g_file_set_attribute()
2019-10-06 01:48:15 +00:00
David Lechner
5dee5263e8 gio/gfileinfo: fix parameter references
This fixes a couple of parameter references for @info in the doc comments.
2019-10-05 22:36:19 +00:00
Alan Coopersmith
2b34f52b01 build: no --export-dynamic ldflags for Solaris
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-10-04 13:23:25 -07:00
Alan Coopersmith
e5e1490990 gunixmounts: Handle Solaris name of mnt_mntopts in place of mnt_opts
Fixes build failure:
../gio/gunixmounts.c: In function ‘_g_get_unix_mounts’:
../gio/gunixmounts.c:742:53: error: ‘struct mnttab’ has no member named ‘mnt_opts’; did you mean ‘mnt_mntopts’?
  742 |                                              mntent.mnt_opts,
      |                                                     ^~~~~~~~
      |                                                     mnt_mntopts

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-10-04 12:55:17 -07:00
Philip Withnall
d207e19d32 Merge branch 'wip/tingping/pkcs11' into 'master'
gtlscertificate: Add pkcs11-uri property and constructor

Closes #1809

See merge request GNOME/glib!933
2019-10-03 12:12:16 +00:00
Patrick Griffis
b6d8efbebc gtlscertificate: Add support for PKCS #11 backed certificates
This adds properties to allow backends to expose PKCS #11 support.
2019-10-02 10:12:40 -07:00
Philip Withnall
0c40f3f6b9 Merge branch 'cross-installed-tests' into 'master'
Always build tests if we enabled installed-tests

See merge request GNOME/glib!1138
2019-10-02 15:54:19 +00:00
Philip Withnall
406c8b04fc Merge branch 'file-permissions-redux' into 'master'
Fix handling of G_FILE_COPY_TARGET_DEFAULT_PERMISSIONS in g_file_copy()

Closes #174

See merge request GNOME/glib!1134
2019-10-02 15:40:09 +00:00
Simon McVittie
14609b0b25 g_file_info_get_modification_date_time: Calculate in integer domain
g_date_time_add_seconds() and g_date_time_add_full() use floating-point
seconds, which can result in the value varying slightly from what's
actually on disk. This causes intermittent test failures in
gio/tests/g-file-info.c on Debian i386, where we set a file's mtime
to be 50µs later, then read it back and sometimes find that it is only
49µs later than the previous value.

I've only seen this happen on i386, which means it might be to do with
different floating-point rounding when a value is stored in the 80-bit
legacy floating point registers rather than in double precision.

g_date_time_add() takes a GTimeSpan, which is in microseconds;
conveniently, that's exactly what we get from the GFileInfo.

Bug-Debian: https://bugs.debian.org/941547
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-10-02 08:30:35 +01:00
Simon McVittie
42d8e17795 Always build tests if we enabled installed-tests
If we're cross-compiling, the installed-tests are useful even if we
can't run them on the build machine: we can copy them to the host
machine (possibly via a distro package like Debian's libglib2.0-tests)
and run them there.

While I'm changing the build-tests condition anyway, deduplicate it.

Based on a patch by Helmut Grohne.

Bug-Debian: https://bugs.debian.org/941509
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-10-01 20:12:16 +01:00
Ignacio Casal Quinteiro
9239f2659f gregistrysettings: bump key name length to 128
32 is just too low for key names, specially since the registry has a limit
of 16,383 chars. Giving that, 128 is a good bump for now.
2019-10-01 14:35:43 +02:00
Philip Withnall
eb2125770d tests: Expand g_file_copy() tests to test DEFAULT_PERMS flag
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-30 14:40:55 +01:00
Philip Withnall
67772b6a70 tests: Unconditionally enable the file permissions test
Skip it on systems which don’t support it, rather than compiling it out.
That gives us more information from test runs about which tests are
being run on which architectures.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-30 14:40:55 +01:00
Philip Withnall
bfdc5fc4fc glocalfileinfo: Only return file mode, not type, as UNIX_MODE attribute
As with the previous commit, `st_mode` contains both the file type
(regular file, directory, symlink, special, etc.) and the file mode. For
`G_FILE_ATTRIBUTE_ID_UNIX_MODE`, we only want the file mode — so mask
`st_mode` with `~S_IFMT`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-30 14:40:55 +01:00
Philip Withnall
5dd5269126 glocalfileoutputstream: Only pass file mode, not type, to chmod()
chmod() technically only accepts file modes, not the file type and mode
as returned by stat(). Filter by `S_IFMT` to avoid sending the file
type (regular file, directory, symbolic link, etc.).

In practice, chmod() ignores anything except the file mode, but we might
as well comply with the specification.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-30 14:40:55 +01:00
Philip Withnall
674ba78f12 gfile: Document a few nullable vfuncs
`GFile` always checks whether these vfuncs are `NULL` before calling
them, so document that it’s safe for implementations of `GFile` to not
implement them.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-30 14:40:55 +01:00
Philip Withnall
7d2bce82e2 glocalfile: Don’t define unsupported copy vfunc
The caller assumes that an unimplemented vfunc means that copying is
unsupported (and falls back to its internal copy implementation), so
there’s no point in implementing the vfunc just to unconditionally
return `G_IO_ERROR_NOT_SUPPORTED`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-30 14:40:55 +01:00
Philip Withnall
1b7ab81c1c glocalfile: Don’t define symlink vfunc if it’s unsupported
Rather than defining a vfunc which only ever returns
`G_IO_ERROR_NOT_SUPPORTED`, just don’t define the vfunc at all. The
caller in `GFile` interprets this as symlinks not being supported — so
we get the same behaviour, but without spending a vfunc call on it.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-30 14:40:55 +01:00
Philip Withnall
775014dd3b gfile: Use a more specific error message if symlinks are not supported
The string is already translated in `GLocalFile`, so this doesn’t
introduce a new translatable string.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-30 14:40:55 +01:00
Philip Withnall
2268f36769 gio-tool: Add a --default-permissions argument to gio copy
This sets the `G_FILE_COPY_DEFAULT_PERMS` flag on the operation,
creating the copied file with default permissions rather than the same
permissions as the source file.

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

Fixes: #174
2019-09-30 14:40:50 +01:00
Philip Withnall
53f6ede628 gfile: Don’t copy files as private if using default permissions
If a copy operation is started with `G_FILE_COPY_TARGET_DEFAULT_PERMS`,
don’t create the destination file as private. Instead, create it with
the process’ current umask (i.e. ‘default permissions’).

This is a partial re-work of commit d8f8f4d637, with
input from Ondrej Holy.

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

Fixes: #174
2019-09-30 14:40:43 +01:00
Philip Withnall
51d73ef5d9 gfile: Factor out flags when copying files
This introduces no functional changes; just reduces duplication in the
code a little.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-30 14:24:38 +01:00
David Lechner
2a4b9eb20c gio/gfileinfo: fix param reference in doc comment
The actual parameter name in g_file_attribute_matcher_new()
attributes, so change the param reference to match. This way,
doc tools can create a proper link.
2019-09-29 01:03:22 +00:00
Matthew Leeds
1015bfb6ba fileinfo: Mention that usec mtimes are set
g_file_info_set_modification_time() and
g_file_info_set_modification_date_time() set the
G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC attribute in addition to
G_FILE_ATTRIBUTE_TIME_MODIFIED, so microsecond precision is available
when provided by the caller, so mention both attributes in the docs.
2019-09-25 13:43:51 +00:00
Niels De Graef
14ba521b6d gliststore: Add item lookup functions
Currently, there is no quick way to find whether and element is already
part of a list store, except for manually writing a for-loop and calling
`g_list_model_get_item()` and breaking when you find the item.

This is mostly just a small API addition to support this use case.

Fixes https://gitlab.gnome.org/GNOME/glib/issues/1011
2019-09-25 08:37:22 +02:00
Philip Withnall
55f9c6d2f4 gatomic: Add various casts to use of g_atomic_*()s to fix warnings
When compiling GLib with `-Wsign-conversion`, we get various warnings
about the atomic calls. A lot of these were fixed by
3ad375a629, but some remain. Fix them by
adding appropriate casts at the call sites.

Note that `g_atomic_int_{and,or,xor}()` actually all operate on `guint`s
rather than `gint`s (which is what the rest of the `g_atomic_int_*()`
functions operate on). I can’t find any written reasoning for this, but
assume that it’s because signedness is irrelevant when you’re using an
integer as a bit field. It’s unfortunate that they’re named a
`g_atomic_int_*()` rather than `g_atomic_uint_*()` functions.

Tested by compiling GLib as:
```
CFLAGS=-Wsign-conversion jhbuild make -ac |& grep atomic
```

I’m not going to add `-Wsign-conversion` to the set of default warnings
for building GLib, because it mostly produces false positives throughout
the rest of GLib.

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

Fixes: #1565
2019-09-21 10:48:23 +02:00
Sebastian Dröge
cf25d9a2ec Merge branch 'wip/oholy/gio-remove-completion' into 'master'
gio: Add missing "gio remove" option to bash completion script

See merge request GNOME/glib!1110
2019-09-17 10:06:49 +00:00
Ondrej Holy
84c8899fca gio: Add missing "gio remove" option to bash completion script
Bash completion	script allows to complete various options, but "gio remove"
is missing. Let's add this missing option.
2019-09-16 11:19:50 +02:00
Egmont Koblinger
8f30e6c3bb doc: fix typo in gio/gsettings.c 2019-09-14 23:11:57 +02:00
Philip Withnall
86c282cd78 Merge branch 'iov-max' into 'master'
Define G_IOV_MAX to 512 on macOS/iOS

See merge request GNOME/glib!1095
2019-09-13 13:37:25 +00:00
Nirbheek Chauhan
b01bbe6536 Merge branch '1767-scan-build-fixes' into 'master'
Various small scan-build fixes

See merge request GNOME/glib!1088
2019-09-13 12:37:37 +00:00
Sebastian Dröge
6d4738ed22 Merge branch '1875-xdgmimecache-robustness' into 'master'
xdgmime: Prevent infinite loops from badly-formed MIME registrations

Closes #1875

See merge request GNOME/glib!1085
2019-09-13 11:42:55 +00:00
Philip Withnall
adf96047f4 xdgmime: Prevent infinite loops from badly-formed MIME registrations
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1875
2019-09-13 12:13:49 +01:00
Sebastian Dröge
81f614533d Define G_IOV_MAX to 512 on macOS/iOS
For macOS/iOS, UIO_MAXIOV is documented in writev(2), but <sys/uio.h> only
declares it if defined(KERNEL)

Inspired by a GStreamer MR by Jim Mason
https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/277
2019-09-10 10:16:03 +03:00
Philip Withnall
475b9b5f7c tests: Add tests for GFileInfo modification time
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-05 17:13:08 +01:00
Philip Withnall
b99cdf56dc tests: Use g_assert_*() rather than g_assert() in g-file-info test
They provide more detailed failure messages, and aren’t compiled out
when building with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-05 17:13:08 +01:00
Christian Hergert
b933b0f369 fileinfo: ignore USEC if not available
When future porting deprecated code to use
g_file_info_get_modification_date_time() we risk a number of breakages
because the current implementation also requires the additional use of
G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC. This handles that situation gracefully
and returns a GDateTime with less precision.

Applications that want the additional precision, are already using the
additional attribute.

(Minor tweaks by Philip Withnall.)
2019-09-05 17:13:08 +01:00
Philip Withnall
8fe58ffe12 gdbusdaemon: Fix unused variable warning
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1767
2019-09-05 14:17:08 +01:00
Philip Withnall
d99653f6fe gdbusdaemon: Add sanity checks on name refcounting
This should make the code a bit easier to reason about, and squash some
static analysis warnings.

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

Helps: #1767
2019-09-05 14:17:05 +01:00
Philip Withnall
0b4162e714 build: Disable dtrace probes under static analysis
The macros for the probes confuse the static analyser, and are often
called with arguments which the analyser things shouldn’t be used any
more (for example, the address of a block of memory which has just been
freed).

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

Helps: #1767
2019-09-05 14:16:58 +01:00
Philip Withnall
18a232be89 glib: Various minor scan-build fixes
These squash various warnings from `scan-build`. None of them are
legitimate bugs, but some of them do improve code readability a bit.

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

Helps: #1767
2019-09-05 13:51:27 +01:00
Will Thompson
4aba03562b gdbus-codegen: emit GUnixFDLists if an arg has type 'h'
Previously, if a method was not annotated with org.gtk.GDBus.C.UnixFD
then the generated code would never contain GUnixFDList parameters, even
if the method has 'h' (file descriptor) parameters. However, in this
case, the generated code is essentially useless: the method cannot be
called or handled except in degenerate cases where the file descriptors
are missing or ignored.

Check the argument types for 'h', and if present, generate code as if
org.gtk.GDBus.C.UnixFD annotation were specified.

This change will break any existing code which refers to the (useless)
wrappers for such methods. The workaround for such code is to add the
org.gtk.GDBus.C.UnixFD annotation, which will cause the same generated
code to be emitted before and after this change.

If this is found to cause widespread problems, we can explore a
different approach (perhaps emitting a warning from the code generator,
or annotating the symbols as deprecated).

https://gitlab.gnome.org/GNOME/glib/issues/1726
2019-09-02 20:47:20 +01:00
Sebastian Dröge
daa308dd6e Merge branch '487-ci-memcheck' into 'master'
Add CI job for running tests under Valgrind

Closes #487

See merge request GNOME/glib!169
2019-09-02 13:52:35 +00:00
Philip Withnall
39052a1cfc tests: Fix some minor memory leaks in tests
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-02 14:16:33 +01:00
Emmanuele Bassi
a0cbb32680 Merge branch '1309-delayed-settings-changed' into 'master'
gsettings: Add missing changed() call to delayed settings backend

Closes #1309

See merge request GNOME/glib!1046
2019-09-02 11:14:59 +00:00
Will Thompson
9b827e5674 gdbus-codegen: process C.UnixFD annotation in one place
This will make it simpler to enable this behaviour based on the method
signature.

https://gitlab.gnome.org/GNOME/glib/issues/1726
2019-09-02 06:54:37 +01:00
Nirbheek Chauhan
9456cec53e Merge branch 'wip/lantw/meson-move-libdl_dep-to-the-top-level' into 'master'
meson: Move libdl_dep to the top level

See merge request GNOME/glib!1071
2019-08-29 18:45:36 +00:00
Ting-Wei Lan
fe3c16608a meson: Move libdl_dep to the top level
Instead of letting each directory to find its way to link with libdl,
it is easier to put the check in the top level, so its result can be
used by all directories.

It is a follow-up of https://gitlab.gnome.org/GNOME/glib/merge_requests/810.
2019-08-29 23:25:40 +08:00
Mihai Moldovan
bd4c16b356 gio: actually install and reference gnativesocketaddress.h.
The header file was installed when building using autotools, but was
inadvertently omitted in the meson targets.

Luckily, ABI is not impacted, since gnativesocketaddress.c was always
compiled and linked into libgio.

Fixes: #1854
2019-08-29 14:32:55 +02:00
Mihai Moldovan
5e18888a94 gio: Housekeeping: sync up and sort gio_{sources,headers} lists 2019-08-29 14:32:55 +02:00
Sergio Costas
09e094a676 gsubprocesslauncher.c: fix documentation
The gobject introspection comments have a reference to an incorrect
class: they have, as 'self', the GSubprocess class instead of
GSubprocessLauncher.

This patch fixes this.
2019-08-29 00:15:03 +02:00
Sebastian Dröge
d3ae4b1d30 GSettingsBackend - Fix thread-safety during destruction of GSettings instances while notifications are emitted
g_settings_backend_watch() uses a weak notify for keeping track of
the target. There's an explanation why this is supposed to be safe but
that explanation is wrong.

The following could happen before:

1. We have the target stored in the watch list
2. The last reference to the target is dropped in thread A and we end up
   in g_settings_backend_watch_weak_notify() right before the mutex
3. g_settings_backend_dispatch_signal() is called from another thread B
   and gets the mutex before 2.
4. g_weak_ref_init() is called on the target from thread B, which at
   this point has a reference count of exactly one (see g_object_unref()
   where it calls the weak notifies)
5. Thread A continues at 3. and drops the last reference and destroys
   the object. Now the GWeakRef from 4. points to a destroyed object. Note
   that GWeakRefs would be cleared before the weak notifies are called
6. At some later point another thread g_weak_ref_get() is called by
   g_settings_backend_invoke_closure() and accesses an already destroyed
   object with refcount 0 from the GWeakRef created in 4. by thread B (or
   worse, already freed memory that was reused).

Solve this by actually storing a GWeakRef of the target in the watch
list and only access the target behind it via the GWeakRef API, and then
pass a strong reference to the notification dispatch code.

The weak notify is only used to remove the (potentially with empty
GWeakRef) target from the list of watches and the only place that
compares the target by pointer instead of going through the GWeakRef
API.

Fixes https://gitlab.gnome.org/GNOME/glib/issues/1870
2019-08-27 11:09:08 +03:00
Philip Withnall
562ac9de43 gwinhttpvfs: Fall back to wrapped VFS if creating a HTTP file fails
If we fail to create a GWinhttpFile for a URI (for example, because it’s
an invalid URI or is badly encoded), don’t just return NULL. Instead,
fall back to the wrapped VFS which might be able to handle it instead.

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

Fixes: #1819
2019-08-27 08:21:26 +03:00
Philip Withnall
4b0421a730 gwinhttpfile: Document constructor as potentially returning NULL
It can return NULL if the URI was badly encoded or couldn’t be handled
by Windows’ API.

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

Helps: #1819
2019-08-27 08:21:26 +03:00
Philip Withnall
e24503a8e9 gvfs: Add an assertion to check that get_file_for_uri() is never NULL
It cannot return a NULL value, as none of its callers have error
handlng. Add an assertion to check the values returned by the VFS
implementations.

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

Helps: #1819
2019-08-27 08:21:25 +03:00
Philip Withnall
833c24f45a gvolumemonitor: Use GIOModule methods for getting default type
This fixes use of `GIO_USE_VOLUME_MONITOR=help`, and simplifies the
code. The reason this wasn’t used already seems to just be because it
was missed when `_g_io_module_get_default_type()` was introduced in
2013. The previous `get_default_native_class()` code in
`gunionvolumemonitor.c` was introduced in 2007.

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

Closes: #1881
2019-08-26 13:41:26 +03:00
Дилян Палаузов
512655aa12 minor typos in the documentation (a/an) 2019-08-24 19:14:05 +00:00
Philip Withnall
c178c9734c Merge branch 'static_analysis_2_40_patches' into 'master'
Static analysis 2 40 patches

Closes #905

See merge request GNOME/glib!1042
2019-08-24 14:22:38 +00:00
Colin Walters
649faee0e6 gio/gnetworkmonitornetlink.c: Add NULL check on dest before using it 2019-08-24 15:55:49 +02:00
Colin Walters
f731dd376c gio/glib-compile-resources.c: Unref objects in error path 2019-08-24 15:44:59 +02:00
Philip Withnall
3c9ff2712f Merge branch 'override' into 'master'
Meson: Override glib-compile-resources/schemas

See merge request GNOME/glib!1037
2019-08-23 11:30:46 +00:00
George Barrett
274985a2ce Erase GI annotation: skip g_cancellable_source_new
Deletes the skip annotation from g_cancellable_source_new(). This was
originally added because GSource wasn't introspectable, but this is no
longer an issue as G_TYPE_SOURCE was added in 2.30.

Fixes: #1877
2019-08-23 01:34:12 +10:00
Philip Withnall
13e947d8cf Merge branch '1867-en-gb-isms' into 'master'
glib-compile-schemas: Fix some minor en_GB-isms in translatable strings

Closes #1867

See merge request GNOME/glib!1038
2019-08-21 17:53:43 +00:00
Philip Withnall
63abca2963 gsettings: Add missing changed() call to delayed settings backend
When resetting a key in the delayed settings backend,
g_settings_backend_changed() was not called to notify the backend of
the change.

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

Fixes: #1309
2019-08-21 20:08:04 +03:00
Philip Withnall
87a71fe4d3 tests: Add a test for peer-to-peer GDBusProxy usage with a bus name
This is a regression test for the fix in !554.

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

Fixes: #1620
2019-08-21 19:49:06 +03:00
Philip Withnall
a01983f94c tests: Add a test for g_dbus_connection_get_flags()
It was added in !554 but never had a unit test.

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

Helps: #1620
2019-08-21 19:49:06 +03:00
Philip Withnall
9fc745db07 tests: Drop unnecessary usage of g_test_bug_base("")
See the previous commit.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-08-21 19:42:27 +03:00
Philip Withnall
389b1820f2 glib-compile-schemas: Fix some minor en_GB-isms in translatable strings
Spotted by Bruce Cowan.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Fixes: #1867
2019-08-14 10:38:23 +02:00
Xavier Claessens
fdcdd5c5b4 Meson: Override glib-compile-resources/schemas
This fix build error for projects that use gnome.compile_resources()
when glib is built as a subproject and not installed on the build
machine.

Note that this is not working for cross compilation cases, because it
would require to compile everything twice (for host and build machines).
A better solution would be to rewrite those tools in python. See #1859.
2019-08-13 08:52:50 -04:00
Philip Withnall
84738f7e80 Merge branch 'wip/hadess/gnetworkmonitor-nm-fixups' into 'master'
gnetworkmonitornm fixups

See merge request GNOME/glib!1016
2019-07-29 15:47:55 +00:00
Bastien Nocera
f299886f1f gnetworkmonitornm: Remove double-space 2019-07-29 17:28:01 +02:00
Bastien Nocera
109f247039 gnetworkmonitornm: Arguments to g-signal's callback are const 2019-07-29 17:28:01 +02:00
Bastien Nocera
7d3ecce346 gnetworkmonitornm: Disconnect g-signal from proxy
So that we're sure never to receive a signal if something is keeping the
proxy alive.
2019-07-29 17:28:01 +02:00
Bastien Nocera
ef1d5b5ee0 gnetworkmonitornm: Remove unneeded ";" in G_DEFINE_INTERFACE_WITH_CODE 2019-07-29 17:28:01 +02:00
Philip Withnall
86ba1b37bd Merge branch 'application-free-remote-actions' into 'master'
gapplication: Fix a leaking GRemoteActionGroup member

See merge request GNOME/glib!1011
2019-07-29 13:21:51 +00:00
Philip Withnall
96c74fd0e6 win32: Stop using deprecated GTimeVal in GWinHttpFile
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1438
2019-07-29 12:27:29 +01:00
Philip Withnall
de25be72f0 tests: Stop using deprecated g_get_current_time()
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1438
2019-07-29 12:27:29 +01:00
Philip Withnall
161654681f gfileinfo: Stop using deprecated GTimeVal
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1438
2019-07-29 12:27:29 +01:00
Philip Withnall
def5db23a3 gdbusutils: Stop using g_get_current_time()
It is deprecated.

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

Helps: #1438
2019-07-29 12:27:29 +01:00
Philip Withnall
4faf4fcfaa gfileinfo: Deprecate g_file_info_{get,set}_modification_time()
They use the deprecated GTimeVal type, which is not year 2038 safe, so
have to be deprecated.

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

Helps: #1438
2019-07-29 12:27:29 +01:00
Philip Withnall
d166a55c64 gfileinfo: Add g_file_info_{get,set}_modification_date_time() APIs
These are alternatives to g_file_info_{get,set}_modification_time(),
which will soon be deprecated due to using the deprecated GTimeVal
type, which is not year 2038 safe.

The new APIs take a GDateTime instead.

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

Helps: #1438
2019-07-29 12:27:29 +01:00
Philip Withnall
8f385b8cf5 Merge branch 'master' into 'master'
windows: fix multicast socket binding to specific network interfaces

Closes #1635

See merge request GNOME/glib!887
2019-07-29 11:10:40 +00:00
Philip Withnall
0f131857ba gapplication: Fix a leaking GRemoteActionGroup member
Fix prompted by Ting-Wei Lan’s similar fix for the inactivity timeout
(!1009).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-07-29 10:49:45 +01:00
Ting-Wei Lan
0ed8605079 gapplication: remove inactivity_timeout source on finalize
The event source used to handle inactivity_timeout doesn't hold a
reference on the application. Therefore, it is possible for callback
function of the event source to run after the application has been
freed, leading to use-after-free problem. To avoid the problem, we
should remove the event source before the application is freed.

This should fix SIGBUS crash of gio/tests/gapplication on FreeBSD.
https://gitlab.gnome.org/GNOME/glib/issues/1846#note_566550
2019-07-27 15:28:23 +08:00
Philip Withnall
78b1278d44 Merge branch '488-assert-gobjects-dont-leak' into 'master'
gobject: Add a g_assert_finalize_object() macro

Closes #1780 and #488

See merge request GNOME/glib!859
2019-07-25 15:42:39 +00:00
Philip Withnall
b6d4da7684 tests: Use g_object_assert_last_unref() in various tests
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-07-25 15:23:21 +01:00
Emmanuele Bassi
17be9e5c4c Merge branch '436-test-coredumps' into 'master'
Fix tests creating coredumps

Closes #436

See merge request GNOME/glib!959
2019-07-25 13:49:09 +00:00
Emmanuele Bassi
298ee8f87c Merge branch '1791-macos-get-mime-dirs' into 'master'
gcontenttype: Add no-op versions of {get,set}_mime_dirs() on win32/macOS

Closes #1791

See merge request GNOME/glib!927
2019-07-25 13:48:04 +00:00
Philip Withnall
3de1b88339 gcontenttype: Add no-op versions of {get,set}_mime_dirs() on win32/macOS
These are here to prevent linker errors, since `gcontenttype.[ch]`
aren’t compiled on Windows or macOS.

The implementations are stubs to be filled out by someone who knows each
platform, at some point in the future.

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

Fixes: #1791
2019-07-24 14:50:53 +01:00
Emmanuele Bassi
00d7568e4f build: Remove unsupported install directives
We're using the `install` argument for configure_file() all over the
place.

The support for an `install` argument for configure_file() was added in
Meson 0.50, but we haven't bumped the minimum version of Meson we
require, yet; which means we're getting compatibility warnings when
using recent versions of Meson, and undefined behaviour when using older
versions.

The configure_file() object defaults to `install: false`, unless an
install directory is used. This means that all instances of an `install`
argument with an explicit `true` or `false` value can be removed,
whereas all instances of `install` with a value determined from a
configuration option must be turned into an explicit conditional.
2019-07-24 12:45:02 +01:00
Simon McVittie
3f1a79a4fa Merge branch 'allow_guid_key_in_dbus_addresses' into 'master'
Allow guid key in dbus addresses

Closes #1018

See merge request GNOME/glib!995
2019-07-23 13:01:09 +00:00
Дилян Палаузов
74583affe0 Add (out) annotation to (optional) parameters
… as the parameters are not (inout).

Closes #1837
2019-07-23 11:41:42 +00:00
Philip Withnall
b649946c00 gdbusconnection: Clarify nullability in a documentation comment
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
2019-07-23 11:34:59 +01:00
Philip Withnall
249299a76f Merge branch 'doc-fixes' into 'master'
Various doc fixes

See merge request GNOME/glib!982
2019-07-17 10:58:21 +00:00
Philip Withnall
fa4423d435 Merge branch 'clang-cl-support' into 'master'
Experimental clang-cl support

See merge request GNOME/glib!979
2019-07-17 10:30:28 +00:00
Matthew Leeds
0c495f3dbf gdbusaddress: Add missing transfer annotation 2019-07-16 13:43:20 -07:00
Emmanuel Fleury
6a1512ed65 Allow guid key in dbus addresses
Original patch from William Hua

Fix issue #1018
2019-07-16 10:34:42 +02:00
Matthew Leeds
ce9ea30b1d gio: Fix minor docs mistakes 2019-07-15 16:07:18 -07:00
Philip Withnall
2ac44f3111 Merge branch 'key-file-no-file' into 'master'
key file: Handle filename being NULL

Closes #1825

See merge request GNOME/glib!984
2019-07-15 12:50:45 +00:00
Philip Withnall
493b8ca021 Merge branch 'keyfile-portal-fixes' into 'master'
Keyfile portal fixes

See merge request GNOME/glib!985
2019-07-15 12:32:01 +00:00
Matthias Clasen
addb8c158a settings: Tweak priorities for keyfile backend
We want to use the keyfile backend in sandboxes,
but we want to avoid people losing their existing
settings that are stored in dconf. Flatpak does
a migration from dconf to keyfile, but only if
the app explictly requests it.

From an app perspective, there are two steps to
the dconf->keyfile migration:
1. Request that flatpak do the migration, by adding
   the migrate-path key to the metadata
2. Stop adding the 'dconf hole' to the sandbox

To keep us from switching to the keyfile backend
prematurely, look at whether the app has stopped
requesting a 'dconf hole' in the sandbox.
2019-07-15 13:01:56 +01:00
Matthias Clasen
9c5d3a6081 portal: Add a getter for dconf access
Add method to find whether the sandbox provides
access to dconf. This will be used to tweak
the priorities for the keyfile settings backend.
2019-07-15 13:01:56 +01:00
DDoSolitary
2718245dc2 Fix test failures for static builds
The plugin modules in these tests get statically linked with a separate
copy of GLib so they end up calling vfuncs in their own copy of GLib.

Fixes #1648
2019-07-15 11:01:04 +00:00
Nirbheek Chauhan
5e7f12b0ce gio/tests: Remove code and comments referring to libtool 2019-07-13 12:23:07 +05:30
Riccardo Bortolato
2b1a9219f1 windows: fix multicast socket binding to specific network interfaces
v7, based on a patch by mrgard (GNOME/glib#1635)
make w32_adapter_ipv4_addr() C90-compliant
check for ERROR_BUFFER_OVERFLOW when calling GetAdaptersAddresses()
code-style fixes
indentation fixes
use g_try_(re)alloc and g_free
style suggestions by pwithnall
drop uni_count variable
cap maximum allowed interface name string length according to windows documentation

Fixes: #1635
2019-07-12 15:21:53 +02:00
Chun-wei Fan
e8d471f3e1 meson: Mostly assume clang-cl is MSVC
We need to enable building the dirent and gnulib sources for clang-cl,
as we are still using the Microsoft-style headers and lib's and CRT.
We need to also do this for the following, for similar reasoning:

-Symbol export (via __declspec(dllexport))
-Dependency discovery without pkg-config files
-long long and ssize_t detection

We do, however, enable the autoptr tests for clang-cl builds.  Note that
at this point real MSVC builds are still better supported than clang-cl
builds, and it will likely remain so for at least the near future,
alhtough real MSVC builds of the GTK stack are consumable and are usable
by clang-cl.
2019-07-11 15:38:21 +08:00
Matthias Clasen
953f23f13c key file: Handle filename being NULL
This happens when we are default-constructed
without explicit arguments.

Closes: https://gitlab.gnome.org/GNOME/glib/issues/1825
2019-07-10 11:14:03 -04:00
Xavier Claessens
8381ce472f doc: Hide some internal function 2019-07-10 10:29:04 -04:00
Xavier Claessens
5c9af3c75c doc: Add some empty lines to unbreak gtkdoc
For some reason gtkdoc thinks g_test_trap_fork() is undefined, unless
some more spacing is added.
2019-07-10 10:10:49 -04:00
Sonny Piers
40b3efe931 gio: fix typo in g_settings_reset documentation 2019-07-10 13:51:53 +00:00
Chun-wei Fan
45a21dcc3a Merge branch 'fix-module-tests-msvc' into 'master'
Fix module tests on Visual Studio builds

See merge request GNOME/glib!937
2019-07-10 07:30:41 +00:00
Matthias Clasen
5f8d787815 Ensure that the keyfile settings backend exists
We need to bring the type into existence.

Closes: https://gitlab.gnome.org/GNOME/glib/issues/1822
2019-07-08 10:32:18 -04:00
Sonny Piers
06f27fc208 doc: fix typo in gio/gresource.c 2019-07-08 10:48:23 +00:00
Philip Withnall
4e538e674c Merge branch 'bug-787-investigation' into 'master'
Fix memory error with GDBusConnection in g_test_dbus_down()

Closes #787

See merge request GNOME/glib!963
2019-07-05 11:52:28 +00:00
David Strauss
979c92df17 Fix typo in request handle 2019-07-04 16:23:44 +00:00
Matthew Leeds
d4db5a8288 gtestdbus: Clarify comment on dropping connection ref
In _g_object_unref_and_wait_weak_notify() we take a weak reference and
then call g_object_unref() in an idle callback, which may look like
we're dropping a strong reference without having one. So change the
comment to make it more clear that the reference being dropped is held
by the caller.
2019-07-03 20:28:36 -07:00
Matthew Leeds
59ce6b10dc gdbus-connection-loss: Fix test failure
Now that we're not calling g_object_run_dispose() indirectly in
g_test_dbus_down() (see commit "Revert "gtestdbus: Properly close server
connections""), the test gdbus-connection-loss is failing with the
message "Bail out! GLib-GIO-FATAL-WARNING: Weak notify timeout, object
ref_count=1". This is because we're holding a reference to the singleton
connection object while calling session_bus_down() in the test's main().
So then we end up waiting for 30 seconds in
_g_object_unref_and_wait_weak_notify() for the GWeakNotify to be
triggered, which never happens.

The fix is to unref the connection before calling session_bus_down().
This is consistent with how other tests work, and is safe because the
only method called on the connection has already errored out, as
asserted by the test.
2019-07-03 20:28:36 -07:00
Matthew Leeds
1c63d5d539 Revert "Work around test failure in gdbus-names"
This reverts commit c37cd19fee.

Now that we've reverted the commit "gtestdbus: Properly close server
connections", g_test_dbus_down() no longer returns early and we no
longer need this workaround. Since the gdbus-names test seems to
properly unref its GDBusConnection objects it's not clear to me why it
needed the sleep to succeed. However even at the time the failure wasn't
reproducible according to this comment[1] so it's probably not worth
spending more effort trying to reproduce it now.

[1] https://gitlab.gnome.org/GNOME/glib/issues/787#note_214235
2019-07-03 20:21:34 -07:00
Matthew Leeds
d03025ba10 Revert "gtestdbus: Properly close server connections"
This reverts commit baf92d09d6.

Closes #787

According to the original commit, this change was made because otherwise
g_test_dbus_down() following a g_test_dbus_stop() hangs until it times
out. The timeout being referred to is the 30 seconds which are waited by
_g_object_unref_and_wait_weak_notify() for the GWeakNotify to be
triggered when the last strong reference to the singleton
GDBusConnection object is dropped. But the patch was not correct and the
leak should have instead been fixed by having the last strong reference
holder drop their reference on the GDBusConnection before calling
g_test_dbus_down(). Timing out after 30 seconds is the desired behavior
in the case where someone holds a reference to the singleton for that
entire period.

There are a few problems with this patch. First, as pointed out here[1],
calling g_object_run_dispose() in the idle callback means we are causing
the GWeakNotify to trigger ~immediately rather than waiting 30 seconds
to give another owner a chance to unref. Second, since someone else may
still hold a reference on the object being disposed, they may call
methods on it after it's been disposed which can seg fault as documented
here[2] and as I also saw recently in another project.

It's unclear what the original leak being fixed was, but many have been
fixed between 2013 and now. I ran all the unit tests under valgrind, and
some do fail (some consistently and some intermittently) but none of the
failures seem to only happen after this reversion commit. I also
couldn't find anywhere in the valgrind output where any GDBusConnection
objects are definitely being lost.

[1] https://gitlab.gnome.org/GNOME/glib/issues/787#note_214226
[2] https://gitlab.gnome.org/GNOME/glib/issues/787#note_214237
2019-07-03 20:01:22 -07:00
Emmanuel Fleury
7c0b11248f Fixing find_enclosing_mount() documentation
Fix issue #453
2019-07-01 15:00:42 +02:00
Philip Withnall
d55f6fb5fe gdesktopappinfo: Update calling convention for gnome-terminal
For several years now (I haven’t looked up the exact date),
`gnome-terminal` has preferred being called as `gnome-terminal
--terminal-args -- /some/other/program --its-args` rather than as
`gnome-terminal --terminal-args -x /some/other/program --its-args`.
Since 2017 it has warned about uses of `-x` (see
ad4edbd118).

So we should change our calling convention for it.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-28 13:05:07 +01:00
Philip Withnall
d50caa8fb9 tests: Don’t spawn test processes via the terminal in the appinfo test
There seems to be no reason to do so, and since the `appinfo` test was
ported to use `G_TEST_OPTION_ISOLATE_DIRS`, it has been causing
coredumps to accumulate. `gnome-terminal` was chosen as the terminal,
but it couldn’t find its GSettings schemas due to all the XDG
environment variables being cleared to `/dev/null` by
`G_TEST_OPTION_ISOLATE_DIRS`.

In order to keep using `gnome-terminal` as a subprocess in the tests,
we’d need to explicitly set up its environment so it can load the right
GSettings schemas. That’s a lot of work for not much gain.

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

Helps: #436
2019-06-28 13:05:07 +01:00
LRN
5e7c18fa48 Merge branch 'nirbheek/preliminary-uwp-support' into 'master'
Preliminary patches for Universal Windows Platform support

See merge request GNOME/glib!951
2019-06-27 16:08:59 +00:00
Matthew Leeds
1f49c5aaeb gio: Make minor docs improvements
This commit changes a comment in _g_dbus_worker_do_read_cb() to be
slightly more useful. At least in my experience debugging an
intermittent unit test failure in another project, this failure
condition occurred because although g_test_dbus_down() ensures that the
session GDBusConnection has exit-on-close set to FALSE before killing
its dbus-daemon, there was still a GDBusConnection on the system bus
which hit this failed read code path, because we had
DBUS_SYSTEM_BUS_ADDRESS set to the address of the #GTestDBus daemon, to
appease libudisks.

Also, make a few other minor improvements to the docs.
2019-06-25 11:11:33 -07:00
Nirbheek Chauhan
cdc2a798cf uwp: workaround a false positive in certification of glib
It seems that the Windows App Certification Kit searches all files and
binaries for the regex '\<reg\>' (or something like it) and throws
errors if it exists. Supposedly this is for preventing apps from
running REG.EXE

https://blogs.msdn.microsoft.com/appconsult/2017/08/16/how-to-validate-if-your-application-is-compliant-with-the-windows-store-polices-windows-10-and-windows-10-s/
2019-06-25 13:09:04 +05:30
Chun-wei Fan
dbea8d5449 Fix module tests on Visual Studio builds
On Visual Studio, Meson builds modules as xxxx.dll, not libxxxx.dll when
xxxx is specified as the name for the shared_module() build directive.

This means that in the test programs if we expect for libxxxx for the
module name, the test will fail as there is no libxxxx.dll but there is
xxxx.dll.  This makes the test program look for the module files
correctly.
2019-06-24 10:58:58 +08:00
Chun-wei Fan
edc5eb98c2 gio/tests/resourceplugin.c: Ensure entry points are exported
Ensure that the entry points/symbols are exported on Visual Studio
builds as well.
2019-06-24 10:58:51 +08:00
Matthias Clasen
99764fd8fa list model: Expand items-changed docs
Point out explicitly that positions change
when ::items-changed is emitted.
2019-06-21 15:53:51 +00:00
Philip Withnall
f8bad07319 Merge branch 'gdbusproxy_prefixes_unstripped_error' into 'master'
gdbus: proxy : Strip remote error on activation failure

Closes #804

See merge request GNOME/glib!925
2019-06-18 10:30:37 +00:00
Philip Withnall
1888deecfc Merge branch 'glib.fixtools.i18n' into 'master'
Tools: Correctly show translated messages on more recent Visual Studio builds

Closes #1169

See merge request GNOME/glib!895
2019-06-18 10:18:31 +00:00
Chun-wei Fan
3046f7b3bb gio-tool.c: Don't hardcode localedir on Windows
We ought to construct the localedir based on the location of the GLib
DLL, like what the other tools do.
2019-06-18 17:29:41 +08:00
Chun-wei Fan
9f709fe1e9 gio tools: Use the proper string for default locale for setlocale()
This makes use of the string we now have from glib-private.h in the
last commit so that setlocale() sets the default system locale
correctly and therefore show the translated messages properly.

Fixes issue #1169.
2019-06-18 17:29:41 +08:00
Emmanuel Fleury
ca7a29e8e0 gdbus: proxy : Strip remote error on activation failure
Original patch proposed by Christian Persch

Related to issue #804
2019-06-18 10:54:09 +02:00
Christian Hergert
22ba4411cc gio: remove use of generic marshaller from GIO objects
Using the generic marshaller has drawbacks beyond performance. One such
drawback is that it breaks the stack unwinding from the Linux kernel due
to having unsufficient data to walk past ffi_call_unixt64. That means that
performance profiling by application developers looks grouped among
seemingly unrelated code paths.

While we can't fix the kernel unwinding here, we can provide proper
c_marshallers and va_marshallers for objects within Gio so that
performance profiling of applications is more reliable.

Related to GNOME/Initiatives#10
2019-06-17 16:29:09 -07:00
Christian Hergert
273c00f620 gio: ensure default va_marshaller is used
If c_marshaller is provided during g_signal_new() registration, the
automatic va_marshaller will not be set. If we leave the c_marshaller as
NULL in the simple cases, both a c_marshaller and va_marshaller will be
set for us.

This is particularly helpful when dealing with stack traces from Linux
perf, which often cannot unwind the stack beyond the ffi_call_unix64
stack-frame on x86_64.

Related to GNOME/Initiatives#10
2019-06-17 16:13:53 -07:00
Christian Hergert
d7c1d477bc gdbusobjectmanager: store signal ids for re-use
Having access to the signal-id is useful when we want to specify additional
signal related settings (such as va_marshaller).
2019-06-17 16:13:53 -07:00
Simon McVittie
833d38b40f Merge branch 'mcatanzaro/gdbus-dir-addresses' into 'master'
gdbus: support unix:dir= addresses, and related cleanups

Closes #1808

See merge request GNOME/glib!911
2019-06-17 18:06:11 +00:00
Michael Catanzaro
30524fbdb5 gdbusserver: properly escape all components of server address
https://gitlab.gnome.org/GNOME/glib/merge_requests/911#note_530668
2019-06-17 12:08:06 -05:00
Michael Catanzaro
16cdda5d35 gdbus: run peer test multiple times with different addresses
This ensures that D-Bus connections established with unix:dir and
unix:path addresses actually work properly. Previously, we only tested
unix:tmpdir and TCP addresses.
2019-06-17 12:08:06 -05:00
Michael Catanzaro
eca16677c0 gdbus: Fix minor leak in peer test
This has to be freed even on Windows.
2019-06-17 12:08:06 -05:00
Michael Catanzaro
beac9fe211 gdbus: Clean up sockets and nonces from filesystem
When we close the GDBusServer, it should remove any non-abstract Unix
sockets or TCP nonce files it created from the filesystem.

Fixes #1808
2019-06-17 12:08:06 -05:00
Michael Catanzaro
f5631ecb94 gdbus: improve an error message
Namespace is one word.
2019-06-17 12:08:06 -05:00
Michael Catanzaro
99b580a0b2 gdbus: Stop server on dispose
This is not going to have much any effect currently since stop() just
disconnects a signal handler (that is going to be disconnected in
finalize anyway) and stops the socket service (that is going to be
destroyed in finalize), but it makes sense to do here for robustness.
2019-06-17 12:08:06 -05:00
Michael Catanzaro
fc597fa5f9 gdbus: support unix:dir= addresses
unix:dir= addresses are exactly the same as unix:tmpdir= addresses,
already supported by GDBus, except they forbid use of abstract sockets.
This is convenient for situations where abstract sockets are
impermissible, such as when a D-Bus client inside a network namespace
needs to connect to a server running in a different network namespace.
An abstract socket cannot be shared between two processes in different
network namespaces.

Applications could use unix:path= addresses instead, so this is only a
convenience, but there's no good reason not to support unix:dir=.
Currently it is not supported simply because unix:dir= is a relatively
recent addition to the D-Bus spec.
2019-06-17 12:07:10 -05:00
Michael Catanzaro
6a5c4252cd Merge branch '940-socket-listener-docs' into 'master'
gsocketlistener: Clarify when g_socket_listener_set_backlog() works

Closes #940

See merge request GNOME/glib!921
2019-06-17 17:05:42 +00:00
Philip Withnall
063722ef80 gsocketlistener: Clarify when g_socket_listener_set_backlog() works
Spotted by Paolo Borelli.

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

Fixes: #940
2019-06-17 16:26:48 +01:00
Philip Withnall
25636e50e0 gdbusmessage: Fix comparisons out of range for enum types
This was warning on macOS.

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

Fixes: #887
2019-06-17 15:45:30 +01:00
Philip Withnall
fa5996927f Merge branch 'drop-g-disable-deprecated' into 'master'
Drop G_DISABLE_DEPRECATED

Closes #1060 and #638

See merge request GNOME/glib!871
2019-06-14 11:24:25 +00:00
Emmanuele Bassi
94a56ae4f5 Merge branch '1807-dbus-server-docs' into 'master'
gdbusserver: Drop reference to non-existing function from documentation

Closes #1807

See merge request GNOME/glib!913
2019-06-12 12:05:56 +00:00
Philip Withnall
b1fbb36ba3 Merge branch 'prop-action-state-hints' into 'master'
property action: Add state hints

See merge request GNOME/glib!906
2019-06-12 11:59:58 +00:00
Philip Withnall
6e25d936fa gdbusserver: Drop reference to non-existing function from documentation
Spotted by Michael Catanzaro.

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

Fixes: #1807
2019-06-12 12:48:49 +01:00
Sebastian Dröge
03ce878736 Merge branch '1729-mime-result-prio' into 'master'
Resolve "g_content_type_guess segfaults when passed an empty data buffer on Mac OS"

Closes #1729

See merge request GNOME/glib!733
2019-06-11 11:38:33 +00:00
Sebastian Dröge
f78194e8d0 Merge branch 'settings-list-order' into 'master'
gsettings: Document that lists are returned in no defined order

See merge request GNOME/glib!851
2019-06-11 11:35:58 +00:00
Sebastian Dröge
e85f1ced5f Merge branch 'compile-schemas-strings' into 'master'
glib-compile-schemas: Improve translatable strings

See merge request GNOME/glib!678
2019-06-11 11:34:05 +00:00
Simon McVittie
11233f572d gdbusdaemon: Only authorize anonymous users on Windows, not Unix
On Unix, we expect EXTERNAL authentication to work.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-11 11:06:36 +01:00
Simon McVittie
a5923d4e49 gdbus-example-peer: Provide an example GDBusAuthObserver
It's somewhat unrealistic to use a GDBusServer without a
GDBusAuthObserver, because most D-Bus servers want to be like the
standard session bus (the owning user can connect) rather than being
like the standard system bus (all users can connect, the server is a
security boundary, and many bugs are security vulnerabilities).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-11 11:06:36 +01:00
Simon McVittie
281a03d603 GDBusAuthObserver: Document how to restrict authentication to EXTERNAL
This is simpler and more robust than DBUS_COOKIE_SHA1, which relies
on assumptions about random numbers and a secure home directory.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-11 11:06:36 +01:00
Simon McVittie
1da3280b9e GDBusAuthObserver: Fix mixup between authentication and authorization
Authentication is about proving who I am; authorization is about
whether, given the knowledge of who I am, I am allowed to do something.
GDBusServer and GDBusConnection carry out authentication automatically,
but rely on the library user to carry out authorization.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-11 11:06:35 +01:00
Simon McVittie
f5a01e0e4a GDBusServer: Document that a GDBusAuthObserver is usually desirable
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-11 11:06:35 +01:00
Simon McVittie
5e24d7cd14 Document where we expect credentials-passing to be supported
This is useful information for implementors of portable software to know
whether they can rely on credentials-passing.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-11 11:06:35 +01:00
Philip Withnall
f6736a2589 tests: Use a temporary directory for testfilemonitor
Previously, its tests were being run in the build directory, which is
fine (it should always be writable). If multiple tests were run in
parallel, for example with Meson’s `--repeat` option, their test files
would collide.

Fix that by running each test instance in a separate subdirectory of
`/tmp`.

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

Helps: #1634
2019-06-10 15:19:34 +01:00
Philip Withnall
f124349fa1 tests: Improve debug output on testfilemonitor failure
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1634
2019-06-10 14:58:45 +01:00
Matthias Clasen
459c4f296a property action: Add state hints
We have this information in the param specs,
we might as well pass it on to give consumers
a chance to present meaningful UIs for these
actions.
2019-06-10 00:03:25 +00:00
Ondrej Holy
f17055f593 gfile: Do not follow symlinks when moving
It is expected that `g_file_move()` moves symlink file itself, not its
target. Unfortunately, copy and delete fallback passes `GFileCopyFlags`
and don't explicitly use `G_FILE_COPY_NOFOLLOW_SYMLINKS`. This may cause
that symlink target is copied and symlink itself is removed. Let's
explicitly pass `G_FILE_COPY_NOFOLLOW_SYMLINKS` to the copy operation to
prevent this unexpected behavior.

https://gitlab.gnome.org/GNOME/glib/issues/986
2019-06-07 09:21:59 +02:00
Ondrej Holy
6694172014 gfile: Remove G_FILE_COPY_NOFOLLOW_SYMLINKS from g_file_move() docs
The `G_FILE_COPY_NOFOLLOW_SYMLINKS` flag doesn't make sense for move operation,
neither local implementation doesn't handle this flag in any way. Therefore
this paragraph should be removed from the docs (it was probably copy&pasted
from `g_file_copy()` docs by mistake).

Closes: https://gitlab.gnome.org/GNOME/glib/issues/986
2019-06-07 09:15:33 +02:00
Philip Withnall
4e00fdea9b Merge branch 'filio' into 'master'
Include <sys/filio.h> for FIONREAD

See merge request GNOME/glib!889
2019-06-05 11:24:56 +00:00
Allison Karlitskaya
efeaf8f747 network-address test: add ipv6-fail ipv4-slow case
Add a case for when the IPv6 result comes back negative and the IPv4
result is significantly delayed.  This is exactly the case that causes
the bug addressed by GNOME/glib!865
2019-06-04 20:09:26 +01:00
Allison Karlitskaya
97f8d3e1d8 gnetworkaddress: fix "happy eyeballs" logic
The "happy eyeballs" RFC states that on receiving a negative response
for an IPv6 address lookup, we should wait for the IPv4 lookup to
complete and use any results we get from there.

The current code was not doing that: it was rather setting a timeout for
failing the resolution entirely.  In scenarios where the IPv4 response
comes more than 50ms after the IPv6 response (which is easily attainable
under valgrind in certain configurations) this means that the IPv4
response will never come.

Remove the timeout and just wait.

See merge request GNOME/glib!865
2019-06-04 20:09:26 +01:00
Maya Rashish
de2ad60578 Include <sys/filio.h> for FIONREAD 2019-06-04 13:13:37 +03:00
Philip Withnall
b73713d893 tests: Add a test for g_content_type_guess() with no arguments
It should produce a generic result, but not crash. It was previously
crashing on macOS.

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

Fixes: #1729
2019-06-03 12:16:50 +01:00
Philip Withnall
4a0cb8f3a1 xdgmime: Don’t set an out argument if it’s NULL
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1729
2019-06-03 12:13:53 +01:00
Philip Withnall
d586ab4c73 tests: Use g_assert_*() instead of g_assert() in contenttype tests
g_assert_*() give more helpful error messages on failure, and aren’t
compiled out by G_DISABLE_ASSERT.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-03 12:13:53 +01:00
Sebastian Dröge
a4d01fcd4b Merge branch '1796-gio-pkg-bin-variables' into 'master'
build: Add various installed utilities to gio-2.0.pc

Closes #1796

See merge request GNOME/glib!881
2019-06-03 10:43:44 +00:00
Philip Withnall
799caf772b gsubprocess: Add missing (nullable) annotation to get_identifier()
The bottom of the documentation comment for this symbol seems to have
been missing.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-31 23:38:58 +01:00
Philip Withnall
7f256e63d0 tests: Fix small race in GSubprocess tests
This was introduced in commit 7846d6154a: g_subprocess_get_identifier()
will return NULL after the subprocess has exited, and the subprocess in
the `noop` test will exit as soon as it has started spawning. So if the
scheduler scheduled the testprog subprocess quickly, descheduled the
parent test process until the testprog exited, then the return value
from g_subprocess_get_identifier() would be NULL.

Move the g_subprocess_get_identifier() test to one which calls testprog
in `sleep-forever` mode, since that is guaranteed not to exit until
killed (which we do later in the test).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-31 23:35:27 +01:00
Philip Withnall
3a9f9e3509 build: Add various installed utilities to gio-2.0.pc
The most useful ones were already listed in the pkg-config file, but
some others (notably, `gio-querymodules`) were not. List them in the
pkg-config file with their installed paths so that the right binary is
used if GIO is installed in a non-default path.

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

Fixes: #1796
2019-05-31 21:23:05 +01:00
Philip Withnall
e37f0cbd89 gnetworkmonitornm: Consider NM_STATE_CONNECTED_SITE to be available
`NM_STATE_CONNECTED_SITE` is documented to mean that a default route is
available, but that the internet connectivity check failed. A default
route being available is compatible with the documentation for
GNetworkMonitor:network-available, which should be true if the system
has a default route for at least one of IPv4 and IPv6.

https://developer.gnome.org/NetworkManager/stable/nm-dbus-types.html

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

Fixes: #1788
2019-05-31 11:19:07 +01:00
Sebastian Dröge
8b3f186d8f Merge branch '1790-file-attribute-as-string-annotation' into 'master'
gfileinfo: Add missing (nullable) annotation to get_attribute_as_string()

Closes #1790

See merge request GNOME/glib!879
2019-05-31 10:16:43 +00:00
Sebastian Dröge
c1a15894e4 Merge branch 'writev-max-num-vectors' into 'master'
Clamp number of vectors to IOV_MAX / UIO_MAXIOV for GOutputStream writev()...

See merge request GNOME/glib!874
2019-05-31 10:04:57 +00:00
Philip Withnall
ebacb64539 gfileinfo: Slightly improve documentation formatting
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-31 10:58:10 +01:00
Philip Withnall
67a0d5237e gfileinfo: Add missing (nullable) annotation to get_attribute_as_string()
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1790
2019-05-31 10:58:00 +01:00
Sebastian Dröge
20a2c379c4 Clamp number of vectors to IOV_MAX / UIO_MAXIOV for GOutputStream writev() calls in the implementations
More vectors will give an error and we can simply clamp here and
consider it like a short write instead.

In case of GSocketOutputStream this is done here instead of inside
GSocket before calling sendmsg() because we we can't generically handle
short writes when sending messages on a socket, e.g. for datagram
sockets this causes only part of the datagram to be sent and an error
would be more useful in this case than sending corrupted data.

Also reduce the fallback limit to 16 in gsocket.c as that's the minimum
value required by POSIX and add a static assertion that the limit is
never bigger than G_MAXINT as that's the type recvmmsg/sendmmsg take.
2019-05-31 12:51:59 +03:00
Philip Withnall
947355c101 Merge branch 'wip/oholy/copy-permissions' into 'master'
CVE-2019-12450: gfile: Limit access to files when copying

See merge request GNOME/glib!876
2019-05-31 09:09:30 +00:00
Philip Withnall
40ff475977 Annotate various types and macros as deprecated
These have all been documented as deprecated for a long time, but we’ve
never had a way to programmatically mark them as deprecated. Do that
now.

This is based on the list of deprecations from the reverted commit
80fcb1bc2.

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

Fixes: #638
2019-05-30 10:39:11 +01:00
Philip Withnall
1741fc2c6e build: Drop use of G_DISABLE_DEPRECATED from the build system
It’s no longer used in any of the headers. See preceding commits.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
e62e89f2f8 Fix various deprecation warnings in code and tests
This code uses, or tests, deprecated functions, types or macros; so
needs to be compiled with deprecation warnings disabled.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
b4d58a7105 glib, gio: Use GLIB_DEPRECATED_MACRO instead of G_DISABLE_DEPRECATED
When defining deprecated macros, annotate them with
`GLIB_DEPRECATED_MACRO_IN_*()` and `GLIB_DEPRECATED_MACRO_IN_*_FOR()` to
conditionally emit warnings if people use them, depending on their
declared minimum and maximum GLib version requirements (see
`GLIB_VERSION_MIN_REQUIRED` and `GLIB_VERSION_MAX_ALLOWED`).

The old way of doing this was for users to define `G_DISABLE_DEPRECATED`
if they didn’t want to use deprecated APIs, but it reported errors via
missing symbols, and wasn’t version-dependent. It’s being phased out.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
70c8a7ef8d gdesktopappinfo: Improve documentation formatting slightly
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
9bfd7e2a9d gdesktopappinfo: Add deprecation version to GDesktopAppInfoLookup
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Ondrej Holy
d8f8f4d637 gfile: Limit access to files when copying
file_copy_fallback creates new files with default permissions and
set the correct permissions after the operation is finished. This
might cause that the files can be accessible by more users during
the operation than expected. Use G_FILE_CREATE_PRIVATE for the new
files to limit access to those files.
2019-05-24 09:58:18 +02:00
Philip Withnall
970599ab7a Merge branch 'osx-psn' into 'master'
gapplication: skip unexpected -psn_ parameter

Closes #1784

See merge request GNOME/glib!864
2019-05-23 10:16:01 +00:00
Ignacio Casal Quinteiro
e367a4f66f gapplication: skip unexpected -psn_ parameter
When an application is launched using Launch Services
osx will add an extra parameter which we were not
handling and then gapplication would abort. Instead we make
an initial parsing and like this we avoid the abort if this
parameter is provided

Fixes https://gitlab.gnome.org/GNOME/glib/issues/1784
2019-05-22 09:11:26 +02:00
Marco Trevisan (Treviño)
5deaf0bfdf gdbusserver: Use g_clear_signal_handler 2019-05-21 12:10:01 -05:00
Philip Withnall
13da7e5c2e Merge branch 'wip/ignazp/gtask-wait-time-fix' into 'master'
gtask: fix task_wait_time estimation

Closes #1683

See merge request GNOME/glib!644
2019-05-20 11:07:54 +00:00
Philip Withnall
9c4026d673 gsettings: Add missing ‘Deprecated’ tag to g_settings_list_keys() docs
It was already deprecated in the header, but the tag was missing from
the documentation.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-17 13:06:08 +01:00
Philip Withnall
d2b419c81f gsettings: Document that lists are returned in no defined order
The caller cannot assume that the lists returned by various GSettings
functions (for example, lists of keys or schemas) will be returned in
any particular order.

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

Helps: #1781
2019-05-17 13:03:27 +01:00
Philip Withnall
505f45ef95 tests: Remove redundant --tap options
Now that TAP output is used by default, passing `--tap` is unnecessary.

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

Helps: #1619
2019-05-14 12:42:51 +01:00
Michael Catanzaro
c252bd150a Merge branch 'wip/tingping/network-address-state' into 'master'
gnetworkaddress: Fix parallel enumerations interfering with each other

Closes #1771

See merge request GNOME/glib!823
2019-05-10 17:46:42 +00:00
Patrick Griffis
5ba42af9b1 gnetworkaddress: Fix parallel enumerations interfering with eachother
The parent GNetworkAddress contains a shared list of resolved
addresses that is used as a cache for multiple enumerations.

This commit ensures that the cache is only set upon completion of
DNS lookups and only read once by enumerations to avoid being in a
bad state.

Fixes #1771
2019-05-10 10:17:23 -07:00
Allison Karlitskaya
bdefe5f9e1 gsocketclient: Fix a leak in the connection code
We miss releasing the async operation's reference on a state object in
one of the error cases.

The call to connection_attempt_remove() (although it calls unref
internally) is not sufficient because this is releasing the reference
that the list owns.

Closes #1774
2019-05-09 12:57:00 +02:00
Philip Withnall
76966e6b28 Merge branch 'wip/ernestask/dtd-fix' into 'master'
gschema.dtd: Add target attribute to alias

See merge request GNOME/glib!814
2019-05-07 10:31:53 +00:00
Philip Withnall
0ff97045b8 Merge branch '1739-freebsd-too' into 'master'
tests: Don’t check for libdl on FreeBSD or NetBSD either

Closes #1739

See merge request GNOME/glib!810
2019-05-07 10:26:57 +00:00
Michael Catanzaro
b17436d952 Merge branch 'wip/tingping/socketclient-cancel-2' into 'master'
gsocketclient: Fix potential critical when cancelling connect

Closes #1747

See merge request GNOME/glib!783
2019-05-06 21:50:25 +00:00
Ernestas Kulik
3d9a896f2b gschema.dtd: Add target attribute to alias
The implementation requires it, but the DTD doesn’t even mention it.
2019-05-06 16:26:53 +02:00
Carlos Garnacho
133ad1d390 gappinfo: Add precondition checks to GAppLaunchContext env methods
Spotted in https://gitlab.gnome.org/GNOME/mutter/issues/586. Bad input
on GAppLaunchContext environment manipulation functions is caught by
inner code, but the warning is not seemingly related.

Add precondition checks to these functions so it's clear where does the
bad input come from.
2019-05-06 13:05:24 +02:00
Sebastian Dröge
d16a7b26eb Merge branch 'socket-docs-trivial' into 'master'
gsocket: Clarify in docs that `flags` arguments can be platform specific

See merge request GNOME/glib!732
2019-05-02 12:54:18 +00:00
Philip Withnall
c6342b975d tests: Don’t check for libdl on FreeBSD or NetBSD either
As with commit c14ac90ed2, it isn’t needed
and doesn’t exist.

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

Fixes: #1739
2019-05-02 13:00:48 +01:00
Philip Withnall
31c4a3afc5 Merge branch 'flaky-monitor' into 'master'
Remove monitor test

See merge request GNOME/glib!785
2019-04-30 10:04:03 +00:00
Philip Withnall
e9389efe5b gsocket: Clarify in docs that flags arguments can be platform specific
As suggested by Philip Chimento.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-29 13:21:08 +01:00
Fabrice Bellet
719133e882 gnetworkmonitornm: Fix network available detection
The network-available property can be asserted by querying the NMState
describing the current overval network state, instead of the
NMConnectivityState. The advantage of the NMState is that is reflects
immediately the network state modification, while the connectivity
state is tested at a fixed frequency.
2019-04-29 12:05:54 +00:00
Philip Withnall
798c59a14f Merge branch 'openbsd-no-ld' into 'master'
gio: tests, don't check for libdl on OpenBSD

See merge request GNOME/glib!802
2019-04-29 11:21:41 +00:00
Philip Withnall
4ceac0d40c Merge branch '1760-txt-record-docs' into 'master'
docs: Clarify support for multiple TXT record strings

Closes #1760

See merge request GNOME/glib!797
2019-04-29 10:50:05 +00:00
Philip Withnall
753eeb1bac gproxy: Add a missing ‘the’ to a documentation comment
Spotted by Michael Catanzaro.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-29 11:33:02 +01:00
Antoine Jacoutot
c14ac90ed2 gio: tests, don't check for libdl on OpenBSD
libdl does not exist on OpenBSD and is not required as the
functionnality is provided in libc.
2019-04-27 18:45:45 +02:00
Philip Withnall
5bb19b04af docs: Clarify support for multiple TXT record strings
Most TXT records only contain a single string, but some may contain
more.

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

Fixes: #1760
2019-04-26 16:49:38 +01:00
Philip Withnall
63af8ed0ea Merge branch 'mate-xfce4-term' into 'master'
gdesktopappinfo: Add support for MATE and Xfce4 terminals

See merge request GNOME/glib!795
2019-04-26 11:27:19 +00:00
Philip Withnall
e036d1bb29 docs: Improve formatting of GVariant types in GResolverRecordType docs
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-26 12:15:55 +01:00
Philip Withnall
38de3e9dc3 docs: Use ‘look up’ as a verb, rather than the noun ‘lookup’
Another niggle fixed.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-26 12:12:31 +01:00
Sebastian Dröge
0b562298fd Merge branch 'master-terminology' into 'master'
general: Remove a few unhelpful references to ‘master’

See merge request GNOME/glib!792
2019-04-25 15:26:06 +00:00
Colomban Wendling
292cb2cb1b gdesktopappinfo: Add support for MATE and Xfce4 terminals
Add support for mate-terminal and xfce4-terminal with higher precedence
over xterm as it's likely people that have those want to use them.
They both use the gnome-terminal `-x` switch instead of xterm's `-e`.
2019-04-25 16:10:49 +02:00
Philip Withnall
aba0b644c2 Merge branch 'issue-1751' into 'master'
cocoanotificationbackend: do not release readonly property

Closes #1751

See merge request GNOME/glib!786
2019-04-25 09:11:44 +00:00
Philip Withnall
192bf09529 general: Remove a few unhelpful references to ‘master’
Some of these have a negative master/slave connotation, and they add no
value. Change or drop them.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-25 09:25:49 +01:00
Ignacio Casal Quinteiro
c4493d22d1 cocoanotificationbackend: do not release readonly property
Fixes a crash when releasing a property that was not retained before.

Helps: https://gitlab.gnome.org/GNOME/glib/issues/1751
2019-04-23 17:10:12 +02:00
Philip Withnall
9144aa2a86 tests: Fix some minor tests in the GResolver tests in manual mode
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/1753
2019-04-23 11:31:04 +01:00
Michael Gratton
6b61395c2d build: Remove */.gitignore files
Since out-of-source-tree builds are now used after switching to meson,
we don't need .gitignore files in the source directories to ignore
build artifacts.

This fixes build errors when doing a meson build after an autotools
build, because generated files such as gio/xdp-dbus.c won't show up in
a `git status`, or be removed by a `git clean -f`, and so it won't be
obvious that such files need to be removed for the meson build to
succeed.
2019-04-22 22:17:43 +10:00
Emmanuele Bassi
5299e8754c Remove monitor test
The `monitor` test was originally written to test GFileMonitor with
directories. Over time, `testfilemonitor` acquired units for testing
directories as well, which made the `monitor` test reduntant.
2019-04-22 10:36:56 +01:00
Patrick Griffis
313e7cbad7 gsocketclient: Fix potential critical when cancelling connect
We are manually tracking the completion state of the connect task
so avoid just calling g_task_return_error_if_cancelled() without
checking that.

Fixes #1747
2019-04-16 10:26:01 -07:00
Adam Duskett
e7b0d89aeb Only build tests if certain conditions are met.
Currently, there is no way to prevent tests from building using meson.
When cross-compiling, building the tests isn't necessary.

Instead, only build the tests on the following conditions:
1) If not cross-compiling.
2) If cross-compiling, and there is an exe wrapper.
2019-04-16 10:19:41 +00:00
Emmanuele Bassi
cd04cf7778 Merge branch '1614-freebsd-threading-flaky' into 'master'
tests: Unmark several gdbus-* tests as flaky

Closes #1614

See merge request GNOME/glib!777
2019-04-15 09:11:13 +00:00
Philip Withnall
b11f323ee5 tests: Only run --external-data test on GNU ld/objcopy
Other GCC-like implementations of ld/objcopy (like LLVM) don’t yet
support the right command line arguments, so can’t compile the test.

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

https://gitlab.gnome.org/GNOME/glib/issues/1709
2019-04-12 18:00:12 +01:00
Philip Withnall
ea8e6502d4 build: Refactor resources test build instructions
This introduces no functional changes, but combines two duplicated lists
and makes the meson.build file a little easier to follow.

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

Helps: #1711
2019-04-12 18:00:12 +01:00
Philip Withnall
a06d7cc7b8 build: Fix some whitespace problems in gio/tests/meson.build
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-12 18:00:12 +01:00
Philip Withnall
bc81b2c4cb tests: Unmark several gdbus-* tests as flaky
After repeated local testing, I can’t reproduce failures with them:

   meson test --repeat 5000 gdbus-auth
   meson test --repeat 5000 gdbus-bz627724
   meson test --repeat 5000 gdbus-connection

The FreeBSD failures from pthread calls mentioned in #1614 should
probably manifest as use-after-free for GMutex or pthread_mutex_t on
Linux. Failing that, I haven’t seen any relevant FreeBSD failures on CI
for at least a month, so if it’s not fixed, the chances of debugging are
very low.

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

https://gitlab.gnome.org/GNOME/glib/issues/1614
2019-04-12 17:08:22 +01:00
Philip Withnall
1fbf82be17 gdbusprivate: Clarify GDBusMessage ownership transfers
Add g_steal_pointer() and g_clear_object() calls in various places to
clarify the ownership transfers for GDBusMessage instances, in a bid to
understand what’s going on in this code and to try to find a
use-after-finalize problem.

This introduces no functional changes, but hopefully makes the code a
little clearer.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-12 16:56:04 +01:00
Philip Withnall
96aa2e34b3 gdbusdaemon: Fix error handling for filtering outgoing messages
If the filter function for an outgoing message fails to copy the
GDBusMessage, that failure was previously ignored, and GDBusMessage
methods could be called on a NULL instance.

Avoid that.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-12 16:55:17 +01:00
Philip Withnall
2dac148299 gthreadedsocketservice: Handle thread pool push failure
This was previously silently ignored, and would result in a leak.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-12 15:24:05 +01:00
Philip Withnall
035c5d03f1 gthreadedsocketservice: Move obj reference to per-job data
Rather than keeping a reference to the GThreadedSocketService as the
user_data for every thread pool job, add it to a member of the per-job
data struct (GThreadedSocketServiceData). This should make no
difference overall, as it’s just moving the refcounting around, but it
does seem to fix an occasional double-unref crash on shutdown where the
GThreadedSocketService is unreffed during finalisation.

In any case, it makes the object ownership clearer.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-12 15:22:19 +01:00
Philip Withnall
63823ae628 gthreadedsocketservice: Abstract out a free function
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-12 15:21:33 +01:00
Philip Withnall
ec569ff2e2 gthreadedsocketservice: Tidy up property declarations
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-12 15:18:48 +01:00
Niels De Graef
6287f64e1d gdbus-tool: Colorize the output of "introspect"
When available on stdout, the `gdbus introspect` command will now add
colors to make it easier for humans to visually parse the output.

https://gitlab.gnome.org/GNOME/glib/merge_requests/761
2019-04-11 18:03:50 +02:00
Emmanuele Bassi
cf54fc3600 Merge branch '1737-gdbus-tool-wait' into 'master'
gdbus-tool: Fix units for `gdbus-tool wait` timeout

Closes #1737

See merge request GNOME/glib!753
2019-04-03 12:36:54 +00:00
Philip Withnall
abde3efb34 Merge branch 'wip/oholy/trash-autofs' into 'master'
gunixmounts: Return the last matching mount for same mount path

Closes #1727

See merge request GNOME/glib!740
2019-04-03 12:23:10 +00:00
Philip Withnall
8349ceeac9 Merge branch 'use_after_free' into 'master'
Fix use-after-free triggered by gnome-session-binary

See merge request GNOME/glib!741
2019-04-03 12:01:04 +00:00
Ignacio Casal Quinteiro
55870d4b42 Properly ensure the cocoa notification backend type 2019-03-29 15:52:38 +01:00
Philip Withnall
d86146df38 gdbus-tool: Fix units for gdbus-tool wait timeout
They were documented as being in seconds, but implemented as
milliseconds.

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

Fixes: #1737
2019-03-27 17:04:58 +00:00
Philip Withnall
ad614fc070 Merge branch 'cygwin-rtld_next' into 'master'
Check for RTLD_NEXT

See merge request GNOME/glib!750
2019-03-27 16:25:48 +00:00
Руслан Ижбулатов
a53ff7460e Check for RTLD_NEXT
Check for RTLD_NEXT being present, and disable the gsocketclient-slow
test if it's absent, since the shlib dependency of that test requires
RTLD_NEXT to function.

This allows the testsuite to be built on Cygwin, which behaves
exactly like UNIX, but doesn't have RTLD_NEXT.
2019-03-27 16:10:17 +00:00
Philip Withnall
ad19bb8f12 Merge branch '1258-input-stream-annotations' into 'master'
ginputstream: Add missing (out) annotations to read() functions

Closes #1258

See merge request GNOME/glib!738
2019-03-26 22:53:27 +00:00
Jan Tojnar
c940816181
gio: Add missing autocleanup definition for GSettingsSchemaKey 2019-03-26 16:40:28 +01:00
Jan Tojnar
edaae619e5
gio: Add missing autocleanup definition for GSettingsSchemaSource 2019-03-26 16:38:06 +01:00
Ignacio Casal Quinteiro
1e1759d5a2 gcocoanotificationbackend: give more priority than the gtk one
On OSX both backends are built. Generally we want to use the cocoa
backend by default and in case it is not supported, i.e because
the application is not using a bundle then we should fallback
to the gtk one.
2019-03-26 10:20:25 +01:00
Stefan Sperling
052ad6098d Fix use-after-free triggered by gnome-session-binary
ostream_flush_cb() was calling flush_data_list_complete() with a single
element list with an item that had already been freed. This was observed
on OpenBSD where memory is overwritten with 0xdf during free():

    error=0x0) at ../glib-2.58.3/gio/gdbusprivate.c:1156
1156          g_mutex_lock (&f->mutex);
(gdb) p /x *f
$74 = {mutex = {p = 0xdfdfdfdfdfdfdfdf, i = {0xdfdfdfdf, 0xdfdfdfdf}},
  cond = { p = 0xdfdfdfdfdfdfdfdf, i = {0xdfdfdfdf, 0xdfdfdfdf}},
  number_to_wait_for = 0xdfdfdfdfdfdfdfdf, error = 0x0}

This happened because the thread freeing the element didn't properly wait
for the asynchronous flush operation to finish.
Gnome's developer docs say: "g_cond_wait() must always be used in a loop"
https://developer.gnome.org/glib/stable/glib-Threads.html#g-cond-wait
2019-03-25 07:44:13 +01:00
Philip Withnall
89416debb0 gresolver: Convert encoding of gai_strerror() return value
It returns a string in the libc locale, which is not necessarily UTF-8.
Convert that to UTF-8 before returning it to the caller.

Spotted by Tomasz Miąsko.

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

Fixes: #1732
2019-03-22 13:32:14 +00:00
Philip Withnall
3a32c75876 ginputstream: Add missing (out) annotations to read() functions
This is a reversion of the reversion of commit
c192595268, after more discussion on the
issue.

Fixes: #1258
2019-03-22 13:20:41 +00:00
Ondrej Holy
bc52235efc gunixmounts: Return the last matching mount for same mount path
More mounts can have same mount path, but only the last one is
accessible. Thus we should always return the last matching mount from
g_unix_mount_at() and g_unix_mount_for(). This should also solve
problems with g_file_trash() on automounted filesystems, which are
caused by the recently added mount checks.

Closes: https://gitlab.gnome.org/GNOME/glib/issues/1727
2019-03-22 12:41:47 +01:00
Philip Withnall
3a11213b68 gresolver: Don’t use gai_strerror() on Windows, as it isn’t threadsafe
Instead, use WSAGetLastError().

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

Helps: #1732
2019-03-21 11:51:37 +00:00
Philip Withnall
114921ccd9 Merge branch 'dbus-address-tests' into 'master'
Improve gdbus-address parsing tests

See merge request GNOME/glib!730
2019-03-19 10:53:44 +00:00
Руслан Ижбулатов
5df0337f52 GIO: Convert ENOTSOCK to G_IO_ERROR_INVALID_ARGUMENT
instead of using a generic G_IO_ERROR_FAILED error code.
This is in line with what W32 part of the code is doing with WSAENOTSOCK.

This fix will break two tests in libsoup, which were written following
the implementation and thus expect G_IO_ERROR_FAILED when attempting to
do stuff with no-longer-valid socket descriptors.
2019-03-16 15:58:16 +00:00
Emmanuele Bassi
e5ba5845a1 Revert "headers: Add various missing G_DISABLE_DEPRECATED guards"
This reverts commit 80fcb1bc26.

G_DISABLE_DEPRECATED should never be used by anybody, least of all by
GLib. We have deprecation annotations for the compiler, these days, and
they are much better suited than a macro that makes symbols appear and
disappear. The fact that gtk-doc doesn't understand the deprecation
annotations is a limitation of gtk-doc, and it's gtk-doc that ought to be
fixed.

Commit 80fcb1bc broke GStreamer, which disables old API that was
deprecated before the introduction of the deprecation annotations, but
still uses newly deprecated one, and relies on the deprecation
annotations to do their thing. It also broke libsoup, as it uses
GValueArray in its own API.
2019-03-16 11:30:13 +00:00
Philip Withnall
631beb0404 tests: Improve test coverage of D-Bus tcp transport addresses
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:36:57 +00:00
Philip Withnall
f9fb7e8765 tests: Add test for unsupported unparseable D-Bus addresses
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:36:57 +00:00
Philip Withnall
3cd30c59e9 tests: Compile the test_unix_address() test unconditionally
Just skip the test if the unix transport isn’t supported. This means we
get better compilation coverage, and more explicit TAP output saying
that the test is being skipped on unsupported platforms.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:36:57 +00:00
Philip Withnall
264617cfb5 tests: Improve test coverage of D-Bus nonce-tcp transport addresses
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:36:57 +00:00
Philip Withnall
88d03facb9 tests: Improve test coverage of D-Bus unix transport addresses
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:36:56 +00:00
Philip Withnall
e0561cfdc5 tests: Split out D-Bus address parsing tests
Rather than having them in the unix-transport specific tests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:36:56 +00:00
Philip Withnall
685d605832 tests: Always check an address is valid before checking it’s supported
This gets us extra test coverage for free.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:22:15 +00:00
Philip Withnall
e458b0168e gdbusaddress: Clean up memory management in _g_dbus_address_parse_entry()
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:20:54 +00:00
Philip Withnall
131ba66160 gdbusaddress: Require that transport names and keys are non-empty
The specification doesn’t explicitly say this, but it doesn’t say
otherwise, and it would be pretty weird to have an empty transport name
or key.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:20:16 +00:00
Philip Withnall
8966b0f8b1 gdbusaddress: Remove some always-true branches
g_strsplit() can never return NULL.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:19:55 +00:00
Philip Withnall
7f9e76d2bc gdbusaddress: Simplify address validation in is_valid_unix()
No need for the `meaningless` label and some unreachable if-branches.
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:18:55 +00:00
Philip Withnall
132c6ba0cf tests: Use g_assert_*() instead of g_assert() in gdbus-addresses test
g_assert_*() give better failure messages, and don’t get compiled out
with G_DISABLE_ASSERT.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 13:46:29 +00:00
Tomasz Miąsko
2f290b3a5f tests: Check that cancelling g_file_replace don't overwrite existing file 2019-03-15 14:03:50 +01:00
Sebastian Dröge
c29bc822c2 Merge branch 'socket-client-connect-gerror-leak' into 'master'
GSocketClient - Free last error if a connection attempt fails and on retry the...

See merge request GNOME/glib!718
2019-03-15 11:46:57 +00:00
Philip Withnall
dd77a87cf8 docs: Fix various typos in linked symbol names
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Philip Withnall
d6aa393578 gpollableoutputstream: Add vfunc documentation for writev_nonblocking
This was missing from the original merge request.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Philip Withnall
6837c34c84 docs: Fix pluralised links to symbols
While gtk-doc can currently detect a link to a symbol which has been
pluralised by adding ‘s’, it can’t detect when ‘es’ is added. While
that’s being fixed, reword the documentation so the links are generated
correctly anyway.

gtk-doc fix here: https://gitlab.gnome.org/GNOME/gtk-doc/merge_requests/22

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Philip Withnall
1f3375235b docs: Stop formatting integer literals using ‘%’
It makes gtk-doc try to link them.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Philip Withnall
1a8f8be6d0 gfile: Fix documentation links to non-existent symbols
I presume this documentation was written before those APIs were renamed
during code review.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Philip Withnall
a385135d8b gfile: Add some missing parameter documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Philip Withnall
d55ed6755e gdesktopappinfo: Fix an overly-specific ‘Since’ documentation line
This was causing gtk-doc to try and link to an API deprecation index
which doesn’t exist.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Philip Withnall
80fcb1bc26 headers: Add various missing G_DISABLE_DEPRECATED guards
As pointed out by gtk-doc, these are all symbols which have been marked
as deprecated, but which aren’t protected by a deprecation guard. We
can’t use G_DEPRECATED_IN_* for them, as they are all non-function
symbols. Instead, wrap them in #ifndef G_DISABLE_DEPRECATED.

In some cases, we also need to wrap one or two functions which use the
deprecated types in G_DISABLE_DEPRECATED too.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Sebastian Dröge
f5a468a83a Merge branch 'socket-flags' into 'master'
gsocket: Remove (type) annotation from flags arguments

Closes gjs#227

See merge request GNOME/glib!728
2019-03-15 10:50:44 +00:00
Philip Withnall
49b807c022 gsocket: Remove (type) annotation from flags arguments
This is essentially a revert of commit
cc7f2f6b28. While those `flags` arguments
do accept values of type GSocketMsgFlags, they also accept OS-specific
flags which are not defined in GSocketMsgFlags.

The use of (type GSocketMsgFlags) makes language bindings like GJS
rightfully assert that values passed in to the argument only contain
flags from GSocketMsgFlags, which precludes the use of OS-specific
flags, and hence breaks various bits of code.

See https://gitlab.gnome.org/GNOME/gjs/issues/227#note_460136 and
https://gitlab.gnome.org/GNOME/glib/merge_requests/710#note_460249.

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

Fixes: https://gitlab.gnome.org/GNOME/gjs/issues/227
2019-03-15 10:28:14 +00:00
Philip Withnall
cf34d59bed Merge branch 'gdbus-win32-no-shortname' into 'master'
gdbusaddress, win32: don't rely on short names

Closes #1566

See merge request GNOME/glib!631
2019-03-15 10:21:08 +00:00
Philip Withnall
00c129f8eb Merge branch 'fix-network-available-check' into 'master'
Handle an UNKNOWN NetworkManager connectivity as NONE

See merge request GNOME/glib!719
2019-03-15 10:03:54 +00:00
Tom Schoonjans
32d012f5a9 build: install gosxappinfo.h on macOS
Closes #1725
2019-03-14 08:09:09 +00:00
Simon McVittie
b94a0fc2b4 appinfo: Fix documentation cross-reference
g_app_info_launch_default_for_uri() should link to _async() as an alternative, not to itself.
2019-03-13 14:52:10 +00:00
Philip Withnall
5649255351 codegen: Fix use of uninitialised variable
If using the --interface-info-{body,header} options to gdbus-codegen,
and the first interface to be outputted has no methods, but does have
properties or signals, an uninitialised variable would be used for the
property/signal ‘since’ values.

In other situations, the ‘since’ value for a prior method would have
been incorrectly used for the properties/signals.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-13 13:13:24 +00:00
Philip Withnall
df62731771 Merge branch 'win32-symlink-refactoring' into 'master'
Win32 symlink code refactoring

See merge request GNOME/glib!269
2019-03-13 11:55:27 +00:00
Vasily Galkin
b245344cec gdbus, tests, win32: test session dbus autolaunch
The test performs implicit autolaunching of a bus
and checks if it is connectible.

In build the test is moved from "only non-windows with have_dbus_daemon"
to "anywhere".

This is intentional: actually it doesn't execute any external
binaries on unix (so doesn't require dbus_daemon)
and now has win32 implementation.

The test has some problems that are not problems of test itself,
but are reasoned by current win32 implementation:

 - since the implementation uses global win32 kernel objects
with fixed names not depending on g_get_user_runtime_dir or other context
if preexisting bus running by some other libgio-using application
the test would silently pass.

 - since the implementation uses problematic time-based synchronization,
that has a race condition between opening and reading mmaped address,
the test may randomly fail (I'd not seen this in practice).

 - since the implementation autolaunched process works for 3 seconds
after last client disconnects, the executed subprocess runs for 3 seconds
after test exit, maybe locking the libgio-2.0-0.dll file for that time.
2019-03-12 21:54:47 +03:00
Vasily Galkin
b1f7c22a24 gdbus, tests: rename gdbus-unix-addresses test to gdbus-address-get-session
In preparation of adding non-unix testcase to the test.
2019-03-12 21:53:43 +03:00
Vasily Galkin
8c7670f0e1 gdbus, win32: autolaunch bus with gdbus.exe instead of rundll32
This is a bit of breaking change:
After this commit the apps relying of win32 dbus autolaunching,
need to install gdbus.exe alongside with libgio-2.0-0.dll.

A new command for gdbus tool is used for running server:
gdbus.exe _win32_run_session_bus

To implement it gdbus.exe uses the same exported function
g_win32_run_session_bus that earlier was used by rundll.
So (private) ABI was not changed.

It runs the bus syncronously, exiting after inactivity timeout -
all exactly like it was runed earlier with the help of rundll32.

While private exported function may have _some_
version compatibility issues between gdbus.exe and libgio-2.0-0.dll
compiling dbus server registration logic directly into gdbus.exe
can lead to _more hidden and more complex_ compatibility issues
since the names and behaviour of syncronization objects
used to publish server address would be required compatible between
gdbus.exe and libgio-2.0-0.dll.

So using "private" exported function to call
looks like more safe behaviour.

gdbus.exe binary was selected for this task since
it has corresponding name and at least for msys2 is shippied
in same package with libgio-2.0-0.dll

turn_off_the_starting_cursor function is also kept as is,
however it is not obvious if it is still needed
(by now I failed reproducing original issue).

Explicit g_warnings added to help with possible
problematic cases for absent or incompatible gdbus.exe

Mainloop is created after successful daemon creation
Before this change the function leaked mainloop on daemon creation fail
2019-03-12 21:53:29 +03:00
2932a58cd5 Handle an UNKNOWN NetworkManager connectivity as NONE
nm_conn_to_g_conn already handles UNKNOWN like NONE (returning
G_NETWORK_CONNECTIVITY_LOCAL in both cases). So in sync_properties
we should also set new_connectivity to G_NETWORK_CONNECTIVITY_LOCAL
for both NM_CONNECTIVITY_UNKNOWN and NM_CONNECTIVITY_NONE.

This has the added benefit that when NetworkManager returns the network
connectivity is UNKNOWN, we set network_available to FALSE as it should
be. Previously, there were cases in a laptop with no network access,
that g_network_monitor_get_network_available returned true, which was
wrong and is also fixed with this commit.
2019-03-12 18:39:42 +01:00
Sebastian Dröge
499c201472 GSocketClient - Free last error if a connection attempt fails and on retry the cancellable is cancelled 2019-03-12 10:32:56 +01:00
Philip Withnall
1b50643c99 gio: Fix various compiler warnings when compiling with G_DISABLE_ASSERT
Mostly unused variables which are only used in a g_assert() call
otherwise.

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

Helps: #1708
2019-03-08 19:46:21 +00:00
Philip Withnall
277c42ddc0 tests: Convert g_assert() to g_assert_*() in gio/tests/gsubprocess.c
g_assert_*() give more informative failure messages, and aren’t compiled
out when building with G_DISABLE_ASSERT.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-08 19:46:20 +00:00
Philip Withnall
6a724d9ccd tests: Convert g_assert() to g_assert_*() in gio/tests/actions.c
g_assert_*() give more informative failure messages, and aren’t compiled
out when building with G_DISABLE_ASSERT.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-08 19:46:20 +00:00
Philip Withnall
d89f18bb22 build: Add -UG_DISABLE_ASSERT when building tests
In order to allow GLib itself to be built with G_DISABLE_ASSERT defined,
we need to explicitly undefine it when building the tests, otherwise
g_test_init() turns into an abort.

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

Fixes: #1708
2019-03-08 19:46:20 +00:00
Philip Withnall
3d4a168715 tests: Fix some larger memory leaks in gdbus-proxy
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-07 13:57:38 +00:00
Philip Withnall
938f716c2f tests: Fix a minor memory leak in gdbus-proxy
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-07 13:04:12 +00:00
Philip Withnall
196e333ec2 tests: Use g_assert_*() instead of g_assert() in gdbus-proxy
g_assert_*() give more informative error messages on failure, and can’t
be disabled by G_DISABLE_ASSERT.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-07 13:03:40 +00:00
Vasily Galkin
4342dbbe4d gdbus, win32: move most W32 dbus autolaunch code to gdbusprivate
This allows referencig them from more than single .c file.

Implementation moved without changes
from gdbusaddress.c to gdbusprivate.c

g_win32_run_session_bus signature also kept, so ABI unchanged.
2019-03-07 15:56:44 +03:00
Vasily Galkin
4ed5abda43 gdbusaddress, win32: don't rely on short names
Closes: https://gitlab.gnome.org/GNOME/glib/issues/1566

Short names were used in win32 implementation to allow launching
on installations where full path to libgio-2.0-0.dll contain spaces.
However, short names are optional on windows: so if they were disabled
that method fails - see issue linked above.

Since rundll32 doesn't support neither spaces, nor quotes in cmdline
this patch changes rundll32 argument to just .\gio-dll-name.dll
and uses the entire path directory containing gio dll as rundll32
current directory.

Added comments informing about potential subtleties discovered during
writing test for gdbusaddress on win32.
There are not known to have real-world user-visible effect,
so by now I'm only adding comments without creating issues.
2019-03-07 15:56:44 +03:00
Sebastian Dröge
c9c88a4b22 Merge branch 'fix-gjs-issue-227' into 'master'
socket: Fix annotation for flags in g_socket_receive_message

Closes gjs#227

See merge request GNOME/glib!710
2019-03-06 20:34:15 +00:00
Andrea Azzarone
d1cb974932 socket: Fix annotation for flags in g_socket_receive_message
Closes: https://gitlab.gnome.org/GNOME/gjs/issues/227
2019-03-06 18:16:52 +00:00
Philip Withnall
62bd79b6a2 Merge branch 'tdr' into 'master'
Fix data races in task test and gmenumodel test

See merge request GNOME/glib!706
2019-03-06 13:53:24 +00:00
Tomasz Miąsko
330f8999a8 tests: Fix data race in task test
Ensure that all tasks have already completed before accessing buf array
from main thread to avoid conflicting data access from multiple threads.
2019-03-06 14:21:13 +01:00
Christoph Reiter
e13c646465 gcancellable: add back lost NULL check in g_cancellable_cancel()
Commit f975858e86 removed the NULL check in g_cancellable_cancel() by
accident which makes it crash when called with NULL.

Add the check back and add a test so this doesn't happen again.

Fixes #1710
2019-03-05 16:44:16 +01:00
Tomasz Miąsko
0679bd2732 tests: Fix data race in gmenumodel test
Synchronize access to server_connection.
2019-03-05 15:14:58 +01:00
Philip Withnall
aeb7dbad30 Merge branch 'tsan' into 'master'
Fix thread safety issues

See merge request GNOME/glib!690
2019-03-05 11:46:33 +00:00
Matthias Clasen
147ac51f90 trash portal: Fix permission checks
Implement the approach suggested in
https://gitlab.gnome.org/GNOME/glib/merge_requests/276

1. Try to open O_RDWR. On success, pass that fd
2. If EACCESS => fail the trash op, we "need" read-write to successfully trash it
3. If EISDIR => re-open the fd with O_PATH, and pass that (which will fail on snap,
   but verify the dir for flatpaks)
2019-03-04 19:47:11 +00:00
Christoph Reiter
7fa9a2a5da Merge branch 'gi-267-rename-header' into 'master'
Rename gobjectenumtypes.[ch] to glib-enumtypes.[ch]

See merge request GNOME/glib!702
2019-03-04 15:03:40 +00:00
Philip Withnall
54317c9118 tests: Run /gsettings/keyfile test in a temporary directory
Don’t pollute the build directory with files generated by running the
test.

Note that there are still other tests in the gsettings.c test suite
which use the build directory, but fixing them is a bit more involved
than I have time for right now. This is a step in the right direction.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-04 12:28:37 +00:00
Matthias Clasen
5e4da714f0 keyfile settings: Use tighter permissions
When creating directories, create them with 700 permissions,
instead of 777.

Closes: #1658
2019-03-04 12:28:37 +00:00
Philip Withnall
c3ac761a18 build: Rename gobjectenumtypes.[ch] to glib-enumtypes.[ch]
To reflect the fact that they contain the GObject types for various
enums defined in libglib.

See https://gitlab.gnome.org/GNOME/glib/merge_requests/481#note_451086.

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

Helps: GNOME/gobject-introspection#267
2019-03-04 11:12:59 +00:00
Patrick Griffis
5967b4501c gthreadedresolver: Remove unused thread pool 2019-02-27 10:41:32 -05:00
Philip Withnall
0d63ee0908 Merge branch 'wip/tingping/socket-client-slow-fix' into 'master'
gsocketclient: Fix critical on cancellation

Closes #1693 and #1653

See merge request GNOME/glib!688
2019-02-27 14:35:53 +00:00
Patrick Griffis
f0fcb68da5 tests: Unmark gsocketclient-slow as flaky
Closes #1653
2019-02-27 09:20:28 -05:00
Patrick Griffis
80af199d7d gsocketclient: Fix critical on cancellation
We need to be more explicit in handling cancellation to avoid
multiple task returns.

Fixes #1693
2019-02-27 09:20:28 -05:00
Tomasz Miąsko
c52021f340 tests: Don't leak check-proxies thread 2019-02-25 14:29:35 +01:00
Philip Withnall
dc6b5f88c4 Merge branch 'update-gvdb' into 'master'
Update gvdb submodule

See merge request GNOME/glib!674
2019-02-25 13:04:08 +00:00
Philip Withnall
2b1bcbc99b Merge remote-tracking branch 'gvdb/master' into update-gvdb 2019-02-25 12:40:10 +00:00
Emmanuele Bassi
78a2dd9632 Merge branch 'threaded-resolver-freebsd' into 'master'
gthreadedresolver: Fix initialisation on FreeBSD

Closes #1697

See merge request GNOME/glib!693
2019-02-25 11:47:56 +00:00
Philip Withnall
6e7e5fff9a gthreadedresolver: Fix initialisation on FreeBSD
res_ninit() requires the __res_state struct passed to it to be
zero-filled on FreeBSD.

Spotted and analysed by Ashish SHUKLA.

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

Fixes #1697
2019-02-25 11:22:45 +00:00
Tomasz Miąsko
f975858e86 gcancellable: Synchronize access to cancelled flag
Synchronize access to cancelled flag of cancellable, which was
previously access without synchronization in g_cancellable_is_cancelled.
Use atomic operations instead of existing global mutex, to avoid
serializing calls to g_cancellable_is_cancelled across all threads.
2019-02-25 00:00:00 +00:00
Tomasz Miąsko
fef1ce37e4 gtask: Separate GTask fields memory locations to avoid data races
Ensure that fields that might be accessed in two different threads,
through conflicting actions are stored in seprate memory locations.
2019-02-22 22:22:07 +01:00
Tomasz Miąsko
6336864171 glocalfilemonitor: Fix data race in local file monitor
Ensure that source is attached to the context before it migth be used
from another thread, since otherwise operation on source are
unsynchronized and not thread-safe.

In particular there was a data race between g_source_attach and
g_source_set_ready_time (used from g_file_monitor_source_handle_event).
2019-02-22 18:09:32 +01:00
Philip Withnall
7321f240f9 glib-compile-resources: Fix a minor leak
Spotted by oss-fuzz using asan.

oss-fuzz#13271

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-22 14:48:25 +00:00
Philip Withnall
07414e17ef tests: Unmark socket-service test as flaky
This essentially reverts commit
cffed58737.

The preceding two commits have fixed the test so it’s no longer flaky.
The following command gives 5000 passes in a row for me:

meson test -C /opt/gnome/build/glib/ socket-service --repeat 5000

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

Fixes: #1679
2019-02-21 18:15:49 +00:00
Philip Withnall
f25c3f2704 tests: Fix unlikely race in socket-service test
It’s occasionally possible for the cancellation of the service to happen
before connection_cb() gets scheduled in the other thread. The
locking/unlocking order of mutex_712570 requires:
 • test_threaded_712570(): lock mutex
 • test_threaded_712570(): start wait loop
 • connection_cb(): lock mutex
 • test_threaded_socket_service_finalize(): unlock mutex
 • test_threaded_712570(): end wait loop
 • test_threaded_712570(): unlock mutex

Fix that by quitting the main loop once connection_cb() has been called
(i.e. once the server thread has received the incoming connection
request), rather than just after the client thread (main thread) has
sent a connection request.

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

Helps: #1679
2019-02-21 18:15:49 +00:00
Philip Withnall
2aea9c84c0 tests: Fix flaky socket-service test caused by GTask scheduling
On about 1 in 3 test runs, the socket-service would fail with the
ref_count assertion in connection_cb() failing (the ref_count would be 3
rather than the expected 2).

This was happening because the GTask from
g_socket_listener_accept_socket_async() now always takes at least one
main context iteration to return a result (whereas before
6f3d57d2ee it might have taken zero), but
the ref_count can drop below 3 before the process of returning a result
starts. During the process of returning a result, the ref_count
temporarily increases again, which is what was breaking the test.

Fix this by waiting for one more main context iteration. This is a bit
of a hack, but the real fix would be to expose the outstanding_accept
boolean from GSocketService as public API (which the test can
interrogate), and that seems too much like exposing internal state.

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

Helps: #1679
2019-02-21 18:14:56 +00:00
Nirbheek Chauhan
2d6c4b289a meson: Add gobjectenumtypes.h to gioenumtypes_dep
Almost everything that needs gioenumtypes.h also needs
gobjectenumtypes.h. Fixes:

ccache cc @gio/win32/gio@win32@@giowin32@sta/gwin32filemonitor.c.obj.rsp
In file included from ../gio/win32/gwin32filemonitor.h:25:0,
                 from ../gio/win32/gwin32filemonitor.c:26:
../glib/glib-object.h:37:10: fatal error: gobject/gobjectenumtypes.h: No such file or directory
 #include <gobject/gobjectenumtypes.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-02-20 22:37:56 +05:30
Nirbheek Chauhan
8e3fc7dfaa gio: Also support modules built with MSVC
GIO modules built with MSVC do not begin with 'lib', but they can
begin with 'gio'. Without this, you can only load GIO modules built
with MSVC that are `name.dll`, not `gioname.dll`.
2019-02-20 21:26:36 +05:30
Felix Potthast
45655b8265 glib-compile-resources: Fixes #1675 2019-02-20 10:38:29 +00:00
Philip Withnall
111f2b79e7 glib-compile-schemas: Fix capitalisation of a command line option help
The other descriptions of command line options start with a capital.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-18 17:21:13 +00:00
Philip Withnall
fd3219aaa1 glib-compile-schemas: Improve translatable strings
Eliminate several cases of splitting sentences between multiple
translatable strings, and remove some newlines from the translatable
strings (they always need to be present, and can confuse translation, so
add them unconditionally afterwards).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-18 17:15:15 +00:00
Philip Withnall
b72b4e2d24 Merge branch 'w32-testsuite-fixes-socket' into 'master'
Socket fixes to W32 test suite

See merge request GNOME/glib!666
2019-02-18 12:54:45 +00:00
Emmanuele Bassi
f011be9c4b Initialize a variable
Compilers get confused when variables are initialized by a function by
taking them as reference in an out argument; this, coupled with the fact
that C does not initialize variables by default, most commonly results
in a "maybe uninitialized" compiler warning.
2019-02-18 09:50:26 +00:00
Michael Catanzaro
eac2b1a1c3 Merge branch 'wip/tingping/socket-cancellation' into 'master'
gsocketclient: Ensure task is always returned on cancel

Closes libsoup#132

See merge request GNOME/glib!647
2019-02-14 18:26:17 +00:00
Christoph Reiter
37f9b613d9 Merge branch 'gdbus-fix-use-after-free' into 'master'
gdbus: Fix a potential use-after-free on connection close. Fixes #1686

Closes #1686

See merge request GNOME/glib!671
2019-02-14 13:36:15 +00:00
Philip Withnall
cca7ab2176 Merge remote-tracking branch 'gvdb/master' into update-gvdb 2019-02-14 13:23:28 +00:00
Christoph Reiter
11309b7940 Revert "tests: Mark gdbus-peer test as flaky". See #1686
This reverts commit 983a40bf34.
2019-02-14 14:20:32 +01:00
Christoph Reiter
067992f8de gdbus: Fix a potential use-after-free on connection close. Fixes #1686
512e9b3b34 added a call to schedule_pending_close() in the read
callback after the reference to the worker is already gone. In case this was
the last reference to the worker this resulted in a use-after-free.

6f3d57d2ee made this more likely to happen because on connection close
the worker cancel action is now async while the reference to the worker
gets dropped right away.

Move the call to schedule_pending_close() before the unref.

Fixes #1686
2019-02-14 14:19:55 +01:00
Dan Nicholson
786753ac21 tests: keyfile writability not affected by file mode for root
When testing as root, changing the permissions of the keyfile will have
no effect on the writability since root bypasses these permissions. See
path_resolution(7). Skip the test in this case.
2019-02-14 11:35:26 +00:00
Philip Withnall
888aa4c5ff tests: Use g_assert_*() rather than g_assert() in GSettings tests
g_assert_*() give more informative error messages, and aren’t compiled
out when building with G_DISABLE_ASSERT.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-14 11:35:26 +00:00
Руслан Ижбулатов
c00724d5c9 socket test: Use loopback for connecting, not 0.0.0.0
getsockname() returns the address that the socket was bound to.
If it was bound to INADDR_ANY, getsockname() will stubbornly return INADDR_ANY
(and someport - that one is valid).
Subsequent connection attempts to INADDR_ANY:someport will fail with winsock.
Actually, it doesn't make even sense to connect to INADDR_ANY at all
(where is the socket connecting to? To a random interface of the host?),
so this is just a straight-up change, without platform-specific ifdefing.

Use loopback instead of INADDR_ANY. To ensure that binding and creation
of INADDR_ANY is still tested, use two addresses: bind to INADDR_ANY,
but connect to loopback, with the port number that we got from the bound
address.
2019-02-13 18:22:10 +00:00
Philip Withnall
fbb97b46d8 Merge branch 'gdbus-peer-flaky' into 'master'
tests: Mark gdbus-peer test as flaky

See merge request GNOME/glib!668
2019-02-13 16:53:32 +00:00
Philip Withnall
843a0422ab Merge branch 'w32-mount-sort' into 'master'
GWin32VolumeMonitor: Sort the volumes correctly

See merge request GNOME/glib!669
2019-02-13 16:41:14 +00:00
Jordan Petridis
3e77699c28
gpollableoutputstream: Fix the description of the interface
Looks like this was a copy-paste typo from the Input interface.
2019-02-13 17:52:21 +02:00
Руслан Ижбулатов
0c16230b28 GWin32VolumeMonitor: Sort the volumes correctly
Use a static GQueue to form the GList of mounts by appending (which
is fast, because GQueue tracks the tail pointer of its internal GList),
then return that GList. This way we don't need to form the list
by prepending, which would have made it necessary to reverse it before
returning.

If the list is not ordered correctly, local drives in GTK places sidebar
are shown in reverse order.
2019-02-13 15:27:29 +00:00
Philip Withnall
983a40bf34 tests: Mark gdbus-peer test as flaky
It is occasionally deadlocking. See #1686.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-13 12:04:26 +00:00
Philip Withnall
c5c9b29b9d Merge branch 'w32-testsuite-fixes-general' into 'master'
General fixes to W32 test suite

Closes #875

See merge request GNOME/glib!665
2019-02-13 10:40:11 +00:00
Philip Withnall
0f26836d73 Merge branch 'w32-testsuite-fixes-gsubprocess' into 'master'
GSubprocess fixes for W32 test suite

See merge request GNOME/glib!667
2019-02-13 10:37:22 +00:00
Iain Lane
95899c11d9 Merge branch 'socketclient-slow-install-preload-library' into 'master'
tests: Install the slow-connect-preload.so library and use it

See merge request GNOME/glib!651
2019-02-13 10:00:13 +00:00
Iain Lane
1ecaae6454
installed-tests: Install the slow-connect-preload.so library and use it
The gsocketclient-slow test needs this, otherwise connect() succeeds
immeidately and the test fails, because it is checking that cancellation
works. We weren't installing it for installed tests.
2019-02-13 09:45:08 +00:00
Iain Lane
07a1a8031d
installed tests: Allow tests to set environment variables
It's necessary sometimes for installed tests to be able to run with a
custom environment. For example, the gsocketclient-slow test requires an
LD_PRELOADed library to provide a slow connect() (this is to be added in
a followup commit).

Introduce a variable `@env@` into the installed test template, which we
can override as necessary when generating `.test` files, to run tests
prefixed with `/usr/bin/env <LIST OF VARIABLES>`.

As the only test that requires this currently lives in `gio/tests/`, we
are only hooking this up for that directory right now. If other tests in
future require this treatment, then the support can be extended at that
point.
2019-02-13 09:43:49 +00:00
Руслан Ижбулатов
1cc78bf082 GSubprocess test: Adjust the cwd test to pass on Windows
There's no /tmp directory on Windows.
Use g_get_tmp_dir(), and adjust the test to work with that.
The test *still* checks the basename of the new CWD, it just
doesn't need to be "tmp" anymore.
2019-02-13 08:52:59 +00:00
Руслан Ижбулатов
4bc1aa23a9 GSubprocess test: Add PATH to the envtable that is passed to child
envp in spawn() functions is the *whole* environment table
for the child process. Including PATH. Thus, unless PATH is explicitly
put into that table, the process will be spawned without PATH.
Since on Windows binaries are found via PATH instead of LD_LIBRARY_PATH
or whatever, almost no program (unless installed in WINDIR, maybe)
can run without a PATH. Certainly not test programs - meson
adds bld subdirs to the PATH to make sure that test programs
use uninstalled glib at runtime.
So make sure that PATH is passed along.
2019-02-13 08:52:58 +00:00
Руслан Ижбулатов
01642d6db5 GSubprocess test: Use LINEEND more
Windows \r\n EOLs strike again. The test already knows about LINEEND,
so make it use LINEEND more (instead of swithcing pipes
to binary mode). This also applies to counting the bytes
read.
2019-02-13 08:52:58 +00:00
Руслан Ижбулатов
f150de2139 socket test: Bind Windows UDP sockets before calling recv()
Winsock can't recv() on unbound UDP sockets. Bind the socket
to loopback before trying to receive data on it.
2019-02-13 08:51:31 +00:00
Руслан Ижбулатов
1f5d7eeaa7 socket test: Adjust for Windows-specific sendto() error
With winsock sending messages to NULL results in G_IO_ERROR_NOT_CONNECTED
instead of G_IO_ERROR_FAILED.
MSDN says:
  WSAENOTCONN
  10057
  Socket is not connected.
  A request to send or receive data was disallowed because the socket is not connected
  and (when sending on a datagram socket using sendto) no address was supplied.
So this is a direct mapping of the implementation error.
Covering it up in the wrapper (by converting it to G_IO_ERROR_FAILED)
doesn't seem feasible or needed (no one, except for the testsuite,
really cares which unrecoverable error is returned by sendto()).
2019-02-13 08:51:31 +00:00
Руслан Ижбулатов
00908bc446 network-address test: Disable scope ID tests on Windows
getaddrinfo() in winsock can't understand scope IDs.
There's no obvious way to fix that, short of re-implementing
that function, so disable that part of the test on Windows.
2019-02-13 08:49:42 +00:00
Руслан Ижбулатов
14aae264d4 autoptr test: Use OS-dependent path separator
Since GFile canonicalizes the path it is given, expect the '\\' separator
on Windows.
2019-02-13 08:49:42 +00:00
Руслан Ижбулатов
294d818336 Use OS-dependent separator for G_RESOURCE_OVERLAYS
G_RESOURCE_OVERLAYS is a list of resource-path and filesystem-path pairs.
Since on Windows filesystem paths use ':', this list can't be ':'-separated
there. Fix that by making it ';'-separated on Windows. Make the parser
error clearer (we're not looking for a slash, we're looking for an absolute
path).
2019-02-13 08:49:42 +00:00
Руслан Ижбулатов
ccbadcfb04 GWinHTTPVfs: use URI parser for parsing URIs
If a URI can't be handled by by WinHTTPVfs, it should pass that URI
along to the URI parser of the wrapped Vfs, not to its generic parser.
Theoretically, generic parser should also be able to handle URIs,
but this is subject to Vfs semantics.

In case of Windows, the wrapped Vfs is GLocalVfs, which is *local* and
treats any generic names as either file:// URIs or as filesystem
paths. It only ever treats URIs as URIs when they are passed
to its URI parser. This breaks the testsuite when g-icon GIO test passes
unhandleable sftp:// URI, and expects it to come through unmolested,
yet GLocalVfs, getting that URI as a generic parse name, treats it as
a filesystem path, and then "canonicalizes" it by prepending CWD.

Fix this by making WinHTTPVfs pass any URIs it gets to the URI parser
of the wrapped Vfs. This way unknown URIs remain URI-ish. This seems
like a reasonable things to do, since the URI parser should not be
given anything other than URIs, so there's no reason to try generic
parsing with these strings.

Closes: #875
2019-02-13 08:49:42 +00:00
Michael Catanzaro
df5592f28d Merge branch 'wip/tingping/network-address-fixes' into 'master'
gnetworkaddress: Never end enumeration before resolving completes

Closes #1680

See merge request GNOME/glib!646
2019-02-11 14:22:05 +00:00
Patrick Griffis
085081ea2c gnetworkaddress: Never end enumeration before resolving completes
Previously once the end of addresses was reached it would return
NULL even if it was waiting on a dns response. Now it will keep
waiting so all addresses are received.

Fixes #1680
2019-02-11 08:59:33 -05:00
Patrick Griffis
c83291049e gnetworkaddress: Factor out initializing address list into function 2019-02-11 08:59:31 -05:00
Debarshi Ray
e13b3a9ee5 gio/tests/task: Add comments documenting how the test works
https://gitlab.gnome.org/GNOME/glib/issues/1608
2019-02-11 12:30:23 +01:00
Debarshi Ray
5d1aaf56bb gio/tests/task: Run the worker indefinitely until it's cancelled
Currently, the actual asynchronous work, represented by
asynchronous_cancellation_run_task, was over before the GCancellable
could be triggered. While that doesn't invalidate the purpose of the
test, since it's fundamentally about cancellation, it would be
nicer if the cancellation actually served some purpose instead of
being a mere formality.

https://gitlab.gnome.org/GNOME/glib/issues/1608
2019-02-11 12:12:47 +01:00
Iain Lane
cc12f3f253
gio tests: Install test1.overlay file when building installed tests
This is used as a GResource overlay, so it must be available to the
test.
2019-02-11 10:21:13 +00:00
Philip Withnall
30ccfac9cf gsocketlistener: Fix multiple returns of GTask when accepting sockets
When calling g_socket_listener_accept_socket_async() on a
GSocketListener with multiple sockets, the accept_ready() callback is
called for the first incoming connection on each socket. It will return
success/failure for the entire accept_socket_async() GTask, and then
free the GSources for listening for incoming connections on the other
sockets in the GSocketListener. The GSources are freed when the GTask is
finalised.

However, if incoming connections arrive for multiple sockets within the
same GMainContext iteration, accept_ready() will be called multiple
times, and will call g_task_return_*() multiple times, before the GTask
is finalised. Calling g_task_return_*() multiple times is not allowed.

Propagate the first success/failure, as before, but then ignore all
subsequent incoming connections until the GTask is finalised.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-11 00:25:48 +00:00
Patrick Griffis
4dd1582625 gsocketclient: Ensure task is always returned on cancel
It was possible for the individual connection attempts to be
cancelled without the main task getting returned.

Fixes libsoup#132
2019-02-09 10:30:24 -05:00
Ignazio Pillai
b465cb158b gtask: fix task_wait_time estimation
The wait time is estimated as function of the number of running threads

Fixes #1683
2019-02-08 10:53:26 +01:00
Patrick Griffis
ed57faeeda tests: Use fewer magic numbers in network-address tests 2019-02-07 11:56:22 -05:00
Patrick Griffis
5827cef22d tests: Unmark network-address test as flaky 2019-02-07 11:56:22 -05:00
Patrick Griffis
5b0fdfda6d gnetworkaddress: Fix incorrect error propagation when resolving addresses
Previously this would always error if ipv6 errored after ipv4
succeeded which was incorrect.

This explicitly tests the order of erroring.

Fixes #1644
2019-02-07 11:56:22 -05:00
Debarshi Ray
381af21072 gio/tests/task: Ensure that cancelled tasks are returned asynchronously
Closes https://gitlab.gnome.org/GNOME/glib/issues/1608
2019-02-06 13:30:01 +00:00
Debarshi Ray
6f3d57d2ee gtask: Return cancelled tasks asynchronously
Once cancelled, a GTask's callback should not only be invoked
asynchronously with respect to the creation of the task, but also with
respect to the GCancellable::cancelled handler. This is particularly
relevant in cases where the cancellation happened in the same thread
where the task is running.

Spotted by Dan Winship and Michael Catanzaro.

Closes https://gitlab.gnome.org/GNOME/glib/issues/1608
2019-02-06 13:30:01 +00:00
Philip Withnall
cffed58737 tests: Tag socket-service test as ‘flaky’
It needs investigating and fixing properly, but let’s not let it disrupt
the CI in the meantime.

Follow-up in https://gitlab.gnome.org/GNOME/glib/issues/1679.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-06 12:50:38 +00:00
Chun-wei Fan
bb73a22448 Win32: gio/gsocket.c: Set WSAEWOULDBLOCK on G_POLLABLE_RETURN_WOULD_BLOCK
To make things consistent across the board as that is the WinSock2 error
code that is received by g_socket_send_message_with_timeout() when it
returns G_POLLABLE_RETURN_WOULD_BLOCK.
2019-02-05 11:15:50 +08:00
Philip Withnall
1f7d5b85d7 Merge branch 'trash-portal' into 'master'
Support the trash portal

See merge request GNOME/glib!276
2019-02-04 13:38:03 +00:00
Matthias Clasen
bca4ff7c5e Support the trash portal
When we are in a sandbox, try to trash files via a portal.
It works.
2019-01-31 19:00:19 -05:00
Philip Withnall
6c14e9a14b tests: Fix a minor memory leak in the gsettings test
g_settings_backend_get_default() returns a strong reference.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-30 14:41:15 +00:00
Philip Withnall
caf5103d4b gsettingsbackend: Fix a minor memory leak
This never caused any problems because the default GSettingsBackend is
cached forever by GIOModule anyway.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-30 14:41:15 +00:00
Philip Withnall
f829b65e51 gsettings: Clarify ownership transfer in a few places
I was trying to debug some memory leaks in the gsettings test.
Eventually, it seems that actually they’re caused by the
GMemorySettingsBackend being cached by GIOModule — so this commit makes
no functional changes. It should make the code and documentation a bit
clearer though.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-30 14:41:15 +00:00
Philip Withnall
9d89ed0c54 gkeyfilesettingsbackend: Add a code comment to clarify things
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-30 14:41:15 +00:00
Michael Catanzaro
930883609c Merge branch 'wip/tingping/gsocketclient-criticals' into 'master'
gsocketclient: Fix criticals

Closes #1649 and #1646

See merge request GNOME/glib!627
2019-01-29 20:59:18 +00:00
Patrick Griffis
d553d92d6e gsocketclient: Fix criticals
This ensures the parent GTask is kept alive as long as an enumeration
is running and trying to connect.

Closes #1646
Closes #1649
2019-01-29 14:46:52 -05:00
Ernestas Kulik
566e1d61a5 gdbus: Avoid printing null strings
This mostly affects the 2.56 branch, but, given that GCC 9 is being
stricter about passing null string pointers to printf-like functions, it
might make sense to proactively fix such calls.

gdbusauth.c: In function '_g_dbus_auth_run_server':
gdbusauth.c:1302:11: error: '%s' directive argument is null
[-Werror=format-overflow=]
 1302 |           debug_print ("SERVER: WaitingForBegin, read '%s'",
 line);
       |

gdbusmessage.c: In function ‘g_dbus_message_to_blob’:
gdbusmessage.c:2730:30: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
 2730 |       tupled_signature_str = g_strdup_printf ("(%s)", signature_str);
      |
2019-01-29 11:06:39 +01:00
Philip Withnall
08e5c89dfc Merge branch 'wip/oholy/gappinfo-async' into 'master'
Make `g_app_info_launch_uris_async()` really asynchronous

Closes #1249 and #1347

See merge request GNOME/glib!609
2019-01-28 16:27:07 +00:00
Simon McVittie
92881babba Merge branch '1642-message-blob-size' into 'master'
gdbusmessage: Fix check on upper limit of message size

Closes #1642

See merge request GNOME/glib!623
2019-01-28 15:45:15 +00:00
Ondrej Holy
051c6ba4e7 gio-tool-open: Use g_app_info_launch_default_for_uri_async()
The recent changes of the g_app_info_launch_default_for_uri_async()
function ensures that the callback is not called before DBus-activated
applications start. Let's use g_app_info_launch_default_for_uri_async()
and remove the workarounds for DBus-activated applications.

Closes: https://gitlab.gnome.org/GNOME/glib/issues/1249
2019-01-28 16:42:34 +01:00
Ondrej Holy
904bb264e9 gappinfo: Use g_app_info_launch_uris_async() for async calls
Currently, the g_app_info_launch_default_for_uri_async() function uses
g_app_info_launch_uris(), which is not fully asynchronous and may cause
for example Nautilus freezes. Let's use the g_app_info_launch_uris_async()
function to prevent the freezes.

Closes: https://gitlab.gnome.org/GNOME/glib/issues/1347
https://gitlab.gnome.org/GNOME/glib/issues/1249
2019-01-28 16:42:34 +01:00
Ondrej Holy
cec5778cad gappinfo: Add launch_uris_async() and launch_uris_finish() vfuncs
The g_app_info_launch_uris_async() and g_app_info_launch_uris_finish()
functions are crucial to fix g_app_info_launch_default_for_uri_async()
to be really asynchronous.

This patch also adds GDesktopAppInfo implementation of that vfuncs.
The implementation may still use some synchronous calls to local MIME DB.

https://gitlab.gnome.org/GNOME/glib/issues/1347
https://gitlab.gnome.org/GNOME/glib/issues/1249
2019-01-28 16:42:34 +01:00
Ondrej Holy
f72a5d65e0 gfile: Add g_file_query_default_handler_async()
This is needed as a first step to fix the
g_app_info_launch_default_for_uri_async() function to be really
asynchronous.

It still uses the g_app_info_get_default_for_uri_scheme() and
g_app_info_get_default_for_type() functions, which may use synchronous
calls to local MIME DB.

https://gitlab.gnome.org/GNOME/glib/issues/1347
https://gitlab.gnome.org/GNOME/glib/issues/1249
2019-01-28 16:42:34 +01:00
Ondrej Holy
0a1730d7ea gfile: Fix leak in g_file_query_default_handler()
Add missing `g_free (uri_scheme)` to fix leak when `uri_scheme[0]`
is equal to `\0`.
2019-01-28 16:42:34 +01:00
Philip Withnall
31b0ba18c1 gdbusmessage: Fix check on upper limit of message size
There was a typo in the figure checked against. Add a unit test.

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

https://gitlab.gnome.org/GNOME/glib/issues/1642
2019-01-28 14:37:22 +00:00
Philip Withnall
140b82083f Merge branch 'trash-mount-points-master' into 'master'
Don't fail trash test if ~/.local doesn't exist or mount points can't be determined (master)

See merge request GNOME/glib!593
2019-01-28 13:53:36 +00:00
Philip Withnall
80f2c96a45 Merge branch 'portals-no-o-path' into 'master'
gio: do not pass O_PATH file descriptors to portal APIs

See merge request GNOME/glib!585
2019-01-28 12:58:03 +00:00
Philip Withnall
eb589e2bfe tests: Ensure GCancellable is cancelled before operation is started
In the writev() tests, the handling of cancellation is tested. However,
the GCancellable was cancelled after the writev_async() call was
started. Depending on the implementation of the writev() vfunc, the
operation could be done in a thread or in callbacks on the current
thread’s main loop. If done in a separate thread, there’s a chance that
enough of the write could happen before cancellation reaches that thread
that the overall operation returns success with a short write.

That would cause the test to fail, sometimes.

Avoid that by cancelling the GCancellable before starting the writev()
operation.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2019-01-26 12:16:35 +00:00
Philip Withnall
cc95f819e2 Merge branch '424-gdbus-proxy-debugging' into 'master'
gdbusproxy: Add G_DBUS_DEBUG=proxy support

Closes #424

See merge request GNOME/glib!618
2019-01-25 14:42:52 +00:00
Philip Withnall
1275ddb794 Merge branch 'gdbus-proxy-test-fixes' into 'master'
gdbus-proxy test fails with GLib-GIO:ERROR:glib/gio/tests/gdbus-proxy.c:832:fail_test: code should not be reached

See merge request GNOME/glib!598
2019-01-25 14:42:05 +00:00
Richard Hughes
cd7bba985e gdbusproxy: Add G_DBUS_DEBUG=proxy support
(Turned into a merge request by Philip Withnall; unmodified from
original patch on https://bugzilla.gnome.org/show_bug.cgi?id=654905.)

https://gitlab.gnome.org/GNOME/glib/issues/424
2019-01-25 14:30:32 +00:00
Philip Withnall
aa3f7eaac7 Merge branch 'wip/chergert/fix-network-address-crash' into 'master'
gnetworkaddress: fix use-after-free for network address

See merge request GNOME/glib!611
2019-01-25 14:22:00 +00:00
Christian Hergert
4b2a60c73a gnetworkaddress: fix use-after-free for network address
This fixes an error where addr_enum can be used after finalization during
complete_queued_task().
2019-01-25 09:03:34 -05:00
James Henstridge
b8477255b3 gio: make g_document_portal_add_documents() fall back to read-only access 2019-01-25 14:06:46 +08:00
Sebastian Dröge
f5541d8a6e Merge branch 'compiler-warnings' into 'master'
Fix a couple of wrong compiler warnings

See merge request GNOME/glib!615
2019-01-24 15:15:07 +00:00
Sebastian Dröge
bd75dffc00 Fix compiler warning about uninitialized variable in desktop-app-info test
It would always be initialized but initialize it to NULL to silence the
compiler, and also check that it is not NULL anymore when we expect it
to contain a valid value.

../gio/tests/desktop-app-info.c: In function ‘test_fallback’:
../gio/tests/desktop-app-info.c:191:18: warning: ‘app’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   g_assert_true (g_app_info_equal (info1, app));
                  ^~~~~~~~~~~~~~~~
2019-01-24 16:37:23 +02:00
Sebastian Dröge
b4a5157f95 Fix compiler warning about uninitialized variable in giomodule
It could've never been uninitialized in this code but the code flow is
not obvious to the compiler. Initialize it to NULL and for clarity also
add an assertion that it is not NULL anymore on usage.

In file included from ../glib/glib.h:62,
                 from ../gobject/gbinding.h:28,
                 from ../glib/glib-object.h:23,
                 from ../gio/gioenums.h:28,
                 from ../gio/giotypes.h:28,
                 from ../gio/giomodule.h:28,
                 from ../gio/giomodule.c:25:
../gio/giomodule.c: In function ‘_g_io_module_get_default’:
../glib/gmessages.h:343:25: warning: ‘extension’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 #define g_debug(...)    g_log (G_LOG_DOMAIN,         \
                         ^~~~~
../gio/giomodule.c:912:17: note: ‘extension’ was declared here
   GIOExtension *extension, *preferred;
                 ^~~~~~~~~
2019-01-24 16:35:13 +02:00
Sebastian Dröge
b94940dfae Add test for blocking and non-blocking and async read/write(v) on UNIX streams 2019-01-24 16:26:05 +02:00
Sebastian Dröge
fe71a19716 Add test for blocking read/write/writev on GSocket*Streams 2019-01-24 16:26:02 +02:00
Sebastian Dröge
61520ae601 Add test for async read/write(v)/close on GSocketConnections 2019-01-24 16:25:59 +02:00
Sebastian Dröge
708aa8f4ee Add some tests for g_output_stream_writev() and its async variant 2019-01-24 16:25:56 +02:00
Sebastian Dröge
e6f5a50cd7 Implement GOutputStream::writev_fn() and GPollableOutputStream::writev_nonblocking() for GSocketOutputStream 2019-01-24 16:25:52 +02:00
Sebastian Dröge
9ae40d982a Rename timeout variables in gsocket.[ch] to include the unit as suffix
Makes it clearer which unit we work with. We have timeouts in seconds,
milliseconds and microseconds in here.
2019-01-24 16:25:50 +02:00
Sebastian Dröge
cc7f2f6b28 Add (type GSocketMsgFlags) to int-typed flags parameters in GSocket 2019-01-24 16:25:48 +02:00
Sebastian Dröge
f0a11b2727 Add g_socket_send_message_with_timeout() 2019-01-24 16:25:46 +02:00
Sebastian Dröge
63ea8d18f3 Simplify some code in GUnixOutputStream 2019-01-24 16:25:44 +02:00
Sebastian Dröge
90d9e4ab72 Implement GOutputStream::writev() and GPollableOutputStream::writev_nonblocking() GUnixOutputStream 2019-01-24 16:25:42 +02:00
Sebastian Dröge
c39264d35b Implement GOutputStream::writev_fn() for GLocalFileOutputStream on UNIX 2019-01-24 16:25:40 +02:00
Sebastian Dröge
89da9eb6c0 Change to g_warning() into assertions in GOutputStream
These would only happen if the API contract of the write() and writev()
functions was broken by subclasses.
2019-01-24 16:25:38 +02:00
Sebastian Dröge
0bcc177378 Add writev() / writev_all() API to GOutputStream and GPollableOutputStream
This comes with default implementations around the normal write
functions and async variants.

Fixes https://gitlab.gnome.org/GNOME/glib/issues/1431
2019-01-24 16:25:34 +02:00
Sebastian Dröge
042b8dc40d Introduce new GPollableReturn enum
This allows returning WOULD_BLOCK without allocating a GError, and
should later be used for various functions of GPollableOutputStream,
GPollableInputStream and anything else that can potentially block.
2019-01-24 16:25:31 +02:00
Matthias Clasen
df5b482781 gio: Support "help" in extension point env vars
Interpret the value "help" for environment variables that
are passed to _g_io_module_get_default(), and print the
names and priorities of available extensions.

This lets users explore what is available, and can be helpful
in figuring out why a certain extension was chosen as default.

It is similar in spirit to what we already do with environment
variables like G_DEBUG.
2019-01-22 13:18:42 -05:00
Matthias Clasen
e6574b228e keyfile settings: Accept unquoted strings
It is hard for users to remember that strings have to be explicitly
quoted in the keyfile. Be lenient and accept strings that lack those
quotes.
2019-01-22 11:11:24 -05:00
Philip Withnall
92b3f22ad5 giomodule: Print the type of each default GIO module
This is useful for debugging in many situations. It’ll be printed with
G_MESSAGES_DEBUG=GLib-GIO or G_MESSAGES_DEBUG=all.

Mostly I need it for debugging the default GNetworkMonitor, but it will
work for all GIO module implementations.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-21 16:27:58 +00:00
Matthias Clasen
2854522379 settings: Prefer the keyfile backend when sandboxed
When we are in a sandboxed situation, bump the priority
of the keyfile settings backend above the dconf one,
so we use a keyfile inside the sandbox instead of requiring
holes in the sandbox for dconf.
2019-01-20 21:03:35 -05:00
Matthias Clasen
c63e3a4ada settings: Add support for defaults to keyfile backend
Stacked databases and locks are dconf features that allow
management software like Fleet Commander to set system-wide
defaults and overrides centrally for applications.

This patch adds minimal support for the same to the keyfile
backend. We look for a keyfile named 'defaults' and a
lock-list named 'locks'.

Suitable files can be produced from a dconf database with
dconf dump and dconf list-locks, respectively.

The default location for these files is /etc/glib-2.0/settings/.
For test purposes, this can be overwritten with the
GSETTINGS_DEFAULTS_DIR environment variable.

Writes always go to the per-user keyfile.
2019-01-20 21:03:35 -05:00
Matthias Clasen
5357a23321 settings: Register the keyfile backend as extension
This was not done previously because the backend
could not be instantiated without parameters.
2019-01-20 21:03:35 -05:00
Matthias Clasen
26c8b29ee1 settings: Make the keyfile backend parameterless
Make it possible to instantiate a keyfile settings backend
without specifying parameters, by turning the arguments to
the new() function into construct-only properties. If no
filename is specified, default to
$XDG_CONFIG_HOME/glib-2.0/settings/keyfile
2019-01-20 21:03:35 -05:00
Ignacio Casal Quinteiro
e9506d7719 gdtlsconnection: do not return on a void method
Fixes:
warning C4098: 'g_dtls_connection_set_advertised_protocols': 'void' function returning a value
2019-01-18 17:27:44 +01:00
Emmanuele Bassi
da2bf2a280 Merge branch '1500-list-store-state' into 'master'
gliststore: Store validity of last_position explicitly

Closes #1500

See merge request GNOME/glib!596
2019-01-18 16:03:56 +00:00
Philip Withnall
5612c90fdf tests: Tag gsocketclient-slow test as ‘flaky’
It needs investigating and fixing properly, but let’s not let it disrupt
the CI in the meantime.

Follow-up in https://gitlab.gnome.org/GNOME/glib/issues/1653.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-18 15:27:45 +00:00
Iain Lane
63038d1e4c
gio/tests/gdbus-proxy: test_proxy: check the server is properly killed
We kill the test service at the end of this test. Let's also ensure that
the name on the bus goes away and that we are notified about this
happening.
2019-01-18 15:26:27 +00:00
Iain Lane
7aa83536af
gio/tests/gdbus-proxy: Make proxy_ready test start the server after the proxy
There's a race here, as revealed by Debian's buildds.

We call g_dbus_proxy_new() to create a proxy for the test server, with
callback proxy_ready() Then we call g_spawn_command_line_async() to
start the test server, and then start the main loop.

proxy_ready() assumes that the test server hasn't been started when it
is called. But there is no guarantee that these asynchronous operations
involving spawning a process won't happen in a different order that mean
the bus name *does* have an owner.

What we can do is move starting the server inside of proxy_ready(), so
we know that the test server isn't started until after the proxy is
created. We also add an assertion to check that it is indeed not running
before we execute it.
2019-01-18 15:26:11 +00:00
Philip Withnall
c9aba16af3 gliststore: Store validity of last_position explicitly
Rather than storing it as an invalid value in last_position, store it as
a separate boolean.

This introduces no functional changes, but should fix some warnings from
MSVC.

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

https://gitlab.gnome.org/GNOME/glib/issues/1500
2019-01-18 15:22:19 +00:00
Simon McVittie
13282768c7
trash test: Don't rely on being able to determine mount points
If we can't find the mount point for target or tmp (as currently
happens on Launchpad autobuilders, and perhaps relatedly, on a
development system that uses btrfs), that's probably not great but is
not really the point of this test.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-17 16:31:10 +00:00
Simon McVittie
56a5cd1337
trash test: Don't assume that ~/.local exists
In a minimal autobuilder environment, this test could conceivably be
the first thing to refer to ~/.local.

Modified by Iain Lane <laney@debian.org>: Don't try to create ~/.local
from tests, but skip if it doesn't exist.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-17 16:31:10 +00:00
Tomasz Miąsko
6994be01f4 gfileinfo: Fix annotation for g_file_info_set_attribute_stringv
Annotate `attr_value` parameter of `g_file_info_set_attribute_stringv`
as zero-terminated array, since it isn't currently recognized as such.
2019-01-17 12:43:07 +01:00
Philip Withnall
c9f883b221 Merge branch 'resource-overlay-info' into 'master'
gresource: Complete the overlay support

Closes #1445

See merge request GNOME/glib!497
2019-01-17 10:13:52 +00:00
Philip Withnall
6a372bf703 Merge branch 'disable-tests' into 'master'
Temporarily disable flaky tests

See merge request GNOME/glib!579
2019-01-15 16:45:15 +00:00
Philip Withnall
b3efef5b6f build: Drop autotools support
So long, and thanks for everything. We’re a Meson-only shop now.

glib-2-58 will remain the last stable GLib release series which is
buildable using autotools.

We continue to install autoconf macros for autotools-using projects
which depend on GLib; they are stable API.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-15 15:11:43 +00:00
Philip Withnall
7cff1b2265 glib: Update various code comments to mention Meson
Rather than referring to the old autotools build system.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-15 15:11:43 +00:00
James Henstridge
9dc0d6bfa5 gio: don't pass O_PATH descriptors to the document portal
Like for the OpenURI portal, O_PATH file descriptors do not prove access
to the underlying file data.  I've used O_RDWR file descriptors here to
mirror the requested read/write permissions.
2019-01-15 16:21:35 +08:00
James Henstridge
e244a78fbc gio: don't use O_PATH file descriptors with OpenURI portal
This change relates to https://github.com/flatpak/xdg-desktop-portal/issues/167

The OpenURI portal requires the caller to pass a file descriptor as
proof of access for local files.  Old versions required this file
descriptor to use the O_PATH mode.  However, this does not prove access
since you can create O_PATH descriptors for files that you can't read.

Since xdg-desktop-portal 1.0.1, regular file descriptors are also
accepted with O_PATH descriptors restricted to flatpaks for the
transition.
2019-01-15 15:59:46 +08:00
Matthias Clasen
37eb1e6645 Add a test for resource overlays
Add a test that checks that g_resources_get_info()
respects the G_RESOURCE_OVERLAYS environment variable.
2019-01-10 13:50:26 -05:00
Matthias Clasen
68bcb8f048 gresource: Complete the overlay support
Unlike the other g_resources_ functions, g_resources_get_info
was not respecting G_RESOURCE_OVERLAYS. Add this missing
support.

Closes: #1445
2019-01-10 12:31:09 -05:00
Philip Withnall
956a54d6d6 tests: Tag several rogue GIO tests as ‘flaky’
These have been flaky for a while now, and nobody has found the time to
fix them properly. They’ve been disrupting development for altogether
far too long.

They need investigating in the following issues, fixing properly, and
the ‘flaky’ tag removing from each one:
 • https://gitlab.gnome.org/GNOME/glib/issues/1644https://gitlab.gnome.org/GNOME/glib/issues/1634https://gitlab.gnome.org/GNOME/glib/issues/1614https://gitlab.gnome.org/GNOME/glib/issues/1515

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-09 10:48:42 +00:00
Michael Gratton
d7aedeff29 gio: Update bad cert error in accept-certificate and GTlsError docs
This makes the documented error returned when the cert is rejected
consistent with both self and reality.
2019-01-08 22:40:54 +11:00
Philip Withnall
74e4b8396f Merge branch 'bad-liststore' into 'master'
Fix overflow in GListStore

Closes #1639

See merge request GNOME/glib!572
2019-01-07 14:09:59 +00:00
Matthias Clasen
d8a0dcb11e list store: Fix overflow issues
Check for over- and underflow when manipulating positions.

This makes the sequence
  g_list_model_get_item (store, 0);
  g_list_model_get_item (store, -1u);
return NULL for the second call, as it should.

Closes: #1639
2019-01-07 08:53:16 -05:00
Matthias Clasen
471153fb20 liststore: Add a test demonstrating overflow issues
Calling
  g_list_model_get_item (store, 0);
  g_list_model_get_item (store, -1u);
does not return NULL for the second call, as it should.

This was showing up in GTK+ list model tests.
2019-01-07 08:52:47 -05:00
Philip Withnall
29e8f5795d gwin32appinfo: Fix a potential free of an uninitialised variable
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1637
2019-01-07 10:25:46 +00:00
Philip Withnall
ae381d795e gtask: Ensure to return 1 or 0 from getters rather than truthy ints
Since commit 290bb0dd, where various members of GTask were converted to
a bitfield, some of the getters:
 • g_task_get_check_cancellable()
 • g_task_get_return_on_cancel()
 • g_task_get_completed()
have been returning truthy ints (zero or an arbitrary non-zero integer)
as boolean values, rather than the canonical boolean ints of 1 and 0.

This broke the `yield` statement in Vala, whose generated C code
compares `g_task_get_completed (…) != TRUE`. i.e. Whether the
`completed` field has a value not equal to 1.

Fix this by explicitly converting truthy ints to canonical boolean ints
in all getters.

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

https://gitlab.gnome.org/GNOME/glib/issues/1636
2019-01-05 07:51:14 +00:00
Philip Withnall
ea0da960ab Merge branch 'issues/1620' into 'master'
Issues/1620

See merge request GNOME/glib!554
2018-12-21 12:46:38 +00:00
Philip Withnall
87ea4ce1ff Merge branch 'gdbus-codegen-propemitschanged' into 'master'
honor "Property.EmitsChangedSignal" annotations

Closes #542

See merge request GNOME/glib!532
2018-12-21 12:34:55 +00:00
Cosimo Cecchi
dec0a6874e gdbusproxy: only connect to NameOwnerChanged for message buses
Names are a message bus feature, so it does not make sense to connect
to NameOwnerChanged when the underlying connection is not a message
bus.

Moreover, g_dbus_connection_signal_subscribe() will also enforce that
condition. Adding this extra check here is helpful to avoid a critical
warning when using GDBusProxy with peer-to-peer connections.

https://gitlab.gnome.org/GNOME/glib/issues/1620
2018-12-20 00:41:19 +00:00
Cosimo Cecchi
7d02e32644 gdbusconnection: add a getter for the flags property
Right now this can only be set at construction but not read back.
That seems unnecessarily restrictive, and we'll need to read these
flags from outside of gdbusconnection.c in the next commit, so let's
just make it public.

https://gitlab.gnome.org/GNOME/glib/issues/1620
2018-12-20 00:41:13 +00:00
Ninja-Koala
d04b9c371d glib-compile-resources: Add external data option
Add option to not encode resource data into the C source file
in order to embed the data using `ld -b binary`. This improves compilation
times, but can only be done on Linux or other platforms with a
supporting linker.

(Rebased by Philip Withnall, fixing minor rebase conflicts.)

Fixes #1489
2018-12-19 16:43:21 +00:00
Philip Withnall
ccb3486543 Revert "tests: Fix GOptionContext leak in GSubprocess tests"
This reverts commit 52bab0254a.

It silently conflicted with another commit,
90ca3b4dd0, which was merged later than
it. I’ve kept commit 90ca3b because it also frees the GError; 52bab
doesn’t.

This is my failure to rebase and test old branches before merging them,
instead of assuming that the lack of automatically detected merge
conflicts actually means there are no merge conflicts.
2018-12-19 14:54:27 +00:00
Philip Withnall
499e08a462 Merge branch 'gtask-set-name' into 'master'
gtask: Add a g_task_set_name() method

See merge request GNOME/glib!384
2018-12-19 13:16:07 +00:00
Philip Withnall
0b80445b0c Merge branch 'gsubprocess-communicate-utf8-tests' into 'master'
Add UTF-8 communication tests for GSubprocess

See merge request GNOME/glib!381
2018-12-19 13:15:04 +00:00
Philip Withnall
04af8f12f0 Merge branch 'master' into 'master'
GTlsConnection: add ALPN support

See merge request GNOME/glib!520
2018-12-19 12:01:50 +00:00
Philip Withnall
0953338704 Merge branch 'tpm-keys-in-pem-files' into 'master'
gtlscertificate: Add support for TPM keys in PEM files

See merge request GNOME/glib!522
2018-12-19 11:53:17 +00:00
Thomas Jost
5731f06541
gdbus-codegen: honor "Property.EmitsChangedSignal" annotations
Co-Authored-by: Andy Holmes <andrew.g.r.holmes@gmail.com>
2018-12-19 11:06:31 +01:00
Michael Gratton
613f63f4a1 gdbus-codegen: Add missing nullable and optional g-i annotations to generated code
Fixes #1615
2018-12-19 18:00:25 +11:00
Scott Hutton
9032e8897d Implement support for ALPN in GTlsConnection, GDtlsConnection 2018-12-18 16:32:55 -08:00
Philip Withnall
26f783576d Merge branch 'docs-fixes' into 'master'
Various minor docs fixes

See merge request GNOME/glib!536
2018-12-18 15:35:07 +00:00
Fredrik Ternerot
a437a50694 gtlscertificate: Allow any type of private key in PEM files
Allow any type of private key in PEM files by treating PEM guards ending
with "PRIVATE KEY-----" as a private key instead of looking for a
pre-defined set of PEM guards. This enables the possibility for custom
GTlsBackend to add support for new key types.

Test cases have been expanded to ensure PEM parsing works for private
key when either header or footer is missing.

Encrypted PKCS#8 is still rejected. Test case has been added for this to
ensure behaviour is the same before and after this change.
2018-12-18 11:43:08 +01:00
Fredrik Ternerot
73ca761a8d tests/tls-certificate: Add PEM files containing CRLF
Add test case to ensure correct parsing of PEM files containing CRLF
(\r\n) line endings.
2018-12-18 11:41:45 +01:00
Fredrik Ternerot
c7ee522172 tests/tls-certificate: Change to g_assert_null/nonnull
Use g_assert_null/g_assert_nonnull instead of g_assert since
g_assert can be compiled out with G_DISABLE_ASSERT.
2018-12-18 11:40:26 +01:00
Philip Withnall
1947834b70 tests: Disable debug output from desktop-app-info subprocess
The `apps` subprocess is spawned by desktop-app-info to interpret the
forest of .desktop files, and its output is provided on stdout. If debug
output is mixed up with that output, tests which parse the output fail.

Disable the debug output from the subprocess to prevent this.

The new debug output appeared as a result of recent changes to the
desktop file dir monitoring code in gdesktopappinfo.c.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
f8421059e9 tests: Add some debug output to desktop-app-info test
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
1ea4ba8d6e tests: Use static appinfo .desktop file when not launching
The appinfo-test.desktop file is set up with an Exec= path which points
to the compiled and installed appinfo-test utility. When running the
tests uninstalled, however, this might not be present, which causes
loading appinfo-test.desktop to fail.

Split appinfo-test.desktop in two: keep the existing
appinfo-test.desktop for tests which need to launch appinfo-test, and
add a new appinfo-test-static.desktop for tests which don’t launch
anything (and, for example, just inspect GAppInfo properties).
appinfo-test-static.desktop uses an Exec= line which should always be
present (`true`) so it should never fail to load.

Allow the tests using appinfo-test-static.desktop to be run uninstalled
or installed. Allow the tests using appinfo-test.desktop to be skipped
if loading appinfo-test.desktop fails, which is an indicator that the
test is running uninstalled.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
60c2533f44 tests: Port appinfo test from g_assert() to g_assert_*()
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
707c3f2495 tests: Isolate directories in mimeapps test
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
d23c893a0f tests: Isolate directories in appmonitor test
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
914e7c6014 tests: Isolate directories in desktop-app-info test
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
797a8b0930 tests: Isolate directories in appinfo test
This is essentially a reversion of commit
a39b847ddf, plus the addition of the new
G_TEST_OPTIONS_ISOLATE_XDG_DIRS option.

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

https://gitlab.gnome.org/GNOME/glib/issues/1601
2018-12-17 17:16:04 +00:00
Philip Withnall
99bc33b632 gdesktopappinfo: Reload the desktop dirs if the $XDG_CONFIG_HOME changes
This causes the desktop directory cache to be correctly reloaded between
unit tests if G_TEST_OPTION_ISOLATE_DIRS is in use.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
e97bf89dd4 gcontenttype: Improve the formatting of some code in a docs comment
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00