HALF ECHO LEARN / REFERENCE COLLECTION
v262.2src/libsystemd/sd-bus/bus-objects.c
Git blob: aa371cceca8fed558554de425a5b7afabbd09d5b
Lines 1001–2000 of 3,204
assert(path);
/* Tests if there's anything attached directly to this node
* for the specified path */
if (!require_fallback && (n->enumerators || n->object_managers))
return true;
LIST_FOREACH(callbacks, k, n->callbacks) {
if (require_fallback && !k->is_fallback)
continue;
return 1;
}
LIST_FOREACH(vtables, c, n->vtables) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
if (require_fallback && !c->is_fallback)
continue;
r = node_vtable_get_userdata(bus, path, c, NULL, &error);
if (r != 0)
return r;
if (bus->nodes_modified)
return 0;
}
return 0;
}
int introspect_path(
sd_bus *bus,
const char *path,
BusNode *n,
bool require_fallback,
bool ignore_nodes_modified,
bool *found_object,
char **ret,
sd_bus_error *reterr_error) {
_cleanup_ordered_set_free_ OrderedSet *s = NULL;
_cleanup_(introspect_done) BusIntrospect intro = {};
bool empty;
int r;
if (!n) {
n = hashmap_get(bus->nodes, path);
if (!n)
return -ENOENT;
}
r = get_child_nodes(bus, path, n, 0, &s, reterr_error);
if (r < 0)
return r;
if (bus->nodes_modified && !ignore_nodes_modified)
return 0;
r = introspect_begin(&intro, bus->trusted);
if (r < 0)
return r;
r = introspect_write_default_interfaces(&intro, !require_fallback && n->object_managers);
if (r < 0)
return r;
empty = ordered_set_isempty(s);
LIST_FOREACH(vtables, c, n->vtables) {
if (require_fallback && !c->is_fallback)
continue;
r = node_vtable_get_userdata(bus, path, c, NULL, reterr_error);
if (r < 0)
return r;
if (bus->nodes_modified && !ignore_nodes_modified)
return 0;
if (r == 0)
continue;
empty = false;
if (c->vtable[0].flags & SD_BUS_VTABLE_HIDDEN)
continue;
r = introspect_write_interface(&intro, c->interface, c->vtable);
if (r < 0)
return r;
}
if (empty) {
/* Nothing?, let's see if we exist at all, and if not
* refuse to do anything */
r = bus_node_exists(bus, n, path, require_fallback);
if (r <= 0)
return r;
if (bus->nodes_modified && !ignore_nodes_modified)
return 0;
}
if (found_object)
*found_object = true;
r = introspect_write_child_nodes(&intro, s, path);
if (r < 0)
return r;
r = introspect_finish(&intro, ret);
if (r < 0)
return r;
return 1;
}
static int process_introspect(
sd_bus *bus,
sd_bus_message *m,
BusNode *n,
bool require_fallback,
bool *found_object) {
_cleanup_free_ char *s = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
int r;
assert(bus);
assert(m);
assert(n);
assert(found_object);
r = introspect_path(bus, m->path, n, require_fallback, false, found_object, &s, &error);
if (r < 0)
return bus_maybe_reply_error(m, r, &error);
if (r == 0)
/* nodes_modified == true */
return 0;
r = sd_bus_message_new_method_return(m, &reply);
if (r < 0)
return r;
r = sd_bus_message_append(reply, "s", s);
if (r < 0)
return r;
r = sd_bus_send(bus, reply, NULL);
if (r < 0)
return r;
return 1;
}
static int object_manager_serialize_path(
sd_bus *bus,
sd_bus_message *reply,
const char *prefix,
const char *path,
bool require_fallback,
bool *found_object_manager,
sd_bus_error *reterr_error) {
const char *previous_interface = NULL;
bool found_something = false;
BusNode *n;
int r;
assert(bus);
assert(reply);
assert(prefix);
assert(path);
assert(found_object_manager);
assert(reterr_error);
n = hashmap_get(bus->nodes, prefix);
if (!n)
return 0;
if (!require_fallback && n->object_managers)
*found_object_manager = true;
LIST_FOREACH(vtables, i, n->vtables) {
void *u;
if (require_fallback && !i->is_fallback)
continue;
r = node_vtable_get_userdata(bus, path, i, &u, reterr_error);
if (r < 0)
return r;
if (bus->nodes_modified)
return 0;
if (r == 0)
continue;
if (!found_something) {
/* Open the object part */
r = sd_bus_message_open_container(reply, 'e', "oa{sa{sv}}");
if (r < 0)
return r;
r = sd_bus_message_append(reply, "o", path);
if (r < 0)
return r;
r = sd_bus_message_open_container(reply, 'a', "{sa{sv}}");
if (r < 0)
return r;
r = sd_bus_message_append(reply, "{sa{sv}}", "org.freedesktop.DBus.Peer", 0);
if (r < 0)
return r;
r = sd_bus_message_append(reply, "{sa{sv}}", "org.freedesktop.DBus.Introspectable", 0);
if (r < 0)
return r;
r = sd_bus_message_append(reply, "{sa{sv}}", "org.freedesktop.DBus.Properties", 0);
if (r < 0)
return r;
if (*found_object_manager) {
r = sd_bus_message_append(
reply, "{sa{sv}}", "org.freedesktop.DBus.ObjectManager", 0);
if (r < 0)
return r;
}
found_something = true;
}
if (!streq_ptr(previous_interface, i->interface)) {
/* Maybe close the previous interface part */
if (previous_interface) {
r = sd_bus_message_close_container(reply);
if (r < 0)
return r;
r = sd_bus_message_close_container(reply);
if (r < 0)
return r;
}
/* Open the new interface part */
r = sd_bus_message_open_container(reply, 'e', "sa{sv}");
if (r < 0)
return r;
r = sd_bus_message_append(reply, "s", i->interface);
if (r < 0)
return r;
r = sd_bus_message_open_container(reply, 'a', "{sv}");
if (r < 0)
return r;
}
r = vtable_append_all_properties(bus, reply, path, i, u, reterr_error);
if (r < 0)
return r;
if (bus->nodes_modified)
return 0;
previous_interface = i->interface;
}
if (previous_interface) {
r = sd_bus_message_close_container(reply);
if (r < 0)
return r;
r = sd_bus_message_close_container(reply);
if (r < 0)
return r;
}
if (found_something) {
r = sd_bus_message_close_container(reply);
if (r < 0)
return r;
r = sd_bus_message_close_container(reply);
if (r < 0)
return r;
}
return 1;
}
static int object_manager_serialize_path_and_fallbacks(
sd_bus *bus,
sd_bus_message *reply,
const char *path,
sd_bus_error *reterr_error) {
_cleanup_free_ char *prefix = NULL;
size_t pl;
int r;
bool found_object_manager = false;
assert(bus);
assert(reply);
assert(path);
assert(reterr_error);
/* First, add all vtables registered for this path */
r = object_manager_serialize_path(bus, reply, path, path, false, &found_object_manager, reterr_error);
if (r < 0)
return r;
if (bus->nodes_modified)
return 0;
/* Second, add fallback vtables registered for any of the prefixes */
pl = strlen(path);
assert(pl <= BUS_PATH_SIZE_MAX);
prefix = new(char, pl + 1);
if (!prefix)
return -ENOMEM;
OBJECT_PATH_FOREACH_PREFIX(prefix, path) {
r = object_manager_serialize_path(bus, reply, prefix, path, true, &found_object_manager, reterr_error);
if (r < 0)
return r;
if (bus->nodes_modified)
return 0;
}
return 0;
}
static int process_get_managed_objects(
sd_bus *bus,
sd_bus_message *m,
BusNode *n,
bool require_fallback,
bool *found_object) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_ordered_set_free_ OrderedSet *s = NULL;
char *path;
int r;
assert(bus);
assert(m);
assert(n);
assert(found_object);
/* Spec says, GetManagedObjects() is only implemented on the root of a
* sub-tree. Therefore, we require a registered object-manager on
* exactly the queried path, otherwise, we refuse to respond. */
if (require_fallback || !n->object_managers)
return 0;
r = get_child_nodes(bus, m->path, n, CHILDREN_RECURSIVE, &s, &error);
if (r < 0)
return bus_maybe_reply_error(m, r, &error);
if (bus->nodes_modified)
return 0;
r = sd_bus_message_new_method_return(m, &reply);
if (r < 0)
return r;
r = sd_bus_message_open_container(reply, 'a', "{oa{sa{sv}}}");
if (r < 0)
return r;
ORDERED_SET_FOREACH(path, s) {
r = object_manager_serialize_path_and_fallbacks(bus, reply, path, &error);
if (r < 0)
return bus_maybe_reply_error(m, r, &error);
if (bus->nodes_modified)
return 0;
}
r = sd_bus_message_close_container(reply);
if (r < 0)
return r;
r = sd_bus_send(bus, reply, NULL);
if (r < 0)
return r;
return 1;
}
static int object_find_and_run(
sd_bus *bus,
sd_bus_message *m,
const char *p,
bool require_fallback,
bool *found_object) {
BusNode *n;
BusVTableMember vtable_key, *v;
int r;
assert(bus);
assert(m);
assert(p);
assert(found_object);
n = hashmap_get(bus->nodes, p);
if (!n)
return 0;
/* First, try object callbacks */
r = node_callbacks_run(bus, m, n->callbacks, require_fallback, found_object);
if (r != 0)
return r;
if (bus->nodes_modified)
return 0;
if (!m->interface || !m->member)
return 0;
/* Then, look for a known method */
vtable_key.path = (char*) p;
vtable_key.interface = m->interface;
vtable_key.member = m->member;
v = set_get(bus->vtable_methods, &vtable_key);
if (v) {
r = method_callbacks_run(bus, m, v, require_fallback, found_object);
if (r != 0)
return r;
if (bus->nodes_modified)
return 0;
}
/* Then, look for a known property */
if (streq(m->interface, "org.freedesktop.DBus.Properties")) {
bool get = false;
get = streq(m->member, "Get");
if (get || streq(m->member, "Set")) {
r = sd_bus_message_rewind(m, true);
if (r < 0)
return r;
vtable_key.path = (char*) p;
r = sd_bus_message_read(m, "ss", &vtable_key.interface, &vtable_key.member);
if (r < 0)
return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Expected interface and member parameters");
v = set_get(bus->vtable_properties, &vtable_key);
if (v) {
r = property_get_set_callbacks_run(bus, m, v, require_fallback, get, found_object);
if (r != 0)
return r;
}
} else if (streq(m->member, "GetAll")) {
const char *iface;
r = sd_bus_message_rewind(m, true);
if (r < 0)
return r;
r = sd_bus_message_read(m, "s", &iface);
if (r < 0)
return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Expected interface parameter");
if (iface[0] == 0)
iface = NULL;
r = property_get_all_callbacks_run(bus, m, n->vtables, require_fallback, iface, found_object);
if (r != 0)
return r;
}
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
if (!isempty(sd_bus_message_get_signature(m, true)))
return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Expected no parameters");
r = process_introspect(bus, m, n, require_fallback, found_object);
if (r != 0)
return r;
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus.ObjectManager", "GetManagedObjects")) {
if (!isempty(sd_bus_message_get_signature(m, true)))
return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Expected no parameters");
r = process_get_managed_objects(bus, m, n, require_fallback, found_object);
if (r != 0)
return r;
}
if (bus->nodes_modified)
return 0;
if (!*found_object) {
r = bus_node_exists(bus, n, m->path, require_fallback);
if (r < 0)
return bus_maybe_reply_error(m, r, NULL);
if (bus->nodes_modified)
return 0;
if (r > 0)
*found_object = true;
}
return 0;
}
int bus_process_object(sd_bus *bus, sd_bus_message *m) {
_cleanup_free_ char *prefix = NULL;
int r;
size_t pl;
bool found_object = false;
assert(bus);
assert(m);
if (bus->is_monitor)
return 0;
if (m->header->type != SD_BUS_MESSAGE_METHOD_CALL)
return 0;
if (hashmap_isempty(bus->nodes))
return 0;
/* Never respond to broadcast messages */
if (bus->bus_client && !m->destination)
return 0;
assert(m->path);
assert(m->member);
pl = strlen(m->path);
assert(pl <= BUS_PATH_SIZE_MAX);
prefix = new(char, pl + 1);
if (!prefix)
return -ENOMEM;
do {
bus->nodes_modified = false;
r = object_find_and_run(bus, m, m->path, false, &found_object);
if (r != 0)
return r;
/* Look for fallback prefixes */
OBJECT_PATH_FOREACH_PREFIX(prefix, m->path) {
if (bus->nodes_modified)
break;
r = object_find_and_run(bus, m, prefix, true, &found_object);
if (r != 0)
return r;
}
} while (bus->nodes_modified);
if (!found_object)
return 0;
if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus.Properties", "Get") ||
sd_bus_message_is_method_call(m, "org.freedesktop.DBus.Properties", "Set")) {
const char *interface = NULL, *property = NULL;
(void) sd_bus_message_rewind(m, true);
(void) sd_bus_message_read_basic(m, 's', &interface);
(void) sd_bus_message_read_basic(m, 's', &property);
r = sd_bus_reply_method_errorf(
m,
SD_BUS_ERROR_UNKNOWN_PROPERTY,
"Unknown interface %s or property %s.", strnull(interface), strnull(property));
} else
r = sd_bus_reply_method_errorf(
m,
SD_BUS_ERROR_UNKNOWN_METHOD,
"Unknown method %s or interface %s.", m->member, m->interface);
if (r < 0)
return r;
return 1;
}
static BusNode* bus_node_allocate(sd_bus *bus, const char *path) {
BusNode *n, *parent;
const char *e;
_cleanup_free_ char *s = NULL;
char *p;
int r;
assert(bus);
assert(path);
assert(path[0] == '/');
n = hashmap_get(bus->nodes, path);
if (n)
return n;
r = hashmap_ensure_allocated(&bus->nodes, &string_hash_ops);
if (r < 0)
return NULL;
s = strdup(path);
if (!s)
return NULL;
if (streq(path, "/"))
parent = NULL;
else {
assert_se(e = strrchr(path, '/'));
p = strndupa_safe(path, MAX(1, e - path));
parent = bus_node_allocate(bus, p);
if (!parent)
return NULL;
}
n = new0(BusNode, 1);
if (!n)
return NULL;
n->parent = parent;
n->path = TAKE_PTR(s);
r = hashmap_put(bus->nodes, n->path, n);
if (r < 0) {
free(n->path);
return mfree(n);
}
if (parent)
LIST_PREPEND(siblings, parent->child, n);
return n;
}
void bus_node_gc(sd_bus *b, BusNode *n) {
assert(b);
if (!n)
return;
if (n->child ||
n->callbacks ||
n->vtables ||
n->enumerators ||
n->object_managers)
return;
assert_se(hashmap_remove(b->nodes, n->path) == n);
if (n->parent)
LIST_REMOVE(siblings, n->parent->child, n);
free(n->path);
bus_node_gc(b, n->parent);
free(n);
}
static int bus_find_parent_object_manager(sd_bus *bus, BusNode **out, const char *path, bool* path_has_object_manager) {
BusNode *n;
assert(bus);
assert(path);
assert(path_has_object_manager);
n = hashmap_get(bus->nodes, path);
if (n)
*path_has_object_manager = n->object_managers;
if (!n) {
_cleanup_free_ char *prefix = NULL;
size_t pl;
pl = strlen(path);
assert(pl <= BUS_PATH_SIZE_MAX);
prefix = new(char, pl + 1);
if (!prefix)
return -ENOMEM;
OBJECT_PATH_FOREACH_PREFIX(prefix, path) {
n = hashmap_get(bus->nodes, prefix);
if (n)
break;
}
}
while (n && !n->object_managers)
n = n->parent;
if (out)
*out = n;
return !!n;
}
static int bus_add_object(
sd_bus *bus,
sd_bus_slot **ret_slot,
bool fallback,
const char *path,
sd_bus_message_handler_t callback,
void *userdata) {
sd_bus_slot *s;
BusNode *n;
int r;
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(object_path_is_valid(path), -EINVAL);
assert_return(callback, -EINVAL);
assert_return(!bus_origin_changed(bus), -ECHILD);
n = bus_node_allocate(bus, path);
if (!n)
return -ENOMEM;
s = bus_slot_allocate(bus, !ret_slot, BUS_NODE_CALLBACK, sizeof(BusNodeCallback), userdata);
if (!s) {
r = -ENOMEM;
goto fail;
}
s->node_callback.callback = callback;
s->node_callback.is_fallback = fallback;
s->node_callback.node = n;
LIST_PREPEND(callbacks, n->callbacks, &s->node_callback);
bus->nodes_modified = true;
if (ret_slot)
*ret_slot = s;
return 0;
fail:
sd_bus_slot_unref(s);
bus_node_gc(bus, n);
return r;
}
_public_ int sd_bus_add_object(
sd_bus *bus,
sd_bus_slot **ret_slot,
const char *path,
sd_bus_message_handler_t callback,
void *userdata) {
return bus_add_object(bus, ret_slot, false, path, callback, userdata);
}
_public_ int sd_bus_add_fallback(
sd_bus *bus,
sd_bus_slot **ret_slot,
const char *prefix,
sd_bus_message_handler_t callback,
void *userdata) {
return bus_add_object(bus, ret_slot, true, prefix, callback, userdata);
}
static void vtable_member_hash_func(const BusVTableMember *m, struct siphash *state) {
assert(m);
string_hash_func(m->path, state);
string_hash_func(m->interface, state);
string_hash_func(m->member, state);
}
static int vtable_member_compare_func(const BusVTableMember *x, const BusVTableMember *y) {
int r;
assert(x);
assert(y);
r = strcmp(x->path, y->path);
if (r != 0)
return r;
r = strcmp(x->interface, y->interface);
if (r != 0)
return r;
return strcmp(x->member, y->member);
}
DEFINE_PRIVATE_HASH_OPS_WITH_KEY_DESTRUCTOR(
vtable_member_hash_ops,
BusVTableMember, vtable_member_hash_func, vtable_member_compare_func, free);
typedef enum {
NAMES_FIRST_PART = 1 << 0, /* first part of argument name list (input names). It is reset by names_are_valid() */
NAMES_PRESENT = 1 << 1, /* at least one argument name is present, so the names will checked.
This flag is set and used internally by names_are_valid(), but needs to be stored across calls for 2-parts list */
NAMES_SINGLE_PART = 1 << 2, /* argument name list consisting of a single part */
} names_flags;
static bool names_are_valid(const char *signature, const char **names, names_flags *flags) {
int r;
assert(signature);
assert(names);
assert(flags);
if ((*flags & NAMES_FIRST_PART || *flags & NAMES_SINGLE_PART) && **names != '\0')
*flags |= NAMES_PRESENT;
while (*flags & NAMES_PRESENT) {
size_t l;
if (!*signature)
break;
r = signature_element_length(signature, &l);
if (r < 0)
return false;
if (**names != '\0') {
if (!member_name_is_valid(*names))
return false;
*names += strlen(*names) + 1;
} else if (*flags & NAMES_PRESENT)
return false;
signature += l;
}
/* let's check if there are more argument names specified than the signature allows */
if (*flags & NAMES_PRESENT && **names != '\0' && !(*flags & NAMES_FIRST_PART))
return false;
*flags &= ~NAMES_FIRST_PART;
return true;
}
/* the current version of this struct is defined in sd-bus-vtable.h, but we need to list here the historical versions
to make sure the calling code is compatible with one of these */
struct sd_bus_vtable_221 {
uint8_t type:8;
uint64_t flags:56;
union {
struct {
size_t element_size;
} start;
struct {
const char *member;
const char *signature;
const char *result;
sd_bus_message_handler_t handler;
size_t offset;
} method;
struct {
const char *member;
const char *signature;
} signal;
struct {
const char *member;
const char *signature;
sd_bus_property_get_t get;
sd_bus_property_set_t set;
size_t offset;
} property;
} x;
};
/* Structure size up to v241 */
#define VTABLE_ELEMENT_SIZE_221 sizeof(struct sd_bus_vtable_221)
/* Size of the structure when "features" field was added. If the structure definition is augmented, a copy of
* the structure definition will need to be made (similarly to the sd_bus_vtable_221 above), and this
* definition updated to refer to it. */
#define VTABLE_ELEMENT_SIZE_242 sizeof(struct sd_bus_vtable)
static int vtable_features(const sd_bus_vtable *vtable) {
if (vtable[0].x.start.element_size < VTABLE_ELEMENT_SIZE_242 ||
!vtable[0].x.start.vtable_format_reference)
return 0;
return vtable[0].x.start.features;
}
bool bus_vtable_has_names(const sd_bus_vtable *vtable) {
return vtable_features(vtable) & _SD_BUS_VTABLE_PARAM_NAMES;
}
const sd_bus_vtable* bus_vtable_next(const sd_bus_vtable *vtable, const sd_bus_vtable *v) {
return (const sd_bus_vtable*) ((char*) v + vtable[0].x.start.element_size);
}
static int add_object_vtable_internal(
sd_bus *bus,
sd_bus_slot **ret_slot,
const char *path,
const char *interface,
const sd_bus_vtable *vtable,
bool fallback,
sd_bus_object_find_t find,
void *userdata) {
sd_bus_slot *s = NULL;
BusNodeVTable *existing = NULL;
const sd_bus_vtable *v;
BusNode *n;
int r;
const char *names = "";
names_flags nf;
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(object_path_is_valid(path), -EINVAL);
assert_return(interface_name_is_valid(interface), -EINVAL);
assert_return(vtable, -EINVAL);
assert_return(vtable[0].type == _SD_BUS_VTABLE_START, -EINVAL);
assert_return(vtable[0].x.start.element_size == VTABLE_ELEMENT_SIZE_221 ||
vtable[0].x.start.element_size >= VTABLE_ELEMENT_SIZE_242,
-EINVAL);
assert_return(!bus_origin_changed(bus), -ECHILD);
assert_return(!streq(interface, "org.freedesktop.DBus.Properties") &&
!streq(interface, "org.freedesktop.DBus.Introspectable") &&
!streq(interface, "org.freedesktop.DBus.Peer") &&
!streq(interface, "org.freedesktop.DBus.ObjectManager"), -EINVAL);
n = bus_node_allocate(bus, path);
if (!n)
return -ENOMEM;
LIST_FOREACH(vtables, i, n->vtables) {
if (i->is_fallback != fallback) {
r = -EPROTOTYPE;
goto fail;
}
if (streq(i->interface, interface)) {
if (i->vtable == vtable) {
r = -EEXIST;
goto fail;
}
existing = i;
}
}
s = bus_slot_allocate(bus, !ret_slot, BUS_NODE_VTABLE, sizeof(BusNodeVTable), userdata);
if (!s) {
r = -ENOMEM;
goto fail;
}
s->node_vtable.is_fallback = fallback;
s->node_vtable.vtable = vtable;
s->node_vtable.find = find;
s->node_vtable.interface = strdup(interface);
if (!s->node_vtable.interface) {
r = -ENOMEM;
goto fail;
}
v = s->node_vtable.vtable;
for (v = bus_vtable_next(vtable, v); v->type != _SD_BUS_VTABLE_END; v = bus_vtable_next(vtable, v)) {
switch (v->type) {
case _SD_BUS_VTABLE_METHOD: {
BusVTableMember *m;
nf = NAMES_FIRST_PART;
if (bus_vtable_has_names(vtable))
names = strempty(v->x.method.names);
if (!member_name_is_valid(v->x.method.member) ||
!signature_is_valid(strempty(v->x.method.signature), false) ||
!signature_is_valid(strempty(v->x.method.result), false) ||
!names_are_valid(strempty(v->x.method.signature), &names, &nf) ||
!names_are_valid(strempty(v->x.method.result), &names, &nf) ||
!(v->x.method.handler || (isempty(v->x.method.signature) && isempty(v->x.method.result))) ||
v->flags & (SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE|SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION)) {
r = -EINVAL;
goto fail;
}
m = new0(BusVTableMember, 1);
if (!m) {
r = -ENOMEM;
goto fail;
}
m->parent = &s->node_vtable;