Commit Graph

6209 Commits

Author SHA1 Message Date
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
Philip Withnall
b06fa34bb1 gcontenttype: Add g_content_type_{get,set}_mime_dirs() API
This allows the list of directories which contain MIME data to be set,
separately from the list of directories returned by
g_get_user_data_home() and g_get_system_data_dirs().

While the latter are overridden for a unit test, we don’t have access to
the system MIME registry, which can sometimes be useful for tests which
need to know about standard MIME associations from shared-mime-info.

Allow g_content_type_set_mime_dirs() to be used from unit tests to allow
them to use the system MIME registry again, or to allow them to be
pointed to another custom registry.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
df2f13f89b gcontenttype: Improve formatting of gcontenttype section documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:03 +00:00
Philip Withnall
b6f7f37427 xdgmime: Add xdg_mime_set_dirs() method to override XDG envvars
In order to make xdgmime properly relocatable so that unit tests can use
it without it reading and modifying the user’s actual xdgmime files, and
without the need to call setenv() (and get tied up with thread safety
problems), add a xdg_mime_set_dirs() method to allow the dirs to be
overridden. They will still default to the values of $XDG_DATA_HOME and
$XDG_DATA_DIRS.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:03 +00:00
Philip Withnall
528d537da8 tests: Port desktop-app-info to use g_assert_*()
g_assert() is for runtime code, and can be compiled out. g_assert_*()
cannot be compiled out, and give more helpful failure messages for
specific types.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:03 +00:00
Philip Withnall
592365239a tests: Drop extraneous newlines from g_test_message() calls in mimeapps
g_test_message() adds a newline already.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:03 +00:00
Philip Withnall
d4f804576a tests: Use g_assert_*() in mimeapps test rather than g_assert()
g_assert() can be compiled out with G_DISABLE_ASSERT, which renders the
test useless. The g_assert_*() functions provide more helpful feedback
on failure too.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:03 +00:00
Philip Withnall
8ddfbb308b tests: Fix indentation of a block in the appinfo test
No functional changes.

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

https://gitlab.gnome.org/GNOME/glib/issues/538
2018-12-17 17:16:03 +00:00
Philip Withnall
46f47641c5 tests: Avoid chdir() call at the start of appinfo tests
By encoding the path to the appinfo-test binary in the .desktop files,
we can avoid a chdir() call in the tests, which was a bit ugly.

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

https://gitlab.gnome.org/GNOME/glib/issues/538
2018-12-17 17:16:03 +00:00
Philip Withnall
b4479d97d5 Revert "Meson: appinfo tests are racy if run in parallel"
This partially reverts commit 27b5fb5892.

The infrastructure for disabling a test is kept, but the appinfo and
desktop-app-info tests no longer need to be run serially.

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

https://gitlab.gnome.org/GNOME/glib/issues/1601
2018-12-17 17:16:03 +00:00
Philip Withnall
c3fbfbd2bd gio: Add missing documentation for G{Proxy,Socket}AddressEnumerator
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 13:53:34 +00:00
Philip Withnall
778132d54c gmountoperation: Add missing documentation
gtk-doc is unhappy that skeleton documentation comments had been written
for these functions (for the introspection annotations) but that the
documentation content was actually missing.

Add that content. I like a happy gtk-doc.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 13:53:34 +00:00
Philip Withnall
903ce7dc02 Merge branch '1191-g_assert_cmpvariant' into 'master'
gtestutils: Add g_assert_cmpvariant()

Closes #1191

See merge request GNOME/glib!529
2018-12-17 13:03:00 +00:00
Ignacio Casal Quinteiro
290c9ee655 Merge branch 'wip/silviol/gsocket_flags' 2018-12-17 10:24:45 +01:00
Michael Catanzaro
c46565d56a Merge branch 'fix-tlscertificate-parse-bug' into 'master'
gtlscertificate: Fix bug in PEM private key parser

See merge request GNOME/glib!534

Also see discussion in GNOME/glib!520
2018-12-14 21:23:04 +00:00
Fredrik Ternerot
feff178c3f gtlscertificate: Fix bug in PEM private key parser
Make sure to not go outside of PEM data buffer when looking for private
key.

Also adding test case that triggers this bug.
2018-12-14 20:18:55 +01:00
Silvio Lazzeretti
e1e5fa0600 added more g_pollable_input_stream_is_readable checks 2018-12-14 17:07:22 +01:00
Silvio Lazzeretti
9e89749e52 Partially revert "GSocket: Fix race conditions on Win32 if multiple threads are waiting on conditions for the same socket"
This partially reverts commit 799f8dcd46.
This patch seems to break the writability status of the server socket: once
somebody writes to it with success, then it reports it is not writable
anymore. Also, when the client socket has the flag FD_CONNECT set once,
it is never cleared and then it reports it is always writable, also when
it is not.
2018-12-14 16:26:59 +01:00
Philip Withnall
d289ef449b tests: Port various tests to use g_assert_cmpvariant()
This should improve test error reporting a little.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-14 15:04:11 +00:00
Silvio Lazzeretti
ac0706aad0 added stream writability checks in pollable unit test
This checks if the stream is writable before writing
to it. If the write succeeded with no error, then the
stream has to be also writable after the write
2018-12-13 11:10:06 +01:00
Ondrej Holy
0f508c7b89 Merge branch '1599-follow-up-from-gunixmounts-stop-considering-cifs-nfs-as-system-file-systems'
Merging this manually because the CI is still broken.

https://gitlab.gnome.org/GNOME/glib/merge_requests/494
2018-12-13 09:36:11 +01:00
Patrick Griffis
4c472f8e3f gsocketaddressenumerator: Make it an error to call next_async before finish
It logically doesn't make sense to repeatedly call next_async()
before the previous one has finished.
2018-12-11 16:12:51 -05:00
Patrick Griffis
8b9e88937b tests: Add gsocketclient test for slow connections 2018-12-11 16:12:48 -05:00
Patrick Griffis
4b29e55097 gnetworkaddress: Interleave ipv4 and ipv6 addresses 2018-12-11 16:12:34 -05:00
Patrick Griffis
c1e32b9057 gsocketclient: Improve handling of slow initial connections
Currently a new connection will not be attempted until the previous
one has timed out and as the current API only exposes a single
timeout value in practice it often means that it will wait 30 seconds
(or forever with 0 (the default)) on each connection.

This is unacceptable so we are now trying to follow the behavior
RFC 8305 recommends by making multiple connection attempts if
the connection takes longer than 250ms. The first connection
to make it to completion then wins.
2018-12-11 16:09:29 -05:00
Patrick Griffis
35e41862c2 gnetworkaddress: Implement parallel ipv4 and ipv6 dns lookups
As RFC 8305 recommends we can start multiple DNS queries in parallel
to more quickly make an initial response, especially when one is
particularly slow/broken.
2018-12-11 16:09:29 -05:00
Patrick Griffis
d6afa6c988 gresolver: Add g_resolver_lookup_by_name_with_flags{_async,_finish,}
This allows higher levels to have more control over resolving
(ipv4 or ipv6 for now) which allows for optimizations such
as requesting both in parallel as RFC 8305 recommends.
2018-12-11 16:09:29 -05:00
Philip Withnall
af39a37312 Merge branch 'fix-gdbus-codegen--interface-info' into 'master'
fix gdbus-codegen --interface-info-{header,body}

See merge request GNOME/glib!514
2018-12-11 12:25:31 +00:00
Will Thompson
335a01ebe4
gdbus-codegen: test --interface-info-{header,body}
This test is rudimentary but better than nothing.
2018-12-11 09:49:22 +00:00
Will Thompson
d946bff480
gdbus-codegen: sort input files
This means the output (including lists of filenames) does not depend on
the order of the input files, which may matter if this tool is invoked
with a glob or some other mechanism that doesn't guarantee an order.
2018-12-11 09:49:22 +00:00
Xavier Claessens
bdc9328bdf Merge branch 'meson-dep' into 'master'
Meson: Fix declare_dependency() calls

See merge request GNOME/glib!518
2018-12-10 22:39:32 +00:00
Xavier Claessens
475f0a9b67 Meson: Fix deprecation warning with 0.49.0 release
http://mesonbuild.com/Release-notes-for-0-49-0.html#deprecation-warning-in-pkgconfig-generator
2018-12-10 09:08:28 -05:00
Xavier Claessens
afd3f3beda Meson: Fix declare_dependency() calls
Turns out the fix in commit 93555577c wasn't enough, when using glib as
subproject and the parent project uses only libgio_dep, and include
<gi18n.h>, it won't find libintl.h because it's in the
include_directories of libglib_dep. Fix that by declaring dependencies
explicitly, which is the right thing to do since glib and gobject are
public dependencies of gio. That reflects what we do for the pkg-config
file as well.
2018-12-10 09:06:17 -05:00
Will Thompson
deafd7256e
gdbus-codegen: don't sort args in --interface-info-body
Previously, method and signal arguments were sorted by name, which
(assuming you don't happen to give your arguments
lexicographically-ordered names) means the generated signatures were
incorrect when there is more than 1 argument.

While sorting the methods and signals themselves (and properties, and
annotations on all these) is fine, it's easiest to not sort anything.
2018-12-06 21:39:27 +00:00
Will Thompson
faa3c319ba
gdbus-codegen: make --interface-info-{header,body} not crash
Since 1217b1bc4f, LICENSE_STR has taken two
parameters, not one. Without this change, running either mode fails
with a traceback like:

    Traceback (most recent call last):
      File "../gdbus-codegen", line 55, in <module>
        sys.exit(codegen_main.codegen_main())
      File ".../codegen_main.py", line 294, in codegen_main
        gen.generate()
      File ".../codegen.py", line 896, in generate
        self.generate_body_preamble()
      File ".../codegen.py", line 682, in generate_body_preamble
        self.outfile.write(LICENSE_STR.format(config.VERSION))
    IndexError: tuple index out of range

8916874ee6, which introduced these flags,
was actually merged after that commit, but I assume it was written
beforehand.
2018-12-06 21:39:17 +00:00
Chun-wei Fan
cd30faae1f gresources: Add a test with resources > 64kb
This is to ensure that the generated code is still compilable by the
running compiler, and see whether we can read the things in there
properly.

See issue #1580.
2018-12-05 18:27:16 +08:00
Chun-wei Fan
4501807d73 glib-compile-resources: Fix code generation for MSVC builds
glib-compile-resources was updated to generate octal byte
representation in a string, but unfortunately this breaks the build
on Visual Studio when the generated string sequence exceeds 65535
characters, which is the imposed limit on Visual Studio compilers.

To make things work on Visual Studio builds and to not slow down things
on other compilers, generate a code path for Visual Studio an array of
octal byte representations, as well as a code path for other compilers
that use the new string representation of octal values, and let the
compiler take the appropriate code path when compiling the
generated code.

Fixes issue #1580.
2018-12-05 16:17:24 +08:00
Matthias Clasen
136f83eefd Add tests for --gapplication-replace
Test the GApplication replacement functionality.
2018-11-26 11:45:30 -05:00
Matthias Clasen
3a4b18f903 GApplication: Add a way to replace a unique instance
While uniqueness is great, sometimes you want to restart
a newer version of the same app. These two flags make that
possible.

We also add a ::name-lost signal, that is emitted when it
happens. The default handler for this signal just calls
g_application_quit(), but applications may want to connect
and do cleanup or state-saving here.
2018-11-26 11:45:29 -05:00
António Fernandes
624e99b9d6 gunixmounts: Don't treat ZFS as a system internal fs
ZFS was originally added to the list of system internal filesystems by
commit 4cafadc955.

The rationale from https://bugzilla.gnome.org/show_bug.cgi?id=542156
doesn't seem very solid, and now we have x-gvfs-hide for this.

Also, this may contribute for trash:/// ignoring `{zfs mount path}/.Trash/`

So, remove zfs from the ignore_fs array.

Closes https://gitlab.gnome.org/GNOME/glib/issues/1599
2018-11-26 15:55:52 +00:00
Philip Withnall
051c9ada8e Merge branch 'glib-as-subproject' into 'master'
Meson: Add missing include_directories when using glib as subproject

See merge request GNOME/glib!491
2018-11-26 14:29:24 +00:00
Emmanuele Bassi
4326d5e27d Merge branch '1498-distcheck' into 'master'
Various distcheck and docs fixes

Closes #1498

See merge request GNOME/glib!488
2018-11-26 11:49:36 +00:00
Xavier Claessens
93555577c5 Meson: Add missing include_directories when using glib as subproject
When using glib as subproject we are forced to pass glib_dep,
gobject_dep and gio_dep to any build target. If we pass only gio_dep it
will missing include directory for glib and gobject.
2018-11-24 20:52:01 -05:00
Emmanuele Bassi
c1e44fda69 Merge branch '1514-appinfo-test-failure' into 'master'
tests: Run appinfo tests with a temporary XDG_CONFIG_HOME

Closes #1514

See merge request GNOME/glib!487
2018-11-23 16:52:51 +00:00
Emmanuele Bassi
9c8166806c Merge branch 'ossfuzz-11120-dbus-message-types' into 'master'
gdbusmessage: Gracefully handle message signatures with invalid types

See merge request GNOME/glib!472
2018-11-23 16:37:36 +00:00
Philip Withnall
cf8a9d3ffc docs: Fix URIs in documentation comments
Putting the raw URIs in the documentation comments would not link them,
and the ‘%20’s in the URIs were being parsed by gtk-doc as symbol
references. Fix that by using Markdown to format them correctly as
links.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-23 13:31:03 +00:00
Philip Withnall
3f2a5ee1cc docs: Fix ‘Since’ line for new function to reference stable release
We only build API ‘since’ indexes for stable releases, so 2.59 needs to
be rounded up to 2.60.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-23 13:30:33 +00:00
Philip Withnall
79aead142f docs: Fix formatting of some literals and properties
Using `%` indicates that you’re linking to a symbol. In these cases we
wanted some nicely formatted literals, or a link to a specific property.
Use backticks for the literals, and link to the property fully.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-23 13:29:30 +00:00
Philip Withnall
e88c2d1ab5 docs: Fix a doubly-defined symbol in the GApplication documentation
Due to the line wrapping, gtk-doc was interpreting this second line as
redefining the @dbus_register documentation.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-23 13:28:29 +00:00
Philip Withnall
8736789855 docs: Fix some typos in GIO documentation comments
These were highlighted by warnings from gtk-doc about broken links.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-23 13:27:58 +00:00
Philip Withnall
a39b847ddf tests: Run appinfo tests with a temporary XDG_CONFIG_HOME
Otherwise they fill your real ~/.config/mimeapps.list with rubbish and
race for access to it. This is arguably not good.

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

https://gitlab.gnome.org/GNOME/glib/issues/1514
2018-11-23 11:27:50 +00:00
Debarshi Ray
326a7fafe2 gio/tests/gdbus-test-codegen: Ensure that G_PARAM_DEPRECATED is present
https://gitlab.gnome.org/GNOME/glib/merge_requests/485
2018-11-23 10:38:28 +01:00
Debarshi Ray
53573d98f5 gdbus-codegen: Tag interfaces so annotated with G_PARAM_DEPRECATED
If a D-Bus interface was annotated with o.fd.DBus.Deprecated, then the
corresponding GObject property, in the common GInterface implemented
by the generated GDBusObjectProxies and GDBusObjectSkeletons, to
access the generated code for the D-Bus interface was not being marked
with G_PARAM_DEPRECATED, even though the gtk-doc snippet had the
'Deprecated: ' tag.

G_PARAM_DEPRECATED is older than gdbus-codegen, 2.26 and 2.30
respectively, hence it can be used unconditionally.

https://gitlab.gnome.org/GNOME/glib/merge_requests/485
2018-11-23 10:38:28 +01:00
Debarshi Ray
52ce05aaa7 gdbus-codegen: Tag properties so annotated with G_PARAM_DEPRECATED
If a D-Bus interface has a property that's annotated with
o.fd.DBus.Deprecated, then the corresponding GObject property was not
being marked with G_PARAM_DEPRECATED, even though the gtk-doc snippet
had the 'Deprecated: ' tag.

G_PARAM_DEPRECATED is older than gdbus-codegen, 2.26 and 2.30
respectively, hence it can be used unconditionally.

https://gitlab.gnome.org/GNOME/glib/merge_requests/485
2018-11-23 10:18:52 +01:00
Philip Withnall
b660a67cb3 Merge branch 'mcatanzaro/tls1.3-handshake' into 'master'
Deprecate TLS rehandshaking

See merge request GNOME/glib!478
2018-11-21 12:09:22 +00:00
Michael Catanzaro
85f7d493d7 Deprecate TLS rehandshake APIs
Allowing unsafe rehandshakes used to be required for web compatibility,
but this is no longer a concern in 2018. So there should no longer be
compatibility benefits to calling this function. All it does is make
your TLS connection insecure.

Also, rehandshaking no longer exists at all in TLS 1.3.

At some point (maybe soon!) glib-networking will begin ignoring the
rehandshake mode, so let's deprecate it now.
2018-11-20 22:07:58 -06:00
Michael Catanzaro
2031e37dfc Update documentation of g_tls_connection_handshake() one last time
Let's entirely deprecate calling this function for rehandshaking. The
current documentation is OK, but guarantees defined behavior (to attempt
a rehandshake) when TLS 1.2 is in use. But there's no way to force TLS
1.2, and also no way to check which version of TLS is in use. I really
should have deprecated use of this function for rehandshaking entirely
last time I updated it.

Fortunately, there should be no compatibility risk for existing code,
because rehandshaking has no visible effects at the API level.
2018-11-20 22:04:50 -06:00
Philip Withnall
5cc6942eab gdbusconnection: Add missing (nullable) annotation to get_unique_name()
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/1594
2018-11-15 09:42:33 +00:00
Philip Withnall
0ff5e5cd32 gdbusmessage: Gracefully handle message signatures with invalid types
With the changes to limit GVariant type nesting (commit 7c4e6e9fbe),
it’s now possible to have a valid type signature which is not a valid
GVariant type when enclosed in parentheses (to make it a tuple).

Check for that when parsing the signature field in a D-Bus message.

Includes a unit test.

oss-fuzz#11120

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-15 09:22:38 +00:00
Xavier Claessens
9534447eb0 Merge branch 'fix-gio-test-build' into 'master'
Meson: Fix build error in gdbus-example-objectmanager

See merge request GNOME/glib!461
2018-11-14 15:37:05 +00:00
Philip Withnall
6f84f6823b Merge branch 'mr285-subscription-docs' into 'master'
docs: Clarify return/error behaviour of D-Bus signal subscriptions

See merge request GNOME/glib!470
2018-11-13 13:57:02 +00:00
Philip Withnall
2a52ff1c7c Merge branch 'settings-list-does-not-exist' into 'master'
Clarify docs for g_settings_list_children

Closes #1362

See merge request GNOME/glib!465
2018-11-13 12:54:41 +00:00
Philip Withnall
c63d37fdc2 docs: Clarify return/error behaviour of D-Bus signal subscriptions
Based on a patch by David Sommerseth, from
https://gitlab.gnome.org/GNOME/glib/merge_requests/285/.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-13 12:44:34 +00:00
Philip Withnall
b323635d79 Merge branch 'wjt/g-file-info-filesystem-readonly-fails' into 'master'
Improve tests/g-file-info-filesystem-readonly, and run it in CI.

Closes #1590

See merge request GNOME/glib!466
2018-11-13 12:38:18 +00:00
Will Thompson
a2f32f6a11
tests/g-file-info-filesystem-readonly: remove output stream stuff
This test is intended to verify the fix for
https://bugzilla.gnome.org/show_bug.cgi?id=787731, which was that
g_file_query_filesystem_info() would return stale information for the
mount. After replacing a read-only mount with a read-write mount, this
test used to only fail if G_FILE_ATTRIBUTE_FILESYSTEM_READONLY was TRUE
and yet the file could be opened for writing. In particular, if (due to
a test bug) the file really was still on a read-only filesystem, the
test would pass.

Now that we have fixed that bug in the test, we can make a stronger
assertion.
2018-11-13 10:34:09 +00:00
Will Thompson
5b106cdc56
tests/g-file-info-filesystem-readonly: unmount lazily
fusermount -z behaves like umount --lazy, which is documented thus:

> Detach the filesystem from the file hierarchy now, and clean up all
> references to this filesystem as soon as it is not busy anymore.

Without this, the call to `fusermount -u` often fails with:

  /usr/bin/fusermount: failed to unmount /home/wjt/src/gnome/glib/_build/dir_bindfs_mountpoint: Device or resource busy

which causes the subsequent call to bindfs to fail:

  fuse: mountpoint is not empty
  fuse: if you are sure this is safe, use the 'nonempty' mount option

It's not clear what is causing the mount to be busy. Inserting a
g_usleep (100 * 1000) before the calls to `fusermount -u` also works to
make the problem go away, but for the purposes of this test the
important point is that the mount is detached from the directory, for
which a lazy unmount is fine.

Fixes #1590.
2018-11-13 10:34:09 +00:00
Will Thompson
3821ba06b1
tests/g-file-info-filesystem-readonly: assert subcommands succeed
In practice, fusermount -u often fails:

  /usr/bin/fusermount: failed to unmount /home/wjt/src/gnome/glib/_build/dir_bindfs_mountpoint: Device or resource busy

which causes the subsequent calls to bindfs to fail:

  fuse: mountpoint is not empty
  fuse: if you are sure this is safe, use the 'nonempty' mount option

This may or may not cause the current test run to fail, but it reliably
causes a repeat run of the test to fail. This change causes the current
run to fail instead.
2018-11-13 10:34:09 +00:00
Philip Withnall
bc320d9fca gsettings: Add an example of a <default> with an empty string
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/1261
2018-11-13 00:31:54 +00:00
Philip Withnall
f81a2b3de2 Merge branch 'mcatanzaro/tls1.3-handshake' into 'master'
Update documentation of g_tls_connection_handshake() again

See merge request GNOME/glib!467
2018-11-12 23:50:16 +00:00
Michael Catanzaro
68878ab50b Update documentation of g_tls_connection_handshake() again
I made a mistake when last updating the documentation in 94a99ae9. I
wrote that, with TLS 1.3, this would perform a rekey instead of a
rehandshake. In fact, that's only true for client connections. For
server connections, it's a no-op.

I was a bit nervous about how to document the behavior anyway, because
we really don't know what behavior will be reasonable with non-GnuTLS
crypto backends. This behavior is reasonable for the GnuTLS backend, but
might not necessarily make sense for OpenSSL. Ideally, we would
discourage API users from doing things which could have unexpected
effects, so instead of documenting what the GnuTLS backend does, I think
it'd be better to document that this is "undefined but not dangerous,"
since of course we want to make sure that existing code that doesn't
know about TLS 1.3 is not broken.
2018-11-12 14:49:30 -06:00
Matthias Clasen
bb1f765df3 Clarify docs for g_settings_list_children
The docs sound like settings list is a thing, and
a ::children-changed signal exists. That is not the
case, and will never be the case at this point, so
stop pretending.

Closes: #1362
2018-11-12 08:07:52 -05:00
Philip Withnall
4ea56957db Merge branch 'issues/1310' into 'master'
gdbusproxy: make g-name-owner property useful with unique names

See merge request GNOME/glib!454
2018-11-12 12:43:27 +00:00
INSUN PYO
bf1a2d7079 gio, tests: fix leak of dbus connection.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1- Start server
   gio/tests/.libs/gdbus-example-peer --server --address unix:abstract=/tmp/peer/myaddr

2- Check the open fds for server process
   lsof -a -p 8253
   ..................
   gdbus-exa 8253 imran    0u   CHR      136,1      0t0        4 /dev/pts/1
   gdbus-exa 8253 imran    1u   CHR      136,1      0t0        4 /dev/pts/1
   gdbus-exa 8253 imran    2u   CHR      136,1      0t0        4 /dev/pts/1
   gdbus-exa 8253 imran    3u  0000        0,9        0     6602 anon_inode
   gdbus-exa 8253 imran    4u  unix 0xf1005680      0t0   966830 @/tmp/peer/myaddr

3- Run the client
   gio/tests/.libs/gdbus-example-peer --address unix:abstract=/tmp/peer/myaddr

4- Check the open fds for server process again
   lsof -a -p 8253
   ..................
   gdbus-exa 8253 imran    0u   CHR      136,1      0t0        4 /dev/pts/1
   gdbus-exa 8253 imran    1u   CHR      136,1      0t0        4 /dev/pts/1
   gdbus-exa 8253 imran    2u   CHR      136,1      0t0        4 /dev/pts/1
   gdbus-exa 8253 imran    3u  0000        0,9        0     6602 anon_inode
   gdbus-exa 8253 imran    4u  unix 0xf1005680      0t0   966830 @/tmp/peer/myaddr
   gdbus-exa 8253 imran    5u  unix 0xf1004280      0t0   965811 @/tmp/peer/myaddr
   gdbus-exa 8253 imran    6u  0000        0,9        0     6602 anon_inode

5- Please note the fd '5u' which is created when client makes connection but even when the client goes down, the descriptor is still there..
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

https://bugzilla.gnome.org/show_bug.cgi?id=734281
2018-11-12 15:45:20 +09:00
Cosimo Cecchi
47be0f7a23 gdbusproxy: make g-name-owner property useful with unique names
Currently, GDBusProxy:g-name-owner only notifies changes to the unique
name owner of the remote object in case the proxy was constructed for a
well-known name.
That sounds like an artificial restriction, and it's convenient to
connect to notify::g-name-owner if a proxy instance has already been
created for an unique name, instead of additionally using
g_bus_watch_name() to track the owner.

To fix this, always connect to NameOwnerChanged after the proxy is
initialized, instead of only doing so when the proxy was constructed for
a well-known name.

https://bugzilla.gnome.org/show_bug.cgi?id=791316
https://gitlab.gnome.org/GNOME/glib/issues/1310
2018-11-10 03:53:32 +00:00
Xavier Claessens
b3c899d295 Meson: Fix build error in gdbus-example-objectmanager
test_c_args is defined in the root meson.build with unfiltered list of
compiler flags, then redefined in gio/tests/meson.build after the
subdir() call. Move it before.
2018-11-09 13:23:43 -05:00
Philip Withnall
0c6346c98f Merge branch 'atomic-ref-count-cnd' into 'master'
Atomic reference count in GVariant, ContainerInfo and GDBus introspection

See merge request GNOME/glib!452
2018-11-08 14:22:03 +00:00
vmlobanov78
0985e70488 glib-compile-resources: Fix size allocation for compressed streams
The length of the stolen data from a memory output stream is given by
get_data_size() — get_size() can be larger, and hence cause unnecessary
overallocation.
2018-11-06 15:03:03 +00:00
Tomasz Miąsko
b599a0f414 gdbusintrospection: Use atomic operations to read ref_count 2018-11-06 14:44:40 +01:00
Simon McVittie
13e206aaeb meson: Centralize test timeout values
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-01 19:13:21 +00:00
Tomasz Miąsko
b7571d5f0f tests: Fix GVariantType leak in GAction tests 2018-11-01 12:15:09 +01:00
Tomasz Miąsko
52bab0254a tests: Fix GOptionContext leak in GSubprocess tests 2018-11-01 12:14:52 +01:00
Tomasz Miąsko
9347c7630f tests: Fix GRand leak in GMenuModel tests 2018-11-01 12:14:09 +01:00
Philip Withnall
e89128a935 gtask: Add a g_task_set_name() method
Similarly to g_source_set_name(), this sets a name on a GTask for
debugging and profiling. Importantly, this name is propagated to the
GSource for idle callbacks for the GTask, ending the glorious reign of
`[gio] complete_in_idle_cb`.

The name can be queried using g_task_get_name(). Locking is avoided by
only allowing the name to be set before the GTask is used from another
thread.

Includes tests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-30 11:51:50 +00:00
Will Thompson
745422afac gdbus-codegen: add autocleanup for FooObject
This is only enabled with `--c-generate-autocleanup all` for the
reasons discussed on https://bugzilla.gnome.org/show_bug.cgi?id=763379.
2018-10-29 22:48:26 +00:00
Will Thompson
5b78c3fdff gdbus-codegen: test generating autocleanups
This is the most degenerate possible test but it does exercise this code
path.

(Tweaked by Philip Withnall <withnall@endlessm.com> to also add the flag
to the autotools build.)
2018-10-29 22:48:26 +00:00
Xavier Claessens
7c70bef8b6 gdbus-peer: Make sure to not include objectmanager-gen.c source
The executable depends only on the generated header file at compile
time, and on the library at link time. So meson can decide to compile
gdbus-peer.c before compiling the library and thus won't have generated
the header yet, causing the build error.

So declare_dependency() should only have the header file in its sources,
to force generating files before compiling gdbus-peer.c without
including objectmanager-gen.c into gdbus-peer's sources.
2018-10-25 07:34:23 -04:00
Will Thompson
cd524d065b
gseekable: fix 'attmepting' typo 2018-10-25 09:33:19 +01:00
Philip Withnall
5263b54a06 Merge branch 'objectmanager-src-dep' into 'master'
gio, tests: ensure objectmanager sources are generated

See merge request GNOME/glib!414
2018-10-25 04:28:09 +00:00
Marco Trevisan (Treviño)
11e4fcca5e gio, tests: ensure objectmanager sources are generated
We use libgdbus_example_objectmanager_dep as dependency for various
tests, but this implies only a link dependency while it doesn't ensure
that the sources are generated.

Make this explicit
2018-10-23 20:58:09 -05:00
Philip Withnall
1564ef5589 Merge branch 'wip/oholy/fix-trash-symlink' into 'master'
glocalfile: Fix access::can-trash if parent is symlink

Closes #1522

See merge request GNOME/glib!326
2018-10-24 00:03:55 +00:00
Philip Withnall
25b7716e0d Merge branch 'nirbheek/macos-library-versions' into 'master'
meson: Add macOS libtool versioning for ABI compatibility

See merge request GNOME/glib!282
2018-10-24 00:00:35 +00:00
Xavier Claessens
372e81b56c Merge branch 'ci-test-installed' into 'master'
CI: Test static build on installed glib

See merge request GNOME/glib!360
2018-10-23 13:56:46 +00:00
Xavier Claessens
7fa6e9e837 CI: Test static build on installed glib 2018-10-23 09:45:12 -04:00
Philip Withnall
7db63898c1 Merge branch 'shorten-gdbus-test-filename' into 'master'
build: work around meson issue with too long filenames on Windows. Fixes #1556

Closes #1556

See merge request GNOME/glib!370
2018-10-23 09:16:58 +00:00
Ondrej Holy
39afe07e27 Merge branch 'wip/oholy/bind-mounts' into 'master'
gunixmounts: Mark mounts as system internal instead of filtering out

See merge request GNOME/glib!366
2018-10-23 07:32:32 +00:00
Ondrej Holy
983a95c9dc gunixmounts: Mark mounts as system internal instead of filtering out
mntent-based implementation filter out mounts with device path that was
repeated. Consequently, it is not possible to show such mounts in UI even
with x-gvfs-show, because they are not returned from g_unix_mounts_get.
libmount-based implementation currently doesn't filter out any mounts
which causes issues to our volume monitors. Let's rather mark mounts
which don't point into fs root as system_internal. This approach won't be
affected by mount order as is mntent-based implementation. It will mark
more mounts as system_internal than it is filtered out with mntend-based
implementation, but there will be always possibility to show them in UI
over x-gvfs-show, which was not possible with mntend-based. We can
probably introduce some improvements later to not mark unique mounts as
system internal even if they don't point into fs root...

https://gitlab.gnome.org/GNOME/glib/issues/1271
2018-10-23 09:01:04 +02:00
Ondrej Holy
e1fa5ffb91 gio: Add g_unix_mount_get_root_path
Currently, there isn't API to determine root path for mounts created
over bind operation (or btrfs subvolumes). This causes issues to our
volume monitors if there is multiple mounts for one device, which can
happen with libmount-based implementation currently. Let's propagate
root path from libmount over g_unix_mount_get_root_path, so we can
handle this somehow in our volume monitors.

https://gitlab.gnome.org/GNOME/glib/issues/1271
2018-10-23 09:01:04 +02:00
Ondrej Holy
a56b9cc6b2 glocalfile: Use MAXSYMLINKS when following symlinks
Currently, readlink() is used only 12 times when expanding symlinks.
However, kernel uses 40 for this purpose and it is defined as MAXSYMLINKS.
Use that constant if available, or 40. See:
https://github.com/torvalds/linux/include/linux/namei.h.
2018-10-23 08:53:55 +02:00
Ondrej Holy
b6191059b8 glocalfile: Return NULL if symlink expansion fails
find_mountpoint_for() uses current file in case of error, because
get_parent() returns NULL for error, but also if parent doesn't exist.
Return "." from get_parent() if parent doesn't exist in order to
differentiate the error state.
2018-10-23 08:53:55 +02:00
Ondrej Holy
57cfbc9341 glocalfile: Add test case for symlink expansion
Test symlink expansion in find_mountpoint_for() function over
 _g_local_file_find_topdir_for(). find_mount_for() is crucial for many
of glocalfile.c functionality (e.g. to determine correct trash location)
and symlink expansion has to work properly.

https://gitlab.gnome.org/GNOME/glib/issues/1522
2018-10-23 08:53:54 +02:00
Philip Withnall
1c421b0158 glib: Port various callers to use g_utf8_validate_len()
These were callers which explicitly specified the string length to
g_utf8_validate(), when it couldn’t be negative, and hence should be
able to unconditionally benefit from the increased string handling
length.

At least one call site would have previously silently changed behaviour
if called with strings longer than G_MAXSSIZE in length.

Another call site was passing strlen(string) to g_utf8_validate(), which
seems pointless: just pass -1 instead, and let g_utf8_validate()
calculate the string length. Its behaviour on embedded nul bytes
wouldn’t change, as strlen() stops at the first one.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
8e60b3dde0 tests: Use g_assert_null() in gdbus-serialization test
This introduces no real functional changes (except when compiling with
G_DISABLE_ASSERT, in which case it fixes the test). Mostly just a code
cleanup.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
c2c9c7fa3b tests: Tidy up GError handling in gdbus-serialization test
This introduces no functional changes; just a bit of code tidying.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
e03d5a335b gdbusmessage: Check for valid GVariantType when parsing a variant blob
The code was checking whether the signature provided by the blob was a
valid D-Bus signature — but that’s a superset of a valid GVariant type
string, since a D-Bus signature is zero or more complete types. A
GVariant type string is exactly one complete type.

This meant that a D-Bus message with a header field containing a variant
with an empty type signature (for example) could cause a critical
warning in the code parsing it.

Fix that by checking whether the string is a valid type string too.

Unit test included.

oss-fuzz#9810

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
968f1c6cad gdbusmessage: Fix a typo in a documentation comment
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
50b544e2c0 gdbusmessage: Clarify error returns for g_dbus_message_new_from_blob()
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
94a9ab3c03 gdbusmessage: Improve documentation for g_dbus_message_get_header()
The caller is responsible for checking the type of the returned
GVariant.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
af712bbce1 gdbusmessage: Validate type of message header signature field
Parsing a D-Bus message with the signature field in the message header
of type other than ‘g’ (GVariant type signature) would cause a critical
warning. Instead, we should return a runtime error.

Includes a test.

oss-fuzz#9825

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00