remove no longer needed "on behalf" logic (ABI break)
authorKay Sievers <kay@vrfy.org>
Tue, 22 Apr 2014 20:25:29 +0000 (22:25 +0200)
committerKay Sievers <kay@vrfy.org>
Tue, 22 Apr 2014 21:17:55 +0000 (23:17 +0200)
kdbus.h
match.c
names.c

diff --git a/kdbus.h b/kdbus.h
index af5e243aebccb19b749a131a1a934ebda27cbabd..b8861ceb017659557c47cd198a792f967684ff46 100644 (file)
--- a/kdbus.h
+++ b/kdbus.h
@@ -716,8 +716,6 @@ struct kdbus_cmd_update {
 /**
  * struct kdbus_cmd_match - struct to add or remove matches
  * @size:              The total size of the struct
- * @owner_id:          Privileged users may (de)register matches on behalf
- *                     of other peers
  * @cookie:            Userspace supplied cookie. When removing, the cookie
  *                     identifies the match to remove
  * @items:             A list of items for additional information
@@ -727,7 +725,6 @@ struct kdbus_cmd_update {
  */
 struct kdbus_cmd_match {
        __u64 size;
-       __u64 owner_id;
        __u64 cookie;
        struct kdbus_item items[0];
 } __attribute__((aligned(8)));
diff --git a/match.c b/match.c
index ccc4042bb338c52c871b6658e26e119cb79bfea7..be25038d9954fcb6bfae5a1df917f165cf070be0 100644 (file)
--- a/match.c
+++ b/match.c
@@ -343,32 +343,12 @@ bool kdbus_match_db_match_kmsg(struct kdbus_match_db *db,
 int kdbus_match_db_add(struct kdbus_conn *conn,
                       struct kdbus_cmd_match *cmd)
 {
-       struct kdbus_conn *target_conn = NULL;
        struct kdbus_match_entry *entry = NULL;
-       struct kdbus_match_db *db;
+       struct kdbus_match_db *db = conn->match_db;
        struct kdbus_item *item;
        LIST_HEAD(list);
        int ret = 0;
 
-       /* privileged users can act on behalf of someone else */
-       if (cmd->owner_id == 0)
-               cmd->owner_id = conn->id;
-       else if (cmd->owner_id != conn->id &&
-                !kdbus_bus_uid_is_privileged(conn->bus))
-               return -EPERM;
-
-       if (cmd->owner_id != 0 && cmd->owner_id != conn->id) {
-               target_conn = kdbus_conn_find_peer(conn, cmd->owner_id);
-               if (!target_conn) {
-                       ret = -ENXIO;
-                       goto exit_free;
-               }
-
-               db = target_conn->match_db;
-       } else {
-               db = conn->match_db;
-       }
-
        entry = kzalloc(sizeof(*entry), GFP_KERNEL);
        if (!entry) {
                ret = -ENOMEM;
@@ -376,7 +356,6 @@ int kdbus_match_db_add(struct kdbus_conn *conn,
        }
 
        entry->cookie = cmd->cookie;
-
        INIT_LIST_HEAD(&entry->rules_list);
 
        KDBUS_ITEMS_FOREACH(item, cmd->items, KDBUS_ITEMS_SIZE(cmd, items)) {
@@ -499,8 +478,6 @@ int kdbus_match_db_add(struct kdbus_conn *conn,
                kdbus_match_entry_free(entry);
 
 exit_free:
-       kdbus_conn_unref(target_conn);
-
        return ret;
 }
 
@@ -517,26 +494,8 @@ exit_free:
 int kdbus_match_db_remove(struct kdbus_conn *conn,
                          struct kdbus_cmd_match *cmd)
 {
-       struct kdbus_conn *target_conn = NULL;
        struct kdbus_match_entry *entry, *tmp;
-       struct kdbus_match_db *db;
-
-       /* privileged users can act on behalf of someone else */
-       if (cmd->owner_id == 0)
-               cmd->owner_id = conn->id;
-       else if (cmd->owner_id != conn->id &&
-                !kdbus_bus_uid_is_privileged(conn->bus))
-               return -EPERM;
-
-       if (cmd->owner_id != 0 && cmd->owner_id != conn->id) {
-               target_conn = kdbus_conn_find_peer(conn, cmd->owner_id);
-               if (!target_conn)
-                       return -ENXIO;
-
-               db = target_conn->match_db;
-       } else {
-               db = conn->match_db;
-       }
+       struct kdbus_match_db *db = conn->match_db;
 
        mutex_lock(&db->entries_lock);
        list_for_each_entry_safe(entry, tmp, &db->entries_list, list_entry)
@@ -544,7 +503,5 @@ int kdbus_match_db_remove(struct kdbus_conn *conn,
                        kdbus_match_entry_free(entry);
        mutex_unlock(&db->entries_lock);
 
-       kdbus_conn_unref(target_conn);
-
        return 0;
 }
diff --git a/names.c b/names.c
index 70407d2fc836ecdf693051f6b7725f6eeaeba31a..92aa4cdb45a2cbdb183005aa29ab77eeed304e22 100644 (file)
--- a/names.c
+++ b/names.c
@@ -650,43 +650,24 @@ int kdbus_cmd_name_acquire(struct kdbus_name_registry *reg,
            !kdbus_name_is_valid(cmd->name, false))
                return -EINVAL;
 
-       /* privileged users can act on behalf of someone else */
-       if (cmd->owner_id != 0) {
-               struct kdbus_conn *new_conn;
-               struct kdbus_bus *bus = conn->bus;
-
-               if (!kdbus_bus_uid_is_privileged(bus))
-                       return -EPERM;
-
-               new_conn = kdbus_conn_find_peer(conn, cmd->owner_id);
-               if (!new_conn)
-                       return -ENXIO;
-
-               conn = new_conn;
-       } else {
-               kdbus_conn_ref(conn);
-       }
-
        if (conn->bus->policy_db) {
                ret = kdbus_policy_check_own_access(conn->bus->policy_db,
                                                    conn, cmd->name);
                if (ret < 0)
-                       goto exit_unref_conn;
+                       goto exit;
        }
 
        if (conn->ep->policy_db) {
                ret = kdbus_policy_check_own_access(conn->ep->policy_db,
                                                    conn, cmd->name);
                if (ret < 0)
-                       goto exit_unref_conn;
+                       goto exit;
        }
 
        ret = kdbus_name_acquire(reg, conn, cmd->name, &cmd->flags, &e);
 
-exit_unref_conn:
+exit:
        kdbus_notify_flush(conn->bus);
-       kdbus_conn_unref(conn);
-
        return ret;
 }
 
@@ -702,29 +683,14 @@ int kdbus_cmd_name_release(struct kdbus_name_registry *reg,
                           struct kdbus_conn *conn,
                           const struct kdbus_cmd_name *cmd)
 {
-       struct kdbus_bus *bus = conn->bus;
        int ret = 0;
 
        if (!kdbus_name_is_valid(cmd->name, false))
                return -EINVAL;
 
-       /* privileged users can act on behalf of someone else */
-       if (cmd->owner_id > 0) {
-               if (!kdbus_bus_uid_is_privileged(bus))
-                       return -EPERM;
-
-               conn = kdbus_conn_find_peer(conn, cmd->owner_id);
-               if (!conn)
-                       return -ENXIO;
-       } else {
-               kdbus_conn_ref(conn);
-       }
-
        ret = kdbus_name_release(reg, conn, cmd->name);
 
        kdbus_notify_flush(conn->bus);
-       kdbus_conn_unref(conn);
-
        return ret;
 }