Commit Graph

30030 Commits

Author SHA1 Message Date
Simon McVittie
d4b6537651 gdbusconnection: Don't deliver signals if the sender doesn't match
Otherwise a malicious connection on a shared bus, especially the system
bus, could trick GDBus clients into processing signals sent by the
malicious connection as though they had come from the real owner of a
well-known service name.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/3268
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-01 13:42:27 +01:00
Simon McVittie
683b14b981 gdbus: Track name owners for signal subscriptions
We will use this in a subsequent commit to prevent signals from an
impostor from being delivered to a subscriber.

To avoid message reordering leading to misleading situations, this does
not use the existing mechanism for watching bus name ownership, which
delivers the ownership changes to other main-contexts. Instead, it all
happens on the single thread used by the GDBusWorker, so the order in
which messages are received is the order in which they are processed.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-01 13:27:24 +01:00
Simon McVittie
26a3fb8518 gdbusconnection: Stop storing sender_unique_name in SignalData
This will become confusing when we start tracking the owner of a
well-known-name sender, and it's redundant anyway. Instead, track the
1 bit of data that we actually need: whether it's a well-known name.

Strictly speaking this too is redundant, because it's syntactically
derivable from the sender, but only via extra string operations.
A subsequent commit will add a data structure to keep track of the
owner of a well-known-name sender, at which point this boolean will
be replaced by the presence or absence of that data structure.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 21:42:24 +01:00
Simon McVittie
7d21b719ed gdbusconnection: Factor out remove_signal_data_if_unused
No functional change, just removing some nesting. The check for whether
signal_data->subscribers is empty changes from a conditional that tests
whether it is into an early-return if it isn't.

A subsequent commit will add additional conditions that make us consider
a SignalData to be still in use and therefore not eligible to be removed.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 21:42:24 +01:00
Simon McVittie
5d7ad6897c gdbusconnection: Factor out add_signal_data()
No functional changes.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 21:42:24 +01:00
Simon McVittie
816da60571 gdbusconnection: Factor out signal_data_new_take()
No functional changes, except that the implicit ownership-transfer
for the rule field becomes explicit (the local variable is set to NULL
afterwards).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 21:42:24 +01:00
Simon McVittie
8dfea5609e gdbusconnection: Move SignalData, SignalSubscriber higher up
Subsequent changes will need to access these data structures from
on_worker_message_received(). No functional change here, only moving
code around.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 21:42:24 +01:00
Simon McVittie
1e648b677f gdbusprivate: Add symbolic constants for the message bus itself
Using these is a bit more clearly correct than repeating them everywhere.
To avoid excessive diffstat in a branch for a bug fix, I'm not
immediately replacing all existing occurrences of the same literals with
these names.

The names of these constants are chosen to be consistent with libdbus,
despite using somewhat outdated terminology (D-Bus now uses the term
"well-known bus name" for what used to be called a service name,
reserving the word "service" to mean specifically the programs that
have .service files and participate in service activation).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 21:41:53 +01:00
Simon McVittie
fd265663f2 tests: Add test coverage for signals that match the message bus's name
This is a special case of unique names, even though it's syntactically
a well-known name.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 19:14:32 +01:00
Simon McVittie
984354e02d tests: Add a test-case for what happens if a unique name doesn't exist
On GNOME/glib#3268 there was some concern about whether this would
allow an attacker to send signals and have them be matched to a
GDBusProxy in this situation, but it seems that was a false alarm.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 19:14:32 +01:00
Simon McVittie
14c3d6938e tests: Add support for subscribing to signals from a well-known name
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 19:14:32 +01:00
Simon McVittie
124b4571bb tests: Add a data-driven test for signal subscriptions
This somewhat duplicates test_connection_signals(), but is easier to
extend to cover different scenarios.

Each scenario is tested three times: once with lower-level
GDBusConnection APIs, once with the higher-level GDBusProxy (which
cannot implement all of the subscription scenarios, so some message
counts are lower), and once with both (to check that delivery of the
same message to multiple destinations is handled appropriately).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 19:08:19 +01:00
Philip Withnall
763cc3b238
2.80.0
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-03-07 21:35:05 +00:00
Philip Withnall
7c909697db Merge branch 'signals-docs' into 'main'
docs: Minor improvements to GSignal documentation

See merge request GNOME/glib!3956
2024-03-07 14:45:42 +00:00
Philip Withnall
a60e6bedae docs: Document that signal connection functions cannot fail
The documentation previously implied that they could. That’s not really
true though: they can only fail if preconditions fail, i.e. they’re
passed invalid input. That’s a programmer error, which is not something
we want to encourage people to check for at runtime (e.g. by dynamically
checking for a 0 return value).

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-03-07 13:12:07 +00:00
Philip Withnall
fafe1a14a8 docs: Minor reformatting / gi-docgenification of signals docs
This is nowhere near a complete check-through and gi-docgenification of
the signals docs, just a few bits I was looking at anyway.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3250
2024-03-07 13:12:07 +00:00
Philip Withnall
8a640f50ca docs: Document signal handler types and arguments
It seems this was missing from the documentation (or, at least, not in
an obvious place).

As spotted on
https://discourse.gnome.org/t/calling-g-main-loop-quit-from-a-signal-handler/19785.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-03-07 13:12:07 +00:00
Danial Behzadi
095142f504 Update Persian translation 2024-03-06 21:37:21 +00:00
Anders Jonsson
d3b2e8f217 Update Swedish translation 2024-03-06 18:27:35 +00:00
Andi Chandler
87ee7dea85 Update British English translation 2024-03-06 14:44:18 +00:00
Philip Withnall
a6dbfcd601 docs: Slightly rephrase signals docs to not use the first person
The rest of the documentation style is to be more indirect, so let’s
consistently use that.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-03-06 13:21:56 +00:00
Philip Withnall
536bdabd6e docs: Add subheadings to signals documentation page
Splits the text up a bit and allows linking directly to those subsections.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-03-06 13:21:30 +00:00
Baurzhan Muftakhidinov
e006624a45 Update Kazakh translation 2024-03-06 03:01:06 +00:00
Michael Catanzaro
a767439117 Merge branch 'wip/bobby285271/fix-docs-dir' into 'main'
docs: Fix building with docs enabled and introspection disabled

See merge request GNOME/glib!3955
2024-03-06 01:12:51 +00:00
Michael Catanzaro
2c2d55e95e Merge branch 'wip/bobby285271/native-gi-docgen' into 'main'
docs: Specify gi-docgen as a native dependency

See merge request GNOME/glib!3953
2024-03-06 01:12:47 +00:00
Bobby Rong
dd97c88f90 docs: Fix building with docs enabled and introspection disabled
We install gvariant-specification-1.0.html to `docs_dir` but that shouldn't require `enable_gir`.

Fixes: docs/reference/glib/meson.build:26:16: ERROR: Unknown variable "docs_dir"
Part-of: <https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3955>
2024-03-05 16:45:21 +00:00
Bobby Rong
c7476cd615 docs: Specify gi-docgen as a native dependency
gi-docgen is supposed to be ran natively on the build machine.

Part-of: <https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3953>
2024-03-05 22:23:01 +08:00
Philip Withnall
04abb73732 Merge branch 'wip/smcv/warn-if-fail' into 'main'
g_warn_if_fail: Document as always evaluating expr

See merge request GNOME/glib!3951
2024-03-05 12:25:42 +00:00
Matej Urbančič
e11d8864d5 Update Slovenian translation 2024-03-05 11:49:43 +00:00
Simon McVittie
88c76b89e0 g_warn_if_fail: Document as always evaluating expr
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-03-05 11:06:10 +00:00
Matej Urbančič
0211f06be3 Update Slovenian translation 2024-03-04 21:34:16 +00:00
Balázs Úr
a5dcd47000 Update Hungarian translation 2024-03-04 10:52:21 +00:00
Aurimas Černius
dfa3d51601 Update Lithuanian translation 2024-03-03 20:35:17 +00:00
Sabri Ünal
73d523b6be Update Turkish translation 2024-03-03 18:34:45 +00:00
Brage Fuglseth
06c173e6ca Update Norwegian Bokmål translation 2024-03-03 14:45:17 +00:00
Luming Zh
cab1d3d752 Update Chinese (China) translation 2024-03-03 09:57:03 +00:00
Yaron Shahrabani
e00ef0aa97 Update Hebrew translation 2024-03-02 22:17:15 +00:00
Artur S0
4e6f7c6c33 Update Russian translation 2024-03-02 19:48:52 +00:00
Asier Sarasua Garmendia
811b4c90ad Update Basque translation 2024-03-01 19:01:58 +00:00
Danial Behzadi
92aed1bab9 Update Persian translation 2024-03-01 17:06:24 +00:00
Khalid Abu Shawarib
d72129b56e Merge branch 'macros-docs-fix' into 'main'
docs: Fix a typo in the macros docs page

See merge request GNOME/glib!3947
2024-03-01 13:29:22 +00:00
Philip Withnall
9249dc6050 Merge branch 'check-missing-install-tag-valgrind' into 'main'
tests: Don’t run check-missing-install-tag.py test under valgrind

See merge request GNOME/glib!3940
2024-03-01 13:15:10 +00:00
Philip Withnall
dd2861cd8a Merge branch '3271-string-fix-again' into 'main'
gfileutils: Use g_format_size() for another translatable string

Closes #3271

See merge request GNOME/glib!3948
2024-03-01 12:21:42 +00:00
Philip Withnall
704d0bb297 gfileutils: Use g_format_size() for another translatable string
As with commit a3c2691c23, another
instance of the same pattern was missed.

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

Fixes: #3271
2024-03-01 11:57:50 +00:00
Danial Behzadi
83137c84e5 Update Persian translation 2024-02-29 20:17:33 +00:00
Yuri Chornoivan
18567239b5 Update Ukrainian translation 2024-02-29 18:20:49 +00:00
Philip Withnall
9ed0ce21df docs: Fix a typo in the macros docs page
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-29 13:58:53 +00:00
Daniel Mustieles
8c92fa1621 Update Spanish translation 2024-02-29 11:39:56 +00:00
Philip Withnall
8618f50d16 Merge branch 'wip/smcv/cli-placeholders' into 'main'
Add missing argument placeholders to several command-line tools

See merge request GNOME/glib!3946
2024-02-29 10:39:53 +00:00
Yaron Shahrabani
4f555c0507 Update Hebrew translation 2024-02-29 06:48:55 +00:00