return CHECK_ERR; \
}
-static struct kdbus_conn *make_conn(const char *buspath)
+static struct kdbus_conn *make_conn(const char *buspath, uint64_t flags)
{
int ret;
struct kdbus_conn *conn;
return NULL;
}
- conn->hello.conn_flags = KDBUS_HELLO_ACCEPT_FD;
+ conn->hello.conn_flags = flags;
conn->hello.attach_flags = KDBUS_ATTACH_TIMESTAMP |
KDBUS_ATTACH_CREDS |
int ret;
/* create a 2nd connection */
- conn = make_conn(env->buspath);
+ conn = make_conn(env->buspath, 0);
ASSERT_RETURN(conn != NULL);
add_match_empty(conn->fd);
return CHECK_OK;
}
+static int check_monitor(struct kdbus_check_env *env)
+{
+ struct kdbus_cmd_name *cmd_name;
+ struct kdbus_conn *conn;
+ size_t size;
+ char *name;
+ int ret;
+
+ conn = make_conn(env->buspath, KDBUS_HELLO_MONITOR);
+ ASSERT_RETURN(conn != NULL);
+
+ /* taking a name must fail */
+ name = "foo.bla.blaz";
+ ret = upload_policy(env->conn->fd, name);
+ ASSERT_RETURN(ret == 0);
+
+ size = sizeof(*cmd_name) + strlen(name) + 1;
+ cmd_name = alloca(size);
+
+ memset(cmd_name, 0, size);
+ strcpy(cmd_name->name, name);
+ cmd_name->size = size;
+ cmd_name->flags = 0;
+
+ /* check that we can acquire a name */
+ ret = ioctl(conn->fd, KDBUS_CMD_NAME_ACQUIRE, cmd_name);
+ ASSERT_RETURN(ret == -1 && errno == EPERM);
+
+ free_conn(conn);
+
+ return CHECK_OK;
+}
+
static int check_name_basic(struct kdbus_check_env *env)
{
struct kdbus_cmd_name *cmd_name;
cmd_name->flags = 0;
/* create a 2nd connection */
- conn = make_conn(env->buspath);
+ conn = make_conn(env->buspath, 0);
ASSERT_RETURN(conn != NULL);
/* allow the new connection to own the same name */
cmd_name->flags = KDBUS_NAME_ALLOW_REPLACEMENT;
/* create a 2nd connection */
- conn = make_conn(env->buspath);
+ conn = make_conn(env->buspath, 0);
ASSERT_RETURN(conn != NULL);
/* allow the new connection to own the same name */
int ret;
/* create a 2nd connection */
- conn = make_conn(env->buspath);
+ conn = make_conn(env->buspath, 0);
ASSERT_RETURN(conn != NULL);
add_match_empty(conn->fd);
}
if (c->flags & CHECK_CREATE_CONN) {
- env->conn = make_conn(env->buspath);
+ env->conn = make_conn(env->buspath, 0);
if (!env->conn)
return EXIT_FAILURE;
}
{ "bus make", check_busmake, 0 },
{ "hello", check_hello, CHECK_CREATE_BUS },
{ "byebye", check_byebye, CHECK_CREATE_BUS | CHECK_CREATE_CONN },
+ { "monitor", check_monitor, CHECK_CREATE_BUS | CHECK_CREATE_CONN },
{ "name basics", check_name_basic, CHECK_CREATE_BUS | CHECK_CREATE_CONN },
{ "name conflict", check_name_conflict, CHECK_CREATE_BUS | CHECK_CREATE_CONN },
{ "name queue", check_name_queue, CHECK_CREATE_BUS | CHECK_CREATE_CONN },