Arbitrary string to DBus path

Lennart Poettering mzqohf at 0pointer.de
Fri Nov 15 09:45:40 PST 2013


On Fri, 15.11.13 11:21, Ted Gould (ted at gould.cx) wrote:

> Hello,
> 
> One problem we've had is taking arbitrary string (usually application
> names) and putting them into object paths on DBus.  The characters
> allowed in the path is limited, which is fine, but we need some way to
> represent the string we're passed through that.  libnih has a small
> function[1] that does this by taking any character that isn't an ASCII
> character or digit and putting it's value as ASCII digits after an
> underscore.  We've been using this in various places, and I think it'd
> be useful if there was an algorithm that was included in the DBus
> spec.

Why? The spec is something you should follow to stay interoperable, but
I don't see how a spec on the precise mappings from some project
specific identifiers to bus paths would be needed for that.

> http://bazaar.launchpad.net/~scott/libnih/trunk/view/head:/nih-dbus/dbus_util.c#L38

This algorithm isn't even correct according to the spec. It needs to
escape numeric characters at the beginning of each label, too.

We use a similar algorithm in systemd too:

http://cgit.freedesktop.org/systemd/systemd/tree/src/shared/util.c#n1360

And I am pretty sure that exposing a similar call in a dbus library
implementation certainly would make sense but I really don't see why
there needs to be a spec about this...

(I mean, I am actually for removing stuff from the spec anyway, for
example, I don't see why we need to list annotations in there that have
no clear uses for general implementations of dbus).

Lennart

-- 
Lennart Poettering, Red Hat


More information about the dbus mailing list