rename "id" to "owner_id" for all actions on behalf of other connections
authorKay Sievers <kay@vrfy.org>
Mon, 23 Dec 2013 18:04:35 +0000 (19:04 +0100)
committerKay Sievers <kay@vrfy.org>
Mon, 23 Dec 2013 18:13:17 +0000 (19:13 +0100)
kdbus.h
match.c
names.c
test/kdbus-util.c
test/test-kdbus.c

diff --git a/kdbus.h b/kdbus.h
index 64bc10cc306468682f7217bb2f8c93149e122c55..7a6225a461c32907e58723653ba5686358c22f81 100644 (file)
--- a/kdbus.h
+++ b/kdbus.h
@@ -528,8 +528,9 @@ enum kdbus_name_flags {
  * struct kdbus_cmd_name - struct to describe a well-known name
  * @size:              The total size of the struct
  * @flags:             Flags for a name entry (KDBUS_NAME_*)
- * @id:                        Privileged users may use this field to (de)register
- *                     names on behalf of other peers.
+ * @owner_id:          The current owner of the name. For requests,
+ *                     privileged users may set this field to
+ *                     (de)register names on behalf of other connections.
  * @conn_flags:                The flags of the owning connection (KDBUS_HELLO_*)
  * @name:              The well-known name
  *
@@ -538,7 +539,7 @@ enum kdbus_name_flags {
 struct kdbus_cmd_name {
        __u64 size;
        __u64 flags;
-       __u64 id;
+       __u64 owner_id;
        __u64 conn_flags;
        char name[0];
 } __attribute__((aligned(8)));
@@ -629,7 +630,7 @@ struct kdbus_conn_info {
 /**
  * struct kdbus_cmd_match - struct to add or remove matches
  * @size:              The total size of the struct
- * @id:                        Privileged users may (de)register matches on behalf
+ * @owner_id:          Privileged users may (de)register matches on behalf
  *                     of other peers. In other cases, set to 0.
  * @cookie:            Userspace supplied cookie. When removing, the cookie
  *                     identifies the match to remove.
@@ -640,7 +641,7 @@ struct kdbus_conn_info {
  */
 struct kdbus_cmd_match {
        __u64 size;
-       __u64 id;
+       __u64 owner_id;
        __u64 cookie;
        struct kdbus_item items[0];
 } __attribute__((aligned(8)));
diff --git a/match.c b/match.c
index d78c18528378de3694954b433cfeaf691a4e2920..160b09299ca33385aab00ea106eebc0364dda5a1 100644 (file)
--- a/match.c
+++ b/match.c
@@ -310,9 +310,9 @@ static int cmd_match_from_user(const struct kdbus_conn *conn,
                return PTR_ERR(cmd_match);
 
        /* privileged users can act on behalf of someone else */
-       if (cmd_match->id == 0)
-               cmd_match->id = conn->id;
-       else if (cmd_match->id != conn->id &&
+       if (cmd_match->owner_id == 0)
+               cmd_match->owner_id = conn->id;
+       else if (cmd_match->owner_id != conn->id &&
                 !kdbus_bus_uid_is_privileged(conn->ep->bus)) {
                kfree(cmd_match);
                return -EPERM;
@@ -369,11 +369,12 @@ int kdbus_match_db_add(struct kdbus_conn *conn, void __user *buf)
        if (ret < 0)
                return ret;
 
-       if (cmd_match->id != 0 && cmd_match->id != conn->id) {
+       if (cmd_match->owner_id != 0 && cmd_match->owner_id != conn->id) {
                struct kdbus_bus *bus = conn->ep->bus;
 
                mutex_lock(&bus->lock);
-               target_conn = kdbus_bus_find_conn_by_id(bus, cmd_match->id);
+               target_conn = kdbus_bus_find_conn_by_id(bus,
+                                                       cmd_match->owner_id);
                mutex_unlock(&bus->lock);
 
                if (!target_conn) {
@@ -531,11 +532,12 @@ int kdbus_match_db_remove(struct kdbus_conn *conn, void __user *buf)
        if (ret < 0)
                return ret;
 
-       if (cmd_match->id != 0 && cmd_match->id != conn->id) {
+       if (cmd_match->owner_id != 0 && cmd_match->owner_id != conn->id) {
                struct kdbus_bus *bus = conn->ep->bus;
 
                mutex_lock(&bus->lock);
-               target_conn = kdbus_bus_find_conn_by_id(bus, cmd_match->id);
+               target_conn = kdbus_bus_find_conn_by_id(bus,
+                                                       cmd_match->owner_id);
                mutex_unlock(&bus->lock);
 
                if (!target_conn) {
diff --git a/names.c b/names.c
index 2f310af8fde6ee4c5d26917e6ff5e996329dc7cf..e9d90f6c0f41985151e361bf1597d4df03ad54b1 100644 (file)
--- a/names.c
+++ b/names.c
@@ -528,7 +528,7 @@ int kdbus_cmd_name_acquire(struct kdbus_name_registry *reg,
        }
 
        /* privileged users can act on behalf of someone else */
-       if (cmd_name->id != 0) {
+       if (cmd_name->owner_id != 0) {
                struct kdbus_conn *new_conn;
                struct kdbus_bus *bus = conn->ep->bus;
 
@@ -538,7 +538,7 @@ int kdbus_cmd_name_acquire(struct kdbus_name_registry *reg,
                }
 
                mutex_lock(&bus->lock);
-               new_conn = kdbus_bus_find_conn_by_id(bus, cmd_name->id);
+               new_conn = kdbus_bus_find_conn_by_id(bus, cmd_name->owner_id);
                mutex_unlock(&bus->lock);
 
                if (!new_conn) {
@@ -628,7 +628,7 @@ int kdbus_cmd_name_release(struct kdbus_name_registry *reg,
        }
 
        /* privileged users can act on behalf of someone else */
-       if (cmd_name->id > 0) {
+       if (cmd_name->owner_id > 0) {
                struct kdbus_bus *bus = conn->ep->bus;
 
                if (!kdbus_bus_uid_is_privileged(bus)) {
@@ -637,7 +637,7 @@ int kdbus_cmd_name_release(struct kdbus_name_registry *reg,
                }
 
                mutex_lock(&bus->lock);
-               conn = kdbus_bus_find_conn_by_id(bus, cmd_name->id);
+               conn = kdbus_bus_find_conn_by_id(bus, cmd_name->owner_id);
                mutex_unlock(&bus->lock);
 
                if (!conn) {
@@ -680,7 +680,7 @@ static int kdbus_name_list_write(struct kdbus_conn *conn,
        if (write) {
                struct kdbus_cmd_name n = {
                        .size = len + nlen,
-                       .id = c->id,
+                       .owner_id = c->id,
                        .flags = e ? e->flags : 0,
                        .conn_flags = c->flags,
                };
index ebda9aadf30092b2977e266130efaaae19e3075f..6e1b56558f438402aee2c1d370ce30b90c57837a 100644 (file)
@@ -475,7 +475,7 @@ int name_list(struct conn *conn, uint64_t flags)
        printf("REGISTRY:\n");
        list = (struct kdbus_name_list *)(conn->buf + cmd_list.offset);
        KDBUS_ITEM_FOREACH(name, list, names)
-               printf("%8llu flags=0x%08llx conn=0x%08llx '%s'\n", name->id,
+               printf("%8llu flags=0x%08llx conn=0x%08llx '%s'\n", name->owner_id,
                       name->flags, name->conn_flags,
                       name->size > sizeof(struct kdbus_cmd_name) ? name->name : "");
        printf("\n");
index 89b1101191dd5c1c6ac47ffe7b49a7614eb4f271..7c00df02d2a0e045f208975937df9e9603d205cf 100644 (file)
@@ -146,7 +146,7 @@ static int conn_is_name_owner(const struct kdbus_conn *conn, uint64_t flags, con
                if (name->size == sizeof(struct kdbus_cmd_name))
                        continue;
 
-               if (name->id == conn->hello.id && strcmp(n, name->name) == 0) {
+               if (name->owner_id == conn->hello.id && strcmp(n, name->name) == 0) {
                        found = 1;
                        break;
                }