Commit Graph

6209 Commits

Author SHA1 Message Date
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
Philip Withnall
da512adc34 Merge branch 'stap-pass-cflags' into 'master'
build-sys: Pass CFLAGS to $(DTRACE)

See merge request GNOME/glib!403
2018-10-22 22:39:59 +00:00
Nirbheek Chauhan
8b3590c231 meson: Add macOS libtool versioning for ABI compatibility
With this, the compatibility version and current version values in macOS
and iOS dylibs will match the values set by Autotools.

See: https://github.com/mesonbuild/meson/issues/1451
2018-10-22 06:51:32 +05:30
Xavier Claessens
a46f88ba1b Meson: Fix linking of gdbus-peer test 2018-10-19 10:08:00 -04:00
Michael Catanzaro
4e94164a72 Fix a couple typos in doc comments 2018-10-17 13:23:36 -05:00
Ondrej Holy
ce9fa7a172 glocalfile: Fix bug uri in trash test
Fix typo in g_test_bug_base and move g_test_bug in the concrete test.
2018-10-17 12:42:04 +02:00
Ondrej Holy
0f5017fb70 glocalfile: Fix access::can-trash if parent is symlink
G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH can be set to a wrong value if
its parent dir is a symlink. This is because the find_mountpoint_for()
function tries to find mountpoint for a filepath and expands symlinks
only in parent dirs. But in this case the path is already parent dir
and needs to be expanded first...

Closes: https://gitlab.gnome.org/GNOME/glib/issues/1522
2018-10-17 12:42:04 +02:00
Colin Walters
d7233ef81e build-sys: Pass CFLAGS to $(DTRACE)
Fedora is using https://fedoraproject.org/wiki/Changes/Annobin
to try to ensure that all objects are built with hardening flags.
Pass down `CFLAGS` to ensure the SystemTap objects use them.
2018-10-15 21:50:31 +00:00
Philip Withnall
efda2be302 Merge branch 'ghash-hpj-2018' into 'master'
GHashTable improvements

See merge request GNOME/glib!208
2018-10-10 23:01:51 +00:00
Philip Withnall
19c7a7bb23 gsubprocess: Add a missing test for invalid UTF-8 output
There were tests for invalid UTF-8 output when asynchronously
communicating with a subprocess, but nothing for synchronous
communication. Add such a test, and refine the code as a result.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-11 11:31:27 +13:00
Philip Withnall
4795dadde4 gsubprocess: Clear std buf outputs to NULL on failure
Instead of sometimes returning a non-NULL buffer, always return NULL.
However, keep the documentation as explicitly returning undefined values
on failure, so that we can change the behaviour in future if needed.

The return values weren’t defined for failure before, so were
implicitly returning undefined values.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-11 11:31:27 +13:00
Philip Withnall
90ca3b4dd0 tests: Fix some minor memory leaks in gsubprocess-testprog
This just makes the valgrind logs a bit cleaner so we can find real
problems in future.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-11 11:28:36 +13:00
Руслан Ижбулатов
62d387151d W32: significant symlink code changes
Put the core readlink() code into a separate
_g_win32_readlink_handle_raw() function that takes a file handle,
can optionally ensure NUL-terminatedness of its output
(for cases where we need a NUL-terminator and do *not* need
to get the exact contents of the symlink as it is stored in FS)
and can either fill a caller-provided buffer *or* allocate
its own buffer, and can also read the reparse tag.

Put the rest of readlink() code into separate
functions that do UTF-16<->UTF-8, strip inconvenient prefix
and open/close the symlink file handle as needed.

Split _g_win32_stat_utf16_no_trailing_slashes() into
two functions - the one that takes a filename and the one
that takes a file descriptor. The part of these functions
that would have been duplicate is now split into the
_g_win32_fill_privatestat() funcion.

Add more comments explaining what each function does.
Only g_win32_readlink_utf8(), which is callable from outside
via private function interface, gets a real doc-comment,
the rest get normal, non-doc comments.

Change all callers to use the new version of the private
g_win32_readlink_utf8() function, which can now NUL-terminate
and allocate on demand - no need to call it in a loop.

Also, the new code should correctly get reparse tag when the
caller does fstat() on a symlink. Do note that this requires
the caller to get a FD for the symlink, not the target. Figuring
out how to do that is up to the caller.

Since symlink info (target path and reparse tag) are now always
read directly, via DeviceIoControl(), we don't need to use
FindFirstFileW() anymore.
2018-10-10 19:19:18 +00:00
Руслан Ижбулатов
19608e36d2 Straighten up the GFileType vs symlinks on Windows situation
On Windows NTFS symlinks are implemented as reparse points,
which are special kinds of files *or directories*. A directory
symlink should link to a directory. A file symlink should link
to a file. Mismatching (such as a file symlink pointing to a
directory) produces symlinks that simply do not function.

Therefore GFileType file vs directory vs symlink distinction is
too simplistic to correctly represent a NTFS filesystem object type.

Since we can't turn back time and choose a better way of representing
file types, make GFileType reflect the file vs directory type on
Windows, meaning that all FS objects are either files or
directories (or shortcuts, which are also files), but never symlinks.

A test for symlinkiness will have to be made via GFileInfo - it
tracks symlinkiness separately from file/directory/whatever.
2018-10-10 08:20:44 +00:00
Philip Withnall
2eaeefdf5d gdbusproxy: Document blocking guarantees of constructors
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/734
2018-10-09 09:15:43 +13:00
Руслан Ижбулатов
c2a5537845 W32: set nlink, clarify comments
The st_nlink field of the stat structure has meaning and should
be put into GFileInfo.

The st_mode field is far less meaningful, but could still be used
for some purposes, adjust the comment to clarify that.
2018-10-04 22:17:08 +00:00
Christoph Reiter
180e59539c build: work around meson issue with too long filenames on Windows. Fixes #1556
When using glib as a meson subproject on Windows the build currently fails
due to too long paths during the build process. See
https://github.com/mesonbuild/meson/issues/4226 for the upstream bug.

To work around the issue shorten the filenames of the generated gdbus files.
2018-10-04 10:45:45 +02:00
Hans Petter Jansson
0600dd3220 tests: Fix bad node ordering assumption
The tests were making assumptions about the order of the returned D-Bus
introspection nodes. However, these are semantically unordered and
changes to e.g. GHashTable would break the tests.

Fix this by applying a sort prior to validation.
2018-10-03 22:14:38 +02:00
Philip Withnall
5002d87dec Merge branch '1525-task-result' into 'master'
gtask: Check an error hasn’t been returned when calling g_task_return*()

Closes #1525

See merge request GNOME/glib!368
2018-10-02 10:07:49 +00:00
Philip Withnall
290bb0dd1b gtask: Compress GTask struct using a bitfield
There are a lot of gbooleans in the private GTask struct, which seems a
bit wasteful. Use a bitfield to compress the struct a bit.

This reduces the size of the struct from 216 bytes to 168 bytes on my
64-bit machine.

One of the fields needs to remain separate, since it’s used from a
TRACE() macro which calls typeof() on it.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-02 09:59:13 +01:00
Philip Withnall
f0cecba199 tests: Add return ordering tests for GTask
These are based on an example test program provided by Will Thompson in
issue #1525.

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

https://gitlab.gnome.org/GNOME/glib/issues/1525
2018-10-02 09:59:13 +01:00
Philip Withnall
bea3770935 gtask: Check an error hasn’t been returned when calling g_task_return*()
These functions already check to see if a successful result has already
been returned; expand them to also check to see if an error has been
returned.

We can’t just check GTask.result_set, as that’s actually an indicator
for whether the GTask.result member is filled — when
g_task_propagate_*() is called, it’s cleared again. We need a new state
bit.

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

https://gitlab.gnome.org/GNOME/glib/issues/1525
2018-10-01 21:45:48 +01:00
Philip Withnall
03232bd6a6 tests: Fix location of an unref in the GTask tests
This method drops the last reference *it* owns to the GTask, but then
continues to call methods on the GTask. This wasn’t resulting in
failures because a ref in another thread kept the GTask alive, but
that’s quite dodgy.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-01 21:45:48 +01:00
Philip Withnall
846a61457a Merge branch 'wjt/g_desktop_app_info_get_string_list' into 'master'
Add g_desktop_app_info_get_string_list(); fix g_key_file_free()

See merge request GNOME/glib!339
2018-10-01 19:21:05 +00:00
Will Thompson
5ca9eca632 gdesktopappinfo: add get_string_list() function
The X-Flatpak-RenamedFrom key is used in .desktop files to identify past
names for the desktop file. It is defined to be a list of strings.
However, there was previously no correct way to retrieve a list of
strings from the GKeyFile wrapped by GDesktopAppInfo, short of
re-parsing the file with GKeyFile.

Note that doing something like:

    g_strsplit (g_desktop_app_info_get_string (...), ";", -1)

is not correct: the raw value "a\;b;" represents the one-element list
["a;b"], but g_key_file_get_string() rejects the sequence "\;", and so
g_desktop_app_info_get_string() returns NULL in this case. (Of course, a
.desktop file with a semicolon in its name is a pathological case.)

Add g_desktop_app_info_get_string_list(), a trivial wrapper around
g_key_file_get_string_list(), similar to g_desktop_app_info_get_string()
and co.

The change from g_key_file_free() to g_key_file_unref() in the test is
needed because g_key_file_free() clears the contents of the keyfile.
This is fine for all the fields which are eagerly loaded and copied into
GDesktopAppInfo, but not when we want to access arbitrary stuff from the
keyfile.
2018-10-01 20:03:55 +01:00
Xavier Claessens
6e0a03ee07 Merge branch '1536-link-whole' into 'master'
Meson: Fix static linking of convenience libraries

Closes #1536

See merge request GNOME/glib!357
2018-09-28 14:54:40 +00:00
Simon McVittie
62af03bda8 Meson: Extract objects from convenience libraries to link them
This avoids the convenience library being treated as though it was
an installed static library (objects not included in the dependent
static library, and convenience library being listed in the pkg-config
metadata), both of which would make static linking impossible.
This is a workaround for meson not having
https://github.com/mesonbuild/meson/pull/3939 merged yet.

Fixes: https://gitlab.gnome.org/GNOME/glib/issues/1536
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-09-28 15:15:48 +01:00
Xavier Claessens
24d7a73b93 Meson: Bump dependency to 0.48.0 2018-09-27 16:01:41 -04:00
Xavier Claessens
27b5fb5892 Meson: appinfo tests are racy if run in parallel 2018-09-25 15:14:53 -04:00
Xavier Claessens
88a1188fc1 Merge branch 'speling' into 'master'
Fix spelling mistakes detected by Debian's Lintian tool

See merge request GNOME/glib!354
2018-09-25 18:16:52 +00:00
Simon McVittie
03cf374848 Spelling: Fix spelling of "unknown"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-09-25 14:35:13 +01:00
Simon McVittie
e0a8df12ef Spelling: Fix spelling of "similarly"
Detected by Debian's Lintian tool.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-09-25 14:35:13 +01:00
Simon McVittie
cbc7fbbf7d meson: Run build-time tests with --tap where supported
This makes it easier to debug test failures, by ensuring that g_debug()
and g_test_message() are printed as TAP diagnostics.

Fixes: https://gitlab.gnome.org/GNOME/glib/issues/1528
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-09-24 23:37:12 +01:00
Xavier Claessens
b512135fc6 Merge branch '1535-tap' into 'master'
Meson: Run in TAP mode installed tests that support it

Closes #1535

See merge request GNOME/glib!343
2018-09-24 14:49:40 +00:00
Xavier Claessens
8391219e4c Meson: Run in TAP mode installed tests that support it 2018-09-23 13:44:15 -04:00
Simon McVittie
fa32ee6481 Remove unnecessary +x permissions
None of these files starts with a #! line, and they are not native
binary executables, so if a user attempts to execute them as a program,
Unix shells will run them as /bin/sh scripts. This is not going to end
well, since none of them are shell scripts (the gio bash completion
is for bash, which is not a lowest-common-denominator POSIX shell, and
in any case is designed to be sourced rather than executed).

Fixes: #1539
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-09-23 17:01:04 +01:00
Emmanuele Bassi
032f1a9782 Merge branch 'gio-fix-build' into 'master'
gio: automake: Add libgmodule dependency

See merge request GNOME/glib!334
2018-09-22 15:49:07 +00:00
Xavier Claessens
96fafcfe92 Meson: Fix missing files when installing tests
Closes #1527
2018-09-21 08:45:02 -04:00
Philip Withnall
18456b74a6 tests: Mark two more tests as slow
These keep on taking just longer than 30s on my local machine when run
in parallel with the rest of the tests (i.e. with `ninja test`). Testing
them individually, they do terminate correctly.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-09-20 17:51:18 +01:00
Bernhard Walle
0d97c4d20c gio: automake: Add libgmodule dependency
Otherwise I get following compile error:

 libtool: link: /home/builduser/toolchains/linux/tc/2017-12/x86-ncp-linux-gnu/bin/i686-ncp-linux-gnu-gcc -Wall -Wstrict-prototypes -Wmisleading-indentation -Wno-bad-function-cast -Werror=declaration-after-statement -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=pointer-arith -Werror=init-self -Werror=format=2 -O2 -Wall -pipe -Wformat -g -fstack-protector-strong -fPIC -fno-strict-aliasing -Wl,-z -Wl,relro -Wl,-z -Wl,now -Wl,-rpath-link=/home/builduser/workspaces/rws_trunk_linux_x86_build_shared-fips/build/3p/linux/x86/install/zlib/lib -Wl,-rpath-link=/home/builduser/workspaces/rws_trunk_linux_x86_build_shared-fips/build/3p/linux/x86/install/libffi/lib -o .libs/gio gio-tool.o gio-tool-cat.o gio-tool-copy.o gio-tool-info.o gio-tool-list.o gio-tool-mime.o gio-tool-mkdir.o gio-tool-monitor.o gio-tool-mount.o gio-tool-move.o gio-tool-open.o gio-tool-rename.o gio-tool-remove.o gio-tool-save.o gio-tool-set.o gio-tool-trash.o gio-tool-tree.o  -L/home/builduser/workspaces/rws_trunk_linux_x86_build_shared-fips/build/3p/linux/x86/install/zlib/lib -L/home/builduser/workspaces/rws_trunk_linux_x86_build_shared-fips/build/3p/linux/x86/install/libffi/lib ./.libs/libgio-2.0.so ../gobject/.libs/libgobject-2.0.so ../glib/.libs/libglib-2.0.so -Wl,-rpath -Wl,/home/builduser/workspaces/rws_trunk_linux_x86_build_shared-fips/build/3p/linux/x86/install/glib/lib
 /home/builduser/toolchains/linux/tc/2017-12/x86-ncp-linux-gnu/bin/../lib/gcc/i686-ncp-linux-gnu/6.3.0/../../../../i686-ncp-linux-gnu/bin/ld: warning: libgmodule-2.0.so.0, needed by ./.libs/libgio-2.0.so, not found (try using -rpath or -rpath-link)
 ./.libs/libgio-2.0.so: undefined reference to `g_module_error'
 ./.libs/libgio-2.0.so: undefined reference to `g_module_close'
 ./.libs/libgio-2.0.so: undefined reference to `g_module_open'
 ./.libs/libgio-2.0.so: undefined reference to `g_module_supported'
 ./.libs/libgio-2.0.so: undefined reference to `g_module_symbol'
 collect2: error: ld returned 1 exit status
 Makefile:2300: recipe for target 'gio' failed

Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
2018-09-18 10:27:19 +02:00
Philip Withnall
f928dfdf57 Merge branch 'master' into 'master'
Issue #1513: fix g_icon_to_string() regression (doc inconsistency).

Closes #1513

See merge request GNOME/glib!305
2018-09-17 10:32:32 +00:00
Iain Lane
d2a1a4bf55 Merge branch '1523-network-monitor-init-failure' into 'master'
gnetworkmonitornm: Set a GError properly on an error handling path

See merge request GNOME/glib!322
2018-09-13 14:27:56 +00:00
Jehan
8519368c0e Fix g_icon_to_string() regression (doc inconsistency).
g_icon_new_for_string() docs states that it should return a single name
when created with a single name. I add a second condition to this case:
the themed icon must not include default fallbacks (i.e. it must not
have been created with `g_themed_icon_new_with_default_fallbacks()`).
Otherwise the return value of `g_icon_new_for_string()` would not
recreate the same icon list when passed to `g_icon_new_for_string()`
(which would be another documentation inconsistency).

g_icon_new_for_string() is now back to old behavior for this specific
case.

I also revert the unit test for this case, and add a new unit test when
using g_themed_icon_new_with_default_fallbacks() with a single name as
well.

Closes #1513.
2018-09-13 13:16:40 +02:00
Iain Lane
6eb5bd8192
network-monitor-race test: Have the subprocess inherit stdout and stderr
If initialising the monitors produces any debug output, it is good to be
able to see it when running this test.
2018-09-13 11:44:16 +01:00
Iain Lane
36c79adb2f
gnetworkmonitornetlink: Pass a GError into read_netlink_messages()
Currently this function calls `g_warning()` explicitly. It would be
nicer to properly propagate these failure up to the caller that tried to
initialise us.
2018-09-13 11:44:16 +01:00
Iain Lane
6629423e7a
gnetworkmonitornetlink: Close the socket after disconnecting its GSources
`read_netlink_messages()` is the callback attached to the netlink socket
(G_IO_IN). It calls `g_socket_receive_message()`. There is a race
condition that if the socket is closed while there is a pending call, we
will try to receive on a closed socket, which fails.

To avoid this, we switch the order of the operations around: first
destroy the source and then close the socket.
2018-09-13 11:14:34 +01:00
Iain Lane
7fe8aa68a2
gnetworkmonitornetlink: Don't check if a passed-in GError ** is NULL
This is not a correct way to check if `g_socket_new_from_fd()` failed.
Instead just see if it returned `NULL` itself.

This was preventing the netlink monitor from being initialised.

Closes #1518
2018-09-13 11:14:34 +01:00
Philip Withnall
c5761146bc gnetworkmonitornm: Set a GError properly on an error handling path
All the other initialisation failure paths set a GError, but this one
didn’t. Set a GError to avoid breaking the invariant that returning
FALSE should always have a GError set.

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

https://gitlab.gnome.org/GNOME/glib/issues/1523
2018-09-13 10:25:05 +01:00
Michael Catanzaro
5bc35a7245 Merge branch 'mcatanzaro/auto-start-portals' into 'master'
Autostart xdg-desktop-portal if needed

See merge request GNOME/glib!317
2018-09-13 04:43:59 +00:00
Philip Withnall
dbe0572d57 Merge branch 'w32-gio-tests-enable' into 'master'
Enable GIO tests on Windows

See merge request GNOME/glib!312
2018-09-12 22:42:16 +00:00
Philip Withnall
3f10c8b059 Merge branch 'gdbus-codegen-type-punned-pointer-warnings' into 'master'
codegen: Change pointer casting to remove type-punning warnings

See merge request GNOME/glib!309
2018-09-12 22:31:54 +00:00
Michael Catanzaro
04989cfafb Autostart xdg-desktop-portal if needed
This is a speculative fix for epiphany#533, which we think might be
caused by xdg-desktop-portal not ever being started. This service is
started on-demand, not automatically.
2018-09-12 15:38:44 -05:00
Michael Catanzaro
0e0b94d635 gdbus: Improve error when well-known name is unowned
We should indicate the name, so that we have some chance of debugging
this problem.
2018-09-12 11:32:55 -05:00
Руслан Ижбулатов
ad3694b82a Enable GIO tests on Windows
1) Remove the non-Windows-only condition for subdir('tests').
2) Add libiphlpapi, libws2_32 and libsecur32 deps, needed for W32 tests.
3) Remove the -no-undefined argument (gcc doesn't understand it,
   it *does* understand -Wl,-no-undefined; either way, the test
   compiles without this argument just fine; maybe meson adds it
   by itself - you can hardly build shared modules without it).
4) Add or fix a number of includes
5) Disable gdbus-objectmanager tests when building with MSVC
   (right now these tests don't work on Windows anyway, so the fact
    that MSVC can't even build them properly is irrelevant;
    most likely gdbus-codegen needs changes to put _GLIB_EXTERN
    before each function)
2018-09-12 15:42:11 +00:00
Руслан Ижбулатов
157dfc8aae test_internal_enhanced_stdio: don't use g_assert()
g_assert() can be disabled, use more specific assertion macros.
2018-09-12 14:35:20 +00:00
Руслан Ижбулатов
c24d3b0fc3 W32: extend the g-file-info test with new DOS attributes 2018-09-12 14:35:18 +00:00
Руслан Ижбулатов
c6b4eff09e W32: new GFileInfo attributes
G_FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT allows mountpoints
(NTFS reparse points with IO_REPARSE_TAG_MOUNT_POINT tag) to
be told apart from symlinks (NTFS reparse points with
IO_REPARSE_TAG_SYMLINK tag), even though both are reported
by glib as "symlinks".

G_FILE_ATTRIBUTE_DOS_REPARSE_POINT_TAG allows the exact
reparse tag value to be obtained by the user. This way
even more exotic reparse points can be identified and
handled by the user (glib itself currently has no code
to work with any reparse points that are not symlinks
or mountpoints).
2018-09-12 14:35:16 +00:00
Philip Withnall
83cd2f6204 gvolumemonitor: Document the need to run a main loop
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/1119
2018-09-07 12:18:44 +01:00
Robert Ancell
64b76c7ca5 codegen: Change pointer casting to remove type-punning warnings
The existing code was generating code with undefined results that modern compilers warn about:

accounts-generated.c:204:23: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     (GDBusArgInfo **) &_accounts_accounts_method_info_list_cached_users_OUT_ARG_pointers,
2018-09-07 10:19:05 +12:00
Emmanuele Bassi
86ab6ffa8d Merge branch '303-list-store-tests' into 'master'
Add more GListStore/GListModel tests

See merge request GNOME/glib!304
2018-09-05 11:11:58 +00:00
Philip Withnall
574e2c8a99 Merge branch 'wip/otte/simplify-liststore-splice' into 'master'
liststore: Simplify code

See merge request GNOME/glib!303
2018-09-05 10:38:59 +00:00
Philip Withnall
53a6689ebf tests: Test g_list_model_get_object()
It wasn’t being tested. It should behave the same as
g_list_model_get_item(), so write a wrapper for the two.

This brings the code coverage of glistmodel.c up to 100%.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-09-05 11:36:13 +01:00
Philip Withnall
7e33c50dd3 tests: Add more GListStore tests to get it too 100% coverage
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-09-05 11:27:06 +01:00
Philip Withnall
35d1ef678a gliststore: Simplify a GType check on construction
When setting the GListStore:item-type property we need to check the
GType is a GObject (or subclass). There was some explicit code for this,
but when actually testing it and looking at the code coverage, it turns
out that the GObject property type check coming from
g_param_spec_gtype() does everything we want, and the custom
g_critical() can never be hit. So turn it into an assertion.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-09-05 11:25:58 +01:00
Philip Withnall
98f326a020 Merge branch 'wip/otte/fallthrough' into 'master'
Add G_GNUC_FALLTHROUGH for __attribute__(fallthrough))

See merge request GNOME/glib!296
2018-09-04 22:06:26 +00:00
Benjamin Otte
e1cec0fb11 liststore: Simplify code
This is also faster, though I doubt anyone's able to measure it.

The previous code was a more complicted way to do the same thing and it
was likely written the more complicated way because it fell out commit
758d7073a9 when fixing
https://bugzilla.gnome.org/show_bug.cgi?id=795307
2018-09-04 20:31:51 +02:00
Benjamin Otte
3aff811d13 Use G_GNUC_FALLTHROUGH where appropriate 2018-09-04 20:24:25 +02:00
Christoph Reiter
912581340e Remove all static ChangeLog files
They only contain old information which is also available in git
2018-09-04 15:56:54 +02:00
Ondrej Holy
6ae061b74d Merge branch 'add-identifier-class-loop' into 'master'
Document new volume class `loop`

See merge request GNOME/glib!293
2018-09-04 08:29:01 +00:00
Philip Withnall
d3656705fa Merge branch 'default-tls-database' into 'master'
gtlsbackend: add support for setting the default TLS database

Closes glib-networking#35

See merge request GNOME/glib!273
2018-09-03 13:22:39 +00:00
Philip Withnall
8f157d0274 Merge branch 'wip/fmuellner/nm-portal-changed-signal' into 'master'
portal network monitor: Always emit changed signal on changed

See merge request GNOME/glib!294
2018-09-03 12:14:18 +00:00
Matthew Waters
27fca3474c gtlsdatabase: document that implementations must be thread-safe 2018-09-03 13:55:57 +10:00
Matthew Waters
b84951eb6f gtlsbackend: add support for setting the default TLS database
There are many cases where a default TLS database is not able to be
defined within the constraints of a system.  For example glib-networking
(or glib-openssl) cannot retrieve the default certificate store on iOS
or Android and need to be initialized from a cert file of certificates
bundled with the application.

Previously GStreamer was relying on a custom patch to glib-networking to
populate the default database from the file pointed to by the
CA_CERTIFICATES environment variable however the mechanism that enabled
this was recently remove from glib-networking.

Adding a more generic g_tls_backend_set_default_database() API allows
application developers to override the default database using their own
certificates as well as allowing equivalent functionality on Android/iOS
(or others) as on the default database handling Linux.

Fixes https://gitlab.gnome.org/GNOME/glib-networking/issues/35
2018-09-03 13:55:57 +10:00
Florian Müllner
423a2936ea portal network monitor: Always emit changed signal on changed
The ::network-changed signal is documented to indicate any change in
network configuration, which doesn't necessarily imply a property
change - additional services becoming available after connecting to
a VPN comes to mind for instance.

In order to match the "native" network monitor's behavior, always
emit the signal when it's in response to the 'changed' D-Bus signal.

Also emit the signal unconditionally when loading the initial property
values, to allow clients to differentiate between "offline" meaning
"offline" and "offline" meaning "uninitialized".
2018-09-01 19:31:45 +02:00
segfault
c341479c23 Document new loop class 2018-08-31 22:02:02 +02:00
Ryan Schmidt
612c450bd4 gio: Don't redefine GKqueueFileMonitor
Fixes build on old compilers that don't allow type redefinitions.

Closes: https://gitlab.gnome.org/GNOME/glib/issues/1506
2018-08-31 09:52:29 -05:00
Philip Withnall
b1cae79f78 glib-compile-resources: Fix generated code compiling with C++ compilers
With 0d685b4946, we now encode resource
data as a string. Strings have trailing nul terminators. A C compiler
will happily ignore the fact that the nul terminator exceeds the stated
array length, and will drop it — but a C++ compiler won’t, and will
raise:

error: initializer-string for array of chars is too long [-fpermissive]

Fix that by increasing the array length by 1, and subtracting it again
in the GStaticResource struct.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-31 12:29:39 +01:00
Philip Withnall
7427bb7184 Merge branch 'wip/oholy/nfs-poll-monitor' into 'master'
glocalfilemonitor: Fallback to poll file monitor for NFS

See merge request GNOME/glib!219
2018-08-31 10:51:25 +00:00
Philip Withnall
9be6122e11 Merge branch 'gresource-string-encoding' into 'master'
glib-compile-resources: encode data as string

See merge request GNOME/glib!264
2018-08-31 10:46:24 +00:00
Philip Withnall
f696f512a5 Merge branch 'mcatanzaro/inappropriate-fallback-error' into 'master'
Add a new GTlsError to indicate protocol downgrade attacks

See merge request GNOME/glib!200
2018-08-31 10:44:30 +00:00
Philip Withnall
d9b331f4d4 Revert "Add a gnet utility"
This reverts commit 3c1902fcf9.

This was accidentally re-added from an old version of the branch before
!265 was merged. It should not have been re-added.
2018-08-28 11:59:04 +01:00
Philip Withnall
f65e8eb7e3 Merge branch 'subprocess-cancellable-callback-fix' into 'master'
subprocess: Fix communicate_cancelled signature

See merge request GNOME/glib!266
2018-08-28 10:32:07 +00:00
Matthias Clasen
917dee45b2 Merge branch 'network-monitor-again' into 'master'
Network monitor again

See merge request GNOME/glib!265
2018-08-27 15:32:51 +00:00
Marco Trevisan (Treviño)
72bf795db5 tests, subprocess: units for cancelled communications 2018-08-27 17:08:47 +02:00
Florian Müllner
d047ca341b portal network monitor: Validate connectivity
Only accept connectivity values that are actually
in the range of GNetworkConnectivity.

https://gitlab.gnome.org/GNOME/glib/merge_requests/227
2018-08-27 10:56:02 -04:00
Matthias Clasen
860735f01b portal network monitor: Drop the version property
Rearrange the code so we try version 3 first,
falling back to version 2 and then version 1.

We still do a construct-time check to ensure
that we work with unsupported versions.

Note that this also takes care of setting the
initial property values in the version 1 case.
2018-08-27 10:55:53 -04:00
Matthias Clasen
5c5881b2ed portal network monitor: use GetStatus when available
Version 3 of the portal interface adds a GetStatus
method that gets all data in a single roundtrip.
Use it when available.
2018-08-27 10:55:30 -04:00
Matthias Clasen
a090d8605b portal network monitor: Implement can_reach
Version 3 of the network monitor portal interface adds
a CanReach method. Use it to implement can_reach.

The docs state that can_reach will either return TRUE
or set an error. So, set an error of G_IO_ERROR_HOST_UNREACHABLE
when the portal returns FALSE for CanReach.
2018-08-27 10:55:01 -04:00
Matthias Clasen
3a3a32a2bb portal network monitor: Always emit ::network-changed
The documentation of this signal is not really clear,
but it seems safer to emit it for all changes, even
if available is unchanged.
2018-08-27 10:54:35 -04:00
Matthias Clasen
8f2393b9b6 Whitespace fixup 2018-08-27 10:48:06 -04:00
Iñigo Martínez
64e9e1f482 gio: Provide schemas directory information in pkg-config file
GSettings XML schema files are installed in a well known directory
under Glib's installation directory: `glib-2.0/schemas`. However,
the Glib installation directory might vary, so the exact location of
the schema files might be unknown.

The information regarding this directory has been added to GIO's
pkg-config file, so it can be checked, and also overrided, by using
the command line utility.
2018-08-27 13:50:34 +02:00
Marco Trevisan (Treviño)
5cc4cca9c6 subprocess: Fix communicate_cancelled signature
The source callback for a GCancellable should have the cancellable itself
as first argument.
This was not the case, and when this code was hit, we were instead trying
to treat the pointer as a CommunicateState reference and thus wrongly
deferencing it, causing a memory error and a crash.
2018-08-24 06:05:03 +02:00
Ninja-Koala
0d685b4946
glib-compile-resources: encode data as string
Some Testing revealed encoding resource data with string
escape codes to compile significantly quicker compared
to the same data encoded as an array with hexadecimal numbers.
See #1489
2018-08-23 10:02:56 +02:00
Matthias Clasen
3c1902fcf9 Add a gnet utility
This is currently just a wrapper around GNetworkMonitor.
2018-08-23 02:59:28 +00:00
Philip Withnall
2df9d38635 build: Clean files left behind after gio/tests/gresource.c test
This is a follow-up to commit 614adf8a75,
which started generating two new files as part of the test; they need to
be cleaned up before distcheck will pass.

Ideally, the test should run a temporary directory and wipe that
directory itself before exiting, but that’s a bit of a big change to
make right now. Deferred to
https://gitlab.gnome.org/GNOME/glib/issues/1495.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-22 15:01:56 +01:00
Ting-Wei Lan
9147403893 gtestdbus: Fix watcher crash on FreeBSD
In file gio/gtestdbus.c, function watch_parent, there is a loop which
waits for commands sent from the parent process and kills all processes
recorded in 'pids_to_kill' array on parent process exit. The detection
of parent process exit is done by calling g_poll and checking whether
the returned event is G_IO_HUP. However, 'revents' is a bit mask, and
we should use a bitwise-AND check instead of the equality check here.

It seems to work fine on Linux, but it fails on FreeBSD because the
g_poll returns both G_IO_IN and G_IO_HUP on pipe close. This means the
watcher process continues waiting for commands after the parent process
exit, and g_io_channel_read_line returns G_IO_STATUS_EOF with 'command'
set to NULL. Then the watcher process crashes with segfault when calling
sscanf because 'command' is NULL. Since the test result is already
reported by the parent process as 'OK', this kind of crash is likely to
be unnoticed unless someone checks dmesg messages after the test:

pid 57611 (defaultvalue), uid 1001: exited on signal 11
pid 57935 (actions), uid 1001: exited on signal 11
pid 57945 (gdbus-bz627724), uid 1001: exited on signal 11
pid 57952 (gdbus-connection), uid 1001: exited on signal 11
pid 57970 (gdbus-connection-lo), uid 1001: exited on signal 11
pid 57976 (gdbus-connection-sl), uid 1001: exited on signal 11
pid 58039 (gdbus-exit-on-close), uid 1001: exited on signal 11
pid 58043 (gdbus-exit-on-close), uid 1001: exited on signal 11
pid 58047 (gdbus-exit-on-close), uid 1001: exited on signal 11
pid 58051 (gdbus-exit-on-close), uid 1001: exited on signal 11
pid 58055 (gdbus-export), uid 1001: exited on signal 11
pid 58059 (gdbus-introspection), uid 1001: exited on signal 11
pid 58065 (gdbus-names), uid 1001: exited on signal 11
pid 58071 (gdbus-proxy), uid 1001: exited on signal 11
pid 58079 (gdbus-proxy-threads), uid 1001: exited on signal 11
pid 58083 (gdbus-proxy-well-kn), uid 1001: exited on signal 11
pid 58091 (gdbus-test-codegen), uid 1001: exited on signal 11
pid 58095 (gdbus-threading), uid 1001: exited on signal 11
pid 58104 (gmenumodel), uid 1001: exited on signal 11
pid 58108 (gnotification), uid 1001: exited on signal 11
pid 58112 (gdbus-test-codegen-), uid 1001: exited on signal 11
pid 58116 (gapplication), uid 1001: exited on signal 11
pid 58132 (dbus-appinfo), uid 1001: exited on signal 11

If the watcher process crashes before killing the dbus-daemon process
spawned by the parent process, the dbus-daemon process will keep running
after all tests complete. Due to the implementation of 'communicate'
function in Python subprocess, it causes meson to crash. 'communicate'
assumes the stdout and stderr pipes are closed when the child process
exits, but it is not true if processes forked by the child process
doesn't exit. It causes Python subprocess 'communicate' function to
block on the call to poll until the timeout expires even if the test
finishes in a few seconds. Meson assumes the timeout exception always
means the test is still running. It calls 'communicate' again and
crashes because pipes no longer exist.

https://gitlab.gnome.org/Infrastructure/GitLab/issues/286
https://github.com/mesonbuild/meson/issues/3967
https://bugs.python.org/issue30154
2018-08-20 11:13:19 +01:00
Christoph Reiter
6b833bc2f1 tests: fix gnotification tests broken due to the recent icon name fallback changes
In !72 themed icons were changed to fall back to the symbolic variant.
The gnotification tests were still testing for the old list of names.
2018-08-19 20:04:41 +02:00
Matthias Clasen
dd3e565e94 Use an existing enum value
We have an enum for this, no need to hardcode numbers.
2018-08-18 20:16:03 -04:00
Philip Withnall
f876f4174f Merge branch 'master' into 'master'
gio: icons should fallback to non-preferred style appropriately.

See merge request GNOME/glib!72
2018-08-17 12:49:03 +00:00
Philip Withnall
61a348f287 glocalfile: Only ignore FS full information for FUSE and ncpfs
Previously, glocalfile.c would not set file system metadata for
the free/used key for file systems which reported 0 free space. This is
because some file systems don’t set that metadata when you call
statfs(), so we can’t reliably report it. However, some do, and they
can legitimately set f_bavail and f_bfree to 0 if the file system is
full.

In order to avoid that, always set the file system metadata unless the
file system is FUSE or ncpfs.

This is a partial revert of commit 0b9f24c1e1: instead of the changes
made in that commit, I think we should maintain a blacklist of file
systems which are known to not correctly report free space.

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

https://gitlab.gnome.org/GNOME/glib/issues/328
2018-08-17 12:41:20 +01:00
Matthias Clasen
18997de7e9 network monitor portal: update properties initially
With version 2, we need to query the values explicitly.
The properties made this automatic.
2018-08-16 21:36:13 +00:00
Philip Withnall
1a30a6a1d0 Merge branch 'fix-gdbus-unix-address' into 'master'
Fix failing tests when G_MESSAGES_DEBUG is set (again)

See merge request GNOME/glib!247
2018-08-16 21:27:47 +00:00
Xavier Claessens
9a3c7eca14 Merge branch '1444-install-tests' into 'master'
Resolve "the meson build doesn't support installed tests"

Closes #1444

See merge request GNOME/glib!245
2018-08-16 20:01:06 +00:00
Xavier Claessens
9f208e9f2b Fix failing tests when G_MESSAGES_DEBUG is set (again)
Similar issue was fixed with commit f929d148, but it's happening again.
Define G_MESSAGES_DEBUG=all when running CI to ensure we won't regress
anymore.
2018-08-16 15:55:51 -04:00
Xavier Claessens
c908ce8f8c Meson: install gio tests 2018-08-16 10:53:31 -04:00
Philip Withnall
faa383936e Merge branch '1454-gvdb-corruption' into 'master'
gvdb: Fix error handling in gvdb_table_new()

Closes #1454

See merge request GNOME/glib!214
2018-08-16 14:52:50 +00:00
Iain Lane
1152d99ded Fix trashing on overlayfs
In order to determine whether to trash a file to the home directory, we
compare its st_dev to our home directory's st_dev field.

This is the wrong thing to do on overlayfs when deleting files, because
st_dev contains the ID of the filesystem providing the file (which can
be the lower or upper filesystem), but directories always return the ID
of the overlayfs. Thus the comparison fails and we are unable to trash
the file.

Fix this by checking st_dev of the parent directory when we are deleting
a file.

Also adjust `test_trash_not_supported` for this - make its st_dev check
look at the parent directory's `st_dev` rather than the temporary file's
own.

Fixes #1027.
2018-08-13 17:41:59 +01:00
Iain Lane
93f3cb7c6d Revert "glocalfile: Check that parent device is the same when trashing"
This reverts commit 15cdcd2e0b.
2018-08-13 17:23:21 +01:00
Philip Withnall
614adf8a75 gvdb: Fix error handling in gvdb_table_new()
The documentation was unclear about what error codes would be returned
on attempting to open an empty or corrupt GVDB file. Previous versions
of the documentation incorrectly said that corrupt GVDB files were
considered equivalent to empty ones.

A recent commit has clarified the documentation to include its error
handling behaviour.

Update the two users of GVDB within GLib, GResource and GSettingsSource,
to follow this change, and add unit tests for them both.

Other users of the GVDB copylib will need to update their copy and make
appropriate changes if they have bugs in their handling of this
situation. dconf is one example of this. GVDB should be updated from
https://gitlab.gnome.org/GNOME/gvdb.

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

https://gitlab.gnome.org/GNOME/glib/issues/1454
2018-08-13 15:38:34 +01:00
Philip Withnall
c652d45c97 gsettingsschema: Port to new GVDB API
This should introduce no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-13 15:37:05 +01:00
Philip Withnall
705dd2b9a9 gresource: Port to new GVDB API
This should introduce no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-13 15:37:05 +01:00
Philip Withnall
ce86a3aed7 glib-compile-schemas: Fix a minor memory leak
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-13 15:37:05 +01:00
Philip Withnall
c9834f234d Merge remote-tracking branch 'gvdb/master' into update-gvdb
Minor merge conflicts in gvdb-reader.c with the documentation.
2018-08-13 15:35:52 +01:00
Arnaud B
438547641f Fix indicative gschema.dtd regarding range.
The range can have only a "min" or only a "max" attribute, and can even have no attributes at all.
2018-08-13 08:19:57 +00:00
Руслан Ижбулатов
075bb0f751 W32: consider NTFS mounpoints to be symlinks
While mountpoints are *not* symlinks, strictly speaking,
they works in a similar enough way, so consider them to be
symlinks for the purpose of querying local file info.
2018-08-08 23:41:07 +00:00
Руслан Ижбулатов
929844fdf7 W32: correctly use st_ctime
On Windows st_ctime field is the file creation time.
POSIX mandates that field to be the file state change time.
Naturally, glib code interpreted st_ctime as POSIX suggested,
and the result was bad.
Fix this by introducing special W32-only logic for setting
attributes from st_ctime field.

Fixes issue #1452.
2018-08-08 23:41:02 +00:00
Pavlo Solntsev
7e2dfa8c44 DOC: Documentation fix in GTask description 2018-08-08 00:17:15 -05:00
Michael Catanzaro
4536deb5af Add a new GTlsError to indicate protocol downgrade attacks
G_TLS_ERROR_MISC suffices, but it's nicer to have a new error here.
2018-08-07 08:20:03 -05:00
Philip Withnall
ab09a5f5a9 gdbusmessage: Fix a typo in the documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-07 11:04:00 +01:00
Philip Withnall
a5f824451f Merge branch 'mcatanzaro/tls-docs' into 'master'
Update TLS documentation

See merge request GNOME/glib!199
2018-08-07 09:46:30 +00:00
Michael Catanzaro
08fe93589e Update documentation of g_tls_client_connection_set_use_ssl3()
We now send the fallback SCSV, meaning use of this function will cause
modern servers to immediately terminate the connection, so let's warn
API users to expect that behavior and be crystal clear that this
function should only be used as a fallback when a normal connection
attempt has already failed.

Also, the documentation is mostly duplicated between the property and
the function, so let's just reference the function documentation from
the property.
2018-08-04 16:33:28 -05:00
Christoph Reiter
99caee2819 build: only test for broken ip_mreq_source on Android. Fixes #1472
7efd76dd67 added these configure time tests to work around a bug
with older Android. Since the test didn't take Windows into account it
wrongfully applied the workaround on Windows too, breaking the build.
With meson this wasn't an issue since the check is skipped on Windows there
and our CI didn't catch this issue.

Change the test to run on Android only for meson and autotools.
This also makes it clear that the test+code can be dropped again if we stop
supporting older Android versions at some point.
2018-08-03 10:24:00 +02:00
Philip Withnall
7f5296d055 Merge branch 'wip/oholy/update-mounts' into 'master'
Be sure that g_volume_get_mount succeed after g_volume_mount

See merge request GNOME/glib!217
2018-08-02 15:40:50 +00:00
Ondrej Holy
3edc50498f glocalfilemonitor: Fallback to poll file monitor for NFS
GLib currently tries to use FAM volume monitor for monitoring files
within home on NFS. If FAM support is not available, it fallbacks by
default to GInotifyFileMonitor. I think we should fallback to
GPollFileMonitor instead, because inotify is not reliable on NFS,
which may cause issues for dconf. With this patch, it should be safe to
not build libgiofam and still be sure that dconf works properly if home
is mounted on NFS. I think this might be a first step to remove FAM
support from GLib completely, because gamin is buggy and dead for
several years already. Gamin just polls files on NFS anyway. This
change applies on files only, because GPollFileMonitor seems doesn't
support dirs, however it should be enough for dconf. The other
drawback is that one can't set poll timeout currently. Just a note
that this can still be overwritten by GIO_USE_FILE_MONITOR.
2018-08-02 13:14:10 +02:00
Ondrej Holy
88b8ebb5dd gio-tool: Hold GVolumeMonitor reference during operations
Releasing GVolumeMonitor before g_volume_mount finish cause that
g_volume_get_mount returns NULL, because the mount is not correctly
propagated to the volume.

https://gitlab.gnome.org/GNOME/glib/issues/1458
2018-08-02 11:35:48 +02:00
Christoph Reiter
70ad484508 gresource-tool: fix build in case libelf is available on Windows. Fixes #1466
The gresource code uses libelf if available but that also depends on mmap but isn't
guarded with HAVE_MMAP. This can make the build fail under MSYS2 where a mingw version
of libelf exists but there is no mmap.

Instead of guarting the libelf code with HAVE_LIBELF add a new macro named USE_LIBELF
which is only defined if libelf and mmap support are available.

Also install the mingw libelf version for CI so we catch similar errors in the future.
2018-08-01 19:08:39 +02:00
Emmanuele Bassi
26c3f2f1b1 Install gioenumtypes.h
We're re-defining nodist_gioinclude_HEADERS and Automake will use the
last definition of the target.
2018-07-31 09:40:22 +01:00
Philip Withnall
2a69cdb1cd build: Stop distributing generated files in autotools tarballs
It is a bug if we distribute files which are generated at build time —
they should be built on the machine which is compiling GLib, not be
shipped in the tarball.

This brings the autotools-generated tarball in line with the
ninja-generated one, with the exception of man pages and gtk-doc HTML
output.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-30 19:58:24 +01:00
Mohammed Sadiq
24f5dbca2c gio/tests: Use the right format specifier
dev_t - the type of st_dev - is always 8 byte.
Use G_GUINT64_FORMAT to ensure 8 byte and thus not fail on i386.
2018-07-30 20:53:15 +05:30
Ondrej Holy
9b6b282e0a gio: Update mounts after g_volume_mount
The documentation claims that g_volume_get_mount should	succeed	after
g_volume_mount. Let's update mounts before releasing g_volume_mount to
be sure that the mount is added to the corresponding volume. The same
is done in GVfsUDisks2VolumeMonitor.

https://gitlab.gnome.org/GNOME/glib/issues/1458
2018-07-30 16:05:41 +02:00
Michael Catanzaro
94a99ae917 Update documentation of g_tls_connection_handshake
Rehandshaking is not a thing in TLS 1.3. In that case,
g_tls_connection_handshake() should instead perform a re-key.
2018-07-27 10:48:50 -05:00
Matthias Clasen
56092b8529 Revert "Add a gnet utility"
This reverts commit 1db3b6def6.

I had forgotten to remove this from the branch before merging.
2018-07-25 07:18:38 -04:00
Matthias Clasen
2480ece23d Merge branch 'new-network-portal' into 'master'
New network portal

See merge request GNOME/glib!192
2018-07-25 11:16:51 +00:00
Nirbheek Chauhan
4e1488eebb Merge branch 'meson-python-module' into 'master'
meson: use the new 'python' module instead of the 'python3' one

Closes #1455

See merge request GNOME/glib!187
2018-07-23 11:17:47 +00:00
Matthias Clasen
1db3b6def6 Add a gnet utility
This is currently just a wrapper around GNetworkMonitor.
2018-07-21 08:21:58 -04:00
Matthias Clasen
7217fe56e0 Stop generating code for NetworkMonitor
The portal implementation no longer uses generated
code for org.freedesktop.portal.NetworkMonitor.
2018-07-21 08:21:43 -04:00
Matthias Clasen
5ed808d7c4 network monitor: Update portal implementation
The network monitor portal interface is changing.
Version 2 is no longer using properties, but getters
instead (this lets the portal apply access control
and avoid sending information to non-networked
sandboxes).

To support both version 1 and 2 of the interface,
we stop using generated code and instead deal with
the api differences in our own code, which is not
too difficult.

Support version 1 as well
2018-07-21 08:19:16 -04:00
Matthias Clasen
e0b120cc3c Add debug spew to module loading
This is useful to verify which modules are loaded, and why.
2018-07-20 18:53:09 -04:00
Christoph Reiter
631c3534b7 meson: use the new 'python' module instead of the 'python3' one. Closes #1455
The new python module, added with 0.46, works with Python 2 and 3 and
allows to pass a path for the interpreter to use, if the need arises.

Previously the meson build set PYTHON, used in the shebang line of
the scripts installed by glib, to the full path of the interpreter.
The new meson module doesn't expose that atm, but we should set it to
a executable name anyway, and not a full path.
2018-07-19 12:32:29 +02:00
Nirbheek Chauhan
057f393bbb meson: Provide our Python tools for builds
Several of our tools are installed and are used by other projects to
generate code. However, there is no 'install' when projects use glib
as a subproject.

We need some way for glib to 'provide' these tools so that when some
project uses glib as a subproject, find_program('glib-mkenums') will
transparently return the glib-mkenums we just built.

Starting from Meson 0.46, this can be done with the
`meson.override_find_program()` function.

As a bonus, the Meson GNOME module will also use these
'overriden'/'provided' programs instead of looking for them in PATH.
2018-07-19 15:53:37 +05:30
Javier Jardón
5f6895d741 gio/Makefile.am: Use PYTHON to call python script 2018-07-17 12:26:34 +01:00
Philip Withnall
b5948c1a39 gsettings: Fix some memory leaks on error paths
Coverity CID: #1393949
Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2018-07-17 12:14:07 +02:00
Philip Withnall
2c79b357b2 gio-tool: Fix a memory leak when returning command line help
Coverity CID: #1393952
Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2018-07-17 12:13:21 +02:00
Xavier Claessens
f456e311cd Meson: Use environment() for test_env 2018-07-16 15:04:03 -04:00
Xavier Claessens
c96f987f0d Merge branch '786-gio-test-leaks' into 'master'
Fix memory leaks in libgio tests and ensure tests are run under Meson

Closes #786

See merge request GNOME/glib!151
2018-07-13 15:46:21 +00:00
Thomas Hindoe Paaboel Andersen
a8b416f9fe python: avoid equality check for None
PEP8 says that:
"Comparisons to singletons like None should always be done with is or
is not, never the equality operators."

glib uses a mix of "== None" and "is None". This patch changes all
cases to the latter.
2018-07-12 23:48:41 +02:00
Philip Withnall
3890f7f5cb tests: Fix skipping of appinfo tests when DISPLAY is unset
Use g_test_skip() so that the TAP output is correct for the tests,
rather than printing using g_printerr().

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

https://gitlab.gnome.org/GNOME/glib/issues/640
2018-07-11 15:58:48 +02:00
Emmanuele Bassi
ad3947c42e Merge branch '927-resource-path-fix' into 'master'
gresource: Fix potential array overflow if using empty paths

Closes #927

See merge request GNOME/glib!150
2018-07-11 09:24:03 +00:00
Philip Withnall
3475afc255 Merge branch '1402-real-time' into 'master'
glib: Don’t use time(NULL) to get current time

Closes #1402

See merge request GNOME/glib!154
2018-07-11 07:51:06 +00:00
Philip Withnall
034bbfd873 gdbusconnection: Drop an outdated TODO comment
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/340
2018-07-10 19:16:35 +02:00
Philip Withnall
92e059280f glib: Don’t use time(NULL) to get current time
Use either g_get_real_time() or g_date_time_new_now_local(). This means
we don’t need to worry about time_t being 32b in future (the year 2038
problem), and it makes the need for error handling a bit more explicit.
Improve the error handling in several cases.

Based on a patch by Niels De Graef
(https://gitlab.gnome.org/GNOME/glib/merge_requests/142).

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

https://gitlab.gnome.org/GNOME/glib/issues/1402
2018-07-09 13:28:02 +02:00
Philip Withnall
9d6a69b73e gio: Link inotify file monitor to GLib and GObject
Apparently this is needed for building PE libraries. It makes no
difference on Linux, where linking of the GLib symbols in the inotify
file monitor code is done lazily.

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

https://gitlab.gnome.org/GNOME/glib/issues/1201
2018-07-09 10:38:04 +01:00
Adrian Perez de Castro
657be4f5fc
gio: Add missing autocleanup definition for GResource
Fixes #1435
2018-07-07 19:44:19 +03:00
Philip Withnall
6438e2c731 tests: Mark gdbus-threading test as slow
It often takes a bit more than 30s on my local machine to run.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-06 15:01:40 +01:00
Philip Withnall
5422838e8d tests: Move two tests from GIO uninstalled helpers to test cases list
These are built and run as tests in the autotools build, and use GTest.
They are tests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-06 14:58:25 +01:00
Philip Withnall
cfc26b5a41 tests: Rework slow test handling for GIO tests
Make it follow the same pattern as in glib/tests/meson.build, using a
slow_tests array.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-05 17:14:53 +01:00
Philip Withnall
cf4f6d4808 tests: Ensure GIO tests which need dbus-daemon are run
The tests array was being wiped out by an assignment instead of an
append. This adds another 19 tests to what’s typically being run
already.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-05 13:26:48 +01:00
Philip Withnall
eeb5015ebe build: Make actions and gdbus-export GIO tests as slow
Increase their timeout.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-05 13:26:48 +01:00
Philip Withnall
a0cebdf4b6 tests: Use Unicode typography in gdbus-export test
This was missed in !137 because some of the GIO tests weren’t being run
under Meson (see following commits).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-05 13:14:22 +01:00
Stef Walter
92a01e2280 gdbus-connection-loss: Fix leak in test
https://gitlab.gnome.org/GNOME/glib/issues/786
2018-07-05 13:13:59 +01:00
Philip Withnall
ab87af1734 gresource: Fix potential array overflow if using empty paths
Adds tests to cover this case and similar cases for various GResource
methods in future.

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

https://gitlab.gnome.org/GNOME/glib/issues/927
2018-07-05 12:03:10 +01:00
Philip Withnall
f62d7c1e2a gresource: Fix wrapping of function return type
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-05 11:19:20 +01:00
Xavier Claessens
deccba2807 Meson: Use subdir_done() now that it has been fixed 2018-07-03 11:06:48 -04:00
Xavier Claessens
95fa229f34 Meson: Fix warnings introduced in 0.47.0 2018-07-03 11:00:54 -04:00
Philip Withnall
4dc927fc2f Merge branch 'ci-memcheck-preparation' into 'master'
Preparation for adding valgrind/memcheck to CI

See merge request GNOME/glib!143
2018-06-29 13:31:43 +00:00
Philip Withnall
f7bd41fdaa tests: Fix leak when checking for du binary
g_find_program_in_path() returns a pointer, not a boolean.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-06-29 12:13:32 +01:00
Philip Withnall
93b519b104 tests: Various minor leak fixes in the GIO tests
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-06-29 12:13:32 +01:00
Philip Withnall
68526565f4 tests: Fix use-after-free in the appinfo tests
When changing the locale using setlocale(), duplicate the old locale
value before updating it, so that we can safely restore the old locale
after running the test.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-06-29 12:13:32 +01:00
Philip Withnall
61da8748fd glocalfile: Fix a minor memory leak
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-06-29 12:13:32 +01:00
Ondrej Holy
51132b1d49 Merge branch 'cifs-is-not-a-system-fs' into 'master'
gunixmounts: Stop considering cifs/nfs as system file systems

See merge request GNOME/glib!125
2018-06-29 07:07:24 +00:00
Philip Withnall
6db2412b41 gdesktopappinfo: Fix a minor command line leak
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-06-27 15:01:09 +01:00
Philip Withnall
c1d8b9c806 gbufferedoutputstream: Fix jump conditional on uninitialised data
The flush data structures were not zero-initialised, which meant the
branch in flush_buffer_thread() was based on an uninitialised condition.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-06-27 15:01:08 +01:00
Philip Withnall
208a6e815a gmain: Add names to various GSources constructed in GLib
For the purposes of debugging, it is quite useful for every GSource to
have a name set. Ensure that any GSource we construct inside GLib has a
name set. For GSources which are then returned to the caller, this name
can then be overridden with something even more useful by the caller.

Since this data is only used for debugging, avoid doing any allocations
for it; just use static strings.

https://gitlab.gnome.org/GNOME/glib/issues/1175
2018-06-26 09:25:39 +01:00
Piotr Drąg
d9fc99256e Use Unicode typography in new translatable strings
See https://developer.gnome.org/hig/stable/typography.html
2018-06-25 16:51:00 +02:00
Philip Withnall
4993f2b7e5 Merge branch 'wip/muktupavels/per-desktop-overrides' into 'master'
GSettings: per-desktop overrides

Closes #1013

See merge request GNOME/glib!105
2018-06-25 10:32:44 +00:00
Alberts Muktupāvels
b618ec40a7 Add a test for per-desktop overrides 2018-06-22 22:02:31 +03:00
Philip Withnall
04c8691208 Revert "build: Look for copied Objective-C files in builddir again"
This reverts commit fe72b8772e.

It still fails on GNOME Continuous:
http://build.gnome.org/continuous/buildmaster/builds/2018/06/21/44/build/.

See https://gitlab.gnome.org/GNOME/glib/merge_requests/129 for
discussion.
2018-06-22 00:21:05 +01:00
Philip Chimento
fe72b8772e build: Look for copied Objective-C files in builddir again
This reverts commit 03c324c64a and fixes
the original problem with e004d5f397 that
caused the revert.

We use $(builddir) instead of $(abs_builddir) so that Automake's
dependency generation works correctly.

See !127.
2018-06-21 14:48:29 -07:00
Philip Withnall
ca98ce4280 Merge branch 'master' into 'master'
Use posix_spawn for optimized process launching

See merge request GNOME/glib!95
2018-06-21 17:10:43 +00:00
Daniel Drake
156d009696 gdesktopappinfo: add g_desktop_app_info_launch_uris_as_manager_with_fds variant
Add an app-launching function which allows standard file descriptors
to be passed to the child process.

This will be used by gnome-shell to pass systemd journal descriptors
as stdout/stderr. gnome-shell's child_setup function can then be
eliminated, which will enable use of the posix_spawn optimized
gspawn codepath for desktop app launching.
2018-06-21 11:44:59 -05:00
Daniel Drake
742efe6232 gdesktopappinfo: enable fast posix_spawn gspawn codepath
In order to use the new posix_spawn gspawn codepath, for more robust
app launching when available memory is low, we need to meet some
conditions.

child_setup needs to be NULL for this optimization to work, so drop
the internal child_setup that is used here. Replace it with a lightweight
wrapper binary (gio-launch-desktop) that sets GIO_LAUNCHED_DESKTOP_FILE_PID
before executing the app.

Adjust PATH for gio tests so that it can execute the new binary from the
build directory.
2018-06-21 11:44:28 -05:00
segfault
76b4d0ab3f Add support for TCRYPT volumes to GMountOperation
Add G_ASK_PASSWORD_TCRYPT flag to GAskPasswordFlags and add the
following properties to GMountOperation:

- hidden_volume [1]
- system_volume [2]
- pim [3]

[1] https://www.veracrypt.fr/en/Hidden%20Volume.html
[2] https://www.veracrypt.fr/en/System%20Encryption.html
[3] https://www.veracrypt.fr/en/Personal%20Iterations%20Multiplier%20(PIM).html
2018-06-21 15:32:04 +02:00
Philip Withnall
a3a6c516c4 gunixmounts: Stop considering cifs/nfs as system file systems
They’re network file systems, but not system file systems (in the sense
that procfs is a system file system). This fixes them disappearing from
the sidebar in the UI.

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

https://gitlab.gnome.org/GNOME/glib/issues/1424
2018-06-20 12:16:34 +01:00
Allison Lortie
83a2e85ec8 glib-compile-schemas: Handle per-desktop overrides
Add a new syntax to override files: if the group name has a ':' in it,
it indicates that we want to override the default values of keys for
only one desktop. For example:

[org.gnome.desktop.interface:Unity]
font-name='Ubuntu 12'

Will override the settings, only if "Unity" is found in
XDG_CURRENT_DESKTOP. Multiple per-desktop overrides can be specified
for a given key: the one which comes first in XDG_CURRENT_DESKTOP will
be used.

https://bugzilla.gnome.org/show_bug.cgi?id=746592
2018-06-19 19:18:58 +03:00
Allison Lortie
6ca449672d gsettingsschema: Allow per-desktop overrides
Recognise a new 'd' option in schema keys which gives a dictionary of
per-desktop default values. This dictionary is searched for the items
found in XDG_CURRENT_DESKTOP, in the order. If nothing matches (or if
the option is missing) then the default value is used as before.

This feature was requested by Alberts Muktupāvels and this patch is
based on an approach devised by them.

https://bugzilla.gnome.org/show_bug.cgi?id=746592
2018-06-19 19:18:58 +03:00
Allison Lortie
c2e7f31697 gsettings: cleanup default value lookup
There are a couple of different ways (and soon one more) to access the
default value of a key. Clean up the various places that access this to
avoid duplication.

https://bugzilla.gnome.org/show_bug.cgi?id=746592
2018-06-19 19:18:58 +03:00
Philip Withnall
1c673535fe tests: Add basic tests for GMountOperation
There were previously no tests for it. These take gmountoperation.c up
to 85.5% coverage of lines.

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

https://gitlab.gnome.org/GNOME/glib/issues/1423
2018-06-19 15:46:59 +01:00
Philip Withnall
6284749487 gfile: Document usefulness of g_file_dup()
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/807
2018-06-19 12:36:37 +01:00
Philip Withnall
40a84b3d1c Merge branch 'wip/lantw/freebsd-kqueue-complex' into 'master'
FreeBSD kqueue file monitor fixes: the complex parts

See merge request GNOME/glib!77
2018-06-19 11:19:43 +00:00
Philip Withnall
f784df722d Merge branch 'wip/hughsie/EOPNOTSUPP' into 'master'
Handle EOPNOTSUPP error from splice()

See merge request GNOME/glib!112
2018-06-19 11:13:37 +00:00
Philip Withnall
e0f4439cad Merge branch 'wip/oholy/gio-bash-completion' into 'master'
Add bash completion for gio tool

See merge request GNOME/glib!115
2018-06-19 11:12:00 +00:00
Ting-Wei Lan
e714e1e951 kqueue: Use the worker context to schedule rescanning of missing files
This makes it consistent with the file monitor itself, which already
attaches kqueue event sources to the worker context.
2018-06-17 11:26:32 +08:00
Ting-Wei Lan
454a9f8de9 tests: Make testfilemonitor test work with kqueue
check_expected_events is heavily modified in this commit to tolerate
event loss and allow renaming to be reported as creation and deletion.

This fixes test failure on FreeBSD.
2018-06-17 11:26:32 +08:00
Ting-Wei Lan
09c019a4f0 kqueue: Make it possible to pass file monitor tests
Previously, kqueue file monitor only add event sources for directories
regardless of the type of the file being monitored. Doing so may be
possible on inotify, but it is not sufficient on kqueue. Watching a
directory on kqueue doesn't report changes made to files under it, and
we must watch files themselves to get notified. This problem is fixed
by adding a second watch for non-directory file monitors, and the result
is that we are now able to receive 'CHANGED' and 'ATTRIBUTE_CHANGED'
events for non-directory files.

Since having two watches on one file monitor requires many code changes
to work properly, this commit also changes the following things:

 - NOTE_ALL macro is now replaced by note_all inline function. Since the
   kqueue backend is shared by all BSD operating systems, there are a
   few difference between these systems. It is easier to do '#ifdef'
   check in a function than in a macro.

 - Both g_kqueue_file_monitor_callback and g_kqueue_file_monitor_cancel
   now holds a lock before accessing kqueue_sub structs. This fixes a
   crash when these two functions are called from different threads,
   causing g_kqueue_file_monitor_callback to access freed memory.

 - 'mask' variable in g_kqueue_file_monitor_callback is now removed.
   The usage of 'mask' was wrong because of the 'mask > 0' check.
   'CHANGED' event has value 0 so the 'mask > 0' check made it
   impossible to emit 'CHANGED' events.

 - kqueue-missing scans can now be triggered from the kqueue event
   callback instead of always waiting for 4 seconds.

 - Don't remove a file from kqueue on unlink unless its hard link count
   has dropped to zero.

 - Don't use 'else if' in the check of 'fflags'. It is possible for a
   kevent to have multiple flags set.

 - Don't use g_file_monitor_emit_event directly. Always use
   g_file_monitor_source_handle_event to report events.
   Events submitted to g_file_monitor_emit_event are delivered
   immediately, but events sent to g_file_monitor_source_handle_event
   are scheduled by GLocalFileMonitor. If we mix the two, the order of
   events will be wrong and tests will fail.

 - Report 'CHANGES_DONE_HINT' immediately after 'CREATED' if the file
   created is not a regular file. This is copied from ih_event_callback.
2018-06-17 11:26:32 +08:00
Olivier Crête
8e65417c6e docs: Change Bugzilla references to GitLab
Including modifications by Philip Withnall <withnall@endlessm.com>
2018-06-15 13:04:39 +01:00
Philip Withnall
3126f73c80 Merge branch '1368-codegen-interface-info' into 'master'
gdbus-codegen: Add a mode to generate GDBusInterfaceInfo structures

Closes #1368

See merge request GNOME/glib!13
2018-06-15 10:35:46 +00:00
Ondrej Holy
e0e0f259c3 gio: Add bash completion for gio tool
GVfs utils used to have bash completion, which was pretty useful. However,
it hasn't been ported to gio tool unfortunately. GLib provides completion
for various utils already, so it would be nice to provide completion also
for gio tool. I've updated old bash completion code and merged with some
my old unmerged fixes.

The gvfs completion used "gvfs-ls --show-completions" helper. This mentioned
option hasn't been obviously ported to "gio list" and the proposed completion
doesn't add this option in "gio list" to not pollute the codes, but maybe it
is a bit slower as consequence.

The proposed bash completion suggests subcommands, uris and paths including
the remote mounts. It contains some workarounds, especially because of proper
handling of paths with colons and other special chars (like spaces)...
2018-06-15 12:34:10 +02:00
Richard Hughes
7a7fe06939 gio: PPC64 returns EOPNOTSUPP from splice() if not supported 2018-06-14 19:18:25 +01:00
Philip Withnall
0e3b137210 codegen: Fix a minor Python linting warning
This introduces no functional changes.

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

https://bugzilla.gnome.org/show_bug.cgi?id=795304
2018-06-14 18:57:53 +01:00
Philip Withnall
3a1536ba34 codegen: Suppress the old --xml-files option in the --help output
Since it’s deprecated in favour of positional arguments, including it in
the help output is confusing.

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

https://bugzilla.gnome.org/show_bug.cgi?id=795304
2018-06-14 18:57:53 +01:00
Philip Withnall
8916874ee6 codegen: Add --interface-info-[body|header] modes
These generate basic .c and .h files containing the GDBusInterfaceInfo
for a D-Bus introspection XML file, but no other code (no skeletons,
proxies, GObjects, etc.).

This is useful for projects who want to describe their D-Bus interfaces
using introspection XML, but who wish to implement the interfaces
manually (for various reasons, typically because the skeletons generated
by gdbus-codegen are too simplistic and limiting). Previously, these
projects would have had to write the GDBusInterfaceInfo manually, which
is painstaking and error-prone.

The new --interface-info-[body|header] options are very similar to
--[body|header], but mutually exclusive with them.

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

https://bugzilla.gnome.org/show_bug.cgi?id=795304
2018-06-14 18:57:53 +01:00