[systemd-devel] DBus service name encoding
lennart at poettering.net
Mon Mar 4 06:31:16 PST 2013
On Sun, 03.03.13 19:06, David Strauss (david at davidstrauss.net) wrote:
> I can't find any documentation on how service names get encoded for
> DBus. It looks pretty close to URL encoding with underscores instead
> of percent signs.
> If I can get a definitive answer, I'll update the wiki. If I can't, I
> can, of course, dive into the source.
This hasn't been documented since it so far wasn't part of the official
ABI. So far you were supposed to invoke GetUnit() with an unescaped unit
name, and it would return you the (escaped) bus path for it. Now, a
while back systemctl was updated to simply do the escaping on the client
side, to get rid of this roundtrip. systemctl of course is shipped with
systemd, so it's not a problem for it to make use of this undocumented
behaviour. That said, we could (and probably should) just open this up
for external users too.
So here's how to do this, it's very simple: every char outside of the
A-Za-z0-9 range is escaped as "_XY" where XY is the numeric code of the
char, as 2 char lower-case hex value. Note that "_" itself is also
escaped, to "_5f".
This is implemented in bus_path_escape() in src/shared/util.c.
If you want to make use of it, please update the wiki dbus docs for the
PID 1 interfaces, and document this there to make this official ABI, and
refer to the sources (and maybe this mail). Please also add a comment
line to the sources referring back to the wiki, so that people who
change bus_path_escape() are aware that this is something that is part
of the documented ABI.
Lennart Poettering - Red Hat, Inc.
More information about the systemd-devel