struct kdbus_conn *kdbus_hello_activator(const char *path, const char *name, const struct kdbus_policy_access *access, size_t num_access) { return kdbus_hello_registrar(path, name, access, num_access, KDBUS_HELLO_ACTIVATOR); }
static int kdbus_test_broadcast_quota(struct kdbus_test_env *env) { int ret; uint64_t offset; unsigned int i; struct kdbus_msg *msg; struct kdbus_conn *privileged_a; struct kdbus_conn *privileged_b; struct kdbus_conn *holder; struct kdbus_policy_access access = { .type = KDBUS_POLICY_ACCESS_WORLD, .id = getuid(), .access = KDBUS_POLICY_TALK, }; uint64_t expected_cookie = time(NULL) ^ 0xdeadbeef; holder = kdbus_hello_registrar(env->buspath, "com.example.a", &access, 1, KDBUS_HELLO_POLICY_HOLDER); ASSERT_RETURN(holder); privileged_a = kdbus_hello(env->buspath, 0, NULL, 0); ASSERT_RETURN(privileged_a); privileged_b = kdbus_hello(env->buspath, 0, NULL, 0); ASSERT_RETURN(privileged_b); /* Acquire name with access world so they can talk to us */ ret = kdbus_name_acquire(privileged_a, "com.example.a", NULL); ASSERT_RETURN(ret >= 0); /* Broadcast matches for privileged connections */ ret = kdbus_add_match_empty(privileged_a); ASSERT_RETURN(ret == 0); ret = kdbus_add_match_empty(privileged_b); ASSERT_RETURN(ret == 0); /* * We start accouting after KDBUS_CONN_MAX_MSGS_UNACCOUNTED * so the first sender will at least send * KDBUS_CONN_MAX_MSGS_UNACCOUNTED + KDBUS_CONN_MAX_MSGS_PER_USER */ ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({ unsigned int cnt; cnt = kdbus_fill_conn_queue(unpriv, KDBUS_DST_ID_BROADCAST, MAX_USER_TOTAL_MSGS); ASSERT_EXIT(cnt == MAX_USER_TOTAL_MSGS); /* * Another message that will trigger the lost count * * Broadcasts always succeed */ ret = kdbus_msg_send(unpriv, NULL, 0xdeadbeef, 0, 0, 0, KDBUS_DST_ID_BROADCAST); ASSERT_EXIT(ret == 0); }));
/* return TEST_OK or TEST_ERR on failure */ static int kdbus_register_policy_holder(char *bus, const char *name, struct kdbus_conn **conn) { struct kdbus_conn *c; struct kdbus_policy_access access[2]; access[0].type = KDBUS_POLICY_ACCESS_USER; access[0].access = KDBUS_POLICY_OWN; access[0].id = geteuid(); access[1].type = KDBUS_POLICY_ACCESS_WORLD; access[1].access = KDBUS_POLICY_TALK; access[1].id = geteuid(); c = kdbus_hello_registrar(bus, name, access, 2, KDBUS_HELLO_POLICY_HOLDER); ASSERT_RETURN(c); *conn = c; return TEST_OK; }