#include "unit.h"
#include "utf8.h"
+static int property_get_where(
+ sd_bus *bus,
+ const char *path,
+ const char *interface,
+ const char *property,
+ sd_bus_message *reply,
+ void *userdata,
+ sd_bus_error *error) {
+
+ Mount *m = ASSERT_PTR(userdata);
+
+ assert(bus);
+ assert(reply);
+
+ _cleanup_free_ char *escaped = mount_get_where_escaped(m);
+ if (!escaped)
+ return -ENOMEM;
+
+ return sd_bus_message_append_basic(reply, 's', escaped);
+}
+
static int property_get_what(
sd_bus *bus,
const char *path,
const sd_bus_vtable bus_mount_vtable[] = {
SD_BUS_VTABLE_START(0),
- SD_BUS_PROPERTY("Where", "s", NULL, offsetof(Mount, where), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("Where", "s", property_get_where, 0, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("What", "s", property_get_what, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Options", "s", property_get_options, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Type", "s", property_get_type, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
path_simplify(m->where);
if (!u->description) {
- r = unit_set_description(u, m->where);
+ _cleanup_free_ char *w = mount_get_where_escaped(m);
+ if (!w)
+ return log_oom();
+
+ r = unit_set_description(u, w);
if (r < 0)
return r;
}
return sd_event_source_is_ratelimited(m->mount_event_source);
}
+char* mount_get_where_escaped(const Mount *m) {
+ assert(m);
+
+ if (!m->where)
+ return strdup("");
+
+ return utf8_escape_invalid(m->where);
+}
+
char* mount_get_what_escaped(const Mount *m) {
_cleanup_free_ char *escaped = NULL;
const char *s = NULL;
int mount_invalidate_state_by_path(Manager *manager, const char *path);
+char* mount_get_where_escaped(const Mount *m);
char* mount_get_what_escaped(const Mount *m);
char* mount_get_options_escaped(const Mount *m);
const char* mount_get_fstype(const Mount *m);
cp /proc/1/mountinfo "$TMP_MOUNTINFO"
# Add a mount entry with a "Unicode non-character" in it
-LANG="C.UTF-8" printf '69 1 252:2 / /foo/mountinfo rw,relatime shared:1 - cifs //foo\ufffebar rw,seclabel\n' >>"$TMP_MOUNTINFO"
+LANG="C.UTF-8" printf '69 1 252:2 / /foo/mount\ufffeinfo rw,relatime shared:1 - cifs //foo\ufffebar rw,seclabel\n' >>"$TMP_MOUNTINFO"
mount --bind "$TMP_MOUNTINFO" /proc/1/mountinfo
systemctl daemon-reload
# On affected versions this would throw an error:
# Failed to get properties: Bad message
-systemctl status foo-mountinfo.mount
+systemctl list-units -t mount
+systemctl status foo-mount\\xef\\xbf\\xbeinfo.mount
umount /proc/1/mountinfo
systemctl daemon-reload