From 51ad59d22c5fe7b8f40db59e10cdc38d1d6bd713 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Nov 05 2019 18:48:41 +0000 Subject: import glib2-2.56.4-7.el8 --- diff --git a/SOURCES/0001-build-sys-Pass-CFLAGS-to-DTRACE.patch b/SOURCES/0001-build-sys-Pass-CFLAGS-to-DTRACE.patch new file mode 100644 index 0000000..7a2aea3 --- /dev/null +++ b/SOURCES/0001-build-sys-Pass-CFLAGS-to-DTRACE.patch @@ -0,0 +1,56 @@ +From d7233ef81e575e84d831414605ba6368394d88b5 Mon Sep 17 00:00:00 2001 +From: Colin Walters +Date: Mon, 15 Oct 2018 21:50:31 +0000 +Subject: [PATCH] build-sys: Pass CFLAGS to $(DTRACE) + +Fedora is using https://fedoraproject.org/wiki/Changes/Annobin +to try to ensure that all objects are built with hardening flags. +Pass down `CFLAGS` to ensure the SystemTap objects use them. +--- + gio/Makefile.am | 2 +- + glib/Makefile.am | 2 +- + gobject/Makefile.am | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/gio/Makefile.am b/gio/Makefile.am +index fc0b91855..05b20cdef 100644 +--- a/gio/Makefile.am ++++ b/gio/Makefile.am +@@ -896,7 +896,7 @@ gio_probes.h: gio_probes.d + < $@.tmp > $@ && rm -f $@.tmp + + gio_probes.lo: gio_probes.d +- $(AM_V_GEN) $(LIBTOOL) --mode=compile $(AM_V_lt) --tag=CC $(DTRACE) -G -s $< -o $@ ++ $(AM_V_GEN) $(LIBTOOL) --mode=compile $(AM_V_lt) --tag=CC env CFLAGS="$(CFLAGS)" $(DTRACE) -G -s $< -o $@ + + BUILT_SOURCES += gio_probes.h gio_probes.lo + CLEANFILES += gio_probes.h gio_probes.h.tmp +diff --git a/glib/Makefile.am b/glib/Makefile.am +index 90d33d082..39163aa7f 100644 +--- a/glib/Makefile.am ++++ b/glib/Makefile.am +@@ -386,7 +386,7 @@ glib_probes.h: glib_probes.d + < $@.tmp > $@ && rm -f $@.tmp + + glib_probes.lo: glib_probes.d +- $(AM_V_GEN) $(LIBTOOL) --mode=compile $(AM_V_lt) --tag=CC $(DTRACE) -G -s $< -o $@ ++ $(AM_V_GEN) $(LIBTOOL) --mode=compile $(AM_V_lt) --tag=CC env CFLAGS="$(CFLAGS)" $(DTRACE) -G -s $< -o $@ + + BUILT_SOURCES += glib_probes.h glib_probes.lo + CLEANFILES += glib_probes.h glib_probes.h.tmp +diff --git a/gobject/Makefile.am b/gobject/Makefile.am +index 4c28acdff..78748e96c 100644 +--- a/gobject/Makefile.am ++++ b/gobject/Makefile.am +@@ -119,7 +119,7 @@ gobject_probes.h: gobject_probes.d + < $@.tmp > $@ && rm -f $@.tmp + + gobject_probes.lo: gobject_probes.d +- $(AM_V_GEN) $(LIBTOOL) --mode=compile $(AM_V_lt) --tag=CC $(DTRACE) -G -s $< -o $@ ++ $(AM_V_GEN) $(LIBTOOL) --mode=compile $(AM_V_lt) --tag=CC env CFLAGS="$(CFLAGS)" $(DTRACE) -G -s $< -o $@ + + BUILT_SOURCES += gobject_probes.h gobject_probes.lo + CLEANFILES += gobject_probes.h +-- +2.21.0 + diff --git a/SOURCES/0001-gdbus-codegen-honor-Property.EmitsChangedSignal-anno.patch b/SOURCES/0001-gdbus-codegen-honor-Property.EmitsChangedSignal-anno.patch new file mode 100644 index 0000000..09e2c84 --- /dev/null +++ b/SOURCES/0001-gdbus-codegen-honor-Property.EmitsChangedSignal-anno.patch @@ -0,0 +1,613 @@ +From aea538fe703652fd0a39b2ac9185133849cfdcc4 Mon Sep 17 00:00:00 2001 +From: Thomas Jost +Date: Thu, 13 Dec 2018 03:06:02 -0800 +Subject: [PATCH] gdbus-codegen: honor "Property.EmitsChangedSignal" + annotations + +Co-Authored-by: Andy Holmes +--- + gio/gdbus-2.0/codegen/codegen.py | 18 ++++++++++----- + gio/gdbus-2.0/codegen/dbustypes.py | 7 ++++++ + gio/tests/gdbus-test-codegen.c | 36 +++++++++++++++++++++++++----- + gio/tests/test-codegen.xml | 6 +++++ + 4 files changed, 56 insertions(+), 11 deletions(-) + +diff --git a/gio/gdbus-2.0/codegen/codegen.py b/gio/gdbus-2.0/codegen/codegen.py +index f6892af95..442bd3f5d 100644 +--- a/gio/gdbus-2.0/codegen/codegen.py ++++ b/gio/gdbus-2.0/codegen/codegen.py +@@ -638,61 +638,62 @@ class CodeGenerator: + '# include \n' + '#endif\n' + '\n') + + self.outfile.write('typedef struct\n' + '{\n' + ' GDBusArgInfo parent_struct;\n' + ' gboolean use_gvariant;\n' + '} _ExtendedGDBusArgInfo;\n' + '\n') + + self.outfile.write('typedef struct\n' + '{\n' + ' GDBusMethodInfo parent_struct;\n' + ' const gchar *signal_name;\n' + ' gboolean pass_fdlist;\n' + '} _ExtendedGDBusMethodInfo;\n' + '\n') + + self.outfile.write('typedef struct\n' + '{\n' + ' GDBusSignalInfo parent_struct;\n' + ' const gchar *signal_name;\n' + '} _ExtendedGDBusSignalInfo;\n' + '\n') + + self.outfile.write('typedef struct\n' + '{\n' + ' GDBusPropertyInfo parent_struct;\n' + ' const gchar *hyphen_name;\n' +- ' gboolean use_gvariant;\n' ++ ' guint use_gvariant : 1;\n' ++ ' guint emits_changed_signal : 1;\n' + '} _ExtendedGDBusPropertyInfo;\n' + '\n') + + self.outfile.write('typedef struct\n' + '{\n' + ' GDBusInterfaceInfo parent_struct;\n' + ' const gchar *hyphen_name;\n' + '} _ExtendedGDBusInterfaceInfo;\n' + '\n') + + self.outfile.write('typedef struct\n' + '{\n' + ' const _ExtendedGDBusPropertyInfo *info;\n' + ' guint prop_id;\n' + ' GValue orig_value; /* the value before the change */\n' + '} ChangedProperty;\n' + '\n' + 'static void\n' + '_changed_property_free (ChangedProperty *data)\n' + '{\n' + ' g_value_unset (&data->orig_value);\n' + ' g_free (data);\n' + '}\n' + '\n') + + self.outfile.write('static gboolean\n' + '_g_strv_equal0 (gchar **a, gchar **b)\n' + '{\n' + ' gboolean ret = FALSE;\n' + ' guint n;\n' +@@ -933,63 +934,67 @@ class CodeGenerator: + '\n') + + # --- + + if len(i.properties) > 0: + for p in i.properties: + if p.readable and p.writable: + access = 'G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE' + elif p.readable: + access = 'G_DBUS_PROPERTY_INFO_FLAGS_READABLE' + elif p.writable: + access = 'G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE' + else: + access = 'G_DBUS_PROPERTY_INFO_FLAGS_NONE' + num_anno = self.generate_annotations('_%s_property_%s_annotation_info'%(i.name_lower, p.name_lower), p.annotations) + self.outfile.write('static const _ExtendedGDBusPropertyInfo _%s_property_info_%s =\n' + '{\n' + ' {\n' + ' -1,\n' + ' (gchar *) "%s",\n' + ' (gchar *) "%s",\n' + ' %s,\n'%(i.name_lower, p.name_lower, p.name, p.arg.signature, access)) + if num_anno == 0: + self.outfile.write(' NULL\n') + else: + self.outfile.write(' (GDBusAnnotationInfo **) &_%s_property_%s_annotation_info_pointers\n'%(i.name_lower, p.name_lower)) + self.outfile.write(' },\n' + ' "%s",\n' + %(p.name_hyphen)) + if not utils.lookup_annotation(p.annotations, 'org.gtk.GDBus.C.ForceGVariant'): +- self.outfile.write(' FALSE\n') ++ self.outfile.write(' FALSE,\n') + else: ++ self.outfile.write(' TRUE,\n') ++ if p.emits_changed_signal: + self.outfile.write(' TRUE\n') ++ else: ++ self.outfile.write(' FALSE\n') + self.outfile.write('};\n' + '\n') + + self.outfile.write('static const GDBusPropertyInfo * const _%s_property_info_pointers[] =\n' + '{\n'%(i.name_lower)) + for p in i.properties: + self.outfile.write(' &_%s_property_info_%s.parent_struct,\n'%(i.name_lower, p.name_lower)) + self.outfile.write(' NULL\n' + '};\n' + '\n') + + num_anno = self.generate_annotations('_%s_annotation_info'%(i.name_lower), i.annotations) + self.outfile.write('static const _ExtendedGDBusInterfaceInfo _%s_interface_info =\n' + '{\n' + ' {\n' + ' -1,\n' + ' (gchar *) "%s",\n'%(i.name_lower, i.name)) + if len(i.methods) == 0: + self.outfile.write(' NULL,\n') + else: + self.outfile.write(' (GDBusMethodInfo **) &_%s_method_info_pointers,\n'%(i.name_lower)) + if len(i.signals) == 0: + self.outfile.write(' NULL,\n') + else: + self.outfile.write(' (GDBusSignalInfo **) &_%s_signal_info_pointers,\n'%(i.name_lower)) + if len(i.properties) == 0: + self.outfile.write(' NULL,\n') + else: + self.outfile.write(' (GDBusPropertyInfo **) &_%s_property_info_pointers,\n'%(i.name_lower)) + if num_anno == 0: +@@ -2568,68 +2573,71 @@ class CodeGenerator: + # this allows use of g_object_freeze_notify()/g_object_thaw_notify() ... + # This is useful when updating several properties from another thread than + # where the idle will be emitted from + self.outfile.write('static void\n' + '%s_skeleton_notify (GObject *object,\n' + ' GParamSpec *pspec G_GNUC_UNUSED)\n' + '{\n' + ' %sSkeleton *skeleton = %s%s_SKELETON (object);\n' + ' g_mutex_lock (&skeleton->priv->lock);\n' + ' if (skeleton->priv->changed_properties != NULL &&\n' + ' skeleton->priv->changed_properties_idle_source == NULL)\n' + ' {\n' + ' skeleton->priv->changed_properties_idle_source = g_idle_source_new ();\n' + ' g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);\n' + ' g_source_set_callback (skeleton->priv->changed_properties_idle_source, _%s_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);\n' + ' g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _%s_emit_changed");\n' + ' g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);\n' + ' g_source_unref (skeleton->priv->changed_properties_idle_source);\n' + ' }\n' + ' g_mutex_unlock (&skeleton->priv->lock);\n' + '}\n' + '\n' + %(i.name_lower, i.camel_name, i.ns_upper, i.name_upper, i.name_lower, i.name_lower)) + + self.outfile.write('static void\n' + '%s_skeleton_set_property (GObject *object,\n' + ' guint prop_id,\n' + ' const GValue *value,\n' + ' GParamSpec *pspec)\n' + '{\n'%(i.name_lower)) +- self.outfile.write(' %sSkeleton *skeleton = %s%s_SKELETON (object);\n' ++ self.outfile.write(' const _ExtendedGDBusPropertyInfo *info;\n' ++ ' %sSkeleton *skeleton = %s%s_SKELETON (object);\n' + ' g_assert (prop_id != 0 && prop_id - 1 < %d);\n' ++ ' info = (const _ExtendedGDBusPropertyInfo *) _%s_property_info_pointers[prop_id - 1];\n' + ' g_mutex_lock (&skeleton->priv->lock);\n' + ' g_object_freeze_notify (object);\n' + ' if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))\n' + ' {\n' +- ' if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)\n' +- ' _%s_schedule_emit_changed (skeleton, (const _ExtendedGDBusPropertyInfo *) _%s_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);\n' ++ ' if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL &&\n' ++ ' info->emits_changed_signal)\n' ++ ' _%s_schedule_emit_changed (skeleton, info, prop_id, &skeleton->priv->properties[prop_id - 1]);\n' + ' g_value_copy (value, &skeleton->priv->properties[prop_id - 1]);\n' + ' g_object_notify_by_pspec (object, pspec);\n' + ' }\n' + ' g_mutex_unlock (&skeleton->priv->lock);\n' + ' g_object_thaw_notify (object);\n' + %(i.camel_name, i.ns_upper, i.name_upper, len(i.properties), i.name_lower, i.name_lower)) + self.outfile.write('}\n' + '\n') + + self.outfile.write('static void\n' + '%s_skeleton_init (%sSkeleton *skeleton)\n' + '{\n' + '#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38\n' + ' skeleton->priv = %s_skeleton_get_instance_private (skeleton);\n' + '#else\n' + ' skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, %sTYPE_%s_SKELETON, %sSkeletonPrivate);\n' + '#endif\n\n' + %(i.name_lower, i.camel_name, + i.name_lower, + i.ns_upper, i.name_upper, i.camel_name)) + self.outfile.write(' g_mutex_init (&skeleton->priv->lock);\n') + self.outfile.write(' skeleton->priv->context = g_main_context_ref_thread_default ();\n') + if len(i.properties) > 0: + self.outfile.write(' skeleton->priv->properties = g_new0 (GValue, %d);\n'%(len(i.properties))) + n = 0 + for p in i.properties: + self.outfile.write(' g_value_init (&skeleton->priv->properties[%d], %s);\n'%(n, p.arg.gtype)) + n += 1 + self.outfile.write('}\n' + '\n') +diff --git a/gio/gdbus-2.0/codegen/dbustypes.py b/gio/gdbus-2.0/codegen/dbustypes.py +index bfc69f596..359880ff7 100644 +--- a/gio/gdbus-2.0/codegen/dbustypes.py ++++ b/gio/gdbus-2.0/codegen/dbustypes.py +@@ -300,89 +300,96 @@ class Signal: + arg_count = 0 + for a in self.args: + a.post_process(interface_prefix, cns, cns_upper, cns_lower, arg_count) + arg_count += 1 + + if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Deprecated') == 'true': + self.deprecated = True + + class Property: + def __init__(self, name, signature, access): + self.name = name + self.signature = signature + self.access = access + self.annotations = [] + self.arg = Arg('value', self.signature) + self.arg.annotations = self.annotations + self.readable = False + self.writable = False + if self.access == 'readwrite': + self.readable = True + self.writable = True + elif self.access == 'read': + self.readable = True + elif self.access == 'write': + self.writable = True + else: + print_error('Invalid access type "{}"'.format(self.access)) + self.doc_string = '' + self.since = '' + self.deprecated = False ++ self.emits_changed_signal = True + + def post_process(self, interface_prefix, cns, cns_upper, cns_lower, containing_iface): + if len(self.doc_string) == 0: + self.doc_string = utils.lookup_docs(self.annotations) + if len(self.since) == 0: + self.since = utils.lookup_since(self.annotations) + if len(self.since) == 0: + self.since = containing_iface.since + + name = self.name + overridden_name = utils.lookup_annotation(self.annotations, 'org.gtk.GDBus.C.Name') + if utils.is_ugly_case(overridden_name): + self.name_lower = overridden_name.lower() + else: + if overridden_name: + name = overridden_name + self.name_lower = utils.camel_case_to_uscore(name).lower().replace('-', '_') + self.name_hyphen = self.name_lower.replace('_', '-') + # don't clash with the GType getter, e.g.: GType foo_bar_get_type (void); G_GNUC_CONST + if self.name_lower == 'type': + self.name_lower = 'type_' + + # recalculate arg + self.arg.annotations = self.annotations + self.arg.post_process(interface_prefix, cns, cns_upper, cns_lower, 0) + + if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Deprecated') == 'true': + self.deprecated = True + ++ # FIXME: for now we only support 'false' and 'const' on the signal itself, see #674913 and ++ # http://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format ++ # for details ++ if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Property.EmitsChangedSignal') in ('false', 'const'): ++ self.emits_changed_signal = False ++ + class Interface: + def __init__(self, name): + self.name = name + self.methods = [] + self.signals = [] + self.properties = [] + self.annotations = [] + self.doc_string = '' + self.doc_string_brief = '' + self.since = '' + self.deprecated = False + + def post_process(self, interface_prefix, c_namespace): + if len(self.doc_string) == 0: + self.doc_string = utils.lookup_docs(self.annotations) + if len(self.doc_string_brief) == 0: + self.doc_string_brief = utils.lookup_brief_docs(self.annotations) + if len(self.since) == 0: + self.since = utils.lookup_since(self.annotations) + + if len(c_namespace) > 0: + if utils.is_ugly_case(c_namespace): + cns = c_namespace.replace('_', '') + cns_upper = c_namespace.upper() + '_' + cns_lower = c_namespace.lower() + '_' + else: + cns = c_namespace + cns_upper = utils.camel_case_to_uscore(c_namespace).upper() + '_' + cns_lower = utils.camel_case_to_uscore(c_namespace).lower() + '_' + else: +diff --git a/gio/tests/gdbus-test-codegen.c b/gio/tests/gdbus-test-codegen.c +index 1c4e83c4c..c906d05ae 100644 +--- a/gio/tests/gdbus-test-codegen.c ++++ b/gio/tests/gdbus-test-codegen.c +@@ -1740,103 +1740,127 @@ on_object_proxy_added (GDBusObjectManagerClient *manager, + gpointer user_data) + { + OMData *om_data = user_data; + om_data->num_object_proxy_added_signals += 1; + g_signal_connect (object_proxy, + "interface-added", + G_CALLBACK (on_interface_added), + om_data); + g_signal_connect (object_proxy, + "interface-removed", + G_CALLBACK (on_interface_removed), + om_data); + } + + static void + on_object_proxy_removed (GDBusObjectManagerClient *manager, + GDBusObjectProxy *object_proxy, + gpointer user_data) + { + OMData *om_data = user_data; + om_data->num_object_proxy_removed_signals += 1; + g_assert_cmpint (g_signal_handlers_disconnect_by_func (object_proxy, + G_CALLBACK (on_interface_added), + om_data), ==, 1); + g_assert_cmpint (g_signal_handlers_disconnect_by_func (object_proxy, + G_CALLBACK (on_interface_removed), + om_data), ==, 1); + } + + static void +-property_d_changed (GObject *object, +- GParamSpec *pspec, +- gpointer user_data) ++property_changed (GObject *object, ++ GParamSpec *pspec, ++ gpointer user_data) + { + gboolean *changed = user_data; + + *changed = TRUE; + } + + static void + om_check_property_and_signal_emission (GMainLoop *loop, + FooiGenBar *skeleton, + FooiGenBar *proxy) + { + gboolean d_changed = FALSE; ++ gboolean quiet_changed = FALSE; ++ gboolean quiet_too_changed = FALSE; + guint handler; + + /* First PropertiesChanged */ + g_assert_cmpint (foo_igen_bar_get_i (skeleton), ==, 0); + g_assert_cmpint (foo_igen_bar_get_i (proxy), ==, 0); + foo_igen_bar_set_i (skeleton, 1); + _g_assert_property_notify (proxy, "i"); + g_assert_cmpint (foo_igen_bar_get_i (skeleton), ==, 1); + g_assert_cmpint (foo_igen_bar_get_i (proxy), ==, 1); + + /* Double-check the gdouble case */ + g_assert_cmpfloat (foo_igen_bar_get_d (skeleton), ==, 0.0); + g_assert_cmpfloat (foo_igen_bar_get_d (proxy), ==, 0.0); + foo_igen_bar_set_d (skeleton, 1.0); + _g_assert_property_notify (proxy, "d"); + + /* Verify that re-setting it to the same value doesn't cause a + * notify on the proxy, by taking advantage of the fact that + * notifications are serialized. + */ + handler = g_signal_connect (proxy, "notify::d", +- G_CALLBACK (property_d_changed), &d_changed); ++ G_CALLBACK (property_changed), &d_changed); + foo_igen_bar_set_d (skeleton, 1.0); + foo_igen_bar_set_i (skeleton, 2); + _g_assert_property_notify (proxy, "i"); + g_assert (d_changed == FALSE); + g_signal_handler_disconnect (proxy, handler); + ++ /* Verify that re-setting a property with the "EmitsChangedSignal" ++ * set to false doesn't emit a signal. */ ++ handler = g_signal_connect (proxy, "notify::quiet", ++ G_CALLBACK (property_changed), &quiet_changed); ++ foo_igen_bar_set_quiet (skeleton, "hush!"); ++ foo_igen_bar_set_i (skeleton, 3); ++ _g_assert_property_notify (proxy, "i"); ++ g_assert (quiet_changed == FALSE); ++ g_assert_cmpstr (foo_igen_bar_get_quiet (skeleton), ==, "hush!"); ++ g_signal_handler_disconnect (proxy, handler); ++ ++ /* Also verify that re-setting a property with the "EmitsChangedSignal" ++ * set to 'const' doesn't emit a signal. */ ++ handler = g_signal_connect (proxy, "notify::quiet-too", ++ G_CALLBACK (property_changed), &quiet_changed); ++ foo_igen_bar_set_quiet_too (skeleton, "hush too!"); ++ foo_igen_bar_set_i (skeleton, 4); ++ _g_assert_property_notify (proxy, "i"); ++ g_assert (quiet_too_changed == FALSE); ++ g_assert_cmpstr (foo_igen_bar_get_quiet_too (skeleton), ==, "hush too!"); ++ g_signal_handler_disconnect (proxy, handler); ++ + /* Then just a regular signal */ + foo_igen_bar_emit_another_signal (skeleton, "word"); + _g_assert_signal_received (proxy, "another-signal"); + } + + static void + check_object_manager (void) + { + FooiGenObjectSkeleton *o = NULL; + FooiGenObjectSkeleton *o2 = NULL; + FooiGenObjectSkeleton *o3 = NULL; + GDBusInterfaceSkeleton *i; + GDBusConnection *c; + GDBusObjectManagerServer *manager = NULL; + GDBusNodeInfo *info; + GError *error; + GMainLoop *loop; + OMData *om_data = NULL; + guint om_signal_id = -1; + GDBusObjectManager *pm = NULL; + GList *object_proxies; + GList *proxies; + GDBusObject *op; + GDBusProxy *p; + FooiGenBar *bar_skeleton; + GDBusInterface *iface; + gchar *path, *name, *name_owner; + GDBusConnection *c2; + GDBusObjectManagerClientFlags flags; + +@@ -2124,73 +2148,73 @@ check_object_manager (void) + "({objectpath '/managed/first': {'com.acme.Coyote': {'Mood': <''>}}},)"); + + /* -------------------------------------------------- */ + + /* create a new object with two interfaces */ + o2 = foo_igen_object_skeleton_new ("/managed/second"); + i = G_DBUS_INTERFACE_SKELETON (foo_igen_bar_skeleton_new ()); + bar_skeleton = FOO_IGEN_BAR (i); /* save for later test */ + foo_igen_object_skeleton_set_bar (o2, FOO_IGEN_BAR (i)); + g_clear_object (&i); + i = G_DBUS_INTERFACE_SKELETON (foo_igen_bat_skeleton_new ()); + foo_igen_object_skeleton_set_bat (o2, FOO_IGEN_BAT (i)); + g_clear_object (&i); + /* ... add it */ + g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (o2)); + /* ... check we get the InterfacesAdded with _two_ interfaces */ + om_data->state = 101; + g_main_loop_run (om_data->loop); + g_assert_cmpint (om_data->state, ==, 102); + g_assert_cmpint (om_data->num_object_proxy_added_signals, ==, 5); + g_assert_cmpint (om_data->num_object_proxy_removed_signals, ==, 3); + g_assert_cmpint (om_data->num_interface_added_signals, ==, 1); + g_assert_cmpint (om_data->num_interface_removed_signals, ==, 1); + + /* -------------------------------------------------- */ + + /* Now that we have a couple of objects with interfaces, check + * that ObjectManager.GetManagedObjects() works + */ + om_check_get_all (c, loop, +- "({objectpath '/managed/first': {'com.acme.Coyote': {'Mood': <''>}}, '/managed/second': {'org.project.Bar': {'y': , 'b': , 'n': , 'q': , 'i': <0>, 'u': , 'x': , 't': , 'd': <0.0>, 's': <''>, 'o': , 'g': , 'ay': , 'as': <@as []>, 'aay': <@aay []>, 'ao': <@ao []>, 'ag': <@ag []>, 'FinallyNormalName': <''>, 'ReadonlyProperty': <''>, 'unset_i': <0>, 'unset_d': <0.0>, 'unset_s': <''>, 'unset_o': , 'unset_g': , 'unset_ay': , 'unset_as': <@as []>, 'unset_ao': <@ao []>, 'unset_ag': <@ag []>, 'unset_struct': <(0, 0.0, '', objectpath '/', signature '', @ay [], @as [], @ao [], @ag [])>}, 'org.project.Bat': {'force_i': <0>, 'force_s': <''>, 'force_ay': <@ay []>, 'force_struct': <(0,)>}}},)"); ++ "({objectpath '/managed/first': {'com.acme.Coyote': {'Mood': <''>}}, '/managed/second': {'org.project.Bar': {'y': , 'b': , 'n': , 'q': , 'i': <0>, 'u': , 'x': , 't': , 'd': <0.0>, 's': <''>, 'o': , 'g': , 'ay': , 'as': <@as []>, 'aay': <@aay []>, 'ao': <@ao []>, 'ag': <@ag []>, 'FinallyNormalName': <''>, 'ReadonlyProperty': <''>, 'quiet': <''>, 'quiet_too': <''>, 'unset_i': <0>, 'unset_d': <0.0>, 'unset_s': <''>, 'unset_o': , 'unset_g': , 'unset_ay': , 'unset_as': <@as []>, 'unset_ao': <@ao []>, 'unset_ag': <@ag []>, 'unset_struct': <(0, 0.0, '', objectpath '/', signature '', @ay [], @as [], @ao [], @ag [])>}, 'org.project.Bat': {'force_i': <0>, 'force_s': <''>, 'force_ay': <@ay []>, 'force_struct': <(0,)>}}},)"); + + /* Set connection to NULL, causing everything to be unexported.. verify this.. and + * then set the connection back.. and then check things still work + */ + g_dbus_object_manager_server_set_connection (manager, NULL); + info = introspect (c, g_dbus_connection_get_unique_name (c), "/managed", loop); + g_assert_cmpint (count_interfaces (info), ==, 0); /* nothing */ + g_dbus_node_info_unref (info); + + g_dbus_object_manager_server_set_connection (manager, c); + om_check_get_all (c, loop, +- "({objectpath '/managed/first': {'com.acme.Coyote': {'Mood': <''>}}, '/managed/second': {'org.project.Bar': {'y': , 'b': , 'n': , 'q': , 'i': <0>, 'u': , 'x': , 't': , 'd': <0.0>, 's': <''>, 'o': , 'g': , 'ay': , 'as': <@as []>, 'aay': <@aay []>, 'ao': <@ao []>, 'ag': <@ag []>, 'FinallyNormalName': <''>, 'ReadonlyProperty': <''>, 'unset_i': <0>, 'unset_d': <0.0>, 'unset_s': <''>, 'unset_o': , 'unset_g': , 'unset_ay': , 'unset_as': <@as []>, 'unset_ao': <@ao []>, 'unset_ag': <@ag []>, 'unset_struct': <(0, 0.0, '', objectpath '/', signature '', @ay [], @as [], @ao [], @ag [])>}, 'org.project.Bat': {'force_i': <0>, 'force_s': <''>, 'force_ay': <@ay []>, 'force_struct': <(0,)>}}},)"); ++ "({objectpath '/managed/first': {'com.acme.Coyote': {'Mood': <''>}}, '/managed/second': {'org.project.Bar': {'y': , 'b': , 'n': , 'q': , 'i': <0>, 'u': , 'x': , 't': , 'd': <0.0>, 's': <''>, 'o': , 'g': , 'ay': , 'as': <@as []>, 'aay': <@aay []>, 'ao': <@ao []>, 'ag': <@ag []>, 'FinallyNormalName': <''>, 'ReadonlyProperty': <''>, 'quiet': <''>, 'quiet_too': <''>, 'unset_i': <0>, 'unset_d': <0.0>, 'unset_s': <''>, 'unset_o': , 'unset_g': , 'unset_ay': , 'unset_as': <@as []>, 'unset_ao': <@ao []>, 'unset_ag': <@ag []>, 'unset_struct': <(0, 0.0, '', objectpath '/', signature '', @ay [], @as [], @ao [], @ag [])>}, 'org.project.Bat': {'force_i': <0>, 'force_s': <''>, 'force_ay': <@ay []>, 'force_struct': <(0,)>}}},)"); + + /* Also check that the ObjectManagerClient returns these objects - and + * that they are of the right GType cf. what was requested via + * the generated ::get-proxy-type signal handler + */ + object_proxies = g_dbus_object_manager_get_objects (pm); + g_assert (g_list_length (object_proxies) == 2); + g_list_free_full (object_proxies, g_object_unref); + op = g_dbus_object_manager_get_object (pm, "/managed/first"); + g_assert (op != NULL); + g_assert (FOO_IGEN_IS_OBJECT_PROXY (op)); + g_assert_cmpstr (g_dbus_object_get_object_path (op), ==, "/managed/first"); + proxies = g_dbus_object_get_interfaces (op); + g_assert (g_list_length (proxies) == 1); + g_list_free_full (proxies, g_object_unref); + p = G_DBUS_PROXY (foo_igen_object_get_com_acme_coyote (FOO_IGEN_OBJECT (op))); + g_assert (p != NULL); + g_assert_cmpint (G_TYPE_FROM_INSTANCE (p), ==, FOO_IGEN_TYPE_COM_ACME_COYOTE_PROXY); + g_assert (g_type_is_a (G_TYPE_FROM_INSTANCE (p), FOO_IGEN_TYPE_COM_ACME_COYOTE)); + g_clear_object (&p); + p = (GDBusProxy *) g_dbus_object_get_interface (op, "org.project.NonExisting"); + g_assert (p == NULL); + g_clear_object (&op); + + /* -- */ + op = g_dbus_object_manager_get_object (pm, "/managed/second"); + g_assert (op != NULL); + g_assert (FOO_IGEN_IS_OBJECT_PROXY (op)); + g_assert_cmpstr (g_dbus_object_get_object_path (op), ==, "/managed/second"); + proxies = g_dbus_object_get_interfaces (op); +diff --git a/gio/tests/test-codegen.xml b/gio/tests/test-codegen.xml +index 885a21f77..39d8769c7 100644 +--- a/gio/tests/test-codegen.xml ++++ b/gio/tests/test-codegen.xml +@@ -79,60 +79,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ++ ++ ++ ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-- +2.21.0 + diff --git a/SOURCES/0001-gfile-Limit-access-to-files-when-copying.patch b/SOURCES/0001-gfile-Limit-access-to-files-when-copying.patch new file mode 100644 index 0000000..6c514e1 --- /dev/null +++ b/SOURCES/0001-gfile-Limit-access-to-files-when-copying.patch @@ -0,0 +1,53 @@ +From d8f8f4d637ce43f8699ba94c9b7648beda0ca174 Mon Sep 17 00:00:00 2001 +From: Ondrej Holy +Date: Thu, 23 May 2019 10:41:53 +0200 +Subject: [PATCH] gfile: Limit access to files when copying + +file_copy_fallback creates new files with default permissions and +set the correct permissions after the operation is finished. This +might cause that the files can be accessible by more users during +the operation than expected. Use G_FILE_CREATE_PRIVATE for the new +files to limit access to those files. +--- + gio/gfile.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/gio/gfile.c b/gio/gfile.c +index 24b136d80..74b58047c 100644 +--- a/gio/gfile.c ++++ b/gio/gfile.c +@@ -3284,12 +3284,12 @@ file_copy_fallback (GFile *source, + out = (GOutputStream*)_g_local_file_output_stream_replace (_g_local_file_get_filename (G_LOCAL_FILE (destination)), + FALSE, NULL, + flags & G_FILE_COPY_BACKUP, +- G_FILE_CREATE_REPLACE_DESTINATION, +- info, ++ G_FILE_CREATE_REPLACE_DESTINATION | ++ G_FILE_CREATE_PRIVATE, info, + cancellable, error); + else + out = (GOutputStream*)_g_local_file_output_stream_create (_g_local_file_get_filename (G_LOCAL_FILE (destination)), +- FALSE, 0, info, ++ FALSE, G_FILE_CREATE_PRIVATE, info, + cancellable, error); + } + else if (flags & G_FILE_COPY_OVERWRITE) +@@ -3297,12 +3297,13 @@ file_copy_fallback (GFile *source, + out = (GOutputStream *)g_file_replace (destination, + NULL, + flags & G_FILE_COPY_BACKUP, +- G_FILE_CREATE_REPLACE_DESTINATION, ++ G_FILE_CREATE_REPLACE_DESTINATION | ++ G_FILE_CREATE_PRIVATE, + cancellable, error); + } + else + { +- out = (GOutputStream *)g_file_create (destination, 0, cancellable, error); ++ out = (GOutputStream *)g_file_create (destination, G_FILE_CREATE_PRIVATE, cancellable, error); + } + + if (!out) +-- +2.21.0 + diff --git a/SOURCES/backport-per-desktop-overrides.patch b/SOURCES/backport-per-desktop-overrides.patch new file mode 100644 index 0000000..fa4572e --- /dev/null +++ b/SOURCES/backport-per-desktop-overrides.patch @@ -0,0 +1,658 @@ +From 5634fd61f17d28dfc05cd47cfbd2bd2f21e6d2b1 Mon Sep 17 00:00:00 2001 +From: Allison Lortie +Date: Wed, 2 Aug 2017 11:06:03 +0100 +Subject: [PATCH 1/4] gsettings: cleanup default value lookup + +There are a couple of different ways (and soon one more) to access the +default value of a key. Clean up the various places that access this to +avoid duplication. + +https://bugzilla.gnome.org/show_bug.cgi?id=746592 +--- + gio/gsettings.c | 20 ++++---------------- + 1 file changed, 4 insertions(+), 16 deletions(-) + +diff --git a/gio/gsettings.c b/gio/gsettings.c +index 10d394d69..5e5816d57 100644 +--- a/gio/gsettings.c ++++ b/gio/gsettings.c +@@ -1204,10 +1204,7 @@ g_settings_get_value (GSettings *settings, + value = g_settings_read_from_backend (settings, &skey, FALSE, FALSE); + + if (value == NULL) +- value = g_settings_schema_key_get_translated_default (&skey); +- +- if (value == NULL) +- value = g_variant_ref (skey.default_value); ++ value = g_settings_schema_key_get_default_value (&skey); + + g_settings_schema_key_clear (&skey); + +@@ -1304,10 +1301,7 @@ g_settings_get_default_value (GSettings *settings, + value = g_settings_read_from_backend (settings, &skey, FALSE, TRUE); + + if (value == NULL) +- value = g_settings_schema_key_get_translated_default (&skey); +- +- if (value == NULL) +- value = g_variant_ref (skey.default_value); ++ value = g_settings_schema_key_get_default_value (&skey); + + g_settings_schema_key_clear (&skey); + +@@ -1360,10 +1354,7 @@ g_settings_get_enum (GSettings *settings, + value = g_settings_read_from_backend (settings, &skey, FALSE, FALSE); + + if (value == NULL) +- value = g_settings_schema_key_get_translated_default (&skey); +- +- if (value == NULL) +- value = g_variant_ref (skey.default_value); ++ value = g_settings_schema_key_get_default_value (&skey); + + result = g_settings_schema_key_to_enum (&skey, value); + g_settings_schema_key_clear (&skey); +@@ -1473,10 +1464,7 @@ g_settings_get_flags (GSettings *settings, + value = g_settings_read_from_backend (settings, &skey, FALSE, FALSE); + + if (value == NULL) +- value = g_settings_schema_key_get_translated_default (&skey); +- +- if (value == NULL) +- value = g_variant_ref (skey.default_value); ++ value = g_settings_schema_key_get_default_value (&skey); + + result = g_settings_schema_key_to_flags (&skey, value); + g_settings_schema_key_clear (&skey); +-- +2.21.0 + + +From 89c6e8f4a0bcda4b58dbaea713e62be01cfc2087 Mon Sep 17 00:00:00 2001 +From: Allison Lortie +Date: Wed, 2 Aug 2017 11:08:17 +0100 +Subject: [PATCH 2/4] gsettingsschema: Allow per-desktop overrides +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Recognise a new 'd' option in schema keys which gives a dictionary of +per-desktop default values. This dictionary is searched for the items +found in XDG_CURRENT_DESKTOP, in the order. If nothing matches (or if +the option is missing) then the default value is used as before. + +This feature was requested by Alberts Muktupāvels and this patch is +based on an approach devised by them. + +https://bugzilla.gnome.org/show_bug.cgi?id=746592 +--- + gio/gsettings.c | 21 +++++++++++++++++ + gio/gsettingsschema-internal.h | 2 ++ + gio/gsettingsschema.c | 41 ++++++++++++++++++++++++++++++++++ + 3 files changed, 64 insertions(+) + +diff --git a/gio/gsettings.c b/gio/gsettings.c +index 5e5816d57..f1130c095 100644 +--- a/gio/gsettings.c ++++ b/gio/gsettings.c +@@ -1739,6 +1739,13 @@ g_settings_get_mapped (GSettings *settings, + if (okay) goto okay; + } + ++ if ((value = g_settings_schema_key_get_per_desktop_default (&skey))) ++ { ++ okay = mapping (value, &result, user_data); ++ g_variant_unref (value); ++ if (okay) goto okay; ++ } ++ + if (mapping (skey.default_value, &result, user_data)) + goto okay; + +@@ -2647,6 +2654,20 @@ g_settings_binding_key_changed (GSettings *settings, + } + } + ++ if (variant == NULL) ++ { ++ variant = g_settings_schema_key_get_per_desktop_default (&binding->key); ++ if (variant && ++ !binding->get_mapping (&value, variant, binding->user_data)) ++ { ++ g_error ("Per-desktop default value for key '%s' in schema '%s' " ++ "was rejected by the binding mapping function.", ++ binding->key.name, g_settings_schema_get_id (binding->key.schema)); ++ g_variant_unref (variant); ++ variant = NULL; ++ } ++ } ++ + if (variant == NULL) + { + variant = g_variant_ref (binding->key.default_value); +diff --git a/gio/gsettingsschema-internal.h b/gio/gsettingsschema-internal.h +index f54de3b34..5f996b4bc 100644 +--- a/gio/gsettingsschema-internal.h ++++ b/gio/gsettingsschema-internal.h +@@ -37,6 +37,7 @@ struct _GSettingsSchemaKey + const GVariantType *type; + GVariant *minimum, *maximum; + GVariant *default_value; ++ GVariant *desktop_overrides; + + gint ref_count; + }; +@@ -58,6 +59,7 @@ gboolean g_settings_schema_key_type_check (GSettin + GVariant * g_settings_schema_key_range_fixup (GSettingsSchemaKey *key, + GVariant *value); + GVariant * g_settings_schema_key_get_translated_default (GSettingsSchemaKey *key); ++GVariant * g_settings_schema_key_get_per_desktop_default (GSettingsSchemaKey *key); + + gint g_settings_schema_key_to_enum (GSettingsSchemaKey *key, + GVariant *value); +diff --git a/gio/gsettingsschema.c b/gio/gsettingsschema.c +index f1274a369..17b7e3b01 100644 +--- a/gio/gsettingsschema.c ++++ b/gio/gsettingsschema.c +@@ -27,6 +27,7 @@ + #include + #include + #include ++#include + + /** + * SECTION:gsettingsschema +@@ -1283,6 +1284,11 @@ g_settings_schema_key_init (GSettingsSchemaKey *key, + endian_fixup (&key->maximum); + break; + ++ case 'd': ++ g_variant_get (data, "@a{sv}", &key->desktop_overrides); ++ endian_fixup (&key->desktop_overrides); ++ break; ++ + default: + g_warning ("unknown schema extension '%c'", code); + break; +@@ -1303,6 +1309,9 @@ g_settings_schema_key_clear (GSettingsSchemaKey *key) + if (key->maximum) + g_variant_unref (key->maximum); + ++ if (key->desktop_overrides) ++ g_variant_unref (key->desktop_overrides); ++ + g_variant_unref (key->default_value); + + g_settings_schema_unref (key->schema); +@@ -1410,6 +1419,35 @@ g_settings_schema_key_get_translated_default (GSettingsSchemaKey *key) + return value; + } + ++GVariant * ++g_settings_schema_key_get_per_desktop_default (GSettingsSchemaKey *key) ++{ ++ static const gchar * const *current_desktops; ++ GVariant *value = NULL; ++ gint i; ++ ++ if (!key->desktop_overrides) ++ return NULL; ++ ++ if (g_once_init_enter (¤t_desktops)) ++ { ++ const gchar *xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP"); ++ gchar **tmp; ++ ++ if (xdg_current_desktop != NULL && xdg_current_desktop[0] != '\0') ++ tmp = g_strsplit (xdg_current_desktop, G_SEARCHPATH_SEPARATOR_S, -1); ++ else ++ tmp = g_new0 (gchar *, 0 + 1); ++ ++ g_once_init_leave (¤t_desktops, (const gchar **) tmp); ++ } ++ ++ for (i = 0; value == NULL && current_desktops[i] != NULL; i++) ++ value = g_variant_lookup_value (key->desktop_overrides, current_desktops[i], NULL); ++ ++ return value; ++} ++ + gint + g_settings_schema_key_to_enum (GSettingsSchemaKey *key, + GVariant *value) +@@ -1698,6 +1736,9 @@ g_settings_schema_key_get_default_value (GSettingsSchemaKey *key) + + value = g_settings_schema_key_get_translated_default (key); + ++ if (!value) ++ value = g_settings_schema_key_get_per_desktop_default (key); ++ + if (!value) + value = g_variant_ref (key->default_value); + +-- +2.21.0 + + +From 3710e830de015829c086c69181a8703645d577ec Mon Sep 17 00:00:00 2001 +From: Allison Lortie +Date: Wed, 2 Aug 2017 11:10:18 +0100 +Subject: [PATCH 3/4] glib-compile-schemas: Handle per-desktop overrides + +Add a new syntax to override files: if the group name has a ':' in it, +it indicates that we want to override the default values of keys for +only one desktop. For example: + +[org.gnome.desktop.interface:Unity] +font-name='Ubuntu 12' + +Will override the settings, only if "Unity" is found in +XDG_CURRENT_DESKTOP. Multiple per-desktop overrides can be specified +for a given key: the one which comes first in XDG_CURRENT_DESKTOP will +be used. + +https://bugzilla.gnome.org/show_bug.cgi?id=746592 +--- + gio/glib-compile-schemas.c | 83 ++++++++++++++++++++++++++++++++++---- + 1 file changed, 75 insertions(+), 8 deletions(-) + +diff --git a/gio/glib-compile-schemas.c b/gio/glib-compile-schemas.c +index 2dc8c7171..59fb68ee7 100644 +--- a/gio/glib-compile-schemas.c ++++ b/gio/glib-compile-schemas.c +@@ -179,6 +179,8 @@ typedef struct + GString *unparsed_default_value; + GVariant *default_value; + ++ GVariantDict *desktop_overrides; ++ + GString *strinfo; + gboolean is_enum; + gboolean is_flags; +@@ -731,6 +733,11 @@ key_state_serialise (KeyState *state) + g_variant_builder_add (&builder, "(y(**))", 'r', + state->minimum, state->maximum); + ++ /* per-desktop overrides */ ++ if (state->desktop_overrides) ++ g_variant_builder_add (&builder, "(y@a{sv})", 'd', ++ g_variant_dict_end (state->desktop_overrides)); ++ + state->serialised = g_variant_builder_end (&builder); + } + +@@ -768,6 +775,9 @@ key_state_free (gpointer data) + if (state->serialised) + g_variant_unref (state->serialised); + ++ if (state->desktop_overrides) ++ g_variant_dict_unref (state->desktop_overrides); ++ + g_slice_free (KeyState, state); + } + +@@ -1878,6 +1888,8 @@ set_overrides (GHashTable *schema_table, + gchar **groups; + gint i; + ++ g_debug ("Processing override file '%s'", filename); ++ + key_file = g_key_file_new (); + if (!g_key_file_load_from_file (key_file, filename, 0, &error)) + { +@@ -1900,18 +1912,31 @@ set_overrides (GHashTable *schema_table, + for (i = 0; groups[i]; i++) + { + const gchar *group = groups[i]; ++ const gchar *schema_name; ++ const gchar *desktop_id; + SchemaState *schema; ++ gchar **pieces; + gchar **keys; + gint j; + +- schema = g_hash_table_lookup (schema_table, group); ++ pieces = g_strsplit (group, ":", 2); ++ schema_name = pieces[0]; ++ desktop_id = pieces[1]; ++ ++ g_debug ("Processing group '%s' (schema '%s', %s)", ++ group, schema_name, desktop_id ? desktop_id : "all desktops"); ++ ++ schema = g_hash_table_lookup (schema_table, schema_name); + + if (schema == NULL) +- /* Having the schema not be installed is expected to be a +- * common case. Don't even emit an error message about +- * that. +- */ +- continue; ++ { ++ /* Having the schema not be installed is expected to be a ++ * common case. Don't even emit an error message about ++ * that. ++ */ ++ g_strfreev (pieces); ++ continue; ++ } + + keys = g_key_file_get_keys (key_file, group, NULL, NULL); + g_assert (keys != NULL); +@@ -1939,6 +1964,32 @@ set_overrides (GHashTable *schema_table, + + fprintf (stderr, _(" and --strict was specified; exiting.\n")); + g_key_file_free (key_file); ++ g_strfreev (pieces); ++ g_strfreev (groups); ++ g_strfreev (keys); ++ ++ return FALSE; ++ } ++ ++ if (desktop_id != NULL && state->l10n) ++ { ++ /* Let's avoid the n*m case of per-desktop localised ++ * default values, and just forbid it. ++ */ ++ fprintf (stderr, ++ _("cannot provide per-desktop overrides for localised " ++ "key '%s' in schema '%s' (override file '%s')"), ++ key, group, filename); ++ ++ if (!strict) ++ { ++ fprintf (stderr, _("; ignoring override for this key.\n")); ++ continue; ++ } ++ ++ fprintf (stderr, _(" and --strict was specified; exiting.\n")); ++ g_key_file_free (key_file); ++ g_strfreev (pieces); + g_strfreev (groups); + g_strfreev (keys); + +@@ -1969,6 +2020,7 @@ set_overrides (GHashTable *schema_table, + + fprintf (stderr, _("--strict was specified; exiting.\n")); + g_key_file_free (key_file); ++ g_strfreev (pieces); + g_strfreev (groups); + g_strfreev (keys); + +@@ -1997,6 +2049,7 @@ set_overrides (GHashTable *schema_table, + + fprintf (stderr, _(" and --strict was specified; exiting.\n")); + g_key_file_free (key_file); ++ g_strfreev (pieces); + g_strfreev (groups); + g_strfreev (keys); + +@@ -2025,6 +2078,7 @@ set_overrides (GHashTable *schema_table, + + fprintf (stderr, _(" and --strict was specified; exiting.\n")); + g_key_file_free (key_file); ++ g_strfreev (pieces); + g_strfreev (groups); + g_strfreev (keys); + +@@ -2032,11 +2086,24 @@ set_overrides (GHashTable *schema_table, + } + } + +- g_variant_unref (state->default_value); +- state->default_value = value; ++ if (desktop_id != NULL) ++ { ++ if (state->desktop_overrides == NULL) ++ state->desktop_overrides = g_variant_dict_new (NULL); ++ ++ g_variant_dict_insert_value (state->desktop_overrides, desktop_id, value); ++ g_variant_unref (value); ++ } ++ else ++ { ++ g_variant_unref (state->default_value); ++ state->default_value = value; ++ } ++ + g_free (string); + } + ++ g_strfreev (pieces); + g_strfreev (keys); + } + +-- +2.21.0 + + +From 2ca9218fb46f32fa02bed43c6e60243c8c5d656f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Alberts=20Muktup=C4=81vels?= +Date: Tue, 19 Jun 2018 23:39:24 +0300 +Subject: [PATCH 4/4] Add a test for per-desktop overrides + +--- + gio/glib-compile-schemas.c | 1 + + gio/tests/Makefile.am | 2 + + gio/tests/gsettings.c | 106 ++++++++++++++++++- + gio/tests/org.gtk.test.gschema.override.orig | 2 + + gio/tests/org.gtk.test.gschema.xml.orig | 6 ++ + 5 files changed, 116 insertions(+), 1 deletion(-) + create mode 100644 gio/tests/org.gtk.test.gschema.override.orig + +diff --git a/gio/glib-compile-schemas.c b/gio/glib-compile-schemas.c +index 59fb68ee7..00dd64146 100644 +--- a/gio/glib-compile-schemas.c ++++ b/gio/glib-compile-schemas.c +@@ -2139,6 +2139,7 @@ main (int argc, char **argv) + + /* These options are only for use in the gschema-compile tests */ + { "schema-file", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME_ARRAY, &schema_files, NULL, NULL }, ++ { "override-file", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME_ARRAY, &override_files, NULL, NULL }, + { NULL } + }; + +diff --git a/gio/tests/Makefile.am b/gio/tests/Makefile.am +index 49a19bf4a..b41317ad9 100644 +--- a/gio/tests/Makefile.am ++++ b/gio/tests/Makefile.am +@@ -367,12 +367,14 @@ test.mo: de.po + EXTRA_DIST += de.po + dist_uninstalled_test_data += \ + org.gtk.test.gschema.xml.orig \ ++ org.gtk.test.gschema.override.orig \ + org.gtk.schemasourcecheck.gschema.xml \ + testenum.h \ + enums.xml.template + # Generated while running the testcase itself... + CLEANFILES += \ + org.gtk.test.gschema.xml \ ++ org.gtk.test.gschema.override \ + org.gtk.test.enums.xml \ + gsettings.store \ + gschemas.compiled \ +diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c +index 2be4122fe..acdeead4c 100644 +--- a/gio/tests/gsettings.c ++++ b/gio/tests/gsettings.c +@@ -2192,6 +2192,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS + "org.gtk.test.range.direct", + "org.gtk.test.mapped", + "org.gtk.test.descriptions", ++ "org.gtk.test.per-desktop", + NULL)); + } + +@@ -2583,6 +2584,100 @@ test_default_value (void) + g_object_unref (settings); + } + ++static gboolean ++string_map_func (GVariant *value, ++ gpointer *result, ++ gpointer user_data) ++{ ++ const gchar *str; ++ ++ str = g_variant_get_string (value, NULL); ++ *result = g_variant_new_string (str); ++ ++ return TRUE; ++} ++ ++/* Test that per-desktop values from org.gtk.test.gschema.override ++ * does not change default value if current desktop is not listed in ++ * $XDG_CURRENT_DESKTOP. ++ */ ++static void ++test_per_desktop (void) ++{ ++ GSettings *settings; ++ TestObject *obj; ++ gpointer p; ++ gchar *str; ++ ++ settings = g_settings_new ("org.gtk.test.per-desktop"); ++ obj = test_object_new (); ++ ++ if (!g_test_subprocess ()) ++ { ++ g_test_trap_subprocess ("/gsettings/per-desktop/subprocess", 0, 0); ++ g_test_trap_assert_passed (); ++ } ++ ++ str = g_settings_get_string (settings, "desktop"); ++ g_assert_cmpstr (str, ==, "GNOME"); ++ g_free (str); ++ ++ p = g_settings_get_mapped (settings, "desktop", string_map_func, NULL); ++ ++ str = g_variant_dup_string (p, NULL); ++ g_assert_cmpstr (str, ==, "GNOME"); ++ g_free (str); ++ ++ g_variant_unref (p); ++ ++ g_settings_bind (settings, "desktop", obj, "string", G_SETTINGS_BIND_DEFAULT); ++ ++ g_object_get (obj, "string", &str, NULL); ++ g_assert_cmpstr (str, ==, "GNOME"); ++ g_free (str); ++ ++ g_object_unref (settings); ++ g_object_unref (obj); ++} ++ ++/* Test that per-desktop values from org.gtk.test.gschema.override ++ * are successfully loaded based on the value of $XDG_CURRENT_DESKTOP. ++ */ ++static void ++test_per_desktop_subprocess (void) ++{ ++ GSettings *settings; ++ TestObject *obj; ++ gpointer p; ++ gchar *str; ++ ++ g_setenv ("XDG_CURRENT_DESKTOP", "GNOME-Classic:GNOME", TRUE); ++ ++ settings = g_settings_new ("org.gtk.test.per-desktop"); ++ obj = test_object_new (); ++ ++ str = g_settings_get_string (settings, "desktop"); ++ g_assert_cmpstr (str, ==, "GNOME Classic"); ++ g_free (str); ++ ++ p = g_settings_get_mapped (settings, "desktop", string_map_func, NULL); ++ ++ str = g_variant_dup_string (p, NULL); ++ g_assert_cmpstr (str, ==, "GNOME Classic"); ++ g_free (str); ++ ++ g_variant_unref (p); ++ ++ g_settings_bind (settings, "desktop", obj, "string", G_SETTINGS_BIND_DEFAULT); ++ ++ g_object_get (obj, "string", &str, NULL); ++ g_assert_cmpstr (str, ==, "GNOME Classic"); ++ g_free (str); ++ ++ g_object_unref (settings); ++ g_object_unref (obj); ++} ++ + static void + test_extended_schema (void) + { +@@ -2603,6 +2698,7 @@ int + main (int argc, char *argv[]) + { + gchar *schema_text; ++ gchar *override_text; + gchar *enums; + gint result; + +@@ -2625,6 +2721,7 @@ main (int argc, char *argv[]) + g_setenv ("XDG_DATA_DIRS", ".", TRUE); + g_setenv ("XDG_DATA_HOME", ".", TRUE); + g_setenv ("GSETTINGS_SCHEMA_DIR", ".", TRUE); ++ g_setenv ("XDG_CURRENT_DESKTOP", "", TRUE); + + if (!backend_set) + g_setenv ("GSETTINGS_BACKEND", "memory", TRUE); +@@ -2647,6 +2744,10 @@ main (int argc, char *argv[]) + g_assert (g_file_set_contents ("org.gtk.test.gschema.xml", schema_text, -1, NULL)); + g_free (schema_text); + ++ g_assert (g_file_get_contents (SRCDIR "/org.gtk.test.gschema.override.orig", &override_text, NULL, NULL)); ++ g_assert (g_file_set_contents ("org.gtk.test.gschema.override", override_text, -1, NULL)); ++ g_free (override_text); ++ + /* Meson build defines this, autotools build does not */ + #ifndef GLIB_COMPILE_SCHEMAS + #define GLIB_COMPILE_SCHEMAS "../glib-compile-schemas" +@@ -2655,7 +2756,8 @@ main (int argc, char *argv[]) + g_remove ("gschemas.compiled"); + g_assert (g_spawn_command_line_sync (GLIB_COMPILE_SCHEMAS " --targetdir=. " + "--schema-file=org.gtk.test.enums.xml " +- "--schema-file=org.gtk.test.gschema.xml", ++ "--schema-file=org.gtk.test.gschema.xml " ++ "--override-file=org.gtk.test.gschema.override", + NULL, NULL, &result, NULL)); + g_assert (result == 0); + +@@ -2736,6 +2838,8 @@ main (int argc, char *argv[]) + g_test_add_func ("/gsettings/read-descriptions", test_read_descriptions); + g_test_add_func ("/gsettings/test-extended-schema", test_extended_schema); + g_test_add_func ("/gsettings/default-value", test_default_value); ++ g_test_add_func ("/gsettings/per-desktop", test_per_desktop); ++ g_test_add_func ("/gsettings/per-desktop/subprocess", test_per_desktop_subprocess); + + result = g_test_run (); + +diff --git a/gio/tests/org.gtk.test.gschema.override.orig b/gio/tests/org.gtk.test.gschema.override.orig +new file mode 100644 +index 000000000..6694baace +--- /dev/null ++++ b/gio/tests/org.gtk.test.gschema.override.orig +@@ -0,0 +1,2 @@ ++[org.gtk.test.per-desktop:GNOME-Classic] ++desktop = "GNOME Classic" +diff --git a/gio/tests/org.gtk.test.gschema.xml.orig b/gio/tests/org.gtk.test.gschema.xml.orig +index c07558335..fbcdce683 100644 +--- a/gio/tests/org.gtk.test.gschema.xml.orig ++++ b/gio/tests/org.gtk.test.gschema.xml.orig +@@ -209,4 +209,10 @@ + + + ++ ++ ++ "GNOME" ++ ++ ++ + +-- +2.21.0 + diff --git a/SOURCES/ghmac-gnutls.patch b/SOURCES/ghmac-gnutls.patch new file mode 100644 index 0000000..5d6ad6f --- /dev/null +++ b/SOURCES/ghmac-gnutls.patch @@ -0,0 +1,728 @@ +From 440a178c5aad19050a3d5b5d76881931138af680 Mon Sep 17 00:00:00 2001 +From: Colin Walters +Date: Fri, 7 Jun 2019 18:44:43 +0000 +Subject: [PATCH 1/2] 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. +--- + glib/Makefile.am | 1 + + glib/ghmac-utils.c | 145 +++++++++++++++++++++++++++++++++++++++++++++ + glib/ghmac.c | 112 ---------------------------------- + glib/meson.build | 1 + + 4 files changed, 147 insertions(+), 112 deletions(-) + create mode 100644 glib/ghmac-utils.c + +diff --git a/glib/Makefile.am b/glib/Makefile.am +index 8da549c7f..c367b09ad 100644 +--- a/glib/Makefile.am ++++ b/glib/Makefile.am +@@ -126,6 +126,7 @@ libglib_2_0_la_SOURCES = \ + ggettext.c \ + ghash.c \ + ghmac.c \ ++ ghmac-utils.c \ + ghook.c \ + ghostutils.c \ + giochannel.c \ +diff --git a/glib/ghmac-utils.c b/glib/ghmac-utils.c +new file mode 100644 +index 000000000..a17359ff1 +--- /dev/null ++++ b/glib/ghmac-utils.c +@@ -0,0 +1,145 @@ ++/* ghmac.h - data hashing functions ++ * ++ * Copyright (C) 2011 Collabora Ltd. ++ * Copyright (C) 2019 Red Hat, Inc. ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public License ++ * along with this library; if not, see . ++ */ ++ ++#include "config.h" ++ ++#include ++ ++#include "ghmac.h" ++ ++#include "glib/galloca.h" ++#include "gatomic.h" ++#include "gslice.h" ++#include "gmem.h" ++#include "gstrfuncs.h" ++#include "gtestutils.h" ++#include "gtypes.h" ++#include "glibintl.h" ++ ++/** ++ * g_compute_hmac_for_data: ++ * @digest_type: a #GChecksumType to use for the HMAC ++ * @key: (array length=key_len): the key to use in the HMAC ++ * @key_len: the length of the key ++ * @data: (array length=length): binary blob to compute the HMAC of ++ * @length: length of @data ++ * ++ * Computes the HMAC for a binary @data of @length. This is a ++ * convenience wrapper for g_hmac_new(), g_hmac_get_string() ++ * and g_hmac_unref(). ++ * ++ * The hexadecimal string returned will be in lower case. ++ * ++ * Returns: the HMAC of the binary data as a string in hexadecimal. ++ * The returned string should be freed with g_free() when done using it. ++ * ++ * Since: 2.30 ++ */ ++gchar * ++g_compute_hmac_for_data (GChecksumType digest_type, ++ const guchar *key, ++ gsize key_len, ++ const guchar *data, ++ gsize length) ++{ ++ GHmac *hmac; ++ gchar *retval; ++ ++ g_return_val_if_fail (length == 0 || data != NULL, NULL); ++ ++ hmac = g_hmac_new (digest_type, key, key_len); ++ if (!hmac) ++ return NULL; ++ ++ g_hmac_update (hmac, data, length); ++ retval = g_strdup (g_hmac_get_string (hmac)); ++ g_hmac_unref (hmac); ++ ++ return retval; ++} ++ ++/** ++ * g_compute_hmac_for_bytes: ++ * @digest_type: a #GChecksumType to use for the HMAC ++ * @key: the key to use in the HMAC ++ * @data: binary blob to compute the HMAC of ++ * ++ * Computes the HMAC for a binary @data. This is a ++ * convenience wrapper for g_hmac_new(), g_hmac_get_string() ++ * and g_hmac_unref(). ++ * ++ * The hexadecimal string returned will be in lower case. ++ * ++ * Returns: the HMAC of the binary data as a string in hexadecimal. ++ * The returned string should be freed with g_free() when done using it. ++ * ++ * Since: 2.50 ++ */ ++gchar * ++g_compute_hmac_for_bytes (GChecksumType digest_type, ++ GBytes *key, ++ GBytes *data) ++{ ++ gconstpointer byte_data; ++ gsize length; ++ gconstpointer key_data; ++ gsize key_len; ++ ++ g_return_val_if_fail (data != NULL, NULL); ++ g_return_val_if_fail (key != NULL, NULL); ++ ++ byte_data = g_bytes_get_data (data, &length); ++ key_data = g_bytes_get_data (key, &key_len); ++ return g_compute_hmac_for_data (digest_type, key_data, key_len, byte_data, length); ++} ++ ++ ++/** ++ * g_compute_hmac_for_string: ++ * @digest_type: a #GChecksumType to use for the HMAC ++ * @key: (array length=key_len): the key to use in the HMAC ++ * @key_len: the length of the key ++ * @str: the string to compute the HMAC for ++ * @length: the length of the string, or -1 if the string is nul-terminated ++ * ++ * Computes the HMAC for a string. ++ * ++ * The hexadecimal string returned will be in lower case. ++ * ++ * Returns: the HMAC as a hexadecimal string. ++ * The returned string should be freed with g_free() ++ * when done using it. ++ * ++ * Since: 2.30 ++ */ ++gchar * ++g_compute_hmac_for_string (GChecksumType digest_type, ++ const guchar *key, ++ gsize key_len, ++ const gchar *str, ++ gssize length) ++{ ++ g_return_val_if_fail (length == 0 || str != NULL, NULL); ++ ++ if (length < 0) ++ length = strlen (str); ++ ++ return g_compute_hmac_for_data (digest_type, key, key_len, ++ (const guchar *) str, length); ++} +diff --git a/glib/ghmac.c b/glib/ghmac.c +index 9b58fd81c..7db38e34a 100644 +--- a/glib/ghmac.c ++++ b/glib/ghmac.c +@@ -329,115 +329,3 @@ g_hmac_get_digest (GHmac *hmac, + g_checksum_update (hmac->digesto, buffer, len); + g_checksum_get_digest (hmac->digesto, buffer, digest_len); + } +- +-/** +- * g_compute_hmac_for_data: +- * @digest_type: a #GChecksumType to use for the HMAC +- * @key: (array length=key_len): the key to use in the HMAC +- * @key_len: the length of the key +- * @data: (array length=length): binary blob to compute the HMAC of +- * @length: length of @data +- * +- * Computes the HMAC for a binary @data of @length. This is a +- * convenience wrapper for g_hmac_new(), g_hmac_get_string() +- * and g_hmac_unref(). +- * +- * The hexadecimal string returned will be in lower case. +- * +- * Returns: the HMAC of the binary data as a string in hexadecimal. +- * The returned string should be freed with g_free() when done using it. +- * +- * Since: 2.30 +- */ +-gchar * +-g_compute_hmac_for_data (GChecksumType digest_type, +- const guchar *key, +- gsize key_len, +- const guchar *data, +- gsize length) +-{ +- GHmac *hmac; +- gchar *retval; +- +- g_return_val_if_fail (length == 0 || data != NULL, NULL); +- +- hmac = g_hmac_new (digest_type, key, key_len); +- if (!hmac) +- return NULL; +- +- g_hmac_update (hmac, data, length); +- retval = g_strdup (g_hmac_get_string (hmac)); +- g_hmac_unref (hmac); +- +- return retval; +-} +- +-/** +- * g_compute_hmac_for_bytes: +- * @digest_type: a #GChecksumType to use for the HMAC +- * @key: the key to use in the HMAC +- * @data: binary blob to compute the HMAC of +- * +- * Computes the HMAC for a binary @data. This is a +- * convenience wrapper for g_hmac_new(), g_hmac_get_string() +- * and g_hmac_unref(). +- * +- * The hexadecimal string returned will be in lower case. +- * +- * Returns: the HMAC of the binary data as a string in hexadecimal. +- * The returned string should be freed with g_free() when done using it. +- * +- * Since: 2.50 +- */ +-gchar * +-g_compute_hmac_for_bytes (GChecksumType digest_type, +- GBytes *key, +- GBytes *data) +-{ +- gconstpointer byte_data; +- gsize length; +- gconstpointer key_data; +- gsize key_len; +- +- g_return_val_if_fail (data != NULL, NULL); +- g_return_val_if_fail (key != NULL, NULL); +- +- byte_data = g_bytes_get_data (data, &length); +- key_data = g_bytes_get_data (key, &key_len); +- return g_compute_hmac_for_data (digest_type, key_data, key_len, byte_data, length); +-} +- +- +-/** +- * g_compute_hmac_for_string: +- * @digest_type: a #GChecksumType to use for the HMAC +- * @key: (array length=key_len): the key to use in the HMAC +- * @key_len: the length of the key +- * @str: the string to compute the HMAC for +- * @length: the length of the string, or -1 if the string is nul-terminated +- * +- * Computes the HMAC for a string. +- * +- * The hexadecimal string returned will be in lower case. +- * +- * Returns: the HMAC as a hexadecimal string. +- * The returned string should be freed with g_free() +- * when done using it. +- * +- * Since: 2.30 +- */ +-gchar * +-g_compute_hmac_for_string (GChecksumType digest_type, +- const guchar *key, +- gsize key_len, +- const gchar *str, +- gssize length) +-{ +- g_return_val_if_fail (length == 0 || str != NULL, NULL); +- +- if (length < 0) +- length = strlen (str); +- +- return g_compute_hmac_for_data (digest_type, key, key_len, +- (const guchar *) str, length); +-} +diff --git a/glib/meson.build b/glib/meson.build +index 9df77b6f9..c7f28b5b6 100644 +--- a/glib/meson.build ++++ b/glib/meson.build +@@ -138,6 +138,7 @@ glib_sources = files( + 'ggettext.c', + 'ghash.c', + 'ghmac.c', ++ 'ghmac-utils.c', + 'ghook.c', + 'ghostutils.c', + 'giochannel.c', +-- +2.21.0 + + +From 423355787ba9133b310c0b72708024b1428d7d14 Mon Sep 17 00:00:00 2001 +From: Colin Walters +Date: Fri, 7 Jun 2019 19:36:54 +0000 +Subject: [PATCH 2/2] 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. + +However, a fun wrinkle is that the GnuTLS HMAC API doesn't expose +the necessary bits to implement `g_hmac_copy()`; OpenSSL does. +I chose to just make that abort for now since I didn't find +apps using it. +--- + glib/Makefile.am | 9 ++- + glib/gchecksum.c | 9 +-- + glib/gchecksumprivate.h | 32 +++++++++ + glib/ghmac-gnutls.c | 151 ++++++++++++++++++++++++++++++++++++++++ + glib/ghmac.c | 1 + + glib/meson.build | 10 ++- + glib/tests/hmac.c | 6 ++ + meson.build | 7 ++ + meson_options.txt | 5 ++ + 9 files changed, 221 insertions(+), 9 deletions(-) + create mode 100644 glib/gchecksumprivate.h + create mode 100644 glib/ghmac-gnutls.c + +diff --git a/glib/Makefile.am b/glib/Makefile.am +index c367b09ad..b0a721ad0 100644 +--- a/glib/Makefile.am ++++ b/glib/Makefile.am +@@ -125,7 +125,7 @@ libglib_2_0_la_SOURCES = \ + gfileutils.c \ + ggettext.c \ + ghash.c \ +- ghmac.c \ ++ ghmac-gnutls.c \ + ghmac-utils.c \ + ghook.c \ + ghostutils.c \ +@@ -352,11 +352,14 @@ pcre_lib = pcre/libpcre.la + pcre_inc = + endif + +-libglib_2_0_la_CFLAGS = $(AM_CFLAGS) $(GLIB_HIDDEN_VISIBILITY_CFLAGS) $(LIBSYSTEMD_CFLAGS) ++gnutls_libs = $(shell pkg-config --libs gnutls) ++gnutls_cflags = $(shell pkg-config --cflags gnutls) ++ ++libglib_2_0_la_CFLAGS = $(AM_CFLAGS) $(GLIB_HIDDEN_VISIBILITY_CFLAGS) $(LIBSYSTEMD_CFLAGS) $(gnutls_cflags) + libglib_2_0_la_LIBADD = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ @ICONV_LIBS@ @G_LIBS_EXTRA@ $(pcre_lib) $(G_THREAD_LIBS_EXTRA) $(G_THREAD_LIBS_FOR_GTHREAD) $(LIBSYSTEMD_LIBS) + libglib_2_0_la_DEPENDENCIES = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ $(glib_win32_res) $(glib_def) + +-libglib_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \ ++libglib_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) $(gnutls_libs) \ + $(glib_win32_res_ldflag) \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ + -export-dynamic $(no_undefined) +diff --git a/glib/gchecksum.c b/glib/gchecksum.c +index 40b1d50e2..2f59d4a66 100644 +--- a/glib/gchecksum.c ++++ b/glib/gchecksum.c +@@ -20,7 +20,7 @@ + + #include + +-#include "gchecksum.h" ++#include "gchecksumprivate.h" + + #include "gslice.h" + #include "gmem.h" +@@ -173,9 +173,9 @@ sha_byte_reverse (guint32 *buffer, + } + #endif /* G_BYTE_ORDER == G_BIG_ENDIAN */ + +-static gchar * +-digest_to_string (guint8 *digest, +- gsize digest_len) ++gchar * ++gchecksum_digest_to_string (guint8 *digest, ++ gsize digest_len) + { + gint len = digest_len * 2; + gint i; +@@ -195,6 +195,7 @@ digest_to_string (guint8 *digest, + + return retval; + } ++#define digest_to_string gchecksum_digest_to_string + + /* + * MD5 Checksum +diff --git a/glib/gchecksumprivate.h b/glib/gchecksumprivate.h +new file mode 100644 +index 000000000..86c7a3b61 +--- /dev/null ++++ b/glib/gchecksumprivate.h +@@ -0,0 +1,32 @@ ++/* gstdioprivate.h - Private GLib stdio functions ++ * ++ * Copyright 2017 Руслан Ижбулатов ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public License ++ * along with this library; if not, see . ++ */ ++ ++#ifndef __G_CHECKSUMPRIVATE_H__ ++#define __G_CHECKSUMPRIVATE_H__ ++ ++#include "gchecksum.h" ++ ++G_BEGIN_DECLS ++ ++gchar * ++gchecksum_digest_to_string (guint8 *digest, ++ gsize digest_len); ++ ++G_END_DECLS ++ ++#endif +\ No newline at end of file +diff --git a/glib/ghmac-gnutls.c b/glib/ghmac-gnutls.c +new file mode 100644 +index 000000000..3b4dfb872 +--- /dev/null ++++ b/glib/ghmac-gnutls.c +@@ -0,0 +1,151 @@ ++/* ghmac.h - data hashing functions ++ * ++ * Copyright (C) 2011 Collabora Ltd. ++ * Copyright (C) 2019 Red Hat, Inc. ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public License ++ * along with this library; if not, see . ++ */ ++ ++#include "config.h" ++ ++#include ++#include ++ ++#include "ghmac.h" ++ ++#include "glib/galloca.h" ++#include "gatomic.h" ++#include "gslice.h" ++#include "gmem.h" ++#include "gstrfuncs.h" ++#include "gchecksumprivate.h" ++#include "gtestutils.h" ++#include "gtypes.h" ++#include "glibintl.h" ++ ++struct _GHmac ++{ ++ int ref_count; ++ GChecksumType digest_type; ++ gnutls_hmac_hd_t hmac; ++ gchar *digest_str; ++}; ++ ++GHmac * ++g_hmac_new (GChecksumType digest_type, ++ const guchar *key, ++ gsize key_len) ++{ ++ gnutls_mac_algorithm_t algo; ++ GHmac *hmac = g_slice_new0 (GHmac); ++ hmac->ref_count = 1; ++ hmac->digest_type = digest_type; ++ ++ switch (digest_type) ++ { ++ case G_CHECKSUM_MD5: ++ algo = GNUTLS_MAC_MD5; ++ break; ++ case G_CHECKSUM_SHA1: ++ algo = GNUTLS_MAC_SHA1; ++ break; ++ case G_CHECKSUM_SHA256: ++ algo = GNUTLS_MAC_SHA256; ++ break; ++ case G_CHECKSUM_SHA384: ++ algo = GNUTLS_MAC_SHA384; ++ break; ++ case G_CHECKSUM_SHA512: ++ algo = GNUTLS_MAC_SHA512; ++ break; ++ default: ++ g_return_val_if_reached (NULL); ++ } ++ ++ gnutls_hmac_init (&hmac->hmac, algo, key, key_len); ++ ++ return hmac; ++} ++ ++GHmac * ++g_hmac_copy (const GHmac *hmac) ++{ ++ g_error ("g_hmac_copy is not available with GnuTLS-backend GHmac"); ++} ++ ++GHmac * ++g_hmac_ref (GHmac *hmac) ++{ ++ g_return_val_if_fail (hmac != NULL, NULL); ++ ++ g_atomic_int_inc (&hmac->ref_count); ++ ++ return hmac; ++} ++ ++void ++g_hmac_unref (GHmac *hmac) ++{ ++ g_return_if_fail (hmac != NULL); ++ ++ if (g_atomic_int_dec_and_test (&hmac->ref_count)) ++ { ++ gnutls_hmac_deinit (hmac->hmac, NULL); ++ g_free (hmac->digest_str); ++ g_slice_free (GHmac, hmac); ++ } ++} ++ ++ ++void ++g_hmac_update (GHmac *hmac, ++ const guchar *data, ++ gssize length) ++{ ++ g_return_if_fail (hmac != NULL); ++ g_return_if_fail (length == 0 || data != NULL); ++ ++ gnutls_hmac (hmac->hmac, data, length); ++} ++ ++const gchar * ++g_hmac_get_string (GHmac *hmac) ++{ ++ guint8 *buffer; ++ gsize digest_len; ++ ++ g_return_val_if_fail (hmac != NULL, NULL); ++ ++ if (hmac->digest_str) ++ return hmac->digest_str; ++ ++ digest_len = g_checksum_type_get_length (hmac->digest_type); ++ buffer = g_alloca (digest_len); ++ ++ gnutls_hmac_output (hmac->hmac, buffer); ++ hmac->digest_str = gchecksum_digest_to_string (buffer, digest_len); ++ return hmac->digest_str; ++} ++ ++ ++void ++g_hmac_get_digest (GHmac *hmac, ++ guint8 *buffer, ++ gsize *digest_len) ++{ ++ g_return_if_fail (hmac != NULL); ++ ++ gnutls_hmac_output (hmac->hmac, buffer); ++ *digest_len = g_checksum_type_get_length (hmac->digest_type); ++} +diff --git a/glib/ghmac.c b/glib/ghmac.c +index 7db38e34a..b12eb07c4 100644 +--- a/glib/ghmac.c ++++ b/glib/ghmac.c +@@ -33,6 +33,7 @@ + #include "gtypes.h" + #include "glibintl.h" + ++#error "build configuration error" + + /** + * SECTION:hmac +diff --git a/glib/meson.build b/glib/meson.build +index c7f28b5b6..a2f9da81c 100644 +--- a/glib/meson.build ++++ b/glib/meson.build +@@ -137,7 +137,6 @@ glib_sources = files( + 'gfileutils.c', + 'ggettext.c', + 'ghash.c', +- 'ghmac.c', + 'ghmac-utils.c', + 'ghook.c', + 'ghostutils.c', +@@ -185,6 +184,7 @@ glib_sources = files( + 'gunidecomp.c', + 'gurifuncs.c', + 'gutils.c', ++ 'gchecksumprivate.h', + 'guuid.c', + 'gvariant.c', + 'gvariant-core.c', +@@ -222,6 +222,12 @@ else + glib_dtrace_hdr = [] + endif + ++if get_option('gnutls') ++ glib_sources += files('ghmac-gnutls.c') ++else ++ glib_sources += files('ghmac.c') ++endif ++ + pcre_static_args = [] + + if use_pcre_static_flag +@@ -238,7 +244,7 @@ libglib = library('glib-2.0', + link_args : platform_ldflags + noseh_link_args, + include_directories : configinc, + link_with : [charset_lib, gnulib_lib], +- dependencies : [pcre, thread_dep, libintl, librt] + libiconv + platform_deps, ++ dependencies : [pcre, thread_dep, libintl, librt] + libiconv + platform_deps + libgnutls_dep, + c_args : ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args + ) + +diff --git a/glib/tests/hmac.c b/glib/tests/hmac.c +index 3ac3206df..5212c2523 100644 +--- a/glib/tests/hmac.c ++++ b/glib/tests/hmac.c +@@ -1,3 +1,5 @@ ++#include "config.h" ++ + #include + #include + #include +@@ -427,6 +429,9 @@ test_hmac_ref_unref (void) + static void + test_hmac_copy (void) + { ++#ifdef HAVE_GNUTLS ++ g_test_skip ("No g_hmac_copy with gnutls"); ++#else + GHmac *hmac, *check; + + hmac = g_hmac_new (G_CHECKSUM_SHA256, (guchar*)"aaa", 3); +@@ -435,6 +440,7 @@ test_hmac_copy (void) + g_assert_cmpstr (g_hmac_get_string (hmac), ==, g_hmac_get_string (check)); + g_hmac_unref (check); + g_hmac_unref (hmac); ++#endif + } + + static void +diff --git a/meson.build b/meson.build +index 0cefee51d..81b16b004 100644 +--- a/meson.build ++++ b/meson.build +@@ -1596,6 +1596,13 @@ if host_system == 'linux' and get_option('libmount') + libmount_dep = [dependency('mount', version : '>=2.23', required : true)] + endif + ++# gnutls is used optionally by ghmac ++libgnutls_dep = [] ++if get_option('gnutls') ++ libgnutls_dep = [dependency('gnutls', version : '>=3.6.7', required : true)] ++ glib_conf.set('HAVE_GNUTLS', 1) ++endif ++ + if host_system == 'windows' + winsock2 = cc.find_library('ws2_32') + endif +diff --git a/meson_options.txt b/meson_options.txt +index 4504c6858..d18c42a36 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -34,6 +34,11 @@ option('libmount', + value : true, + description : 'build with libmount support') + ++option('gnutls', ++ type : 'boolean', ++ value : false, ++ description : 'build with gnutls support') ++ + option('internal_pcre', + type : 'boolean', + value : false, +-- +2.21.0 + diff --git a/SPECS/glib2.spec b/SPECS/glib2.spec index 14f9cee..3681ef1 100644 --- a/SPECS/glib2.spec +++ b/SPECS/glib2.spec @@ -5,13 +5,19 @@ Name: glib2 Version: 2.56.4 -Release: 1%{?dist} +Release: 7%{?dist} Summary: A library of handy utility functions License: LGPLv2+ URL: http://www.gtk.org Source0: http://download.gnome.org/sources/glib/2.56/glib-%{version}.tar.xz +# https://gitlab.gnome.org/GNOME/glib/merge_requests/903 +# https://bugzilla.redhat.com/show_bug.cgi?id=1630260 +Patch37: ghmac-gnutls.patch +# And the BR for this +BuildRequires: pkgconfig(gnutls) + BuildRequires: chrpath BuildRequires: gettext BuildRequires: perl-interpreter @@ -40,11 +46,19 @@ Patch01: 0001-gdbus-unix-addresses-test-don-t-g_debug-when-also-te.patch # Backported from git master Patch10: 0001-codegen-Change-pointer-casting-to-remove-type-punnin.patch Patch11: 0001-spawn-add-shebang-line-to-script.patch +Patch12: 0001-build-sys-Pass-CFLAGS-to-DTRACE.patch +Patch13: 0001-gfile-Limit-access-to-files-when-copying.patch # Backported from git glib-2-56 branch Patch20: 0001-tests-Allocate-gvariant-data-from-the-heap-to-guaran.patch Patch21: 0002-gvariant-test-Also-force-alignment-for-tuple-test-da.patch +# Backported from 2.58 (for 3.32 GNOME rebase) +Patch30: backport-per-desktop-overrides.patch + +# Backported from git +Patch40: 0001-gdbus-codegen-honor-Property.EmitsChangedSignal-anno.patch + %description GLib is the low-level core library that forms the basis for projects such as GTK+ and GNOME. It provides data structure handling for C, @@ -93,6 +107,9 @@ the functionality of the installed glib2 package. %prep %autosetup -n glib-%{version} -p1 +# restore timestamps after patching to appease multilib for .pyc files +tar vtf %{SOURCE0} | while read mode user size date time name; do touch -d "$date $time" ../$name; done + %build autoreconf -f -i @@ -239,6 +256,27 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || : %{_datadir}/installed-tests %changelog +* Sat Jul 13 2019 Colin Walters - 2.56.4-7 +- Backport patch for CVE-2019-12450 + Resolves: #1722101 + +* Mon Jun 17 2019 Ray Strode - 2.56.4-5 +- Backport glib2 change needed for accountsservice dbus + codegen fix + Resolves: #1713081 + +* Mon Jun 10 2019 Colin Walters - 2.56.4-4 +- Back GHmac with GnuTLS for FIPS +- Resolves: #1630260 + +* Fri May 31 2019 Florian Müllner - 2.56.4-3 +- Backport per-desktop overrides +- Resolves: #1715951 + +* Tue Apr 02 2019 Colin Walters - 2.56.4-2 +- Add system LDFLAGS +- Resolves: #1630566 + * Mon Jan 14 2019 Kalev Lember - 2.56.4-1 - Update to 2.56.4 - Resolves: #1660859