Commit Graph

7494 Commits

Author SHA1 Message Date
Marc-André Lureau
af1777d3d3 meson: compile GUnixCredentialsMessage on all platforms
The header is now also installed under the common GIO include directory.

Sorry if it breaks any build, you had to use the correct header path.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
37cab227fd gio: compile GSocketAddress with AF_UNIX on all platforms
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
3308cfb020 gio: compile GUnixSocketAddress on all platforms
Move the header under the common GIO include directory.

Sorry if it breaks any build, you had to use the correct header path.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
4339192b53 gio: add fallback afunix.h header
afunix.h is only recently distributed with Windows SDK & MinGW.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:23 +04:00
Sebastian Wilhelmi
c74177337d gdbusmessage: Disallow zero-length elements in arrays
They are not allowed in the specification, and can lead to infinite
loops when parsing.

That’s a security issue if your application is accepting D-Bus messages
from untrusted peers (perhaps in a peer-to-peer connection). It’s not
exploitable when your application is connected to a bus (such as the
system or session buses), as the bus daemons (dbus-daemon or
dbus-broker) filter out such broken messages and don’t forward them.

Arrays of zero-length elements are disallowed in the D-Bus
specification: https://dbus.freedesktop.org/doc/dbus-specification.html#container-types

oss-fuzz#41428, #41435
Fixes: #2557
2022-01-26 13:04:49 +00:00
Sebastian Wilhelmi
6499ad5356 gdbusmessage: Disallow empty structures/tuples in D-Bus messages
They are disallowed in the specification:
https://dbus.freedesktop.org/doc/dbus-specification.html#container-types

Helps: #2557
2022-01-26 13:04:49 +00:00
Loic Le Page
42c77c7ac7 Enable full-static build on Windows
Glib cannot be built statically on Windows because glib, gobject and gio
modules need to perform specific initialization when DLL are loaded and
cleanup when unloaded. Those initializations and cleanups are performed
using the DllMain function which is not called with static builds.

Issue is known for a while and solutions were already proposed but never
merged (see: https://gitlab.gnome.org/GNOME/glib/-/issues/692). Last
patch is from version 2.36.x and since then the
"constructor/destructor" mechanism has been implemented and used in
other part of the system.

This patch takes back the old idea and updates it to the last version of
glib to allow static compilation on Windows.

WARNING: because DllMain doesn't exist anymore in static compilation
mode, there is no easy way of knowing when a Windows thread finishes.
This patch implements a workaround for glib threads created by calling
g_thread_new(), so all glib threads created through glib API will behave
exactly the same way in static and dynamic compilation modes.
Unfortunately, Windows threads created by using CreateThread() or
_beginthread/ex() will not work with glib TLS functions. If users need
absolutely to use a thread NOT created with glib API under Windows and
in static compilation mode, they should not use glib functions within
their thread or they may encounter memory leaks when the thread finishes.

This should not be an issue as users should use exclusively the glib API
to manipulate threads in order to be cross-platform compatible and this
would be very unlikely and cumbersome that they may mix up Windows native
threads API with glib one.

Closes #692
2022-01-26 10:14:02 +01:00
Pablo Correa Gómez
d4cbe9ce4e
xdgmime: Fix unused-variable warning
../gio/xdgmime/xdgmimemagic.c:489:24: warning:
unused variable 'i' [-Wunused-variable]
  489 |           unsigned int i;
      |                        ^
2022-01-25 20:18:41 +01:00
Philip Withnall
e00069010e Merge branch 'win32-mem-monitor' into 'main'
gio/win32: add GMemoryMonitorWin32

See merge request GNOME/glib!2452
2022-01-25 18:11:53 +00:00
Marc-André Lureau
bb1b9d90ec gio/win32: add GMemoryMonitorWin32
Windows has CreateMemoryResourceNotification() API:

https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-creatememoryresourcenotification

It only notifies whether "Available physical memory is running low."

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-25 20:55:57 +04:00
Marc-André Lureau
0ed621e905 gio/tests: use g_message to print --watch result
g_debug() isn't printed by default.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-25 16:31:10 +04:00
Marc-André Lureau
06160facf3 gio/tests: simplify enum to string in memory-monitor
Also results in more robust handling, since it can get a NULL eclass.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-25 16:31:10 +04:00
Sebastian Dröge
1979bfed4b Add (array length) annotation to g_tls_certificate_new_from_pkcs12() 2022-01-25 12:39:18 +02:00
Emmanuele Bassi
ba2725f263 tests: Check "gdbus-codegen --generate-docbook"
Verify that the command line argument works, by checking it's not writing
to stdout/stderr, and that the generated file isn't empty.
2022-01-22 01:30:16 +00:00
Emmanuele Bassi
4db9d43f1a tests: Check "gdbus-codegen --generate-rst"
Verify that the command line argument works, by checking it's not writing
to stdout/stderr, and that the generate file isn't empty.
2022-01-22 01:30:16 +00:00
Emmanuele Bassi
e2fe3aa0e7 Build the reStructuredText docs for the object-manager example
Just like we build them for the DocBook. We are not including them in the
API reference, for now.
2022-01-22 01:30:16 +00:00
Emmanuele Bassi
66e4ba806a Add reStructuredText generator to gdbus-codegen
The gdbus-codegen tool generates documentation from the XML introspection
description of a D-Bus interface. Currently, only DocBook is supported at
the moment, but not every modern documentation generator can handle that
format. The reStructuredText format is a bit more well-supported,
especially in documentation generators for non-C languages.

Unlike DocBook, we get to make our own structure and conventions for how
we structure the documentation when using reStructuredText.
2022-01-22 01:30:16 +00:00
Emmanuele Bassi
5013d08315 codegen: Do not add extra paragraph elements while parsing
When parsing a comment we're adding <para> elements ourselves, but the
DocBook generator already wraps any block of text that does not start
with a <para> element with one.
2022-01-22 01:30:16 +00:00
Philip Withnall
aad2cbd2db Merge branch 'nacho/off_t' into 'main'
giowin32: use gint64 and _lseeki64

See merge request GNOME/glib!2447
2022-01-21 13:00:25 +00:00
Ignacio Casal Quinteiro
1a34988296 _g_stat_size: return goffset
Otherwise on windows we would be capped at 32bit off_t.
2022-01-20 12:22:18 +01:00
Ignacio Casal Quinteiro
1848905a99 credentials: support the local peerpid on macos
xucred does not provide the peer pid id, but this can be fetched
from the socket LOCAL_PEERPID option. Note that we only support
it when creating the credentials from a local socket, if
the credential comes from a message over a socket the peer
pid id will not be set and -1 will be returned when trying
to get the pid for the credential.
2022-01-20 10:52:01 +01:00
Simon McVittie
cc2b28b68c Merge branch 'dbus-external-sid' into 'main'
gdbus: make client work with EXTERNAL on Windows

See merge request GNOME/glib!2429
2022-01-19 18:38:20 +00:00
Marc-André Lureau
7d7b52edbd gio: make client connection work with EXTERNAL on win32
D-Bus reference implementation doesn't require more than the claimed
process SID as part of the AUTH initial data for EXTERNAL.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-18 22:09:03 +04:00
Marc-André Lureau
e66b9489b7 gio: re-use win32 SID helpers
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-18 22:08:16 +04:00
Maximiliano Sandoval R
525f20a247 docs: Replace broken link 2022-01-18 13:48:43 +00:00
Maximiliano Sandoval R
7118c16347 docs: Improve docs for gdbusutils.c 2022-01-18 13:48:43 +00:00
Marc-André Lureau
d4a66baadb gio: add win32 SID helper functions
The code is based from #1351 patch and existing similar code in
gdbusprivate.c. The next commit will replace that existing code with
those helpers.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-18 17:40:02 +04:00
Philip Withnall
ea18fcff58 Merge branch 'mwleeds/fix-codegen-typo' into 'main'
gdbus-codegen: Fix a typo in a comment

See merge request GNOME/glib!2426
2022-01-17 15:38:50 +00:00
Phaedrus Leeds
6342922d27 gdbus-codegen: Fix a typo in a comment 2022-01-11 20:03:13 -08:00
Patrick Griffis
96ce3feeb9 gtlscertificate: Add ability to load PKCS #12 encrypted files
This depends on the GTlsBackend implementing these properties
2022-01-07 11:27:56 -06:00
Ralf Habacker
229f7d4a03 Fix cross build error for Windows with gcc
This commit puts an additional underscore before the external symbol
`_g_binary_test1_resource_data` when using gcc for Windows, to match
the compiler's expectation.

Fixes #2571

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-01-06 09:20:54 +01:00
Kelvin Zhang
2a4422b0f2 Use meson dependency to link against apple framework
Using ld_flags would work, but that does not propagate ldflags to users
of glib. Meson's dependency() call will propagate apple framework
dependencies to downstream users.
2022-01-05 11:32:32 -08:00
Andy Russell
82ece18644
annotate g_content_type_guess parameter as filename 2021-12-28 15:36:54 -05:00
Philip Withnall
954a8724c2 xdgmime: Add missing S_ISREG definitions for VS2022
Otherwise building with VS2022 fails with:
```
Creating library D:/temp/29/.sw/out/323969/gnome.glib.gio-2.71.0.lib and object D:/temp/29/.sw/out/323969/gnome.glib.gio-2.71.0.exp
xdgmime.c.4b279509.obj : error LNK2019: unresolved external symbol S_ISREG referenced in function _gio_xdg_get_mime_type_for_file
xdgmimecache.c.79af418f.obj : error LNK2001: unresolved external symbol S_ISREG
D:\temp\29\.sw\out\323969\gnome.glib.gio-2.71.0.dll : fatal error LNK1120: 1 unresolved externals
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2560
2021-12-23 12:35:48 +00:00
Philip Withnall
4d6da4457a gthreadedresolver: Tighten up types and constness of parsing code
Not everything should be an int. This code is quite dated. We now try to
use `guint8*` to represent arbitrary binary data, rather than `guchar*`
(which makes it sound like some form of string).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-12-15 17:04:20 +00:00
Patrick Griffis
49e667d250 gthreadedresolver: Export g_resolver_records_from_res_query()
While it’s not a supported public part of the API, exporting this
symbol from the library means we can easily test the DNS record parser,
which is important to do since it handles untrusted data from the
network.
2021-12-15 16:55:01 +00:00
Michael Catanzaro
376e2915e2 Add test for child_err_report_fd conflation with target fds
This tests for glib#2506.
2021-12-14 13:47:31 -06:00
Michael Catanzaro
d4c486779d Add tests for GSubprocess fd conflation issues
This tests for #2503. It's fragile, but there is no non-fragile way to
test this. If the test breaks in the future, it will pass without
successfully testing the bug, not fail spuriously, so I think this is
OK.
2021-12-14 13:47:31 -06:00
Michael Catanzaro
2a7547f8a5 gsubprocess: ensure we test fd remapping on the posix_spawn() codepath
We should run test_pass_fd twice, once using gspawn's fork/exec codepath
and once attempting to use its posix_spawn() codepath. There's no
guarantee we'll actually get the posix_spawn() codepath, but it works
for now on Linux.

For good measure, run it a third time with no flags at all.

This causes the test to fail if I separately break the fd remapping
implementation. Without this, we fail to test fd remapping on the
posix_spawn() codepath.
2021-12-14 13:45:39 -06:00
Philip Withnall
f493d3fd24 Merge branch 'cxx-test' into 'main'
Removing redundant cxx test tests/cxx-test.cpp

See merge request GNOME/glib!2391
2021-12-14 15:23:16 +00:00
Emmanuel Fleury
ae345e56c2 Distribute cxx test tests/cxx-test.cpp to each module tests directory
tests/cxx-test.cpp is removed and splitted into gio/tests/cxx.cpp,
gmodule/tests/cxx.cpp and gobject/tests/cxx.cpp.

Helps issue #1434
2021-12-14 14:43:03 +01:00
Ivaylo Dimitrov
f065497acf GDesktopAppInfo: Try to always correctly set id
Specs say that on Unix id should be desktop file id from the xdg menu
specification, however, currently code just uses basename of .desktop file.
Fix that by finding the .desktop file in all the desktop_file_dirs and use
basename only as a fallback.

See https://specifications.freedesktop.org/menu-spec/latest/go01.html#term-desktop-file-id
and https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s02.html#desktop-file-id

"To determine the ID of a desktop file, make its full path relative to the
$XDG_DATA_DIRS component in which the desktop file is installed, remove the
"applications/" prefix, and turn '/' into '-'."

Also, add unit test that verifies Desktop Id is being correctly set

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
2021-12-14 11:46:57 +00:00
Philip Withnall
72377e3b6e Merge branch 'new_alloca0_newa0' into 'main'
galloca: Add new API g_alloca0 and g_newa0

Closes #475

See merge request GNOME/glib!2367
2021-11-26 12:38:46 +00:00
Nishal Kulkarni
48d0d9f76b gsocket: Use new g_alloca0() function
Replace `g_alloca()` and `memset()` with `g_alloca0()`
2021-11-26 12:24:23 +00:00
Sebastian Dröge
5fcd2495f9 De-duplicate g_nearest_pow() implementation
And put it as static inline function into a private shared header instead.
2021-11-25 14:05:42 +02:00
Michael Catanzaro
f877b82573 gresolver: add missing locking
This is sad, but GResolver has one member variable for historical
reasons, to implement the reload signal. Since it offers a global
singleton, we should make sure it's really safe to use from multiple
threads at once.
2021-11-24 09:16:11 -06:00
Michael Catanzaro
6eb741a6ac gresolver: rename internal reload function
Since there is not actually anything to reload, let's just say we emit
the reload signal.
2021-11-24 09:16:11 -06:00
Michael Catanzaro
c2b5fe9f2d gresolver: remove unneeded call to res_init()
This call was needed once upon a time, when GResolver had subclasses
that presumably relied on this. Nowadays, we have only
GThreadedResolver, which does not need it. res_init() is dangerous
because it modifies global state, so let's get rid of it.
2021-11-24 09:16:11 -06:00
Nirbheek Chauhan
ed7c3dd343 Merge branch 'wip/pwithnall/freebsd-objcopy-fix-why-oh-why' into 'main'
tests: Allow `objcopy --help` to fail, because it fails on FreeBSD

See merge request GNOME/glib!2364
2021-11-24 15:12:15 +00:00
Luca Bacci
de6da5aa73
GWin32AppInfo: Implement should_show vfunc 2021-11-24 15:48:10 +01:00
Luca Bacci
ebddb60e3e
Add vfunc checks in gappinfo.c
Fixes crashes caused by calling unimplemented vfuncs on Windows
2021-11-24 15:06:46 +01:00
Philip Withnall
dc243a5113 tests: Allow objcopy --help to fail, because it fails on FreeBSD
This is a partial revert of b248f3481c. Eventually, this commit can be
dropped once `objcopy --help` doesn’t exit with a non-zero status on
FreeBSD.

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2360#note_1318608

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-24 12:01:39 +00:00
Philip Withnall
6bdb06ff4b Merge branch 'run_command-check' into 'main'
meson: specify when commands need to succeed in run_command

See merge request GNOME/glib!2360
2021-11-24 10:31:41 +00:00
Eli Schwartz
b248f3481c
meson: specify when commands need to succeed in run_command
meson in git master now warns about a missing `check:` kwarg, and may
eventually change the default from false to true.

Take the opportunity to require `objcopy --help` to succeed -- it is
unlikely to fail, but if it does something insane happened.
2021-11-24 00:31:18 -05:00
Aleksandr Mezin
bff4db527e gdbusproxy: Make 'g-signal' signal detailed
Fixes #2536
2021-11-23 22:14:19 +06:00
Philip Withnall
56b0b8069d Merge branch 'dbus-daemon-print-address-fd' into 'main'
gtestdbus: Print the dbus address on a specific FD intead of stdout

Closes #2537

See merge request GNOME/glib!2354
2021-11-23 13:32:24 +00:00
Marco Trevisan (Treviño)
d98a52254b gtestdbus: Print the dbus address on a specific FD intead of stdout
We used to use a pipe for the dbus daemon stdout to read the defined
address, but that was already requiring a workaround to ensure that dbus
daemon children were then able to write to stdout.
However the current implementation is still causing troubles in some
cases in which the daemon is very verbose, leading to hangs when writing
to stdout.

As per this, just don't handle stdout ourself, but use instead a
specific pipe to get the address address. That can now be safely closed
once we've received the data we need.

This reverts commit d80adeaa96.

Fixes: #2537
2021-11-23 13:07:50 +00:00
Philip Withnall
1f8390c002 gdbusmessage: Remove arbitrary restriction on minimum D-Bus blob length
The code in `g_dbus_message_new_from_blob()` has now been fixed to
correctly error out on all truncated messages, so there’s no need for an
arbitrary programmer error if the input is too short to contain a valid
D-Bus message header.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2528
2021-11-23 12:57:29 +00:00
Sebastian Wilhelmi
c58be7d569 tests: Add test cases for truncated D-Bus messages
(Minor code formatting tweaks and leak fixes by Philip Withnall.)

Helps: #2528
2021-11-23 12:55:00 +00:00
Sebastian Wilhelmi
4b9a27a868 gdbusmessage: Add more bounds checking when parsing D-Bus messages
Perform strict bounds checking when reading data from the D-Bus message,
and propagate errors to the callers.

Previously, truncated D-Bus messages could cause out-of-bounds reads.

This is a security issue, but one which is only exploitable when
communicating with an untrusted peer (who might send malicious
messages). Almost all D-Bus traffic is with a session or system bus,
where the dbus-daemon or dbus-broker is trusted, and is known to have
already rejected malformed (malicious) messages.

Accordingly, this is only exploitable with peer-to-peer D-Bus
conversations with an untrusted peer.

(Includes some minor cleanups from Philip Withnall.)

oss-fuzz#17408
Fixes: #2528
2021-11-23 12:32:31 +00:00
Michael Catanzaro
82999879bc gtlsconnection: warn about footguns of using a non-default database
Since
https://gitlab.gnome.org/GNOME/glib-networking/-/merge_requests/173,
there is now a really surprising implication to using a non-default
GTlsDatabase: your database could do nothing at all other than wrap the
default database, which you would expect to result in no behavior
changes, but in fact it causes fewer security checks to be performed
during certificate verification. This is because certificate
verification moved from GTlsDatabase to GTlsConnection, allowing for
more security checks to be performed. But if using a non-default
GTlsDatabase, we have to fall back to letting GTlsDatabase to the
verification, as before.

This is the best we can do. It's not a regression for applications,
because it means applications get the previous pre-2.72 behavior. But it
does mean that new security checks added in 2.72 are not applied, which
is unfortunate, so we should warn developers about this.
2021-11-22 15:56:56 +00:00
Michael Catanzaro
a6a41cfc17 gtlscertificate: tone down warning about g_tls_certificate_verify() 2021-11-22 15:56:56 +00:00
Michael Catanzaro
5f585225a2 gtlsdatabase: tone down warning about g_tls_database_verify_chain()
This is only true for the default GnuTLS backend. It is not true for the
OpenSSL backend, so let's say "may" instead of "will."
2021-11-22 15:56:56 +00:00
Michael Catanzaro
3b3d56a45c gtlsdatabase: remove stray "Since: 2.70"
This feature has been reverted for now because I messed up the
implementation and it was doing sync I/O during async API calls. Oops!
Since it's not present in 2.70 nor in 2.72, let's remove the reference
to the exact GLib version that this behavior was introduced in. I'd like
to get it working properly for 2.74, but it's not ready yet and just
changing the version to 2.74 feels optimistic.
2021-11-22 15:56:56 +00:00
Sebastian Dröge
6d8045ddb4 Merge branch 'gdbus-call-interactive' into 'main'
gdbus: Add --interactive option to `gdbus call`

See merge request GNOME/glib!2329
2021-11-22 13:58:46 +00:00
Philip Withnall
8e185e12c9 tests: Fix a flaky wait in converter-stream
Rather than waiting for a fixed period of time, poll in a loop until the
condition the test is expecting is true.

A better solution would be to use a `GSource` and wait until that’s
dispatched. But doing so might affect the behaviour of the
`GInputStream` under test, so busy-wait instead.

Fixes this CI failure: https://gitlab.gnome.org/GNOME/glib/-/jobs/1630758

```
(some socket debug output)
Bail out! GLib-GIO:ERROR:../gio/tests/converter-stream.c:1037:test_converter_pollable: assertion failed (res == -1): (1 == -1)
```

I could not reproduce the failure remotely with a few hundred
invocations of the test, so it might only present itself on BSD, which
presumably has different socket timing behaviour from Linux.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-22 13:22:25 +00:00
Philip Withnall
40037ebbfc tests: Use g_assert_*() rather than g_assert() in converter-stream.c
`g_assert()` is compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-22 13:20:17 +00:00
Alexander Kanavin
e161c62292 gio/tests/codegen.py: bump timeout to 100 seconds
This may be necessary on overloaded CI systems.
2021-11-18 14:07:11 +01:00
Frederic Martinsons
296a8c6522 Sort output of gsettings command-line tool
Closes #1781

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-11-18 08:59:55 +01:00
Philip Withnall
b09ccc4635 Merge branch 'fix_all_warnings' into 'main'
Fix final warnings in Windows code

See merge request GNOME/glib!2323
2021-11-17 15:15:46 +00:00
Emmanuel Fleury
22037bfab2 Fix set but unused parameter warning in gio/tests/gio-du.c
gio/tests/gio-du.c: In function 'main':
gio/tests/gio-du.c:74:11: error: parameter 'argc' set but not used
   74 | main (int argc, char **argv)
      |       ~~~~^~~~
2021-11-17 14:40:38 +01:00
Emmanuel Fleury
dea0ec3df6 Fix signedness warning in gio/ginputstream.c
gio/ginputstream.c: In function 'g_input_stream_real_skip':
gio/ginputstream.c:433:31: error: comparison of integer expressions of different signedness: 'goffset' {aka 'long long int'} and 'long long unsigned int'
  433 |               (start + count) > (guint64) end)
      |                               ^
2021-11-17 14:40:38 +01:00
Emmanuel Fleury
264055f3c0 Fix signedness warnings in gio/gwin32appinfo.c
gio/gwin32appinfo.c: In function 'uwp_package_cb':
gio/gwin32appinfo.c:3383:17: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
   for (i = 0; i < supported_extgroups->len; i++)
                 ^
gio/gwin32appinfo.c:3389:29: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
       for (i_ext = 0; i_ext < grp->extensions->len; i_ext++)
                             ^
gio/gwin32appinfo.c:3430:35: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
           for (i_verb = 0; i_verb < grp->verbs->len; i_verb++)
                                   ^
gio/gwin32appinfo.c:3463:33: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
       for (i_hverb = 0; i_hverb < ext->verbs->len; i_hverb++)
                                 ^
gio/gwin32appinfo.c:3478:17: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
   for (i = 0; i < supported_protocols->len; i++)
                 ^
gio/gwin32appinfo.c:3541:33: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
       for (i_hverb = 0; i_hverb < url->verbs->len; i_hverb++)
                                 ^
gio/gwin32appinfo.c: In function 'g_win32_app_info_launch_internal':
gio/gwin32appinfo.c:4799:37: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
           for (p_index = 0; p_index <= g_strv_length (envp); p_index++)
                                     ^~
2021-11-17 14:40:38 +01:00
Emmanuel Fleury
f9b4a557b1 Fix signedness warning in gio/gwin32packageparser.c
gio/gwin32packageparser.c: In function 'WIN32_FROM_HRESULT':
gio/gwin32packageparser.c:99:30: warning: comparison of integer expressions of different signedness: 'long unsigned int' and 'long int'
   if ((hresult & 0xFFFF0000) == MAKE_HRESULT (SEVERITY_ERROR, FACILITY_WIN32, 0) ||
                              ^~
2021-11-17 14:40:28 +01:00
Hristo Venev
9bd4730008 gsubprocess: Add G_SUBPROCESS_FLAGS_SEARCH_PATH_FROM_ENVP 2021-11-17 12:27:46 +00:00
Philip Withnall
511c5f5bf0 tests: Wait for gdbus-testserver to die when killing it
This was previously done (by commit 63038d1e4c) in one of the cases
where `kill_test_service()` was called — but not the other.

This meant that one instance of `gdbus-testserver` could still be
around when (as it happens, due to the order of the tests) the
`/gdbus/proxy/no-match-rule` test was run. It would start a second
instance of `gdbus-testserver`, which would exit early due to the test
name still being owned on the bus. The first (killed) instance of
`gdbus-testserver` would then exit, leaving no test servers running, and
hence the new test would fail.

This was being seen as frequent CI failures, particularly on FreeBSD
(must have slightly different timing for process signalling and
termination from Linux).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-16 22:47:15 +00:00
Michael Catanzaro
d1e9e0c094 gsocketclient: deprecate tls-validation-flags property
It doesn't work as expected, and you shouldn't be trying to use it
anyway.
2021-11-16 15:21:22 +00:00
Michael Catanzaro
38de97c148 gtlsclientconnection: deprecate validation-flags property
It doesn't work as expected, and you shouldn't be trying to use it
anyway.
2021-11-16 15:21:21 +00:00
Michael Catanzaro
780af9cff3 Document potential footgun with GTlsCertificateFlags
Once upon a time, we tried to return all possible certificate errors,
but it never actually worked reliably and nowadays we have given up.
This needs to be documented because a reasonable developer would not
expect it.

Because mistakes could be security-critical, I decided to copy the same
warning in several different places rather than relying only on
cross-referencese.
2021-11-16 15:21:21 +00:00
Sebastian Dröge
6a7187cae4 Merge branch 'actions-test-fix' into 'main'
tests: Drop arbitrary and flaky waits from actions tests

See merge request GNOME/glib!2336
2021-11-16 14:37:24 +00:00
Maurice
366597a10d Fix GSettings dict error macOS 2021-11-16 14:21:00 +00:00
Philip Withnall
4eafbaba94 tests: Fix two small leaks in the actions test
These are known leaks, as they were being done in tests which were
checking precondition failures.

However, since we know what happens when the failures occur, we can
still free the input data reliably, so do that.

This improves the valgrind output for `actions` to show zero definite
leaks.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-16 14:03:36 +00:00
Philip Withnall
c8fa295f6a tests: Drop arbitrary and flaky waits from actions tests
The `actions` test previously waited an arbitrary 100ms for various
D-Bus messages to be sent/received, before checking the results of those
messages.

Normally, this would work, but on heavily loaded CI systems, it would
sometimes fail. For example,
https://gitlab.gnome.org/GNOME/glib/-/jobs/1611701.

Fix that by waiting for the condition being checked to evaluate to true,
rather than waiting an arbitrary period of time. On faster machines,
this will speed the tests up too.

Assume that the global default `GMainContext` is in use, so a
`GMainContext*` pointer doesn’t have to be passed around.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-16 14:01:24 +00:00
Emmanuel Fleury
9e3a08b222 Fix signedness warning in gio/gcontenttype-win32.c
gio/gcontenttype-win32.c: In function 'get_registry_classes_key':
gio/gcontenttype-win32.c:66:78: warning: comparison of integer expressions of different signedness: 'DWORD' {aka 'long unsigned int'} and 'int'
               if (ExpandEnvironmentStringsW (wc_temp, wc_temp_expanded, len) == len)
                                                                              ^~
2021-11-12 14:58:52 +01:00
Philip Withnall
b75a16b048 gdbus: Add --interactive option to gdbus call
This allows the flag to allow interactive auth to be set. Previously, it
was unconditionally unset.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-11 11:26:22 +00:00
Lubomir Rintel
a107a328e4 gdbusproxy: Add G_DBUS_PROXY_FLAGS_NO_MATCH_RULE flag
D-Bus has an upper limit on number of Match rules and it's rather easy to hit
with a big number of proxies with signal subscriptions. This happens with
NetworkManager with hundreds of devices or connection settings. By passing
G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE to g_dbus_connection_signal_subscribe(), the
user can call AddMatch with a less granular match instead of a match per every
proxy.

Tests subsequently added by Philip Withnall.

Fixes: #1109
2021-11-04 11:44:18 +00:00
Michael Catanzaro
caf777984b Merge branch '2426-delayed-settings-null-handling' into 'main'
gdelayedsettingsbackend: Fix applying after calling g_settings_reset()

Closes #2426

See merge request GNOME/glib!2161
2021-11-03 18:03:21 +00:00
Philip Withnall
7be79cb840 Merge branch '2310-xdgmime-leaks' into 'main'
gcontenttype: Ignore intentional one-time leaks from xdgmime

Closes #2310

See merge request GNOME/glib!2268
2021-11-03 15:42:20 +00:00
Philip Withnall
fd080d8564 Merge branch 'list-model-doc-fixes' into 'main'
docs: Fix the GListModel description

See merge request GNOME/glib!2319
2021-11-03 11:46:28 +00:00
Philip Withnall
1161bd8078 Merge branch 'drop-old-xdgmime-change' into 'main'
Revert "Don't compile some unused functions in gio/xdgmime/"

See merge request GNOME/glib!2277
2021-11-02 09:28:22 +00:00
Emmanuele Bassi
192b3e6c2d docs: Fix the GListModel description
- Isolate the first meaningful paragraph, for gi-docgen's summary
- Describe get_object() as a binding API
- Fix reference to get_item() inside get_item_type()
2021-11-01 18:41:50 +00:00
Philip Withnall
726c44c348 Merge branch '2400-dbus-race' into 'main'
gdbusconnection: Fix race between method calls and object unregistration

Closes #2400

See merge request GNOME/glib!2265
2021-11-01 18:37:17 +00:00
Pablo Correa Gómez
14c5589ed6
gdbusaddress: setuid error message references AT_SECURE
g_check_setuid does more than setuid checks when using AT_SECURE.
Make sure that it is referenced in the error message to help
users debug in case or errors

Closes #2518
2021-11-01 15:54:55 +01:00
Philip Withnall
3dcae415a4 Revert "Don't compile some unused functions in gio/xdgmime/"
This reverts commit 14e46ca288.

Diverging from upstream xdgmime is a maintenance burden, and this
isn’t really much additional code to compile. It should be dropped by
the linker since it’s unused.

See https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/15.
2021-11-01 12:06:26 +00:00
Philip Withnall
e4bb09d8ec Merge branch 'fix-win32-app-info-registry-key-assert' into 'main'
GWin32AppInfo: Do not assert about successful open'ing of registry keys

See merge request GNOME/glib!2260
2021-11-01 10:41:31 +00:00
Philip Withnall
34ce204fd7 tests: Add D-Bus object/subtree unregistration tests
These tests cover the fixes from the previous two commits.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
117b748e44 gdbusconnection: Fix race between subtree method call and unregistration
Fix another variant of the previous commit, this time specific to the
idle callback of a method call on a subtree object, racing with
unregistration of that subtree.

In this case, the `process_subtree_vtable_message_in_idle_cb()` idle
callback already has a pointer to the right `ExportedSubtree` struct,
but again doesn’t have a strong reference to it.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
50fbf05d61 gdbusconnection: Fix race between method calls and object unregistration
If `g_dbus_connection_unregister_object()` (or `unregister_subtree()`)
was called from one thread, while an idle callback for a method call (or
a property get or set) was being invoked in another, it was possible for
the two to race after the idle callback had checked that the
object/subtree was registered, but before it had finished dereferencing
all the data related to that object/subtree.

Unregistering the object/subtree would immediately free the data,
leading the idle callback to cause a use-after-free error.

Fix that by giving the idle callback a strong reference to the data from
inside the locked section where it checks whether the object/subtree is
still registered.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
c8c2ed4af5 gdbusconnection: Make ExportedInterface/ExportedSubtree refcounted
This is needed for an upcoming change which decouples their lifecycle
from their presence in the `map_id_to_ei` and `map_id_to_es` hash
tables.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
a497fdf302 gdbusconnection: Add some ownership annotations
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-10-28 14:53:48 +01:00
Philip Withnall
310f2c1632 gdbusconnection: Move ExportedSubtree definition
Move it further up the file, but make no changes to it. This will help
with a subsequent commit.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
44cbba5d78 gsettings: Drop internal delayed member
This introduces no functional changes; it only simplifies the code.

Instead of maintaining a separate pointer to the backend iff it’s a
`GDelayedSettingsBackend`, just test the `backend` pointer’s type.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2426
2021-10-26 14:29:31 +01:00
Philip Withnall
0101ccba16 gsettings: Clarify that g_settings_get_child() inherits delay-apply
Previously, the delay-apply status of the parent `GSettings` object
would be partially inherited: `settings->priv->backend` in the child
`GSettings` object would point to a `GDelayedSettingsBackend`, but
`settings->priv->delayed` would be `NULL`.

The expectation from https://bugzilla.gnome.org/show_bug.cgi?id=720891
was that `get_child()` would fully inherit delay-apply status.

So, ensure that `settings->priv->delayed` is correctly set to point to
the delayed backend when constructing any `GSettings`. Update the tests
to work again (presumably the inverted test was an oversight in the
original changes).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2426
2021-10-26 14:25:51 +01:00
Philip Withnall
3db22ab8db gsettings: Improve documentation formatting slightly
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-10-26 14:02:54 +01:00
Philip Withnall
05523b7503 tests: Use a helper macro to drop redundant code in gsettings test
This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-10-26 13:38:22 +01:00
Philip Withnall
8b443c3556 gdelayedsettingsbackend: Fix applying after calling g_settings_reset()
`g_settings_reset()` changes the value of the setting to `NULL`;
`add_to_tree()` was not handling that correctly.

Add a unit test.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2426
2021-10-26 13:38:22 +01:00
Emmanuel Fleury
8444dc5695 Fix cast from pointer to integer of different size warning in gio/gwin32appinfo.c 2021-10-26 11:48:48 +00:00
Marc-André Lureau
b26855579c gio: fix GFile doc indentation and nullable annotations
Add missing (nullable), and use 2-space indentation to avoid markdown
pre-formatted blocks when unwanted.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-10-25 12:57:13 +01:00
Marc-André Lureau
3a6e8bc887 gio: check the given child name is not an absolute path
As this would have undesirable consequence.

Quoting Philip Withnall:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2305#note_1294729:

  The documentation never said anything about accepting absolute paths,
  so any code which is relying on that is relying on undocumented
  behaviour. We’re allowed to change that.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-10-25 12:57:13 +01:00
Marc-André Lureau
1df7c2ea80 gio: document g_file_get_relative_path() with absolute path
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-10-25 12:57:13 +01:00
Philip Withnall
464470dd8f Merge branch '2507-file-enumerator-docs' into 'main'
gfileenumerator: Warn if name is not available for get_child()

Closes #2507

See merge request GNOME/glib!2307
2021-10-21 11:58:32 +00:00
Philip Withnall
b6424b5ce1 gfileenumerator: Warn if name is not available for get_child()
`standard::name` must be available for `g_file_enumerator_get_child()`
to work. Emit a critical warning and return if it’s not. This is similar
to the existing behaviour in `g_file_enumerator_iterate()`.

Improve the documentation to mention this.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2507
2021-10-21 12:23:06 +01:00
Philip Withnall
e508a0a8df gfileenumerator: Upgrade existing warning to critical warning
The code cannot function correctly if the `standard::name` attribute is
not present, so upgrade the existing warning to a critical warning and
return if it fails in `g_file_enumerator_iterate()`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2507
2021-10-21 12:23:06 +01:00
Philip Withnall
0630272388 gfileenumerator: Add missing precondition to get_child()
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2507
2021-10-21 12:23:06 +01:00
Philip Withnall
9b1b04587c gunixmounts: Drop references to pamconsole mount option
It was Red Hat specific when it was introduced in 2004, was never
supported by mount(8) upstream, and was removed entirely in 2008.

It’s confusing for GLib to keep references to it around.

Thanks to Karel Zak for digging up the history of it:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2298#note_1294519

And thanks to Xidorn Quan for looking into it in the first place (see
!2298).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-10-21 12:22:54 +01:00
Emmanuel Fleury
db5a9d8397 Fix signedness warning in gio/gsocket.c
gio/gsocket.c: In function 'g_socket_get_available_bytes':
gio/gsocket.c:3141:17: warning: comparison of integer expressions of different signedness: 'u_long' {aka 'long unsigned int'} and 'int'
       if (avail == -1)
                 ^~
gio/gsocket.c: In function 'g_socket_send_messages_with_timeout':
gio/gsocket.c:5283:19: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
     for (i = 0; i < num_messages; ++i)
                   ^
gio/gsocket.c:5308:76: warning: operand of ?: changes signedness from 'int' to 'gsize' {aka 'long long unsigned int'} due to unsignedness of other operand
         result = pollable_result == G_POLLABLE_RETURN_OK ? bytes_written : -1;
                                                                            ^~
2021-10-20 17:09:50 +02:00
Emmanuel Fleury
23e9017aff Fix signedness warning in gio/win32/gwinhttpfile.c
gio/win32/gwinhttpfile.c: In function 'g_winhttp_file_query_info':
gio/win32/gwinhttpfile.c:554:13: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long long unsigned int'}
           n == wcslen (content_length))
             ^~
2021-10-19 18:44:38 +02:00
Emmanuel Fleury
a16d6398d7 Fix signedness warning in gio/win32/gwin32fsmonitorutils.c
gio/win32/gwin32fsmonitorutils.c: In function 'g_win32_fs_monitor_handle_event':
gio/win32/gwin32fsmonitorutils.c:107:11: warning: comparison of integer expressions of different signedness: 'GFileMonitorEvent' {aka 'enum <anonymous>'} and 'int'
   if (fme != -1)
           ^~
2021-10-19 18:44:38 +02:00
Emmanuel Fleury
059dc76ae1 Fix signedness warnings in gio/win32/gwinhttpvfs.c
gio/win32/gwinhttpvfs.c: In function 'g_winhttp_vfs_get_file_for_uri':
gio/win32/gwinhttpvfs.c:172:17: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int'
   for (i = 0; i < G_N_ELEMENTS (winhttp_uri_schemes); i++)
                 ^
gio/win32/gwinhttpvfs.c: In function 'g_winhttp_vfs_get_supported_uri_schemes':
gio/win32/gwinhttpvfs.c:210:17: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int'
   for (i = 0; i < G_N_ELEMENTS (winhttp_uri_schemes); i++)
                 ^
2021-10-19 18:44:38 +02:00
Philip Withnall
aa729f0bbf Merge branch 'modern-nm-properties-changed' into 'main'
gio: Stop using deprecated NM PropertiesChanged signal

Closes #2505

See merge request GNOME/glib!2291
2021-10-18 12:15:51 +00:00
Philip Withnall
c8e78f395b Merge branch 'fatal-meson-warnings' into 'main'
meson: fix warnings for extract_all_objects function

See merge request GNOME/glib!2286
2021-10-18 11:57:50 +00:00
Philip Withnall
2423419a29 Merge branch 'static-analysis' into 'main'
fix issues found by svace static code analyzer

See merge request GNOME/glib!2285
2021-10-18 11:03:33 +00:00
Eli Schwartz
abb8e1c3a0 meson: fix warnings for extract_all_objects function
The "recursive:" kwarg is available in the targeted minimum version of
meson, and is basically required if you want to not emit warnings and
maybe error with --fatal-meson-warnings.

There are two basic solutions to this problem:

- The current default behavior is false, so explicitly opt in to that
  value. None of these internal libraries use recursive objects anyway.

- Use link_with to link to the static library directly, rather than the
  extracted objects.

Option 2 is what used to be done before commit
62af03bda8, but it only works with meson
>=0.52 and previously had buggy behavior.

Since the minimum version of meson is now 0.52, it is safe to revert
that commit and go back to using link_with, and therefore option 2 is
chosen.
2021-10-18 11:50:49 +01:00
Egor Bychin
9f1c59eef2 add OOM handling in mimemagic 2021-10-15 14:15:43 +03:00
Egor Bychin
b32727d43d gsocks5proxy: Fix buffer overflow on a really long domain name 2021-10-15 14:15:43 +03:00
Egor Bychin
328bd31631 gsocket: Add ignorant of an fcntl return value 2021-10-15 14:15:43 +03:00
Egor Bychin
cdb9762072 gsettings-mapping: Fix HANDLE being treated as unsigned 2021-10-15 14:15:43 +03:00
Egor Bychin
a50e605d52 gproxyaddressenumerator: Fix string leakage on an invalid input 2021-10-15 14:15:43 +03:00
Egor Bychin
9dc7475f93 gopenuriportal: Fix GVariantBuilder and string leakage on g_open failure 2021-10-15 14:15:38 +03:00
Julian Andres Klode
643fc7ea49 gnetworkmonitornm: Do not re-update cached property
GDBusProxy already takes care of updating the cached property
before emitting the signal, so there is no need to do this
a second time ourselves.
2021-10-12 17:31:42 +02:00
Julian Andres Klode
f419966808 gnetworkmonitornm: Stop using removed PropertiesChanged signal
Use the org.freedesktop.DBus.Properties interface to listen
to PropertiesChanged signals on /org/freedesktop/NetworkManager.

NetworkManager used to provide its own legacy PropertiesChanged
signal, but that was dropped in
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/853

This requires NetworkManager >= 1.2 (2016)

Fixes: #2505
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1946196
2021-10-12 17:22:55 +02:00
Egor Bychin
e90eaff490 gmarshal-internal: Fix string leakage due to misplaced check 2021-10-11 13:59:05 +03:00
Egor Bychin
5a032f32ea glocalfileinfo: Fix atime/mtime mix due to bad copy/paste 2021-10-11 13:56:43 +03:00
Egor Bychin
16ce10eb3c glocalfile: Fix g_stat return value not being checked 2021-10-11 13:55:17 +03:00
Egor Bychin
84affed056 gdbusauthmechanismsha1: Fix pointer being freed after being NULLed 2021-10-11 13:54:07 +03:00
Egor Bychin
36531f7015 gcontenttype: Fix strchr failure leading to a NULL dereference 2021-10-11 13:52:26 +03:00
Simon McVittie
4023c9b567 Merge branch '2500-object-manager-path-validation' into 'main'
gdbusobjectmanagerserver: Disallow child objects at `/`

Closes #2500

See merge request GNOME/glib!2282
2021-10-06 12:03:30 +00:00
Philip Withnall
f0e0754f62 gdbusobjectmanagerserver: Disallow child objects at /
Previously, the code validated that child objects have a path with the
object manager strictly as a prefix. That doesn’t work in the case where
the object manager’s path is `/`. This case is not recommended, but is
supported.

If the object manager’s path is `/`, validate that child objects’ paths
are not equal to it. If they are equal to it, warn the user rather than
emitting a critical warning, since we can’t expect any users who’ve not
been compliant with the spec to instantly rework their D-Bus APIs.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2500
2021-10-06 12:34:41 +01:00
Guido Günther
7665b748bb gappinfo: Add launch-started signal
Emit this when we're about to spawn or DBus activate a GAppInfo.  This
allows lauchers to keep the appinfo associated with a startup id.

We use a GVariant to allow for future exansion of the supplied data.
2021-10-04 10:29:08 +02:00
Guido Günther
5890b2bdea gdesktopappinfo: Emit "launched" and "launch-failed" signals for DBus activation too
When using g_desktop_app_info_launch_uris_as_manager the "launched"
signal allows to map a desktop-startup-id to a GAppInfo. Make this
possible for DBus activation too.

Since we don't have a PID there we pass a 0. Update the signal
description accordingly.
2021-10-04 10:29:08 +02:00
Guido Günther
bd7a3e2561 gappinfo: Modernize GAppInfo signals docs a bit
Use type::signal instead of ::signal so gtk-doc can create links and use
`` for variable names and GVariant type string bits.
2021-10-04 10:29:08 +02:00
Philip Withnall
1c37f08004 gdbusobjectmanagerserver: Factor out child object path validation
This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2500
2021-10-01 10:33:17 +01:00
Philip Withnall
24644208cf giomodule: Skip introspection of two virtual plugin functions
These should be implemented by loadable IO module libraries, but are not
callable in GLib itself.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2498
2021-09-29 13:36:04 +01:00
Philip Withnall
36408b119f Merge branch '2404-task-docs-main-context' into 'main'
gtask: Document dependency on GMainContext more explicitly

Closes #2404

See merge request GNOME/glib!2264
2021-09-28 12:47:50 +00:00
Bart Jacobs
1348b36dda g_simply_proxy_resolver_set_ignore_hosts: add missing GIR annotations 2021-09-28 10:24:48 +00:00
Philip Withnall
f31e5e6c66 tests: Re-enable contenttype tests under AddressSanitizer
This is a partial revert of commit
f378352051, as the previous commits have
silenced the AddressSanitizer warnings for `GContentType`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2310
2021-09-27 13:14:00 +01:00
Philip Withnall
c2562bdf58 gcontenttype: Ignore intentional one-time leaks from xdgmime
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2310
2021-09-27 13:13:40 +01:00
Philip Withnall
60173d0a38 Merge branch 'xdgmime_update' into 'main'
Updating xdgmime

See merge request GNOME/glib!2029
2021-09-27 11:50:48 +00:00
Philip Withnall
ef72bed1c0 gtask: Document dependency on GMainContext more explicitly
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2404
2021-09-24 07:57:49 +01:00
Daniel Cheng
2f98cbe483 Remove function pointer casts when calling xdg_run_command_on_dirs().
The function pointer casts silence the compiler and allow the code to
build (and even run in the typical case). However, when building with
control flow integrity checks, the runtime (rightfully) complains about
calling a function via a mismatched function pointer type.
2021-09-23 21:56:21 +02:00
Philip Withnall
38869ece24 xdgmime: Prevent infinite loops from badly-formed MIME registrations
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1875
2021-09-23 19:23:33 +02:00
Philip Withnall
fa6f45536d 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>
2021-09-23 19:23:33 +02:00
Sébastien Wilmet
b765c7950c gio/xdgmime/: LGPLv2+ -> LGPLv2.1+
https://bugzilla.gnome.org/show_bug.cgi?id=776504
2021-09-23 19:23:33 +02:00
Руслан Ижбулатов
e4d1813368 xdgmime: Finer handling for cases where mmap() is not available
Allocate an empty cache object, check cache objects for being empty
before using them.
Otherwise the code will re-read cache every 5 seconds, as NULL cache
does not trigger the code that stores mtime, which makes the cache
file appear modified/unloaded permanently.

https://bugzilla.gnome.org/show_bug.cgi?id=735696
2021-09-23 19:23:33 +02:00
Matthias Clasen
e7822bd303 Silence an uninitialize variable warning 2021-09-23 19:23:33 +02:00
Matthias Clasen
14e46ca288 Don't compile some unused functions in gio/xdgmime/ 2021-09-23 19:23:33 +02:00
Matthias Clasen
a1bfe899ab Don't give up too early when collecting mime types
Since returning exactly one match has special significance, don't
give up matching before we've found at least 2 types. Also, make
sure that we don't return the same mime type more than once.
Bug 541236.
2021-09-23 19:23:33 +02:00
Emmanuel Fleury
b4893986b0 Force to use the config.h header file (required for HAVE_MMAP macro) 2021-09-23 11:32:02 +02:00
Emmanuel Fleury
3d2ac608de Update gio/xdgmime with commit 722325f of xdgmime project 2021-09-23 11:32:02 +02:00
Philip Withnall
3b4a34c29a gdbusobjectmanagerclient: Remove an unused label
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-09-22 18:39:46 +01:00
Philip Withnall
8d82453cf1 gdbusobjectmanagerclient: Don’t warn if removing an interface fails
If an `InterfacesRemoved` signal is received for an object which doesn’t
exist in the local map of interfaces, don’t emit a warning.

This seems to happen in the real world (see #2401). Without a trace of
the D-Bus traffic it’s not possible to know exactly what situation is
causing this, but it seems possible that the peer could disappear and
its `notify::name-owner` signal could be processed before its
`InterfacesRemoved` signal, or something similar.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2401
2021-09-22 18:34:08 +01:00
Luca Bacci
0460e78bc6
GWin32AppInfo: Remove assertion on the opened registry key
Relax assertion about opened registry key as it may have been removed
in the meantime between enumeration and when opening, or (more likely)
we may not have the required permissions to open the some enumerated
keys (i.e. RegOpenKeyExW fails and returns ERROR_ACCESS_DENIED).

Fixes https://gitlab.com/inkscape/inbox/-/issues/5669
2021-09-21 16:09:23 +02:00
Philip Withnall
6483808df6 Merge branch 'fix-2471' into 'main'
g_output_stream_write_all: Allow NULL empty buffer

Closes #2471

See merge request GNOME/glib!2243
2021-09-21 10:40:14 +00:00
James Westman
f6ddce4b16 g_output_stream_write_all: Allow NULL empty buffer 2021-09-21 10:40:14 +00:00
Philip Withnall
45588107c6 Merge branch 'gio-add-gsettings-nullable-annotations' into 'main'
gsettings: Add various missing (nullable) or (not nullable) annotations

See merge request GNOME/glib!2242
2021-09-21 10:39:37 +00:00
Philip Withnall
afaa08142b Merge branch 'object-manager-doc-wrong-class' into 'main'
Fix documentation for g_dbus_object_manager_get_object().

See merge request GNOME/glib!2257
2021-09-21 10:19:44 +00:00
Robert Ancell
e8568e25ba Fix documentation for g_dbus_object_manager_get_object().
The class in the documentation is true for GDBusObjectManagerClient, but not for GDBusObjectManagerServer.
2021-09-21 15:24:20 +12:00
shironeko
b60cd327fe gdesktopappinfo: Return failure rather than blindly call xterm
Instead of calling xterm when it clearly does not exist and causes a silent error,
inform the user that the launch failed so they can take the right action.
2021-09-09 10:32:44 -04:00
Emmanuele Bassi
21a27f4eb7 Merge branch '2425-settings-schema-range-check' into 'main'
gsettingsschema: Fix docs for g_settings_schema_key_range_check()

Closes #2425

See merge request GNOME/glib!2160
2021-09-07 10:59:09 +00:00
Luke Yelavich
452afce221 gsettings: Add various missing (nullable) or (not nullable) annotations
Also added (transfer full) or (transfer none) annotations while I was at it.

This is the result of checking each `Returns:` line in these files. I’ve
only considered nullability and transferability, and not other (potentially
missing or incorrect) annotations.

Helps: #2227
2021-09-07 18:51:18 +10:00
Philip Withnall
4f62fdfd29 tests: Fix subsequent tests after first power-profile test failure
If the first power-profile installed test fails (for example, because
xdg-desktop-portal isn’t available), correctly tear down the dbusmock
object, or it will cause setUp() to fail when the next test in the suite
is run.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2481
2021-09-06 18:57:06 +01:00
Philip Withnall
d051ef1611 gpowerprofilemonitorportal: Set property value by default
When first creating the monitor, correctly set its property value to the
value from the portal, rather than waiting for the portal value to
change to set it.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2481
2021-09-06 18:56:12 +01:00
Philip Withnall
a37b9d8652 gpowerprofilemonitordbus: Fix a crash if no property is cached
It’s not always guaranteed that a property is cached, so handle the case
when it isn’t.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-09-06 18:55:04 +01:00
Philip Withnall
28ad07373a gpowerprofilemonitordbus: Fix a memory leak
get_cached_property() returns a new reference.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-09-06 18:54:06 +01:00
Bastien Nocera
e1819c42fb gio: Fix conditions in memory-monitor test
We were lucky that this worked in some cases (the test is racy), but we
should actually run the condition check each loop, rather than when the
function is called.

Spotted by Martin Pitt:
96a8c02d24 (r54773831)
2021-09-06 14:46:15 +02:00
Philip Withnall
51b0cd3ccc Merge branch '2343-async-result-docs' into 'main'
giotypes: Document refcounting of source object for GAsyncReadyCallback

Closes #2343

See merge request GNOME/glib!1988
2021-08-19 11:38:10 +00:00
Philip Withnall
e31aa76045 Merge branch '2316-dbus-session-hardening-again' into 'main'
Revert "gdbus: Use DBUS_SESSION_BUS_ADDRESS if AT_SECURE but not setuid"

Closes #2316

See merge request GNOME/glib!2212
2021-08-19 09:37:26 +00:00
Simon McVittie
052e335500 tests: Make use of g_test_fail_message()
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-19 09:49:11 +01:00
Simon McVittie
26fbd14954 tests: Use g_test_skip_printf()
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-19 09:41:08 +01:00
Philip Withnall
ae486f6dc6 Merge branch 'wip/pwithnall/gdbus-names-livelock' into 'main'
tests: Add missing wakeup calls to gdbus-names test

See merge request GNOME/glib!2157
2021-08-17 13:25:55 +00:00
Bastien Nocera
2e9842cafc gio: Simplify memory monitor tests by using assertEventually() helper
assertEventually is a helper used in a number of projects that use
dbusmock.

See https://github.com/martinpitt/python-dbusmock/issues/82
2021-08-13 01:32:31 +02:00
Bastien Nocera
66acea8418 gio: Remove left-over debug statement from memory monitor portal test 2021-08-13 01:32:31 +02:00
Bastien Nocera
18eb29897d gio: Add GPowerProfileMonitor tests
Tests both the portal and direct D-Bus variants.
2021-08-13 01:32:31 +02:00
Bastien Nocera
9645cbffa8 gio: Add portal version of GPowerProfileMonitor 2021-08-13 01:32:31 +02:00
LRN
14f583bc23 Merge branch 'filename-length' into 'main'
gwin32packageparser: Fix read past end of buffer

Closes #2454

See merge request GNOME/glib!2213
2021-08-07 05:36:40 +00:00
Michael Catanzaro
b11d3fc2f4 gtlscertificate: improve documentation
Let's explain the advantages of relying on GTlsConnection to perform
certificate verification.

Also, document that the issuer property is a little tricky, because the
issuer certificate might not be the certificate that actually gets used
in final certification path building. This is very unexpected to anybody
who is not an expert.
2021-08-04 14:39:11 -05:00
Michael Catanzaro
235401b056 gtlsdatabase: improve documentation
Because TLS certificate verification is extremely complex, the lookup
issuer function may be tempting to misuse even by experienced
developers. There is a notion that the issuer certificate will always be
used in the final certification path, but it's just not always true.
Trying to make security decisions based on the results of this function is
a trap, so let's document that.

It turns out that old versions of glib-networking actually reordered the
certificate chain to match the final verification path. This no longer
happens since a long time ago, because it was a buggy mess. Instead, we
rely on the TLS library to build the final verification path. Their path
building is not very good, but at least it's consistent. The point of
these doc updates is to clarify that only the TLS library can make
security decisions.

Document that HTTP requests may be performed to look up missing
certificates.

Finally, let's document that certificate verification using GTlsDatabase
cannot be as smart as certificate verification performed directly by
GTlsConnection.
2021-08-04 14:39:11 -05:00
Jonathan Boeing
032eceb9a1 gwin32packageparser: Fix read past end of buffer
g_win32_package_parser_enum_packages() reads beyond the end of a buffer
when doing a memcpy.  With app verifier enabled on Windows, it causes
the application to crash on startup.

This change limits the memcpy to the size of the source string.

Fixes: #2454
2021-08-04 09:19:30 -07:00
Philip Withnall
0f9c7ed021 Revert "gdbus: Use DBUS_SESSION_BUS_ADDRESS if AT_SECURE but not setuid"
This reverts commit 7aa0580cc5.

As stated in #2316, that commit was a workaround to allow gnome-keyring
and msmtp to continue to get their session bus address from
`DBUS_SESSION_BUS_ADDRESS`, even though they’re `AT_SECURE`. The timeout
on that workaround has expired so that commit is now being reverted.

Fixes: #2316
2021-08-04 16:16:16 +01:00
Philip Withnall
709df8eeb4 Merge branch 'docgen-fixes' into 'main'
Adapt documentation to gi-docgen

See merge request GNOME/glib!2206
2021-08-03 13:53:38 +00:00
Guido Günther
8704c521fd gfdonotificationbackend: Pass on category 2021-08-02 19:26:38 +02:00
Guido Günther
791218a5f5 GNotification: Allow to set a category
Some backends like the FDO one allow to set a category. This helps the
notification daemon to select a proper feedback type.
2021-08-02 19:26:38 +02:00
Emmanuele Bassi
d6f7f8e961 docs: Use the proper Markdown syntax for lists
You need to separate the first entry in the list from the preceding
paragraph, and you should add a space before the enumerating symbol.

GTK-Doc accepts a very lax Markdown syntax, but any other tool parsing
our documentation will likely fail.
2021-08-02 16:29:16 +01:00
Emmanuele Bassi
24a0c3a940 docs: Break GFileAttribute descriptions into paragraph
Keep the first paragraph short, to act as a summary.
2021-08-02 16:21:37 +01:00
Руслан Ижбулатов
ae5e016edc GWin32AppInfo: Fix missing initialization
The value should be initialized to NULL before calling
g_win32_registry_key_get_value_w(), to ensure that cleanup
can be done unconditionally afterward.
2021-08-02 14:19:35 +00:00
Emmanuele Bassi
6081e92daf docs: Match GZlib(De)Compressor section with the type name
Otherwise the introspection scanner won't be able to match the
documentation stanza to the corresponding type.
2021-08-02 13:27:55 +01:00
Руслан Ижбулатов
4e9e7bfd34 GWin32AppInfo: re-trigger registry watcher from the callback
To ensure that the watch is properly re-set every time, call
watch_keys() from the watch callback. Previously the watch was only
renewed after a data update was done in a worker thread, which made
no sense, since the update function was implemented in such a way
that it can (and should) be re-triggered on each key change, until
the changes stop coming, and that can only happen if we renew
the registry watcher right away.
2021-07-31 11:01:06 +00:00
Руслан Ижбулатов
6885a29428 GWin32RegistryKey: ensure reqeueing works correctly
If a key watch is renewed from the key watch callback, it results
in the callback being NULL, since we clear it after we call it.

Rearrange the function to make sure that the changes done by the
callback function are preserved properly.
2021-07-31 10:57:44 +00:00
Руслан Ижбулатов
8c25302726 GWin32RegistryKey: Change STATUS_SUCCESS handling
This function can, in fact, return STATUS_SUCCESS. We shouldn't
assert that it doesn't.

For now interpret it just like STATUS_PENDING (i.e. APC will be called),
see how it goes (it isn't documented how the function behaves in this
case, we have to play it by ear).

Note that while we *can* use a better-documented RegNotifyChangeKeyValue() here,
it communicates back to us via event objects, which means that the registry
watcher would have to interact with the main loop directly and insert its
events (plural; one event per key) there. That would make the API more complicated.
Whereas the internal NT function communicates by calling an APC - we're good
as long as something somewhere puts the thread in alertable state.
2021-07-31 10:50:12 +00:00
Patrick Griffis
889bdb994f Add GPowerProfileMonitor 2021-07-28 15:56:02 +02:00
Bastien Nocera
92399e7114 gio: Do not block when low-memory-monitor daemon appears 2021-07-28 15:31:16 +02:00
Bastien Nocera
a7000cd989 gio: g_clear_signal_handler() can handle NULL args 2021-07-28 15:31:01 +02:00
Bastien Nocera
2e500304e3 tests: Remove unused constant in GMemoryMonitor test 2021-07-28 15:04:46 +02:00
Emmanuele Bassi
39d5f34442 Fix doc stanzas for GDataInputStream properties
There's no such thing as a GDataStream.
2021-07-27 12:50:03 +01:00
Philip Withnall
808cde540a Merge branch 'source-static-name' into 'main'
Port internal uses to use g_source_set_static_name()

See merge request GNOME/glib!2198
2021-07-26 15:05:50 +00:00
Philip Withnall
ef6a551739 Merge branch 'main' into 'main'
Fix some test suite memory leaks

See merge request GNOME/glib!2195
2021-07-26 10:06:08 +00:00
Philip Withnall
8e963e0e31 Port internal uses to use g_source_set_static_name()
This should reduce allocations.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-07-26 11:01:07 +01:00
Chun-wei Fan
8093da7ce6 GResource compiler: Prefix static [con|de]strutors with c_name
When attempting to test Windows support for building libadwaita, since we are
using multiple GResource files, one would hit linker errors where multiple
definitions of the following symbols have been defined, when
glib-compile-resources was invoked without manual register:

resource_constructor_wrapper
resource_destructor_constructor
_arrayresource_constructor
_arrayresource_destructor

In order to avoid that, just prefix the definitions of resource_constructor
and resource_destructor, like what we do when --manual-register is used, with
what we pass in with --c-name so that we ensure that we do not end up in such
name collisions.
2021-07-26 17:05:23 +08:00
GOUJON Évan
dd69955e58 gio/tests/async-splice-output-stream: Fix a memory leak 2021-07-23 22:21:23 +02:00
Philip Withnall
e74c955335 Merge branch 'g_mod' into 'main'
API: Add g_module_open_full()

Closes #203

See merge request GNOME/glib!2169
2021-07-21 21:07:06 +00:00
Philip Withnall
be012a8067 giomodule: Port to new g_module_open_full() API
Port all existing calls in GLib to the new API so that they can receive
more detailed error information (although none of them actually make use
of it at the moment).

This also serves to test the new API better through use.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #203
2021-07-21 21:54:35 +01:00
Philip Withnall
bdbe65dd40 Merge branch 'nsec-typo' into 'main'
glocalfileinfo: Fix usec/nsec confusion with filetimes on Windows

See merge request GNOME/glib!2182
2021-07-14 10:45:47 +00:00
markus
648994dba4 glocalfile: Fix the global trash dir detection
The `g_file_trash` function fails with the `Unable to find or create trash
directory` error when the global `.Trash` directory exists. This is because
the commit 7f2af262 introduced the `gboolean success` variable to signalize
the detection of the trash folder, but didn't set it in all code branches.
Since for a time this variable was not initialized the bug wasn't visible
when the trash folder existed. The bug became effective after the `success`
variable was initialized with `FALSE` by the commit c983ded0. Let's explicitly
set the `success` variable in all branches to fix the global trash dir
detection.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2439
2021-07-12 11:08:25 +01:00
Philip Withnall
7e8163b30b glocalfileinfo: Fix usec/nsec confusion with filetimes on Windows
The function which calls `SetFileTime()` works with seconds and
nanosecond, but the functions which call it are doing so with seconds
and microseconds.

Fix them so they convert to nanoseconds first.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-07-09 12:00:31 +01:00
Philip Withnall
dda45b0493 glocalfileinfo: Fix a typo in a file time utility function
The code appears to be dealing with time in units of 100ns, not 100µs,
so name the variable accordingly.

The rest of the arithmetic in that function appears consistent and
correct.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-07-09 11:52:23 +01:00
Ross Burton
289f8be1b3 gio/tests/g-file-info: don't assume million-in-one events don't happen
The modification time test creates a file, gets the modification time in
seconds, then gets the modification time in microseconds and assumes
that the difference between the two has to be above 0.

As rare as this may be, it can happen:

$ stat g-file-info-test-50A450 -c %y
2021-07-06 18:24:56.000000767 +0100

Change the test to simply assert that the difference not negative to
handle this case.
2021-07-06 19:32:54 +01:00
Michael Olbrich
3b452cb164 data-to-c.py: generate new-line at the end of the file
This is necessary when building glib with icecc. Icecc splits the build
process into two parts. The file is locally preprocessed with
-fdirectives-only to resolve any includes. This adds linemarkers to the
intermediate file. Without the new-line at the end of the file this:

 #include "gconstructor_as_data.h"
 #include "glib/glib-private.h"

Is turned into this:

const char gconstructor_code[] = "...";# 1 "glib/glib-private.h"
...

The result is a compile error:

In file included from ../glib/gio/glib-compile-resources.c:45:
gio/gconstructor_as_data.h:1: error: stray '#' in program
gio/gconstructor_as_data.h:1: error: expected identifier or '(' before numeric constant
In file included from ../glib/glib/glib-private.h:22,
                 from gio/gconstructor_as_data.h:2,
                 from ../glib/gio/glib-compile-resources.c:45:
../glib/glib/gwakeup.h:27:1: error: unknown type name 'GWakeup'
../glib/glib/gwakeup.h:28:42: error: unknown type name 'GWakeup'
../glib/glib/gwakeup.h:30:42: error: unknown type name 'GWakeup'
../glib/glib/gwakeup.h:32:42: error: unknown type name 'GWakeup'
../glib/glib/gwakeup.h:33:42: error: unknown type name 'GWakeup'
In file included from gio/gconstructor_as_data.h:2,
                 from ../glib/gio/glib-compile-resources.c:45:
../glib/glib/glib-private.h:98:3: error: unknown type name 'GWakeup'
../glib/glib/glib-private.h:99:58: error: unknown type name 'GWakeup'
../glib/glib/glib-private.h💯58: error: unknown type name 'GWakeup'
../glib/glib/glib-private.h:102:58: error: unknown type name 'GWakeup'
../glib/glib/glib-private.h:103:58: error: unknown type name 'GWakeup'
In file included from gio/gconstructor_as_data.h:2,
                 from ../glib/gio/glib-compile-resources.c:45:
../glib/glib/glib-private.h:164:53: warning: file "../glib/gio/glib-compile-resources.c" linemarker ignored due to incorrect nesting

To avoid this, generate gconstructor_as_data.h with a new-line at the end
of the file.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2021-07-02 14:42:54 +02:00
Guido Günther
693ca5eb01 gdbusobjectmanagerclient: Cancel GetManagedObjects on dispose
Make sure there's no async call lingering when disposing the object.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2021-06-28 17:04:17 +02:00
Guido Günther
c548ac0796 gdbusobjectmanagerclient: Call GetManagedObjects async
This helps to void deadlocks when two processes call interfaces on each
other one of them being org.freedesktop.DBus.ObjectManager.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2021-06-28 15:27:36 +02:00
Guido Günther
04a4da8065 gdbusobjectmanagerclient: Move weak ref helpers upwards
This allows it to be used in on_notify_g_name_owner() as well

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2021-06-28 15:27:36 +02:00
Michael Catanzaro
ed49de8b0f Merge branch 'mcatanzaro/gtlscertificate-introspection' into 'main'
gtlscertificate: Add more annotations to new properties

See merge request GNOME/glib!2166
2021-06-21 16:07:42 +00:00
Michael Catanzaro
5e19ccd237 gtlscertificate: Add more annotations to new properties 2021-06-21 16:07:42 +00:00
Michael Catanzaro
2cd187aa5e gio: add missing Since tags in GTlsConnection/GDtlsConnection 2021-06-21 09:31:17 -05:00
Michael Catanzaro
1ea88f46ff gdtlsconnection: document get_binding_data vfunc 2021-06-21 09:28:23 -05:00
Michael Catanzaro
09a4203b38 gtlsconnection: Add doc comment for GTlsConnectionClass 2021-06-21 09:28:23 -05:00
Michael Catanzaro
5e6c2e1e2c gtlsconnection: use a vfunc to implement get_negotiated_protocol()
The current code is unsafe to use from multiple threads at once.
GIOStream functions like this are supposed to be semi-threadsafe. It's
allowed for them to be called on both a reader thread and a writer
thread at the same time. Of course, it's still tricky and dangerous,
because it's only *really* threadsafe if the handshake has finished,
and API users have no plausible way to know that because the API
does not require performing an explicit handshake operation. But that's
a glib-networking problem. We can at least avoid the most obvious
threadsafety issue here in the API layer.

Note that we'll need to implement the new vfunc in glib-networking for
this to actually work.

Fixes #2393
2021-06-21 09:28:23 -05:00
Philip Withnall
72f692eae4 gdbusnamewatching: Ensure GDestroyNotify is called in correct context
The documentation for `g_bus_watch_name()` implies that the
`GDestroyNotify` for the user data will be called in the current thread
default `GMainContext`. Currently, it could be called in any thread, as
`client_unref()` can be called in any thread.

Fix that by deferring it to an idle source if `client_unref()` finalises
the `Client` object in a different thread.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-06-21 14:16:36 +01:00
Philip Withnall
323c5d7e21 tests: Add some missing main context iterations to gdbus-names
These were missing from the test before the previous commit ported from
`GMainLoop` to `GMainContext`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-06-21 14:16:03 +01:00
Philip Withnall
32e8e4ad91 tests: Port gdbus-names test entirely to GMainContext
It makes combination exit conditions a lot easier than when using
`g_main_loop_quit()` from different callbacks.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-06-21 14:15:55 +01:00
Philip Withnall
9d694f636f Merge branch 'app_name' into 'main'
gfdonotificationbackend: set app_name if available

Closes #2069

See merge request GNOME/glib!2159
2021-06-16 11:07:55 +00:00
Philip Withnall
f6fdc9b5f2 Merge branch 'mcatanzaro/readable-private-key' into 'main'
gtlscertificate: make private key properties readable

See merge request GNOME/glib!2087
2021-06-16 11:01:40 +00:00
Philip Withnall
4d6dbe0904 Merge branch 'g_dbus' into 'main'
gdbus: Add g_dbus_is_error_name() symbol for g_dbus_is_interface_name()

Closes #402

See merge request GNOME/glib!2156
2021-06-16 10:58:04 +00:00
Philip Withnall
9c7caf540e gsettingsschema: Fix docs for g_settings_schema_key_range_check()
The first sentence incorrectly said that it checked the type of the
value, and then the second sentence explicitly said it was a programmer
error to give a value of the wrong type.

According to the code, the second sentence is correct.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2425
2021-06-16 11:14:03 +01:00
nitinosiris
a70df97c63 Added test case for g_dbus_is_error_name 2021-06-16 08:06:03 +05:30
nitinosiris
5b9a8e2048 gdbus: Add g_dbus_is_error_name() symbol for g_dbus_is_interface_name()
Closes #402
2021-06-16 08:05:50 +05:30
Michael Catanzaro
022ea47603 gtlscertificate: add some doc links to PKCS #11 specification 2021-06-15 16:06:52 -05:00
Michael Catanzaro
c50e543e9d gtlscertificate: make private key properties readable
WebKit wants these private key properties to be readable in order to
implement a deserialization function. Currently they are read-only
because at the time GTlsCertificate was originally designed, the plan
was to support PKCS#11-backed private keys: private keys that are stored
on a smartcard, where the private key is completely unreadable. The
design goal was to support both memory-backed and smartcard-backed
private keys with the same GTlsCertificate API, abstracting away the
implementation differences such that code using GTlsCertificate doesn't
need to know the difference.

The original PKCS#11 implementation was never fully baked and at some
point in the past I deleted it all. It has since been replaced with a
new implementation, including a GTlsCertificate:private-key-pkcs11-uri
property, which is readable. So our current API already exposes the
differences between normal private keys and PKCS#11-backed private keys.
The point of making the private-key and private-key-pem properties
write-only was to avoid exposing this difference.

Do we have to make this API function readable? No, because WebKit could
be just as well served if we were to expose serialize and deserialize
functions instead. But WebKit needs to support serializing and
deserializing the non-private portion of GTlsCertificate with older
versions of GLib anyway, so we can do whatever is nicest for GLib. And I
think making this property readable is nicest, since the original design
reason for it to not be readable is now obsolete. The disadvantage to
this approach is that it's now possible for an application to read the
private-key or private-key-pem property, receive NULL, and think "this
certificate must not have a private key," which would be incorrect if
the private-key-pkcs11-uri property is set. That seems like a minor
risk, but it should be documented.
2021-06-15 16:06:52 -05:00
André Apitzsch
53632c84d8 gfdonotificationbackend: set app_name if available
Fixes: #2069
2021-06-15 20:55:07 +02:00
Philip Withnall
00feb4d5a9 Merge branch 'wip/wait-status' into 'main'
Distinguish more clearly between wait status and exit status

See merge request GNOME/glib!1967
2021-06-15 18:22:02 +00:00
Ondrej Holy
757cc93520 Merge branch 'unix-mount-for-docs' into 'main'
gunixmounts: Document NULL return value for g_unix_mount_for()

See merge request GNOME/glib!2145
2021-06-15 15:29:58 +00:00
Simon McVittie
e0b6b8037d Distinguish more clearly between wait status and exit status
On Unix platforms, wait() and friends yield an integer that encodes
how the process exited. Confusingly, this is usually not the same as
the integer passed to exit() or returned from main(): conceptually it's
an integer encoding of this tagged union:

    enum { EXITED, SIGNALLED, ... } tag;
    union {
        int exit_status;         /* if EXITED */
        struct {
            int terminating_signal;
            bool core_dumped;
        } terminating_signal;    /* if SIGNALLED */
        ...
    } detail;

Meanwhile, on Windows, wait statuses and exit statuses are
interchangeable.

I find that it's clearer what is going on if we are consistent about
referring to the result of wait() as a "wait status", and the value
passed to exit() as an "exit status".

GSubprocess already gets this right: g_subprocess_get_status() returns
the wait status, while g_subprocess_get_exit_status() genuinely returns
the exit status. However, the GSpawn family of APIs has tended to
conflate the two.

Confusingly, g_spawn_check_exit_status() has always checked a wait
status, and it would not be correct to pass an exit status to it; so
let's deprecate it in favour of g_spawn_check_wait_status(), which
does the same thing that g_spawn_check_exit_status() always did.
Code that needs backwards-compatibility with older GLib can use:

    #if !GLIB_CHECK_VERSION(2, 69, 0)
    #define g_spawn_check_wait_status(x) (g_spawn_check_exit_status (x))
    #endif

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-15 14:33:14 +01:00
Simon McVittie
f2be22ca52 subprocess test: Check wait status correctly
Confusingly, g_spawn_check_exit_status() takes a wait status, not an
exit status, so passing g_subprocess_get_exit_status() to it is
incorrect (although both encodings happen to use 0 to encode success
and a nonzero value to encode failure, so in practice this probably
had the desired effect).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-15 14:32:33 +01:00
Philip Withnall
bd8d139a77 tests: Add missing wakeup calls to gdbus-names.c
Following on from the previous commit, some explicit
`g_main_context_wakeup()` calls were missing from the test code which
only uses `GMainContext`.

Add them, and also add some assertions to check that these functions are
being called in the expected thread (as the code comments say).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-06-15 13:48:03 +01:00
Philip Withnall
031e5020ee Merge branch 'wip/pwithnall/local-file-monitor-deadlock' into 'main'
glocalfilemonitor: Avoid a deadlock on finalization

See merge request GNOME/glib!2155
2021-06-15 12:24:51 +00:00
Philip Withnall
1ed67a9c44 gapplication: Expose zero-valued numbers in handle-local-options
This is a bit of a compromise. Since the option parsing in
`GApplication` is built on `GOptionContext`, there’s no way to
reliably indicate that a given option was passed by the user, other than
by its value changing. If the default value is zero, but the user
explicitly passed zero, nothing changes, so it’s not obvious that the
option was explicitly provided.

When just `GOptionContext` is being used, this is fine, as that’s
obvious what will happen from the way the API is built. With
`GApplication::handle-local-options`, though, the `GVariantDict`
provided by GLib to the callback claims to only contain the values of
the options provided by the user, and no defaults.

It’s not actually possible for GLib to do that reliably.

Previously, GLib was dropping all numeric values which were zero valued
(i.e. the defaults), as they *could* have been the defaults. It seems
like a slightly better behaviour to instead *not* drop those numeric
values, and err on the side of reporting some defaults as user-provided
(even if they weren’t) rather than dropping some user-provided values
which happen to be the defaults.

This adds a test for the case of parsing a double; the cases for
integers are analogous.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2329
2021-06-15 13:04:21 +01:00
Philip Withnall
8530a6a8e4 tests: Add missing wakeup calls to gdbus-names test
The tests in `gdbus-names.c` use a mixture of `GMainLoop` and iterating
a `GMainContext` directly. Some of the helper functions based around the
`OwnNameData` struct use the `loop` `GMainLoop` even when called from
tests like `watch_with_different_context()` which themselves use
`GMainContext` directly.

Thus, it’s possible for the `GMainLoop` to not be running, while the
test is iterating on `g_main_context_iteration()`. In this case,
`g_main_loop_quit()` is a no-op and will not wake up the `GMainContext`.
This causes the test to livelock in around 1 in 1200 test runs.

Fix this by adding an explicit `g_main_context_wakeup()` call after each
`g_main_loop_quit()` call. A more comprehensive fix would be to port all
the tests in this file to iterating `GMainContext` directly, and drop
all the `GMainLoop` usage, but I don’t have time for that right now.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-06-15 13:01:28 +01:00
Philip Withnall
838dc04c76 glocalfilemonitor: Avoid a deadlock on finalization
If `g_file_monitor_source_dispatch()` drops the last reference to its
`GLocalFileMonitor`, a deadlock will occur, because disposing the
`GLocalFileMonitor` causes synchronous disposal of the
`GFileMonitorSource`, and hence an attempt to re-lock the already-locked
mutex in the `GFileMonitorSource`.

Fix that by dropping the reference to the `GLocalFileMonitor` after
unlocking.

Diagnosed by Ting-Wei Lan. The bug was originally introduced by me in
commit 592a13b483.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-06-14 15:09:52 +01:00
Philip Withnall
e522768ef4 tests: Allow GResource external data tests to use llvm-objcopy
Relax the requirement for the test to only be compiled/run under gcc,
since a version of LLVM was released which supports `--add-symbol`.

`objcopy` should be overrideable to be `llvm-objcopy` by using a machine
file as per https://mesonbuild.com/Machine-files.html#binaries.

Suggested and tested by Grigory Vasilyev.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2423
2021-06-14 14:49:59 +01:00
Philip Withnall
de74a70b7e Merge branch 'try-tls-binding-tests-again' into 'main'
Revert "tests: Deactivate tls-bindings test suite for windows"

See merge request GNOME/glib!2130
2021-06-10 12:46:12 +00:00
Philip Withnall
76ecdeffd0 Merge branch '2409-application-must-be-registered' into 'main'
gapplication: Guard g_application_mark_busy()

Closes #2409

See merge request GNOME/glib!2111
2021-06-10 12:44:13 +00:00