mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
gdbusobjectmanagerserver: Disallow child objects at /
Previously, the code validated that child objects have a path with the object manager strictly as a prefix. That doesn’t work in the case where the object manager’s path is `/`. This case is not recommended, but is supported. If the object manager’s path is `/`, validate that child objects’ paths are not equal to it. If they are equal to it, warn the user rather than emitting a critical warning, since we can’t expect any users who’ve not been compliant with the spec to instantly rework their D-Bus APIs. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #2500
This commit is contained in:
parent
1c37f08004
commit
f0e0754f62
@ -457,10 +457,31 @@ registration_data_free (RegistrationData *data)
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
/* Validate whether an object path is valid as a child of the manager. According
|
||||
* to the specification:
|
||||
* https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager
|
||||
* this means that:
|
||||
* > All returned object paths are children of the object path implementing this
|
||||
* > interface, i.e. their object paths start with the ObjectManager's object
|
||||
* > path plus '/'
|
||||
*
|
||||
* For example, if the manager is at `/org/gnome/Example`, children will be
|
||||
* `/org/gnome/Example/(.+)`.
|
||||
*
|
||||
* It is permissible (but not encouraged) for the manager to be at `/`. If so,
|
||||
* children will be `/(.+)`.
|
||||
*/
|
||||
static gboolean
|
||||
is_valid_child_object_path (GDBusObjectManagerServer *manager,
|
||||
const gchar *child_object_path)
|
||||
{
|
||||
/* Historically GDBus accepted @child_object_paths at `/` if the @manager
|
||||
* itself is also at `/". This is not spec-compliant, but making GDBus enforce
|
||||
* the spec more strictly would be an incompatible change.
|
||||
*
|
||||
* See https://gitlab.gnome.org/GNOME/glib/-/issues/2500 */
|
||||
g_warn_if_fail (!g_str_equal (child_object_path, manager->priv->object_path_ending_in_slash));
|
||||
|
||||
return g_str_has_prefix (child_object_path, manager->priv->object_path_ending_in_slash);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user