summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyotaek Shim <hyotaek.shim@samsung.com>2016-09-04 19:38:59 -0700
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>2016-09-04 19:38:59 -0700
commit6548bd155c97a33d9c293192ca92c6b0e02a2a42 (patch)
treefa1843defbb589e5cc5ab871a88310ebe0adfe6b
parent529196aff1705d96c61521e75e618ece4ce75254 (diff)
parent09e57e6a9079157ca71433cd05e0413c54ce9ed5 (diff)
downloadlibdbuspolicy-submit/tizen/20160905.095924.tar.gz
libdbuspolicy-submit/tizen/20160905.095924.tar.bz2
libdbuspolicy-submit/tizen/20160905.095924.zip
-rw-r--r--src/libdbuspolicy1.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/src/libdbuspolicy1.c b/src/libdbuspolicy1.c
index e1e9216..bce1ed5 100644
--- a/src/libdbuspolicy1.c
+++ b/src/libdbuspolicy1.c
@@ -44,6 +44,8 @@
#define SYSTEM_BUS 0
#define SESSION_BUS 1
+#define CONNECTION_LABEL "libdbuspolicy1-kdbus"
+
#define ALIGN8(l) (((l) + 7) & ~7)
#define ALIGNDN8(l) ((l) & ~7)
#define UID_INVALID ((uid_t) -1)
@@ -78,27 +80,39 @@ static int kdbus_open_bus(const char *path)
static int kdbus_hello(bool bus_type, uint64_t hello_flags, uint64_t attach_flags_send, uint64_t attach_flags_recv)
{
- struct kdbus_cmd_hello cmd;
+ struct kdbus_cmd_hello* cmd;
struct kdbus_cmd_free cmd_free;
+ volatile struct kdbus_item* item;
int fd = g_conn[bus_type].fd;
-
- cmd.size = sizeof(cmd);
- cmd.flags = hello_flags;
- cmd.attach_flags_send = attach_flags_send;
- cmd.attach_flags_recv = attach_flags_recv;
- cmd.pool_size = KDBUS_POOL_SIZE;
-
- if (ioctl(fd, KDBUS_CMD_HELLO, &cmd) < 0)
- return -errno;
-
- g_conn[bus_type].id = cmd.id;
+ int size = ALIGN8(sizeof(struct kdbus_cmd_hello)) + ALIGN8(offsetof(struct kdbus_item, data) + sizeof(CONNECTION_LABEL));
+
+ cmd = calloc(1, size);
+ cmd->size = size;
+ cmd->flags = hello_flags;
+ cmd->attach_flags_send = attach_flags_send;
+ cmd->attach_flags_recv = attach_flags_recv;
+ cmd->pool_size = KDBUS_POOL_SIZE;
+
+ item = cmd->items;
+ item->size = offsetof(struct kdbus_item, data) + sizeof(CONNECTION_LABEL);
+ item->type = KDBUS_ITEM_CONN_DESCRIPTION;
+ memcpy (item->str, CONNECTION_LABEL, sizeof(CONNECTION_LABEL));
+ if (ioctl(fd, KDBUS_CMD_HELLO, cmd) < 0)
+ goto err;
+
+ g_conn[bus_type].id = cmd->id;
if (MAP_FAILED == (g_conn[bus_type].pool = mmap(NULL, KDBUS_POOL_SIZE, PROT_READ, MAP_SHARED, fd, 0)))
- return -errno;
+ goto err;
- cmd_free.offset = cmd.offset;
+ cmd_free.offset = cmd->offset;
cmd_free.size = sizeof(struct kdbus_cmd_free);
ioctl(g_conn[bus_type].fd, KDBUS_CMD_FREE, &cmd_free);
+ free(cmd);
return 0;
+
+err:
+ free(cmd);
+ return -errno;
}
static bool kdbus_is_unique_id(const char* name)