Commit Graph

23274 Commits

Author SHA1 Message Date
Philip Withnall
2f91caf77e tests: Add a basic test for require-same-user D-Bus auth flag
It’s not feasible to test that the require-same-user flag can cause
authentication to fail, as that would require the build environment to
have two users available. We can, however, test that it passes when
authenticating a client and server running under the same user account.

I have manually tested that the new flag works, by running the following
as user A:
```
`$prefix/gdbus-daemon --print-env &`
gdbus call --session --dest org.freedesktop.DBus --object-path /org/freedesktop/DBus --method org.freedesktop.DBus.ListNames
```

And then running the `gdbus call` command again as user B (with the same
value for `DBUS_SESSION_BUS_ADDRESS` in the environment), which
produces:
```
Error connecting: Unexpected lack of content trying to read a line
```
(an authentication rejection)

Commenting out the use of
`G_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER` from
`gdbusdaemon.c`, the `gdbus call` command succeeds for both users.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-11 16:12:40 +00:00
Philip Withnall
5d0ffe73b7 gdbusdaemon: Use require-same-user flag to avoid auth observer signal
This doesn’t change the `GDBusDaemon` behaviour, but does simplify the
code a little.

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

Helps: #1804
2021-02-11 16:12:40 +00:00
Philip Withnall
1a6aa9a493 gdbus: Add flags to require authentication as the same user
This eliminates a common use case for the
`GDBusAuthObserver::authorize-authenticated-peer` signal, which is often
implemented incorrectly by people.

Suggested by Simon McVittie.

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

Fixes: #1804
2021-02-11 16:12:40 +00:00
Philip Withnall
137a9bdcc2 gdbusauth: Use g_clear_object() to simplify the code a little
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-11 16:06:27 +00:00
Philip Withnall
a1db705bc2 Merge branch 'wip/gdbus-flags-from-the-future' into 'master'
gdbus: Reject attempts to set future connection or server flags

See merge request GNOME/glib!1934
2021-02-11 11:53:13 +00:00
Philip Withnall
490b638e72 Merge branch 'byte-array-take' into 'master'
gbytearray: Do not accept too large byte arrays

See merge request GNOME/glib!1942
2021-02-11 10:27:42 +00:00
Krzesimir Nowak
acb7b0ec69 gbytearray: Do not accept too large byte arrays
GByteArray uses guint for storing the length of the byte array, but it
also has a constructor (g_byte_array_new_take) that takes length as a
gsize. gsize may be larger than guint (64 bits for gsize vs 32 bits
for guint). It is possible to call the function with a value greater
than G_MAXUINT, which will result in silent length truncation. This
may happen as a result of unreffing GBytes into GByteArray, so rather
be loud about it.

(Test case tweaked by Philip Withnall.)
2021-02-11 10:14:15 +00:00
Daniel Mustieles
6647137e3e Updated Spanish translation 2021-02-11 10:10:45 +01:00
Sebastian Dröge
90d34b3078 Merge branch 'keyfile-settings-fix-again' into 'master'
gkeyfilesettingsbackend: Fix basename handling when group is unset

See merge request GNOME/glib!1941
2021-02-11 08:00:00 +00:00
Philip Withnall
68ce7a28e1 tests: Add tests for key name handling in the keyfile backend
This tests the two recent commits.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-10 22:10:00 +00:00
Philip Withnall
a59247608f gkeyfilesettingsbackend: Disallow empty key or group names
These should never have been allowed; they will result in precondition
failures from the `GKeyFile` later on in the code.

A test will be added for this shortly.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-10 21:20:11 +00:00
Philip Withnall
9d27c57f70 gkeyfilesettingsbackend: Fix basename handling when group is unset
Fix an effective regression in commit
7781a9cbd2, which happens when
`convert_path()` is called with a `key` which contains no slashes. In
that case, the `key` is entirely the `basename`.

Prior to commit 7781a9cb, the code worked through a fluke of `i == -1`
cancelling out with the various additions in the `g_memdup()` call, and
effectively resulting in `g_strdup (key)`.

Spotted by Guido Berhoerster.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-10 21:16:39 +00:00
Philip Withnall
efe49e46cf Merge branch 'fix_more_warnings' into 'master'
Fix more warnings

See merge request GNOME/glib!1938
2021-02-10 20:01:08 +00:00
Emmanuel Fleury
bdcd7eca3b Fix missing initializer warning in gio/glib-compile-resources.c
gio/glib-compile-resources.c: In function ‘parse_resource_file’:
gio/glib-compile-resources.c:553:3: error: missing initializer for field ‘passthrough’ of ‘GMarkupParser’ {aka ‘struct _GMarkupParser’}
  553 |   GMarkupParser parser = { start_element, end_element, text };
      |   ^~~~~~~~~~~~~
2021-02-10 20:44:21 +01:00
Emmanuel Fleury
7c7aec9b31 Fix several signedness warnings in gio/gio-tool-tree.c
gio/gio-tool-tree.c: In function ‘do_tree’:
gio/gio-tool-tree.c:124:22: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’
  124 |        for (n = 0; n < level; n++)
      |                      ^
gio/gio-tool-tree.c:197:21: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’
  197 |       for (n = 0; n < level; n++)
      |                     ^
2021-02-10 20:43:58 +01:00
Emmanuel Fleury
a54ebd6860 Fix missing initializer warning in gio/gio-tool-monitor.c
gio/gio-tool-monitor.c:48:3: error: missing initializer for field ‘description’ of ‘GOptionEntry’ {aka ‘const struct _GOptionEntry’}
   48 |   { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &watch_default },
      |   ^
2021-02-10 20:41:16 +01:00
Emmanuel Fleury
85f2492111 Fix signedness warning in gio/gio-tool.c:attribute_flags_to_string()
gio/gio-tool.c: In function ‘attribute_flags_to_string’:
gio/gio-tool.c:171:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
  171 |   for (i = 0; i < G_N_ELEMENTS (flag_descr); i++)
      |                 ^
2021-02-10 20:41:16 +01:00
Emmanuel Fleury
6b3e39fafd Fix several missing initializer warnings in gio/glib-compile-schemas.c
gio/glib-compile-schemas.c: In function ‘parse_gschema_files’:
gio/glib-compile-schemas.c:1773:3: error: missing initializer for field ‘passthrough’ of ‘GMarkupParser’ {aka ‘struct _GMarkupParser’}
 1773 |   GMarkupParser parser = { start_element, end_element, text };
      |   ^~~~~~~~~~~~~
gio/glib-compile-schemas.c: In function ‘main’:
gio/glib-compile-schemas.c:2176:5: error: missing initializer for field ‘arg_description’ of ‘GOptionEntry’ {aka ‘struct _GOptionEntry’}
 2176 |     { "allow-any-name", 0, 0, G_OPTION_ARG_NONE, &allow_any_name, N_("Do not enforce key name restrictions") },
      |     ^
2021-02-10 20:41:16 +01:00
Emmanuel Fleury
93f3831ed3 Fix several signedness warnings in gio/glib-compile-schemas.c
gio/glib-compile-schemas.c: In function ‘key_state_set_range’:
gio/glib-compile-schemas.c:376:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
  376 |   for (i = 0; i < G_N_ELEMENTS (table); i++)
      |                 ^
gio/glib-compile-schemas.c: In function ‘key_state_serialise’:
gio/glib-compile-schemas.c:714:29: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
  714 |               for (i = 0; i < size / sizeof (guint32); i++)
      |                             ^
2021-02-10 20:41:16 +01:00
Emmanuel Fleury
8b1959dafe Fix several signedness warnings in gio/gsettings-mapping.c
gio/gsettings-mapping.c: In function ‘g_settings_set_mapping_int’:
gio/gsettings-mapping.c:65:23: error: comparison of integer expressions of different signedness: ‘gint64’ {aka ‘long int’} and ‘long unsigned int’
   65 |       if (0 <= l && l <= G_MAXUINT64)
      |                       ^~
gio/gsettings-mapping.c: In function ‘g_settings_set_mapping_float’:
gio/gsettings-mapping.c:120:23: error: comparison of integer expressions of different signedness: ‘gint64’ {aka ‘long int’} and ‘long unsigned int’
  120 |       if (0 <= l && l <= G_MAXUINT64)
      |                       ^~
gio/gsettings-mapping.c: In function ‘g_settings_get_mapping_int’:
gio/gsettings-mapping.c:224:27: error: comparison of integer expressions of different signedness: ‘gint64’ {aka ‘long int’} and ‘long unsigned int’
  224 |       return (0 <= l && l <= G_MAXUINT64);
      |                           ^~
gio/gsettings-mapping.c: In function ‘g_settings_get_mapping_float’:
gio/gsettings-mapping.c:269:27: error: comparison of integer expressions of different signedness: ‘gint64’ {aka ‘long int’} and ‘long unsigned int’
  269 |       return (0 <= l && l <= G_MAXUINT64);
      |                           ^~
2021-02-10 20:41:16 +01:00
Emmanuel Fleury
1f8d8b397e Fix wrong position for static qualifier warning in fuzzing/fuzz_dbus_message.c
fuzzing/fuzz_dbus_message.c:3:1: error: ‘static’ is not at beginning of declaration
    3 | const static GDBusCapabilityFlags flags = G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING;
      | ^~~~~
2021-02-10 20:41:16 +01:00
Hugo Carvalho
206ebfbff6 Update Portuguese translation 2021-02-10 19:18:07 +00:00
Sebastian Dröge
6528760468 Merge branch 'kjellahl/turkish-strdown' into 'master'
guniprop: Fix g_utf8_strdown() for Turkish locale

See merge request GNOME/glib!1930
2021-02-10 16:35:26 +00:00
Kjell Ahlstedt
e008301cf8 guniprop, glib/tests/unicode: Fix style issues 2021-02-10 18:25:53 +02:00
Kjell Ahlstedt
b9a4897900 guniprop: Fix g_utf8_strdown() for Turkish locale
In the Turkish locale the lowercase equivalent of a capital I with dot above
is a normal lowercase i with a dot above.

Fixes part of issue #390
2021-02-10 18:25:53 +02:00
Fran Dieguez
3c5339266d Update Galician translation 2021-02-10 15:14:50 +00:00
Philip Withnall
6bdd153618 Merge branch 'wip/pwithnall/macos-ci-disable' into 'master'
ci: Temporarily disable macOS CI job as runner is offline

See merge request GNOME/glib!1939
2021-02-10 14:42:12 +00:00
Philip Withnall
1d0d2ee5bb ci: Temporarily disable macOS CI job as runner is offline
See https://gitlab.gnome.org/Infrastructure/GitLab/-/issues/495

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-10 14:19:36 +00:00
Florentina Mușat
654a0446b1 Update Romanian translation 2021-02-10 08:38:57 +00:00
Yuri Chornoivan
471fb5a3bf Update Ukrainian translation 2021-02-10 08:28:06 +00:00
Matej Urbančič
3d3fe34d5e Update Slovenian translation 2021-02-09 21:17:04 +00:00
Luna Jernberg
50d817977c Update Swedish translation 2021-02-09 20:26:08 +00:00
Philip Withnall
ec77b30fed Merge branch 'fix_missing_overflow_checks' into 'master'
Adding a missing test on integer overflow within g_http_proxy_connect()

See merge request GNOME/glib!1917
2021-02-09 18:07:20 +00:00
Emmanuel Fleury
a5e3be4a0c Adding a missing test on integer overflow within g_http_proxy_connect()
Fixes #2315
2021-02-09 18:07:20 +00:00
Philip Withnall
3e5e7aa8e9 Merge branch 'master' into 'master'
Add support for Tilix and Konsole

See merge request GNOME/glib!1923
2021-02-09 11:09:59 +00:00
Philip Withnall
57a5ed3d08 tests: Fix leak of dlopened module in pollable test
Coverity CID: #1446243

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-09 11:06:53 +00:00
Philip Withnall
dc1f133c88 Merge branch '225' into 'master'
string: Add find and replace function

Closes #225

See merge request GNOME/glib!1828
2021-02-09 10:50:16 +00:00
Joshua Lee
c576a4cd82 string: Add find and replace function
This adds g_string_replace(), a function that replaces instances of one string
with another in a GString. It allows the caller to specify the maximum number
of replacements to perform, and returns the number of replacements performed
to the caller.

Fixes: #225
2021-02-09 10:50:16 +00:00
Philip Withnall
652026b9d1 Merge branch 'fix_more_warnings' into 'master'
Fix more warnings

See merge request GNOME/glib!1918
2021-02-09 10:45:51 +00:00
Simon McVittie
ba25c8a770 gdbus: Reject attempts to set future connection or server flags
The GDBusConnectionFlags and GDBusServerFlags can affect how we carry
out authentication and authorization, either making it more or less
restrictive, so it's desirable to "fail closed" if a program is compiled
against a new version of GLib but run against an old version.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-08 13:35:16 +00:00
Sebastian Dröge
203e078fdf Merge branch 'giochannel-check' into 'master'
giochannel: Fix length_size bounds check

Closes #2323

See merge request GNOME/glib!1931
2021-02-08 11:06:59 +00:00
Simon McVittie
d8fe3646c5 Merge branch 'wip/tlspassword' into 'master'
gtlspassword: Fix inverted assertion

See merge request GNOME/glib!1932
2021-02-08 11:05:01 +00:00
Simon McVittie
63f37f8c3b io-channel test: Add coverage for g_io_channel_set_line_term(., ., -1)
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-08 10:37:01 +00:00
Simon McVittie
5dc8b0014c giochannel: Don't store negative line_term_len in GIOChannel struct
Adding test coverage indicated that this was another bug in 0cc11f74.

Fixes: 0cc11f74 "giochannel: Forbid very long line terminator strings"
Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/2323
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-08 10:37:01 +00:00
Simon McVittie
df4501316c tls-interaction: Add test coverage for various ways to set the password
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-08 10:22:48 +00:00
Simon McVittie
61bb52ec42 gtlspassword: Fix inverted assertion
The intention here was to assert that the length of the password fits
in a gssize. Passwords more than half the size of virtual memory are
probably excessive.

Fixes: a8b204ff "gtlspassword: Forbid very long TLS passwords"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-08 10:05:15 +00:00
Emmanuel Fleury
05c311a961 Fix several missing initializer in gio/gsettingsschema.c:parse_into_text_tables()
gio/gsettingsschema.c: In function ‘parse_into_text_tables’:
gio/gsettingsschema.c:682:3: error: missing initializer for field ‘passthrough’ of ‘GMarkupParser’ {aka ‘struct _GMarkupParser’}
  682 |   GMarkupParser parser = { start_element, end_element, text };
      |   ^~~~~~~~~~~~~
gio/gsettingsschema.c:683:3: error: missing initializer for field ‘gettext_domain’ of ‘TextTableParseInfo’ [-Werror=missing-field-initializers]
  683 |   TextTableParseInfo info = { summaries, descriptions };
      |   ^~~~~~~~~~~~~~~~~~
2021-02-08 11:00:33 +01:00
Emmanuel Fleury
7c32b1173a Fix signedness warning in gio/gmenu.c:g_menu_remove()
gio/gmenu.c: In function ‘g_menu_remove’:
gio/gmenu.c:483:47: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  483 |   g_return_if_fail (0 <= position && position < menu->items->len);
      |                                               ^
2021-02-08 11:00:33 +01:00
Emmanuel Fleury
2174bcf000 Fix signedness warning in gio/gmenu.c:g_menu_insert_item()
gio/gmenu.c: In function ‘g_menu_insert_item’:
gio/gmenu.c:165:32: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  165 |   if (position < 0 || position > menu->items->len)
      |                                ^
2021-02-08 11:00:33 +01:00
Emmanuel Fleury
f598a93332 Fix signedness warning in gio/glocalfileinfo.c:get_access_rights()
gio/glocalfileinfo.c: In function ‘get_access_rights’:
gio/glocalfileinfo.c:932:9: error: comparison of integer expressions of different signedness: ‘uid_t’ {aka ‘unsigned int’} and ‘int’
  932 |     uid == parent_info->owner ||
      |         ^~
2021-02-08 11:00:25 +01:00