COMMON_SRC =\
src/libdbuspolicy1-private.h \
src/libdbuspolicy1.c \
+ src/kdbus.c \
src/internal/internal.cpp \
src/internal/naive_policy_checker.cpp \
src/internal/policy.cpp \
#include <sys/types.h>
#include <stdbool.h>
-#define KDBUS_CONN_MAX_NAMES 256
-
typedef enum {
SYSTEM_BUS = 0,
SESSION_BUS = 1
}
MatchItemSR::MatchItemSR(const char* i, const char* me, const char* p, MessageType t)
- : names_num(0), type(t) {
+ : type(t) {
if (i) interface = i;
if (me) member = me;
if (p) path = p;
}
void MatchItemSR::addName(const char* name) {
- names[names_num++] = boost::string_ref(name);
+ names.push_back(name);
}
bool MatchItemSR::addNames(const char* name) noexcept {
if (name) {
boost::string_ref current(name);
- while (!current.empty() && names_num < KDBUS_CONN_MAX_NAMES + 1) {
+ while (!current.empty()) {
if (!(isalnum(current[0]) || current[0] == ' '))
tslog::log_verbose("Wrong name(", current, "): ", name, "\n");
auto space = current.find_first_of(" ");
- names[names_num++] = current.substr(0, space);
+ names.push_back(current.substr(0, space));
if (space != current.npos) // skip the space
current = current.substr(space+1);
else
current.clear();
}
- if (names_num >= KDBUS_CONN_MAX_NAMES + 1)
- return false;
}
return true;
}
return false;
if (!_name.empty()) {
- for (int i = 0; i < names_num; i++) {
- if (!boost::algorithm::starts_with(names[i], _name))
+ for (const auto &match_name: names) {
+ if (!boost::algorithm::starts_with(match_name, _name))
continue;
- if (names[i].length() == _name.length())
+ if (match_name.length() == _name.length())
return true;
- else if (_is_name_prefix && names[i][_name.length()] == '.')
+ else if (_is_name_prefix && match_name[_name.length()] == '.')
return true;
}
return false;
/** Struct which allows to contain multiple connection names then compared in s/r policy checker */
struct MatchItemSR {
- int names_num;
- boost::string_ref names[KDBUS_CONN_MAX_NAMES+1];
+ std::vector<boost::string_ref> names;
boost::string_ref interface;
boost::string_ref member;
boost::string_ref path;
std::ostream &operator<<(std::ostream& stream, const ldp_xml_parser::MatchItemSR &item)
{
stream << ": services(";
- for (int i = 0; i < item.names_num; i++) {
- stream << item.names[i];
- if (i != item.names_num -1)
- stream << " ";
- }
+ for (const auto &name: item.names)
+ stream << name << " ";
+
return stream << "), interface(" << item.interface << "), member(" << item.member <<
"), path(" << item.path << "), type(" << __message_type_to_str(item.type) << ")";
}
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include "kdbus.h"
+#include <dbuspolicy1/libdbuspolicy1.h>
+
+#include <dlog/dlog.h>
+
+#include <linux/kdbus.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdbool.h>
+
+#define CONNECTION_LABEL "libdbuspolicy1-kdbus"
+
+#define KDBUS_POOL_SIZE (1024UL * 1024UL)
+
+#define ALIGN8(l) (((l) + 7) & ~7)
+#define ALIGNDN8(l) ((l) & ~7)
+#define UID_INVALID ((uid_t) -1)
+#define GID_INVALID ((gid_t) -1)
+
+#define MAX_DBUS_NAME_LEN 255
+
+static int kdbus_open_bus(kdbus_connection *conn, const char *path)
+{
+ conn->fd = open(path, O_RDWR|O_NOCTTY|O_LARGEFILE|O_CLOEXEC);
+ return conn->fd;
+}
+
+static int kdbus_hello(struct kdbus_connection *conn,
+ uint64_t hello_flags,
+ uint64_t attach_flags_send,
+ uint64_t attach_flags_recv)
+{
+ struct kdbus_cmd_hello* cmd;
+ struct kdbus_cmd_free cmd_free;
+ struct kdbus_item* item;
+ size_t size = ALIGN8(sizeof(struct kdbus_cmd_hello)) + ALIGN8(offsetof(struct kdbus_item, data) + sizeof(CONNECTION_LABEL));
+
+ cmd = calloc(1, size);
+ if (!cmd)
+ goto err;
+ 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(conn->fd, KDBUS_CMD_HELLO, cmd) < 0)
+ goto err;
+
+ if (MAP_FAILED == (conn->pool = mmap(NULL, KDBUS_POOL_SIZE, PROT_READ, MAP_SHARED, conn->fd, 0)))
+ goto err;
+
+ cmd_free.offset = cmd->offset;
+ cmd_free.size = sizeof(struct kdbus_cmd_free);
+ ioctl(conn->fd, KDBUS_CMD_FREE, &cmd_free);
+ free(cmd);
+ return 0;
+
+err:
+ free(cmd);
+ return -errno;
+}
+
+void kdbus_shared_init_fd(kdbus_connection *conn, int fd)
+{
+ conn->fd = fd;
+}
+
+void kdbus_shared_init_pool(kdbus_connection *conn, void *pool)
+{
+ conn->pool = pool;
+}
+
+int kdbus_connect(kdbus_connection *conn,
+ const char *path,
+ uint64_t hello_flags,
+ uint64_t attach_flags_send,
+ uint64_t attach_flags_recv)
+{
+ if ((conn->fd = kdbus_open_bus(conn, path)) < 0) {
+ LOGE("Error opening bus: %s", path);
+ return -1;
+ }
+ if (kdbus_hello(conn, hello_flags, attach_flags_send, attach_flags_recv) < 0) {
+ LOGE("Error: bus hello failed");
+ close(conn->fd);
+ return -1;
+ }
+ return 0;
+}
+
+static bool kdbus_is_unique_id(const char* name)
+{
+ return ':' == name[0];
+}
+
+static uint64_t kdbus_unique_id(char const *name)
+{
+ uint64_t res;
+ unsigned i = 2;
+ int c;
+
+ /* unique id : ':1.001010'. starting index is 3 */
+ while (!(c = name[++i] - '0'));
+ res = (unsigned)c;
+ while ((c = name[++i] - '0') >= 0)
+ res = res*10 + (unsigned)c;
+ return res;
+}
+
+union kdbus_cmd_union {
+ struct kdbus_cmd_info cmd_info;
+ uint8_t _buffer_[sizeof(struct kdbus_cmd_info) + offsetof(struct kdbus_item, data) + ALIGN8(MAX_DBUS_NAME_LEN+1)];
+};
+
+int kdbus_get_conn_info(kdbus_connection *conn,
+ const char *destination,
+ struct kdbus_cmd_param *info,
+ conn_info_type conn_info_type)
+{
+ char const *label = NULL;
+ int r;
+ uid_t uid_n = UID_INVALID;
+ gid_t gid_n = GID_INVALID;
+ union kdbus_cmd_union cmd;
+
+ struct kdbus_info *conn_info;
+ struct kdbus_item *item;
+ uintptr_t items_end;
+
+ cmd.cmd_info.flags = 0;
+ if (conn_info_type == POLICY_CONN_INFO_ALL)
+ cmd.cmd_info.attach_flags = (KDBUS_ATTACH_CREDS | KDBUS_ATTACH_NAMES | KDBUS_ATTACH_SECLABEL);
+ else
+ cmd.cmd_info.attach_flags = KDBUS_ATTACH_NAMES;
+
+ if (kdbus_is_unique_id(destination)) {
+ cmd.cmd_info.size = sizeof(cmd.cmd_info);
+ cmd.cmd_info.id = kdbus_unique_id(destination);
+ } else {
+ unsigned int l = strlen(destination);
+ cmd.cmd_info.size = sizeof(struct kdbus_cmd_info) + offsetof(struct kdbus_item, data) + ALIGN8(l+1);
+ cmd.cmd_info.id = 0;
+ cmd.cmd_info.items->size = (__u64)offsetof(struct kdbus_item, data) + (__u64)l + (__u64)1;
+ cmd.cmd_info.items->type = KDBUS_ITEM_NAME;
+ *(uint64_t*)ALIGNDN8((uintptr_t)cmd.cmd_info.items->str + l) = 0; /* trailing zero + padding */
+ memcpy(cmd.cmd_info.items->str, destination, l + 1);
+ }
+ r = ioctl(conn->fd, KDBUS_CMD_CONN_INFO, &cmd.cmd_info);
+ if (r < 0) {
+ if (errno == ENXIO || errno == ESRCH)
+ return DBUSPOLICY_RESULT_DEST_NOT_AVAILABLE;
+
+ return DBUSPOLICY_RESULT_KDBUS_ERROR;
+ }
+
+ info->free_offset = cmd.cmd_info.offset;
+
+ conn_info = (struct kdbus_info *) ((uint8_t *) conn->pool + cmd.cmd_info.offset);
+ items_end = (uintptr_t)conn_info + (unsigned)conn_info->size;
+
+ _Static_assert((unsigned)KDBUS_ITEM_CREDS == KDBUS_ITEM_CREDS, "KDBUS_ITEM_CREDS not preserved when cast to unsigned");
+ _Static_assert((unsigned)KDBUS_ITEM_SECLABEL == KDBUS_ITEM_SECLABEL, "KDBUS_ITEM_SECLABEL not preserved when cast to unsigned");
+ _Static_assert((unsigned)KDBUS_ITEM_OWNED_NAME == KDBUS_ITEM_OWNED_NAME, "KDBUS_ITEM_OWNED_NAME not preserved when cast to unsigned");
+
+ info->names_num = 0;
+ for (item = conn_info->items; (uintptr_t)item < items_end; item = (typeof(item))ALIGN8((uintptr_t)item + (unsigned)item->size)) {
+ switch ((unsigned)item->type) {
+ case KDBUS_ITEM_CREDS:
+ uid_n = item->creds.euid;
+ gid_n = item->creds.egid;
+ break;
+ case KDBUS_ITEM_SECLABEL:
+ label = item->str;
+ break;
+ case KDBUS_ITEM_OWNED_NAME:
+ info->k_names[info->names_num++] = item->name.name;
+ break;
+ }
+ }
+
+ info->label = label;
+ info->uid_n = uid_n;
+ info->gid_n = gid_n;
+
+ return r;
+}
+
+int kdbus_free_by_offset(kdbus_connection *conn, __u64 offset)
+{
+ struct kdbus_cmd_free cmd;
+ cmd.size = sizeof(cmd);
+ cmd.flags = 0;
+ cmd.offset = offset;
+
+ if (ioctl(conn->fd, KDBUS_CMD_FREE, &cmd) != 0)
+ return errno;
+
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#pragma once
+
+#include <linux/kdbus.h>
+#include <stdint.h>
+#include <pwd.h>
+#include <grp.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+
+#define KDBUS_CONN_MAX_NAMES 256
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct kdbus_connection {
+ int fd;
+ char *pool;
+};
+
+typedef struct kdbus_connection kdbus_connection;
+
+struct kdbus_cmd_param {
+ char const *label;
+ const char* k_names[KDBUS_CONN_MAX_NAMES];
+ __u64 free_offset;
+ uid_t uid_n;
+ gid_t gid_n;
+ uint16_t names_num;
+};
+
+void kdbus_shared_init_fd(kdbus_connection *conn, int fd);
+void kdbus_shared_init_pool(kdbus_connection *conn, void *pool);
+
+int kdbus_connect(kdbus_connection *conn,
+ const char *path,
+ uint64_t hello_flags,
+ uint64_t attach_flags_send,
+ uint64_t attach_flags_recv);
+
+typedef enum { POLICY_CONN_INFO_ALL, POLICY_CONN_INFO_NAME } conn_info_type;
+
+int kdbus_get_conn_info(kdbus_connection *conn,
+ const char *destination,
+ struct kdbus_cmd_param *info,
+ conn_info_type conn_info_type);
+
+int kdbus_free_by_offset(kdbus_connection *conn, __u64 offset);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
#define DBUSPOLICY1_EXPORT __attribute__ ((visibility("default")))
-typedef uint8_t dbus_name_len;
-#define MAX_DBUS_NAME_LEN 255
-
#define LOG_TAG "LIBDBUSPOLICY"
#include <dlog.h>
* limitations under the License.
*/
+
+#include "kdbus.h"
+#include "internal/internal.h"
+#include "libdbuspolicy1-private.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <stddef.h>
-#include <stdarg.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
-#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/ioctl.h>
#include <fcntl.h>
-#include <stdint.h>
-#include <sys/mman.h>
#include <pwd.h>
#include <grp.h>
-#include <limits.h>
+#include <linux/limits.h>
#include <pthread.h>
-
-#include <dbuspolicy1/libdbuspolicy1.h>
-#include "libdbuspolicy1-private.h"
-#include "internal/internal.h"
+#include <stdbool.h>
#define KDBUS_PATH_PREFIX "/sys/fs/kdbus/"
#define KDBUS_SYSTEM_BUS_PATH "/sys/fs/kdbus/0-system/bus"
-#define KDBUS_POOL_SIZE (1024UL * 1024UL)
-
-#define CONNECTION_LABEL "libdbuspolicy1-kdbus"
-
-#define ALIGN8(l) (((l) + 7) & ~7)
-#define ALIGNDN8(l) ((l) & ~7)
-#define UID_INVALID ((uid_t) -1)
-#define GID_INVALID ((gid_t) -1)
-
-#define POLICY_CONN_INFO_ALL (__u64)(KDBUS_ATTACH_CREDS | KDBUS_ATTACH_NAMES | KDBUS_ATTACH_SECLABEL)
-#define POLICY_CONN_INFO_NAME (__u64)(KDBUS_ATTACH_NAMES)
/** A user ID */
typedef unsigned long dbus_uid_t;
typedef unsigned long dbus_gid_t;
struct kconn {
- int fd;
- char *pool;
+ kdbus_connection conn;
BusType bus_type;
-} g_conn[2] = {
- {.pool = MAP_FAILED},
- {.pool = MAP_FAILED}
-};
+} g_conn[2];
struct udesc {
dbus_uid_t uid;
strncpy(g_udesc.label, label, strlen(label) + 1);
}
-static int kdbus_open_bus(const char *path)
-{
- return open(path, O_RDWR|O_NOCTTY|O_LARGEFILE|O_CLOEXEC);
-}
-
-static int kdbus_free_by_offset(int fd, __u64 offset)
-{
- struct kdbus_cmd_free cmd;
- cmd.size = sizeof(cmd);
- cmd.flags = 0;
- cmd.offset = offset;
-
- if (ioctl(fd, KDBUS_CMD_FREE, &cmd) != 0)
- return errno;
-
- return 0;
-}
-
-static int kdbus_hello(struct kconn *kconn, uint64_t hello_flags, uint64_t attach_flags_send, uint64_t attach_flags_recv)
-{
- struct kdbus_cmd_hello* cmd;
- struct kdbus_item* item;
- size_t size = ALIGN8(sizeof(struct kdbus_cmd_hello)) + ALIGN8(offsetof(struct kdbus_item, data) + sizeof(CONNECTION_LABEL));
-
- cmd = calloc(1, size);
- if (!cmd)
- goto err;
- 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(kconn->fd, KDBUS_CMD_HELLO, cmd) < 0)
- goto err;
-
- if (MAP_FAILED == (kconn->pool = mmap(NULL, KDBUS_POOL_SIZE, PROT_READ, MAP_SHARED, kconn->fd, 0)))
- goto err;
-
- kdbus_free_by_offset(kconn->fd, cmd->offset);
- free(cmd);
- return 0;
-
-err:
- free(cmd);
- return -errno;
-}
-
-static bool kdbus_is_unique_id(const char* name)
-{
- return ':' == name[0];
-}
-
-static uint64_t kdbus_unique_id(char const *name)
-{
- uint64_t res;
- unsigned i = 2;
- int c;
-
- /* unique id : ':1.001010'. starting index is 3 */
- while (!(c = name[++i] - '0'));
- res = (unsigned)c;
- while ((c = name[++i] - '0') >= 0)
- res = res*10 + (unsigned)c;
- return res;
-}
-
static bool dbuspolicy_init_once_locked(void)
{
if (init_once_done)
return &g_conn[bus_type];
struct kconn *result = &g_conn[bus_type];
- if ((result->fd = kdbus_open_bus(resolved_path)) < 0) {
- LOGE("Error opening bus: %s", resolved_path);
+ if (kdbus_connect(&result->conn, resolved_path, 0, _KDBUS_ATTACH_ALL, 0) < 0)
return NULL;
- }
- if (kdbus_hello(result, 0, _KDBUS_ATTACH_ALL, 0) < 0) {
- LOGE("Error: bus hello failed");
- close(result->fd);
- return NULL;
- }
result->bus_type = bus_type;
init_once_conn[bus_type] = true;
LOGE("Error: failed to allocate memory for policy configuration");
return NULL;
}
- result->fd = fd;
+ kdbus_shared_init_fd(&result->conn, fd);
result->bus_type = bus_type;
return result;
}
DBUSPOLICY1_EXPORT void dbuspolicy1_init_set_pool(void *configuration, void *pool)
{
- struct kconn *conf = configuration;
- conf->pool = pool;
+ kdbus_shared_init_pool(configuration, pool);
}
DBUSPOLICY1_EXPORT void dbuspolicy1_free(void* configuration)
free(configuration);
}
-union kdbus_cmd_union {
- struct kdbus_cmd_info cmd_info;
- uint8_t _buffer_[sizeof(struct kdbus_cmd_info) + offsetof(struct kdbus_item, data) + ALIGN8(MAX_DBUS_NAME_LEN+1)];
-};
-
-struct kdbus_cmd_param {
- char const *label;
- const char* k_names[KDBUS_CONN_MAX_NAMES];
- __u64 free_offset;
- uid_t uid_n;
- gid_t gid_n;
- uint16_t names_num;
-};
-
-int kdbus_get_conn_info(struct kconn *kconn, const char *destination, struct kdbus_cmd_param *info, __u64 flags)
-{
- char const *label = NULL;
- int r;
- uid_t uid_n = UID_INVALID;
- gid_t gid_n = GID_INVALID;
- union kdbus_cmd_union cmd;
-
- struct kdbus_info *conn_info;
- struct kdbus_item *item;
- uintptr_t items_end;
-
- cmd.cmd_info.flags = 0;
- cmd.cmd_info.attach_flags = flags;
-
- if (kdbus_is_unique_id(destination)) {
- cmd.cmd_info.size = sizeof(cmd.cmd_info);
- cmd.cmd_info.id = kdbus_unique_id(destination);
- } else {
- unsigned int l = strlen(destination);
- cmd.cmd_info.size = sizeof(struct kdbus_cmd_info) + offsetof(struct kdbus_item, data) + ALIGN8(l+1);
- cmd.cmd_info.id = 0;
- cmd.cmd_info.items->size = (__u64)offsetof(struct kdbus_item, data) + (__u64)l + (__u64)1;
- cmd.cmd_info.items->type = KDBUS_ITEM_NAME;
- *(uint64_t*)ALIGNDN8((uintptr_t)cmd.cmd_info.items->str + l) = 0; /* trailing zero + padding */
- memcpy(cmd.cmd_info.items->str, destination, l + 1);
- }
- r = ioctl(kconn->fd, KDBUS_CMD_CONN_INFO, &cmd.cmd_info);
- if (r < 0) {
- if (errno == ENXIO || errno == ESRCH)
- r = DBUSPOLICY_RESULT_DEST_NOT_AVAILABLE;
- else
- r = DBUSPOLICY_RESULT_KDBUS_ERROR;
- goto end;
- }
-
- /* flags already 0 */
- info->free_offset = cmd.cmd_info.offset;
-
- conn_info = (struct kdbus_info *) ((uint8_t *) kconn->pool + cmd.cmd_info.offset);
- items_end = (uintptr_t)conn_info + (unsigned)conn_info->size;
-
- _Static_assert((unsigned)KDBUS_ITEM_CREDS == KDBUS_ITEM_CREDS, "KDBUS_ITEM_CREDS not preserved when cast to unsigned");
- _Static_assert((unsigned)KDBUS_ITEM_SECLABEL == KDBUS_ITEM_SECLABEL, "KDBUS_ITEM_SECLABEL not preserved when cast to unsigned");
- _Static_assert((unsigned)KDBUS_ITEM_OWNED_NAME == KDBUS_ITEM_OWNED_NAME, "KDBUS_ITEM_OWNED_NAME not preserved when cast to unsigned");
-
- info->names_num = 0;
- for (item = conn_info->items; (uintptr_t)item < items_end; item = (typeof(item))ALIGN8((uintptr_t)item + (unsigned)item->size)) {
- switch ((unsigned)item->type) {
- case KDBUS_ITEM_CREDS:
- uid_n = item->creds.euid;
- gid_n = item->creds.egid;
- break;
- case KDBUS_ITEM_SECLABEL:
- label = item->str;
- break;
- case KDBUS_ITEM_OWNED_NAME:
- info->k_names[info->names_num++] = item->name.name;
- break;
- }
- }
-
-end:
- info->label = label;
- info->uid_n = uid_n;
- info->gid_n = gid_n;
-
- return r;
-}
-
DBUSPOLICY1_EXPORT int dbuspolicy1_check_out(void* configuration,
const char *destination,
const char *sender,
/* check can send */
/* if broadcasting, then pass - null destination */
if (destination && *destination) {
- r = kdbus_get_conn_info(kconn, destination, &info, POLICY_CONN_INFO_ALL);
+ r = kdbus_get_conn_info(&kconn->conn, destination, &info, POLICY_CONN_INFO_ALL);
if (r < 0)
goto end;
free_conn_info = true;
dest_label = strdup(info.label);
if (free_conn_info) {
- kdbus_free_by_offset(kconn->fd, info.free_offset);
+ kdbus_free_by_offset(&kconn->conn, info.free_offset);
free_conn_info = false;
}
}
/* check can recv */
/* get sender information from kdbus */
- r = kdbus_get_conn_info(kconn, sender, &info, POLICY_CONN_INFO_NAME);
+ r = kdbus_get_conn_info(&kconn->conn, sender, &info, POLICY_CONN_INFO_NAME);
if (r < 0) {
fprintf(stderr, "failed to kdbus conn info:%d\n", r);
goto end;
end:
if (free_conn_info)
- kdbus_free_by_offset(kconn->fd, info.free_offset);
+ kdbus_free_by_offset(&kconn->conn, info.free_offset);
if (dest_label)
free(dest_label);
__internal_enter();
if (destination && *destination) {
- r = kdbus_get_conn_info(kconn, destination, &info, POLICY_CONN_INFO_NAME);
+ r = kdbus_get_conn_info(&kconn->conn, destination, &info, POLICY_CONN_INFO_NAME);
if (r < 0)
goto end;
}
goto end;
end:
if (info.free_offset)
- kdbus_free_by_offset(kconn->fd, info.free_offset);
+ kdbus_free_by_offset(&kconn->conn, info.free_offset);
__internal_exit();
return r;