Commit Graph

30549 Commits

Author SHA1 Message Date
Michael Catanzaro
2671527542 Add test for GHmac in FIPS mode
This will test a few problems that we hit recently:

g_hmac_copy() is broken, https://bugzilla.redhat.com/show_bug.cgi?id=1786538

Crash in g_hmac_update() in FIPS mode, https://bugzilla.redhat.com/show_bug.cgi?id=1971533

Crash when passing -1 length to g_hmac_update() (discovered in #1971533)

We'll also test to ensure MD5 fails, and stop compiling the other MD5
tests.
2024-07-19 11:55:37 +01:00
Michael Catanzaro
780c2e18fc dlopen GnuTLS instead of linking directly
I'd like to enable our GnuTLS GHmac patchset in Fedora in order to
ensure it is receiving sufficient real-world testing, since we've
discovered several bugs thus far. Problem is Fedora has one requirement
that RHEL does not: it needs to build glib as a static lib. This is
needed by QEMU in Fedora for complicated technical reasons that I don't
understand. However, nothing in RHEL needs it. This means we failed to
notice that glib2-static is broken in RHEL, because there is no
gnutls-static! We could fix this by adding a gnutls-static package, but
that seems like overkill, and adding more static libraries where they're
not truly necessary is not the direction we want to move in anyway. So
instead, let's just dlopen GnuTLS to sidestep this problem entirely.

This would not be a good solution for upstream, but upstream has made
clear that this patchset is already non-upstreamable, so it will be fine
for our purposes.
2024-07-19 11:55:37 +01:00
Colin Walters
3ef71255bb Add a gnutls backend for GHmac
For RHEL we want apps to use FIPS-certified crypto libraries,
and HMAC apparently counts as "keyed" and hence needs to
be validated.

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1630260
Replaces: https://gitlab.gnome.org/GNOME/glib/merge_requests/897

This is a build-time option that backs the GHmac API with GnuTLS.
Most distributors ship glib-networking built with GnuTLS, and
most apps use glib-networking, so this isn't a net-new library
in most cases.

=======================================================================

mcatanzaro note:

I've updated Colin's original patch with several enhancements:

Implement g_hmac_copy() using gnutls_hmac_copy(), which didn't exist
when Colin developed this patch.

Removed use of GSlice

Better error checking in g_hmac_new(). It is possible for
gnutls_hmac_init() to fail if running in FIPS mode and an MD5 digest is
requested. In this case, we should return NULL rather than returning a
broken GHmac with a NULL gnutls_hmac_hd_t. This was leading to a later
null pointer dereference inside gnutls_hmac_update(). Applications are
responsible for checking to ensure the return value of g_hmac_new() is
not NULL since it is annotated as nullable. Added documentation to
indicate this possibility.

Properly handle length -1 in g_hmac_update(). This means we've been
given a NUL-terminated string and should use strlen(). GnuTLS doesn't
accept -1, so let's call strlen() ourselves.

Crash the application with g_error() if gnutls_hmac() fails for any
reason. This is necessary because g_hmac_update() is not fallible, so we
have no way to indicate error. Crashing seems better than returning the
wrong result later when g_hmac_get_string() or g_hmac_get_digest() is
later called. (Those functions are also not fallible.) Fortunately, I
don't think this error should actually be hit in practice.

https://gitlab.gnome.org/GNOME/glib/-/merge_requests/903
2024-07-19 11:55:37 +01:00
Colin Walters
9ef5cacbf9 ghmac: Split off wrapper functions into ghmac-utils.c
Prep for adding a GnuTLS HMAC implementation; these are just
utility functions that call the "core" API.
2024-07-19 11:55:37 +01:00
Philip Withnall
107b47226c Merge branch 'introspection-correct-gio-windows-pkg' into 'main'
introspection: Correct GIO-Windows pkg-config name

See merge request GNOME/glib!4159
2024-07-18 08:30:41 +00:00
Chun-wei Fan
297d808c6b introspection: Correct GIO-Windows pkg-config name
It's gio-windows-2.0.pc, not gio-win32-2.0.pc.

Otherwise, we get warnings/errors where the package cannot be located
but since we are linking to the same GIO library file, this did not
manifest itself.
2024-07-17 16:28:34 +08:00
Philip Withnall
d3cb9d638d Merge branch 'traverse-diagrams' into 'main'
docs(GNode): Traversal diagrams, color & dark-mode

See merge request GNOME/glib!4157
2024-07-15 15:58:45 +00:00
Philip Withnall
a931a75c4f docs(GNode): Traversal diagrams, color & dark-mode
* Create a dark-mode variant of each traversal diagram, with the
  traversal path colorized `--primary` blue, instead of the original
  black.
* Apply the same colorizations to the light-mode diagrams, but
  using the light-theme `--primary` blue.
* Add SPDX license/copyright comments to all eight SVG files.
* Add new files to documentation configs in `glib.toml.in`.
* Update documentation comment in `gnode.c` to embed both color
  variants via picture tags, instead of markdown image embeds.
* Add alt text to all four images.
* Add additional blank lines to documentation comment, so that
  a. First item in bulleted list does not get folded into
     preceding intro paragraph
  b. Intro paragraph and diagrams are not part of first paragraph
     in documentation. (This also gets them out of the top-level
     table-of-contents/index list, where they previously appeared
     in full.)
* (Accidental change I didn't realize I was making): Convert line
  endings in breadth-first diagram from CRLF to LF.
2024-07-15 15:58:45 +00:00
Philip Withnall
79c57b5b80 Merge branch 'gbsneto/doc-fixes-pt1' into 'main'
Port some GIO files to gi-docgen

See merge request GNOME/glib!4113
2024-07-11 21:01:39 +00:00
Georges Basile Stavracas Neto
a84c67da71 gio/appinfo: Directly link GdkAppLaunchContext
We can only use the [class@Foo.Bar] syntax for identifiers under
namespaces included by the current namespace. Naturally, we cannot
include the GDK namespace.

Use a direct link for this instead.
2024-07-11 16:23:06 +01:00
Georges Basile Stavracas Neto
ecc9904996 gio/applaunchcontext: Port docs to gi-docgen
This one is a little more self-contained, even though the class name
doesn't match the file it is in.
2024-07-11 15:33:41 +01:00
Georges Basile Stavracas Neto
b8db83940b gio/appinfo: Port docs to gi-docgen
Adjust all docs to use the gi-docgen referencing syntax, reindent
some of the comments, and add missing annotations to some async
methods.

The error arguments are not necessary with gi-docgen so they're
removed.

Confusingly enough, the docks for GAppInfo is spread between two
files.
2024-07-11 15:33:41 +01:00
Georges Basile Stavracas Neto
110e76a140 gio/actionmap: Port docs to gi-docgen 2024-07-11 15:33:41 +01:00
Georges Basile Stavracas Neto
3bd477b454 gio/actiongroupexporter: Port docs to gi-docgen 2024-07-11 15:33:41 +01:00
Philip Withnall
1b7336583c Merge branch 'darwin-rtld_local-fix' into 'main'
gmodule-dl: fix G_MODULE_BIND_LOCAL on Darwin

See merge request GNOME/glib!4154
2024-07-11 14:11:19 +00:00
Randy Eckenrode
3ab13ddc4b
gmodule: skip local-binding test on Windows 2024-07-11 00:47:42 -04:00
Randy Eckenrode
73d913519d
gmodule-dl: fix G_MODULE_BIND_LOCAL on Darwin
According to POSIX, the default behavior of `dlopen` is unspecified when
its flags include neither `RTLD_LOCAL` nor `RTLD_GLOBAL`. Consequently,
different platforms have different default behavior.

The default on Linux is `RTLD_LOCAL`, but the default on Darwin is
`RTLD_GLOBAL`. By passing `0` to `dlopen`, this results in the opposite
of the caller's intent when using `G_MODULE_BIND_LOCAL`.

Passing `RTLD_LOCAL` for `G_MODULE_BIND_LOCAL` allows the correct
behavior to be observed regardless of the platform's default.
2024-07-10 20:00:22 -04:00
Michael Catanzaro
4a73fbda8b Merge branch 'wip/pwithnall/resolver-parsing-bsd-fix' into 'main'
tests: Fix compilation of resolver-parsing test on FreeBSD

See merge request GNOME/glib!4152
2024-07-09 23:07:02 +00:00
Philip Withnall
fd2295c545 Merge branch 'port-gfilteroutputstream.c-comments' into 'main'
gfilteroutputstream.c: Port all doc comments to gi-docgen

See merge request GNOME/glib!4145
2024-07-09 22:54:47 +00:00
Philip Withnall
8bf5873272 Merge branch 'bilelmoussaoui-main-patch-13638' into 'main'
gi: Add missing Since annotation

See merge request GNOME/glib!4144
2024-07-09 22:08:49 +00:00
Philip Withnall
dfe6d0f8ce Merge branch 'ebassi/docs-location' into 'main'
docs: Add source location URL

See merge request GNOME/glib!4142
2024-07-09 21:06:02 +00:00
Philip Withnall
929f2ae06b
tests: Fix compilation of resolver-parsing test on FreeBSD
This fixes commit cdcb179808.

`dn_comp()` is needed to build fake DNS records for most of the tests in
this file. The new ownership test is no exception.

See https://gitlab.gnome.org/GNOME/glib/-/jobs/4058481

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-09 21:41:03 +01:00
Philip Withnall
ef57fa8a29 Merge branch 'port-gbufferedinputstream.c-comments' into 'main'
gbufferedinputstream: Port all doc comments to gi-docgen

See merge request GNOME/glib!4146
2024-07-09 19:36:55 +00:00
Philip Withnall
a7da10fea8 Merge branch 'asan-cygwin-build-fix' into 'main'
glib-private: fix build under Cygwin

See merge request GNOME/glib!4150
2024-07-09 19:25:31 +00:00
Emmanuele Bassi
a807604ef6 docs: Add source location URL
If the base URL for source location is set, gi-docgen will automatically
generate a link to the location of declarations and doc blocks in the
source.
2024-07-09 20:17:09 +01:00
Bilal Elmoussaoui
a31479316d gi: Add missing Since annotation
Fixes b32e1b63ee
2024-07-09 20:16:20 +01:00
Philip Withnall
fc01879341 Merge branch 'wip/pwithnall/macos-ci-fix' into 'main'
tests: Make an error check less specific in gsocketclient-slow

See merge request GNOME/glib!4149
2024-07-09 19:13:26 +00:00
Christoph Reiter
a49815926c glib-private: fix build under Cygwin
fb58d55187 added weak linking for ASAN,
skipping it for MinGW because weak symbols are broken there.
The same is true for Cygwin, so skip things there too.

This fixes the following build error under MSYS2:

/usr/lib/gcc/x86_64-pc-msys/13.3.0/../../../../x86_64-pc-msys/bin/ld:
    glib/msys-glib-2.0-0.dll.p/gutils.c.o:gutils.c:
        (.rdata$.refptr.__lsan_enable[.refptr.__lsan_enable]+0x0): undefined reference to `__lsan_enable'
2024-07-09 20:34:02 +02:00
Sudhanshu Tiwari
2e7e51be56 gbufferedinputstream: Port all doc comments to gi-docgen 2024-07-09 18:21:42 +01:00
Philip Withnall
325a9af5e0 Merge branch 'port-gbufferedoutputstream.c-comments' into 'main'
gbufferedoutputstream.c: Port doc comments to gi-docgen

See merge request GNOME/glib!4148
2024-07-09 17:01:46 +00:00
Philip Withnall
8d0bf4ed39
tests: Make an error check less specific in gsocketclient-slow
On Linux the error will be `G_IO_ERROR_CONNECTION_REFUSED`, but on macOS
it will be `G_IO_ERROR_TIMED_OUT`. Both errors seem reasonable to me, so
let’s not specifically require one of them.

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4104#note_2161451

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-09 17:40:16 +01:00
Sudhanshu Tiwari
c48fd73189 gbufferedoutputstream.c: Port doc comments to gi-docgen 2024-07-09 18:03:03 +05:30
Sudhanshu Tiwari
a8b52cd9d6 gfilteroutputstream.c: Port all doc comments to gi-docgen 2024-07-09 17:30:32 +05:30
Philip Withnall
de71e95041 Merge branch 'wip/leoziyou/macos-network-monitor' into 'main'
GOsxNetworkMonitor: Add network monitor backend for OS X

Closes #1326

See merge request GNOME/glib!3744
2024-07-07 19:36:48 +00:00
Leo Assini
202d345a82 GOsxNetworkMonitor: Add network monitor backend for OS X 2024-07-07 19:36:48 +00:00
Emmanuele Bassi
fc72d920cd Merge branch 'packaging-version' into 'main'
codegen: Drop unused import

See merge request GNOME/glib!4143
2024-07-07 14:09:42 +00:00
Philip Withnall
3993d8db52
codegen: Drop unused import
This should have been dropped in commit
38faeca62e but somehow that didn’t happen
and somehow it wasn’t caught by the CI until afterwards.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/jobs/4049254

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-07 13:48:46 +01:00
Philip Withnall
8320085557 Merge branch 'andyholmes/resolver-ownership' into 'main'
gthreadedresolver: ref-sink returned records in lookup_records()

Closes #3393

See merge request GNOME/glib!4110
2024-07-05 06:26:51 +00:00
Andy Holmes
cdcb179808
tests: ensure DNS records are full-reference variants
For each test expected to return valid DNS records, test that the
record variants are not floating references.

Also add an test which checks this explicitly for a simple TXT record.
2024-07-04 17:37:44 -07:00
Philip Withnall
7878938e9a Merge branch 'pr/fix_some_windows_testsuite_failures' into 'main'
tests: fix some Windows testsuite failures

Closes #3370

See merge request GNOME/glib!4125
2024-07-04 19:35:47 +00:00
Benoit Pierre
caf7f8ef49 tests: fix some Windows testsuite failures
Add test dependencies on the 2 spawn helpers required on Windows.
2024-07-04 19:35:47 +00:00
Andy Holmes
da3510575e
gthreadedresolver: ref-sink returned records in lookup_records()
The return value to `lookup_records()` methods is set as `transfer full`
but the code path in `g_resolver_records_from_res_query()` doesn't
sink the GVariant.

Add the `g_variant_ref_sink()` call when prepending the record, so
the list hold a full reference on each records.

closes #3393
2024-07-04 12:06:12 -07:00
Philip Withnall
b29f249544 Merge branch 'async_queue_copy_free_func' into 'main'
GAsyncQueue: Add copy-func and free-func annotations

See merge request GNOME/glib!4131
2024-07-04 13:11:31 +00:00
Philip Withnall
70784b99b1 Merge branch 'wsign-conversion' into 'main'
gqsort: Add g_sort_array() and deprecate g_qsort_with_data()

See merge request GNOME/glib!4127
2024-07-04 12:33:38 +00:00
Philip Withnall
22d699943d Merge branch 'menu-model-diagram' into 'main'
Docs: Replace Gio.MenuModel diagram with SVG

See merge request GNOME/glib!4140
2024-07-04 11:55:11 +00:00
Philip Withnall
f953212cc5
tests: Add a test for g_value_array_sort_with_data()
It’s deprecated, but I was modifying it anyway and it didn’t have any
coverage, so let’s add a simple test (as suggested by Michael
Catanzaro).

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-04 12:34:20 +01:00
FeRD (Frank Dana)
f4d944119c Menu model example: Update diagram
- Add licensing tags
- Tweak spacing, colors, line thicknesses
- Create light-mode version
- Use `<picture>` tag to include appropriate version for each media
  color scheme.
2024-07-04 12:13:53 +01:00
FeRD (Frank Dana)
85c8a7c0d8 Docs: Replace Gio.MenuModel diagram with SVG
Recreate the `menu-model.png` diagram in SVG, with box outlines and
connectors recolored from black to white. This will allow the diagram
to show up better in the dark documentation theme.
2024-07-04 12:13:53 +01:00
Philip Withnall
41d34f4976 Merge branch 'erniGH/remove-distutils' into 'main'
replace package.version.Version by internal code

See merge request GNOME/glib!4133
2024-07-04 11:04:39 +00:00
Ernesto de Gracia Herranz
38faeca62e replace package.version.Version by internal code
This drops the dependency on the Python `packaging` module.

Signed-off-by: Ernesto de Gracia Herranz <ernestodgh@jfrog.com>
2024-07-04 11:04:38 +00:00