diff options
author | Hyotaek Shim <hyotaek.shim@samsung.com> | 2016-09-04 19:38:59 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.vlan103.tizen.org> | 2016-09-04 19:38:59 -0700 |
commit | 6548bd155c97a33d9c293192ca92c6b0e02a2a42 (patch) | |
tree | fa1843defbb589e5cc5ab871a88310ebe0adfe6b | |
parent | 529196aff1705d96c61521e75e618ece4ce75254 (diff) | |
parent | 09e57e6a9079157ca71433cd05e0413c54ce9ed5 (diff) | |
download | libdbuspolicy-submit/tizen/20160905.095924.tar.gz libdbuspolicy-submit/tizen/20160905.095924.tar.bz2 libdbuspolicy-submit/tizen/20160905.095924.zip |
Merge "Added description label to libdbuspolicy kdbus connection" into tizensubmit/tizen/20160905.095924submit/tizen/20160905.094007submit/tizen/20160905.073119accepted/tizen/wearable/20160907.060138accepted/tizen/tv/20160907.060118accepted/tizen/mobile/20160907.060103accepted/tizen/ivi/20160907.060151accepted/tizen/common/20160905.171616
-rw-r--r-- | src/libdbuspolicy1.c | 42 |
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) |