Commit Graph

8616 Commits

Author SHA1 Message Date
Ondrej Holy
ed24edd7c8 gunixmounts: Use fallback if libmount monitoring fails
The recently added libmount-based unix mount monitoring may fail when the
device exceeds inotify limits. Let's fallback to the older implementation
in case of the `mnt_monitor_get_fd` function failure. This among others
fixes tracker-miners failures caused by seccomp rules.

Fixes: https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/315
2024-04-23 12:50:06 +01:00
Ville Skyttä
9a4638f9f6 completion: make gsettings work in nounset mode
With the shell in nounset mode, an error is emitted on referencing
`schemadir` as it is not initialized in all code paths.

Initialize to an empty string to fix.

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
2024-04-01 15:08:15 +01:00
Sudhanshu Tiwari
fa5237650b Ported the first 3 documentation comments in gaction.c to gi-docgen 2024-03-20 11:34:33 +00:00
Philip Withnall
e83e4c5535 tests: Mark several additional tests as can_fail on GNU Hurd
These consistently fail on scheduled CI runs, which is not helping our
ability to catch Hurd regressions.

For example, https://gitlab.gnome.org/GNOME/glib/-/jobs/3709402

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

See: #3148
2024-03-19 13:01:26 +00:00
Nirbheek Chauhan
92a97c4f48 meson: Fix a needless recompilation of some gdbus tests
The gdbus-example-objectmanager visibility header was being re-created
on reconfigure, causing a needless rebuild of gdbus tests that were
using the visibility header.

All other invocations of gen_visibility_macros are via custom_target.
2024-03-13 03:32:56 +05:30
Simon McVittie
fb4b780eea glib-compile-resources: Provide placeholders for options with an argument
If we don't do this, the --help text is formatted as though the option
did not expect an argument.

IDENTIFIER is a new translated string, but it is developer-oriented,
so a missing translation is not particularly bad. COMMAND is already
present in translations.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-28 11:28:00 +00:00
Simon McVittie
5622a4a625 gdbus: Add command-line placeholder for ADDRESS
If we don't do this, the --help text is formatted as though the option
did not expect an argument.

This introduces a new translated string, but it is developer-oriented,
so a missing translation is not particularly bad.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-28 11:27:21 +00:00
Philip Withnall
9a661ab970 gsocketclient: Fix a use-after-free in g_socket_client_connected_callback()
The ref held by `data->task` may be the last one on the `GTask`. The
`GTask` stores `attempt->data` as its task data, and so when the `GTask`
is finalised, `attempt->data` is too. `connection_attempt_remove()`
needs to access `attempt->data`, so must be called before the
`g_object_unref()` in this situation.

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

Fixes: #3266
2024-02-27 09:03:03 +00:00
Philip Withnall
ca4e6f81d2 Merge branch 'wip/oholy/gvolumemonitor-leak' into 'main'
gcontextspecificgroup: Wait until stop_func is done

Closes #3258

See merge request GNOME/glib!3934
2024-02-26 18:06:45 +00:00
Luca Bacci
4337f8f735 GWinHttpFile: Check for matching attributes before sending the HTTP(S) request
We might not need to make an HTTP(S) request at all

Fixes #3080
2024-02-21 11:56:36 +01:00
Luca Bacci
c515f793e5 GWinHttpFile: Set display-name and type at the start of the query_info() function
Those attributes do not need the HTTP(S) request data, so just set them
right away.
2024-02-21 11:52:36 +01:00
Ondrej Holy
bf7d941088 gcontextspecificgroup: Wait until stop_func is done
Currently, the `stop_func` is executed on an extra thread, and the
`g_context_specific_group_remove` function returns before the `stop_func`
finishes. It may happen that the `stop_func` is never executed if the
program terminates soon after calling it. Let's wait until the `stop_func`
is done.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/3258
2024-02-20 13:39:31 +01:00
Philip Withnall
43924f7cf5 Merge branch 'fix-issue-3210' into 'main'
GWinHttpFile: Add support for G_FILE_ATTRIBUTE_STANDARD_TYPE

Closes #3210

See merge request GNOME/glib!3908
2024-02-14 09:22:36 +00:00
Luca Bacci
6ee0772146 GWinHttpFile: Add support for G_FILE_ATTRIBUTE_STANDARD_TYPE
Fixes #3210
2024-02-14 10:06:50 +01:00
Philip Withnall
434d3ff524 docs: Mention GioUnix-2.0 GIR namespace alongside gio-unix-2.0.pc
This should clarify things a little for users of language bindings, who
don’t directly use `.pc` files.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-12 17:54:10 +00:00
Philip Withnall
c498c9a8c9 docs: Split out platform specific GIO and GLib documentation
This creates `GioUnix`, `GioWin32`, `GLibUnix` and `GLibWin32`. These
bodies of documentation are in addition to the main, platform agnostic,
documentation for both libraries.

This commit necessarily includes various mechanical changes to update
the repository namespace used in various existing documentation links to
platform specific APIs.

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

Helps: #3037
2024-02-12 17:54:10 +00:00
Philip Withnall
0d9170c6b8 gio: Remove unnecessary appinfo_sources variable
There was no obvious logical need to list the `GAppInfo` subclass
sources separately in the build. It makes more sense to add them to the
platform-specific source lists, since they are platform specific.

This will be used in an upcoming commit which generates
platform-specific GIR files, so needs the full platform-specific lists
of sources.

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

Helps: #3037
2024-02-12 17:54:10 +00:00
Philip Withnall
f63cc38328 gfiledescriptorbased: Move across typedef from giotypes.h
`GFileDescriptorBased` is in `gio-unix-2.0` rather than `gio-2.0`, so
its types shouldn’t be declared in a header belonging to the latter.

This hasn’t been a problem previously because C is fine with that. But
upcoming commits are going to split the introspection scanning for
`gio-2.0` and `gio-unix-2.0`, and the introspection scanner is a little
more picky about declarations not being spread all over the place.

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

Helps: #3037
2024-02-12 17:54:10 +00:00
Philip Withnall
2cacc09398 Merge branch '3231-gir-symbols-cleanup' into 'main'
introspection: Remove various public symbols from newly generated GIRs

Closes #3231

See merge request GNOME/glib!3910
2024-02-09 10:58:29 +00:00
Philip Withnall
71801e445e gthreadedresolver: Move private testing symbols to a private header
The symbols still have to be exported from the library (since they’re
called from unit tests), but there was never any reason for them to be
in a public header.

This means they now disappear from `Gio-2.0.gir`.

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

Helps: #3231
2024-02-09 10:05:56 +00:00
Maxim Moskalets
cbcb35a77a gapplication: add GApplication:version property
This property is supposed to be used by authors of applications that use GAppliaction to output the version by --version flag or otherwise if a version is needed.

Closes #3198

Signed-off-by: Maxim Moskalets <Maxim.Moskalets@kaspersky.com>
2024-02-09 10:04:14 +00:00
Luca Bacci
665ab65e7e file_copy_fallback: Check if attributes could be retrieved
See #3210
2024-02-08 17:11:01 +01:00
Michael Catanzaro
b7ef29560d Merge branch 'statvfs-type' into 'main'
glocalfile: Support statvfs.f_type

See merge request GNOME/glib!3893
2024-02-07 14:24:52 +00:00
Philip Withnall
9eeb8a87d3 glocalfile: Support statvfs.f_type
This is another way to get the file system type from `statvfs()`, newly
added in glibc 2.39
(https://lwn.net/ml/libc-alpha/38790850.J2Yia2DhmK@pinacolada/).

This hasn’t been tested with glibc 2.39 as I don’t have it, but the
change seems fairly straightforward.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-07 10:34:59 +00:00
Philip Withnall
90ec3d3499 gtask: Clarify when GTask:completed is suitable to use
It’s not suitable to use to check if your own code has already called
`g_task_return_*()`, as it doesn’t directly correlate to that.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-07 10:34:08 +00:00
Philip Withnall
15cef2ea59 gfiledescriptorbased: Fix incorrect precondition return value
`0` is a valid FD, `-1` is not, so `-1` is more suitable to use.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-07 10:34:08 +00:00
Simon McVittie
fc7942f46b gdbus-codegen: If writing body to stdout, don't try to include header
If we're writing the body to standard output, we cannot know what the
filename of the corresponding header is going to be, but it seems
vanishingly unlikely that it will be either `stdout.h` (which we would
traditionally have generated) or `-.h` (which we would have generated
since !3886).

This makes some of the output snippets sufficiently short that black(1)
requires that they are folded into a single line.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-06 14:06:45 +00:00
Simon McVittie
5e8f053d33 tests: Exercise gdbus-codegen --interface-info-header with empty input
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-06 13:55:35 +00:00
Simon McVittie
02a3417ac4 tests: Exercise gdbus-codegen --interface-info-body with empty input
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-06 13:55:33 +00:00
Simon McVittie
6a1fdb8145 codegen: Use - instead of stdout for output to stdout
In command-line tools, ordinary filenames normally do not have
special-cased meanings, so commit 3ef742eb "Don't skip dbus-codegen tests
on Win32" was a command-line API break: in the unlikely event that a
user wanted to write to a file named exactly `stdout`, this would have
been an incompatible change.

There is a conventional pseudo-filename to represent standard output,
which is `-` (for example `cat -` is a no-op filter). Adding support
for this is technically also a command-line API break (in the very
unlikely event that a user wants to write to a file named exactly `-`,
they would now have to write it as `./-`), but filenames starting with
a dash often require special treatment anyway, so this probably will not
come as a surprise to anyone.

When the output filename is `-` we don't want to use `#ifdef _____` as
a header guard, so special-case it as `__STDOUT__` as before.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-06 11:53:06 +00:00
Philip Withnall
1757365af3 Merge branch 'dbus-codegen-tests' into 'main'
Don't skip dbus-codegen tests on Win32

Evolved from https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3857

See merge request GNOME/glib!3874
2024-02-05 10:18:28 +00:00
Maxim Moskalets
aa8ed92fba gresources: fix memory leak from libelf
Memory was leaking when allocating it inside libelf and losing the pointer to it (it was an automatic variable) when returning NULL from the get_elf function in some cases

Closes #3242

Signed-off-by: Maxim Moskalets <Maxim.Moskalets@kaspersky.com>
2024-02-03 15:23:15 +03:00
Jordan Petridis
9c65e9ba2d gio: tests: Use slightly more explicit assert functions
Found by using teyit [1] on the code

https://github.com/isidentical/teyit
2024-02-02 16:15:35 +02:00
Philip Withnall
5744f55c11 Revert "Don't skip dbus-codegen tests on Win32"
This reverts commit fbdc9a2d03.

It was not submitted through a merge request and broke CI. Reverting it
immediately to unbreak CI and hence the rest of the development
pipeline. The changes can be re-submitted as a merge request so they’re
properly tested in CI before being merged.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3857#note_1994336
2024-02-02 10:01:24 +00:00
John Ralls
fbdc9a2d03 Don't skip dbus-codegen tests on Win32
And coincidentally on Darwin either.
2024-02-01 15:17:26 -08:00
Philip Withnall
5f12851312 Merge branch 'wip/oholy/libmnt_monitor' into 'main'
gunixmounts: Use libmnt_monitor API for monitoring

See merge request GNOME/glib!3845
2024-01-31 14:30:09 +00:00
Ondrej Holy
c7254fb3ad gunixmounts: Use mnt_monitor_veil_kernel option
The previous commit enabled the `/run/mount/utab` monitoring. The problem
is that the `mount-changed` signal can be emitted twice for one mount. One
for the `/proc/mounts` file change and another one for the `/run/media/utab`
file change. This is still not ideal because e.g. the `GMount` objects for
mounts with the `x-gvfs-hide` option are added and immediately removed.
Let's enable the `mnt_monitor_veil_kernel` option to avoid this.

Related: https://github.com/util-linux/util-linux/pull/2725
2024-01-31 14:53:42 +01:00
Ondrej Holy
1abbbd761e gunixmounts: Use libmnt_monitor API for monitoring
The `GUnixMountMonitor` object implements monitoring on its own currently.
Only the `/proc/mounts` file changes are monitored. It is not aware of the
`/run/mount/utab` file changes. This file contains the userspace mount
options (e.g. `x-gvfs-notrash`, `x-gvfs-hide`) among others. There is a
problem when `/sbin/mount.<type>` (e.g. `mount.nfs`) helper programs are
used. In that case, the `/run/mount/utab` file is updated later than the
`/proc/mounts` file and thus the `GUnixMountMonitor` clients (e.g.
`gvfs-udisks2-volume-monitor`, `gvfsd-trash`) don't see the userspace
options until the next `mount-changed` signal. Let's use the `libmnt_monitor`
API for monitoring instead and emit the `mount-changed` signal also when the
`/run/mount/utab` file is changed.

Related: https://issues.redhat.com/browse/RHEL-14607
Related: https://github.com/util-linux/util-linux/pull/2607
2024-01-31 14:53:42 +01:00
Michael Catanzaro
936bb9ecfb Merge branch 'memory-monitor-portal-fix' into 'main'
tests: Fix typo in memory-monitor-portal.py.in

See merge request GNOME/glib!3860
2024-01-30 16:39:09 +00:00
Philip Withnall
8da4fc17b9 gthreadedresolver: Fix leak on error path
Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3236
2024-01-30 09:53:00 +00:00
Philip Withnall
b2144afe28 tests: Fix typo in memory-monitor-portal.py.in
This was my mistake in commit 67a9fbf1fa.

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

Helps: #3237
2024-01-30 07:38:13 +00:00
John Ralls
3ef742ebee Don't skip dbus-codegen tests on Win32
And coincidentally on Darwin either.
2024-01-28 20:07:44 -08:00
Philip Chimento
28835733a2 tests: Fix defaultvalue test on macOS
Without these includes, the g_osx_app_info_get_type() in
giotypefuncs.inc is missing a declaration.
2024-01-23 21:35:54 -08:00
Philip Withnall
67a9fbf1fa tests: Wait for memory monitor to be able to handle signals before testing
This fixes a race condition which frequently caused the
`memory-monitor-dbus.py` test to fail.

The registration of the `LowMemoryMonitor` object on the bus, and the
`GMemoryMonitorDBus`’s connection to the warning signal raced, such that
it was possible for the mock `LowMemoryMonitor` to emit a warning signal
before the `GMemoryMonitorDBus` proxy was listening, and hence the proxy
would never see the signal.

Fix this by explicitly synchronising the two before proceeding to the
tests.

Make the same changes in the `memory-monitor-portal.py` test too, even
though that one was not failing. This should remove the need for a 2s
wait on every test run.

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

Fixes: #2887
2024-01-23 11:02:48 +00:00
Philip Withnall
e0276a3a17 tests: Wait for LMM server to be available when starting test
Otherwise the test can go on to wait for a signal from the service
before it’s actually finished starting up.

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

Helps: #2887
2024-01-23 11:02:48 +00:00
Philip Withnall
1f2d9e69c9 tests: Assert correct monitor implementation is used in power-profile-monitor-dbus
This wasn’t failing, but it seems like a sensible thing to check.

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

Helps: #2887
2024-01-23 11:02:48 +00:00
Philip Withnall
6b22aaaa68 tests: Assert correct monitor implementation is used in memory-monitor-dbus
This wasn’t failing, but it seems like a sensible thing to check.

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

Helps: #2887
2024-01-23 11:02:48 +00:00
Philip Withnall
e3b81b3f0d tests: Rework assertEventually() to use GLib main context
Rather than sleeping and blocking everything, use a timeout source on
the main context so that inputs can continue to be handled while waiting
for a timeout.

This introduces no functional changes to the test.

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

Helps: #2887
2024-01-23 11:02:48 +00:00
Philip Withnall
8a4ad5f998 tests: Add some debug output to memory-monitor-dbus.py test
This will hopefully help diagnose #2887.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #2887
2024-01-22 11:22:45 +00:00
Philip Withnall
5278efbd63 tests: Ensure Python assertEventually() function uses correct main context
It should be doing already (or the tests would never work), but make it
clearer in the code that the same `GMainContext` is being iterated as is
being woken up in the rest of the test.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #2887
2024-01-22 11:22:01 +00:00