diff options
author | Tom Gundersen <teg@jklm.no> | 2015-02-09 12:00:33 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-02-09 12:20:10 +0100 |
commit | c8f5edeab0b007081cf89aeb1d23d428382c2a4f (patch) | |
tree | 6dbdd6b09ed89b0260bcfec20c03dec076612149 /src/network/networkd-link-bus.c | |
parent | networkd: add support for IPv6 tokens (diff) | |
download | systemd-c8f5edeab0b007081cf89aeb1d23d428382c2a4f.tar.xz systemd-c8f5edeab0b007081cf89aeb1d23d428382c2a4f.zip |
networkd: bus - switch to properly escaped object paths
Diffstat (limited to 'src/network/networkd-link-bus.c')
-rw-r--r-- | src/network/networkd-link-bus.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/network/networkd-link-bus.c b/src/network/networkd-link-bus.c index 7c4f47305b..370707c307 100644 --- a/src/network/networkd-link-bus.c +++ b/src/network/networkd-link-bus.c @@ -38,12 +38,18 @@ const sd_bus_vtable link_vtable[] = { }; static char *link_bus_path(Link *link) { + _cleanup_free_ char *ifindex = NULL; char *p; + int r; assert(link); assert(link->ifindex > 0); - if (asprintf(&p, "/org/freedesktop/network1/link/_%d", link->ifindex) < 0) + if (asprintf(&ifindex, "%d", link->ifindex) < 0) + return NULL; + + r = sd_bus_path_encode("/org/freedesktop/network1/link", ifindex, &p); + if (r < 0) return NULL; return p; @@ -80,6 +86,7 @@ int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, char *** } int link_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) { + _cleanup_free_ char *identifier = NULL; Manager *m = userdata; Link *link; int ifindex, r; @@ -90,7 +97,11 @@ int link_object_find(sd_bus *bus, const char *path, const char *interface, void assert(m); assert(found); - if (sscanf(path, "/org/freedesktop/network1/link/_%d", &ifindex) != 1) + r = sd_bus_path_decode(path, "/org/freedesktop/network1/link", &identifier); + if (r < 0) + return 0; + + if (sscanf(identifier, "%d", &ifindex) != 1) return 0; r = link_get(m, ifindex, &link); |